Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
teble committed Jun 11, 2024
1 parent d0cb559 commit be9c8da
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ public class MainHook implements IXposedHookLoadPackage {
MethodMatcher.create()
.modifiers(Modifier.PUBLIC)
.paramTypes("boolean")
// Specify the methods called in the method list
// Specify the method invoke the methods list
.invokeMethods(MethodsMatcher.create()
.add(MethodMatcher.create()
.modifiers(Modifier.PUBLIC | Modifier.STATIC)
.returnType("int")
// Specify the strings used in the method called in the method,
// be invoke method using strings
.usingStrings(List.of("getRandomDice: "), StringMatchType.Equals)
)
// Only need to contain the call to the above method
Expand Down
2 changes: 1 addition & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public class MainHook implements IXposedHookLoadPackage {
.add(MethodMatcher.create()
.modifiers(Modifier.PUBLIC | Modifier.STATIC)
.returnType("int")
// 指定方法中调用的方法中使用的字符串,所有字符串均使用 Equals 匹配
// 被调用方法中使用的字符串,所有字符串均使用 Equals 匹配
.usingStrings(List.of("getRandomDice: "), StringMatchType.Equals)
)
// 只需要包含上述方法的调用即可
Expand Down
20 changes: 12 additions & 8 deletions doc-source/src/en/guide/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ private fun findMethodWithFuzzyParam(bridge: DexKitBridge) {

How can you serialize and save the results obtained from DexKit queries for later use?

DexKit provides corresponding packaging classes for Class, Method, and Field,
namely `DexClass`, `DexMethod`, and `DexField`. The wrapper class inherits the `Serializable`
interface, so it can be saved directly using Java's serialization method. For the objects returned
by the query, you can directly use `toDexClass()`, `toDexMethod()`, `toDexField()` methods to
convert to a wrapper class. Of course, you can also use the Data object's `descriptor` attribute,
which is a `Dailvik description` that identifies a unique object.
DexKit provides corresponding wrapper classes for Class, Method, and Field, namely `DexClass`,
`DexMethod`, and `DexField`. These wrapper classes inherit from the `ISerializable` interface,
allowing them to be freely converted to and from strings. For objects returned by queries,
you can directly use the `toDexClass()`, `toDexMethod()`, and `toDexField()` methods to convert
them into the respective wrapper classes.


```kotlin
private fun saveData(bridge: DexKitBridge) {
Expand All @@ -263,9 +263,10 @@ private fun saveData(bridge: DexKitBridge) {
usingStrings("onClick")
}
}.single().let {
val descriptor = it.descriptor
val dexMethod = it.toDexMethod()
val serialize = dexMethod.serialize()
val sp = getSharedPreferences("dexkit", Context.MODE_PRIVATE)
sp.edit().putString("onClickMethod", descriptor).apply()
sp.edit().putString("onClickMethod", serialize).apply()
}
}

Expand All @@ -274,6 +275,9 @@ private fun readData(): Method {
val descriptor = sp.getString("onClickMethod", null)
if (descriptor != null) {
val dexMethod = DexMethod(descriptor)
// val dexMethod = DexMethod.deserialize(serialize)
// val dexMethod = ISerializable.deserialize(serialize) as DexMethod
// val dexMethod = ISerializable.deserializeAs<DexMethod>(serialize)
val method = dexMethod.getMethodInstance(hostClassLoader)
return method
}
Expand Down
20 changes: 10 additions & 10 deletions doc-source/src/en/guide/structural-zoom-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@

### FieldMatcher

| Field Name | Type | Description |
|:--------------|:------------------------------------------|:----------------------------------|
| name | [StringMatcher](#stringmatcher) | Name of the field |
| modifiers | [AccessFlagsMatcher](#accessflagsmatcher) | Modifiers of the field |
| declaredClass | [ClassMatcher](#classmatcher) | Declaring class of the field |
| type | [ClassMatcher](#classmatcher) | Type of the field |
| annotations | [AnnotationsMatcher](#annotationsmatcher) | List of annotations for the field |
| getMethods | [MethodsMatcher](#methodsmatcher) | List of methods to get the field |
| putMethods | [MethodsMatcher](#methodsmatcher) | List of methods to set the field |
| Field Name | Type | Description |
|:--------------|:------------------------------------------|:-----------------------------------|
| name | [StringMatcher](#stringmatcher) | Name of the field |
| modifiers | [AccessFlagsMatcher](#accessflagsmatcher) | Modifiers of the field |
| declaredClass | [ClassMatcher](#classmatcher) | Declaring class of the field |
| type | [ClassMatcher](#classmatcher) | Type of the field |
| annotations | [AnnotationsMatcher](#annotationsmatcher) | List of annotations for the field |
| readMethods | [MethodsMatcher](#methodsmatcher) | List of methods to read the field |
| writeMethods | [MethodsMatcher](#methodsmatcher) | List of methods to write the field |

### FieldsMatcher

Expand All @@ -230,7 +230,7 @@
| usingFields | Collection&lt;[UsingFieldMatcher](#usingfieldmatcher)&gt; | List of fields used in the method |
| usingNumbers | Collection&lt;Number&gt; | List of numbers used in the method |
| invokeMethods | [MethodsMatcher](#methodsmatcher) | List of methods invoked by the method |
| callMethods | [MethodsMatcher](#methodsmatcher) | List of methods that call the method |
| callerMethods | [MethodsMatcher](#methodsmatcher) | List of methods that call the method |

### MethodsMatcher

Expand Down
13 changes: 8 additions & 5 deletions doc-source/src/zh-cn/guide/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,8 @@ private fun findMethodWithFuzzyParam(bridge: DexKitBridge) {
使用 DexKit 查询到的结果如何序列化保存下来,以便下次使用呢?

DexKit 中对 Class、Method、Field 提供了相应的包装类,分别是 `DexClass``DexMethod``DexField`
包装类继承了 `Serializable` 接口,因此可以直接使用 Java 的序列化方式来保存。对于查询返回的对象,可以直接使用
`toDexClass()``toDexMethod()``toDexField()` 方法来转换为包装类。当然,您也可以使用 Data 对象的
`descriptor` 属性来保存,它是一个 `Dailvik 描述` 标识了唯一的对象。
包装类继承了 `ISerializable` 接口,可以使用它将包装类与字符串自由转换。对于查询返回的对象,可以直接使用
`toDexClass()``toDexMethod()``toDexField()` 方法来转换为包装类。

```kotlin
private fun saveData(bridge: DexKitBridge) {
Expand All @@ -256,9 +255,10 @@ private fun saveData(bridge: DexKitBridge) {
usingStrings("onClick")
}
}.single().let {
val descriptor = it.descriptor
val dexMethod = it.toDexMethod()
val serialize = dexMethod.serialize()
val sp = getSharedPreferences("dexkit", Context.MODE_PRIVATE)
sp.edit().putString("onClickMethod", descriptor).apply()
sp.edit().putString("onClickMethod", serialize).apply()
}
}

Expand All @@ -267,6 +267,9 @@ private fun readData(): Method {
val descriptor = sp.getString("onClickMethod", null)
if (descriptor != null) {
val dexMethod = DexMethod(descriptor)
// val dexMethod = DexMethod.deserialize(serialize)
// val dexMethod = ISerializable.deserialize(serialize) as DexMethod
// val dexMethod = ISerializable.deserializeAs<DexMethod>(serialize)
val method = dexMethod.getMethodInstance(hostClassLoader)
return method
}
Expand Down
6 changes: 3 additions & 3 deletions doc-source/src/zh-cn/guide/structural-zoom-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@
| declaredClass | [ClassMatcher](#classmatcher) | 字段的声明类 |
| type | [ClassMatcher](#classmatcher) | 字段的类型 |
| annotations | [AnnotationsMatcher](#annotationsmatcher) | 字段的注解 |
| getMethods | [MethodsMatcher](#methodsmatcher) | 读取该字段的方法列表 |
| putMethods | [MethodsMatcher](#methodsmatcher) | 设置该字段的方法列表 |
| readMethods | [MethodsMatcher](#methodsmatcher) | 读取该字段的方法列表 |
| writeMethods | [MethodsMatcher](#methodsmatcher) | 设置该字段的方法列表 |

### FieldsMatcher

Expand All @@ -229,7 +229,7 @@
| usingFields | Collection&lt;[UsingFieldMatcher](#usingfieldmatcher)&gt; | 方法中使用的字段列表 |
| usingNumbers | Collection&lt;Number&gt; | 方法中使用的数字列表 |
| invokeMethods | [MethodsMatcher](#methodsmatcher) | 方法中调用的方法列表 |
| callMethods | [MethodsMatcher](#methodsmatcher) | 调用了该方法的方法列表 |
| callerMethods | [MethodsMatcher](#methodsmatcher) | 调用了该方法的方法列表 |

### MethodsMatcher

Expand Down

0 comments on commit be9c8da

Please sign in to comment.