dexsql 文档 打开应用

SQL 查询示例

Markdown 源文件 · dexsql app

选择下面的示例,将类、方法或值替换为你要检查的目标。DEX 数据模型介绍 descriptor 的写法,以及引用与定义的区别。

查找字符串引用

-- 查找引用了某个字符串的方法(先精确,再子串)。
SELECT DISTINCT method FROM method_strings WHERE value = 'https://api.example.com';
SELECT DISTINCT method FROM method_strings WHERE value LIKE '%api.example.com%';

查找调用方与被调用方

-- 被调用方:com.example.Foo.bar() 调用了哪些方法。
SELECT DISTINCT callee FROM method_calls
WHERE method = 'Lcom/example/Foo;->bar()V';

-- 调用方:哪些方法调用了 com.example.Foo.bar()。
SELECT DISTINCT method FROM method_calls
WHERE callee = 'Lcom/example/Foo;->bar()V';

查找字段访问

-- 某个方法访问的字段。
SELECT DISTINCT field FROM method_field_accesses
WHERE method = 'Lcom/example/Foo;->bar()V';

查找引用的类型

-- 某个方法用到的类型(Java 风格名字)。
SELECT DISTINCT type_name FROM method_used_types
WHERE method = 'Lcom/example/Foo;->bar()V';

查找数值常量

-- 加载了某个立即数的方法。
SELECT DISTINCT method FROM method_using_numbers WHERE long_value = 114514;

检查注解

-- 谁携带了某个注解类型。
SELECT DISTINCT owner FROM annotation_elements_resolved
WHERE annotation = 'Landroidx/annotation/Keep;';

-- 注解 + element 值,按注解类型收窄。
SELECT owner, element_name, value_i64, value_index
FROM annotation_elements_resolved
WHERE annotation = 'Landroidx/annotation/Keep;';

-- 某个 owner 上 runtime 保留的注解。
SELECT annotation, element_name, value_i64, value_index
FROM annotation_elements_resolved
WHERE owner = 'Lcom/example/Foo;' AND retention_policy = 'runtime';

列出声明的方法

-- 列出某个类声明的方法。
SELECT method_descriptor FROM class_methods WHERE class_descriptor = 'Lcom/example/Foo;';

-- 对比:下面这条列出的是「被引用到的方法」,包含该类在其他 dex 中未定义的引用,
-- 且同一方法可能出现多次。参见「引用与定义」。
SELECT descriptor FROM methods WHERE class_descriptor = 'Lcom/example/Foo;';

匹配指令序列

-- 按连续 opcode 序列匹配方法。`opcode_hex` 是空格分隔的
-- 两位十六进制 opcode 流,支持包含、前缀 '6e 0c%'、后缀 '%6e 0c' 和精确匹配。
SELECT DISTINCT descriptor FROM methods WHERE opcode_hex LIKE '%6e 0c 6e%';

接口及 override 相关调用见调用查询。展开注解元素前先按注解类型或 owner 过滤。重复查询时复用已准备的数据集或缓存。


Copyright (c) 2026 LSPosed Developers。本文档采用 MIT 许可证。