mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 01:35:17 +08:00
Update reflection documentation
This commit is contained in:
@@ -659,6 +659,32 @@ Test::class.java.method {
|
||||
}.get(instance) // Get this method
|
||||
```
|
||||
|
||||
If you are not sure about the type of each parameter, you can create a conditional method body with the `param { ... }` method.
|
||||
|
||||
> The following example
|
||||
|
||||
```kotlin
|
||||
// Assume this is an instance of this Class
|
||||
val instance = Test()
|
||||
// Call and execute using YukiHookAPI
|
||||
Test::class.java.method {
|
||||
name = "release"
|
||||
// Get the it (Class) method parameter type array instance
|
||||
// To only determine the known type and its position
|
||||
param { it[0] == StringClass && it[2] == BooleanType }
|
||||
}.get(instance) // Get this method
|
||||
```
|
||||
|
||||
::: tip
|
||||
|
||||
Use **param { ... }** to create a conditional method body, where the variable **it** is the **Class** type array instance of the current method parameter, and you can freely use **Class** all objects and their methods in.
|
||||
|
||||
The condition at the end of the method body needs to return a **Boolean**, which is the final condition judgment result.
|
||||
|
||||
For more functions, please refer to [FieldFinder.type](../public/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder#type-method-1), [MethodFinder.param](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#param-method-1), [MethodFinder.returnType](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#returntype-method-1), [ConstructorFinder.param](../public/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder#param-method-1) method.
|
||||
|
||||
:::
|
||||
|
||||
### Find in Super Class
|
||||
|
||||
You will notice that `Test` extends `BaseTest`, now we want to get the `doBaseTask` method of `BaseTest`, how do we do it without knowing the name of the super class?
|
||||
@@ -793,7 +819,7 @@ Use **name { ... }** to create a conditional method body, where the variable **i
|
||||
|
||||
The condition at the end of the method body needs to return a **Boolean**, which is the final condition judgment result.
|
||||
|
||||
For more functions, please refer to [NameRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/NameRules).
|
||||
For more functions, please refer to [FieldFinder.name](../public/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder#name-method-1), [MethodFinder.name](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#name-method-1) methods and [NameRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/NameRules).
|
||||
|
||||
:::
|
||||
|
||||
@@ -887,7 +913,7 @@ Use **paramCount { ... }** to create a conditional method body, where the variab
|
||||
|
||||
The condition at the end of the method body needs to return a **Boolean**, which is the final condition judgment result.
|
||||
|
||||
For more functions, please refer to [CountRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/CountRules).
|
||||
For more functions, please refer to [MethodFinder.paramCount](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#paramcount-method-2), [ConstructorFinder.paramCount](../public/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder#paramcount-method-2) methods and [CountRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/CountRules).
|
||||
|
||||
:::
|
||||
|
||||
@@ -951,7 +977,7 @@ Use **modifiers { ... }** to create a conditional method body, at which point yo
|
||||
|
||||
The condition at the end of the method body needs to return a **Boolean**, which is the final condition judgment result.
|
||||
|
||||
For more features, please refer to [ModifierRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/ModifierRules).
|
||||
For more functions, please refer to [FieldFinder.modifiers](../public/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder#modifiers-method), [MethodFinder.modifiers](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#modifiers-method), [ConstructorFinder.modifiers](../public/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder#modifiers-method) methods and [ModifierRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/ModifierRules).
|
||||
|
||||
:::
|
||||
|
||||
|
@@ -614,6 +614,31 @@ Test::class.java.method {
|
||||
}.get(instance) // 得到这个方法
|
||||
```
|
||||
|
||||
如果你并不确定每一个参数的类型,你可以通过 `param { ... }` 方法来创建一个条件方法体。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 假设这就是这个 Class 的实例
|
||||
val instance = Test()
|
||||
// 使用 YukiHookAPI 调用并执行
|
||||
Test::class.java.method {
|
||||
name = "release"
|
||||
// 得到 it (Class) 方法参数类型数组实例来仅判断已知的类型和它的位置
|
||||
param { it[0] == StringClass && it[2] == BooleanType }
|
||||
}.get(instance) // 得到这个方法
|
||||
```
|
||||
|
||||
::: tip
|
||||
|
||||
使用 **param { ... }** 创建一个条件方法体,其中的变量 **it** 即当前方法参数的 **Class** 类型数组实例,此时你就可以自由使用 **Class** 中的所有对象及其方法。
|
||||
|
||||
方法体末尾条件需要返回一个 **Boolean**,即最终的条件判断结果。
|
||||
|
||||
更多功能请参考 [FieldFinder.type](../public/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder#type-method-1)、[MethodFinder.param](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#param-method-1)、[MethodFinder.returnType](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#returntype-method-1)、[ConstructorFinder.param](../public/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder#param-method-1) 方法。
|
||||
|
||||
:::
|
||||
|
||||
### 在父类查找
|
||||
|
||||
你会注意到 `Test` 继承于 `BaseTest`,现在我们想得到 `BaseTest` 的 `doBaseTask` 方法,在不知道父类名称的情况下,要怎么做呢?
|
||||
@@ -748,7 +773,7 @@ Test::class.java.method {
|
||||
|
||||
方法体末尾条件需要返回一个 **Boolean**,即最终的条件判断结果。
|
||||
|
||||
更多功能请参考 [NameRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/NameRules)。
|
||||
更多功能请参考 [FieldFinder.name](../public/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder#name-method-1)、[MethodFinder.name](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#name-method-1) 方法以及 [NameRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/NameRules)。
|
||||
|
||||
:::
|
||||
|
||||
@@ -840,7 +865,7 @@ Test::class.java.method {
|
||||
|
||||
方法体末尾条件需要返回一个 **Boolean**,即最终的条件判断结果。
|
||||
|
||||
更多功能请参考 [CountRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/CountRules)。
|
||||
更多功能请参考 [MethodFinder.paramCount](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#paramcount-method-2)、[ConstructorFinder.paramCount](../public/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder#paramcount-method-2) 方法以及 [CountRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/CountRules)。
|
||||
|
||||
:::
|
||||
|
||||
@@ -904,7 +929,7 @@ Test::class.java.method {
|
||||
|
||||
方法体末尾条件需要返回一个 **Boolean**,即最终的条件判断结果。
|
||||
|
||||
更多功能请参考 [ModifierRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/ModifierRules)。
|
||||
更多功能请参考 [FieldFinder.modifiers](../public/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder#modifiers-method)、[MethodFinder.modifiers](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#modifiers-method)、[ConstructorFinder.modifiers](../public/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder#modifiers-method) 方法以及 [ModifierRules](../public/com/highcapable/yukihookapi/hook/core/finder/base/rules/ModifierRules)。
|
||||
|
||||
:::
|
||||
|
||||
|
Reference in New Issue
Block a user