mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 17:55:24 +08:00
Added more function in MethodFinder, ConstructorFinder, FieldFinder
This commit is contained in:
@@ -16,6 +16,8 @@ class ConstructorFinder internal constructor(override val hookInstance: YukiMemb
|
||||
|
||||
> `Constructor` 查找类。
|
||||
|
||||
可通过指定类型查找指定构造方法或一组构造方法。
|
||||
|
||||
### paramCount [field]
|
||||
|
||||
```kotlin
|
||||
@@ -112,6 +114,24 @@ fun paramCount(num: Int): IndexTypeCondition
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
### paramCount [method]
|
||||
|
||||
```kotlin
|
||||
fun paramCount(numRange: IntRange): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Constructor` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
### superClass [method]
|
||||
|
||||
```kotlin
|
||||
@@ -160,7 +180,7 @@ inline fun constructor(initiate: ConstructorFinder.() -> Unit)
|
||||
|
||||
> 创建需要重新查找的 `Constructor`。
|
||||
|
||||
你可以添加多个备选构造方法,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
你可以添加多个备选 `Constructor`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
#### Result [class]
|
||||
|
||||
@@ -179,13 +199,17 @@ inner class Result internal constructor()
|
||||
##### onFind [method]
|
||||
|
||||
```kotlin
|
||||
fun onFind(initiate: Constructor<*>.() -> Unit)
|
||||
fun onFind(initiate: HashSet<Constructor<*>>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.1` `新增`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
`initiate` 参数 `Constructor` 变为 `HashSet<Constructor>`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
@@ -207,13 +231,17 @@ constructor {
|
||||
### Result [class]
|
||||
|
||||
```kotlin
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, internal val e: Throwable?)
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, internal val throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0` `添加`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
继承到接口 `BaseResult`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Constructor` 查找结果实现类。
|
||||
@@ -247,6 +275,7 @@ constructor {
|
||||
// Your code here.
|
||||
}.result {
|
||||
get().call()
|
||||
all()
|
||||
remedys {}
|
||||
onNoSuchConstructor {}
|
||||
}
|
||||
@@ -266,6 +295,8 @@ fun get(): Instance
|
||||
|
||||
> 获得 `Constructor` 实例处理类。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
!> 若你设置了 `remedys` 请使用 `wait` 回调结果方法。
|
||||
|
||||
**功能示例**
|
||||
@@ -300,6 +331,36 @@ constructor {
|
||||
}.get().newInstance<TestClass>("param1", "param2")
|
||||
```
|
||||
|
||||
#### all [method]
|
||||
|
||||
```kotlin
|
||||
fun all(): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Constructor` 实例处理类数组。
|
||||
|
||||
返回全部查询条件匹配的多个 `Constructor` 实例结果并在 `isBindToHooker` 时设置到 `hookInstance`。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Constructor`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
constructor {
|
||||
// Your code here.
|
||||
}.all().forEach { instance ->
|
||||
instance.call(...)
|
||||
}
|
||||
```
|
||||
|
||||
#### give [method]
|
||||
|
||||
```kotlin
|
||||
@@ -314,6 +375,28 @@ fun give(): Constructor<*>?
|
||||
|
||||
> 得到构造方法本身。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
在查询条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
#### giveAll [method]
|
||||
|
||||
```kotlin
|
||||
fun giveAll(): HashSet<Constructor<*>>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Constructor` 本身数组。
|
||||
|
||||
返回全部查询条件匹配的多个 `Constructor` 实例。
|
||||
|
||||
在查询条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
#### wait [method]
|
||||
|
||||
```kotlin
|
||||
@@ -328,6 +411,28 @@ fun wait(initiate: Instance.() -> Unit)
|
||||
|
||||
> 获得 `Constructor` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Constructor` 结果只会返回第一个。
|
||||
|
||||
!> 若你设置了 `remedys` 必须使用此方法才能获得结果。
|
||||
|
||||
!> 若你没有设置 `remedys` 此方法将不会被回调。
|
||||
|
||||
#### waitAll [method]
|
||||
|
||||
```kotlin
|
||||
fun waitAll(initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Constructor` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查询条件匹配的多个 `Constructor` 实例结果。
|
||||
|
||||
!> 若你设置了 `remedys` 必须使用此方法才能获得结果。
|
||||
|
||||
!> 若你没有设置 `remedys` 此方法将不会被回调。
|
||||
@@ -348,11 +453,11 @@ inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建构造方法重查找功能。
|
||||
> 创建 `Constructor` 重查找功能。
|
||||
|
||||
**功能示例**
|
||||
|
||||
当你遇到一种构造方法可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchConstructor` 捕获异常二次查找构造方法。
|
||||
当你遇到一种 `Constructor` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchConstructor` 捕获异常二次查找 `Constructor`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
@@ -387,7 +492,7 @@ inline fun onNoSuchConstructor(result: (Throwable) -> Unit): Result
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 监听找不到构造方法时。
|
||||
> 监听找不到 `Constructor` 时。
|
||||
|
||||
只会返回第一次的错误信息,不会返回 `RemedyPlan` 的错误信息。
|
||||
|
||||
@@ -410,13 +515,17 @@ fun ignoredError(): Result
|
||||
#### Instance [class]
|
||||
|
||||
```kotlin
|
||||
inner class Instance internal constructor()
|
||||
inner class Instance internal constructor(private val constructor: Constructor<*>?)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.2` `新增`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
新增 `constructor` 参数
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Constructor` 实例处理类。
|
||||
@@ -433,7 +542,7 @@ fun call(vararg param: Any?): Any?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行构造方法创建目标实例,不指定目标实例类型。
|
||||
> 执行 `Constructor` 创建目标实例,不指定目标实例类型。
|
||||
|
||||
##### newInstance [method]
|
||||
|
||||
@@ -447,4 +556,4 @@ fun <T> newInstance(vararg param: Any?): T?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 执行构造方法创建目标实例 ,指定 `T` 目标实例类型。
|
||||
> 执行 `Constructor` 创建目标实例 ,指定 `T` 目标实例类型。
|
@@ -16,6 +16,8 @@ class FieldFinder internal constructor(override val hookInstance: YukiMemberHook
|
||||
|
||||
> `Field` 查找类。
|
||||
|
||||
可通过指定类型查找指定变量或一组变量。
|
||||
|
||||
### ~~classSet [field]~~ <!-- {docsify-ignore} -->
|
||||
|
||||
**变更记录**
|
||||
@@ -58,7 +60,7 @@ var type: Any?
|
||||
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
可不填写类型,默认模糊查找并取第一个匹配的 `Field`。
|
||||
可不填写类型。
|
||||
|
||||
### modifiers [method]
|
||||
|
||||
@@ -78,7 +80,7 @@ inline fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition
|
||||
|
||||
> 设置 `Field` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件,默认模糊查找并取第一个匹配的 `Field`。
|
||||
可不设置筛选条件。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -110,7 +112,7 @@ fun name(value: String): IndexTypeCondition
|
||||
|
||||
> 设置 `Field` 名称。
|
||||
|
||||
!> 若不填写名称则必须存在一个其它条件,默认模糊查找并取第一个匹配的 `Field`。
|
||||
!> 若不填写名称则必须存在一个其它条件。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -128,7 +130,7 @@ inline fun name(initiate: NameConditions.() -> Unit): IndexTypeCondition
|
||||
|
||||
> 设置 `Field` 名称条件。
|
||||
|
||||
!> 若不填写名称则必须存在一个其它条件,默认模糊查找并取第一个匹配的 `Field`。
|
||||
!> 若不填写名称则必须存在一个其它条件。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -146,7 +148,7 @@ fun type(value: Any): IndexTypeCondition
|
||||
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
!> 可不填写类型,默认模糊查找并取第一个匹配的 `Field`。
|
||||
!> 可不填写类型。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -166,16 +168,92 @@ fun superClass(isOnlySuperClass: Boolean)
|
||||
|
||||
!> 若当前 `classSet` 的父类较多可能会耗时,API 会自动循环到父类继承是 `Any` 前的最后一个类。
|
||||
|
||||
### RemedyPlan [class]
|
||||
|
||||
```kotlin
|
||||
inner class RemedyPlan internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 重查找实现类,可累计失败次数直到查找成功。
|
||||
|
||||
#### field [method]
|
||||
|
||||
```kotlin
|
||||
inline fun field(initiate: FieldFinder.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建需要重新查找的 `Field`。
|
||||
|
||||
你可以添加多个备选 `Field`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
#### Result [class]
|
||||
|
||||
```kotlin
|
||||
inner class Result internal constructor()
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `RemedyPlan` 结果实现类。
|
||||
|
||||
##### onFind [method]
|
||||
|
||||
```kotlin
|
||||
fun onFind(initiate: HashSet<Field>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以方便地对重查找的 `Field` 实现 `onFind` 方法。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.onFind {
|
||||
// Your code here.
|
||||
}
|
||||
```
|
||||
|
||||
### Result [class]
|
||||
|
||||
```kotlin
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, private val e: Throwable?)
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, private val throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0` `添加`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
继承到接口 `BaseResult`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 查找结果实现类。
|
||||
@@ -212,22 +290,28 @@ field {
|
||||
get(instance).string()
|
||||
get(instance).cast<CustomClass>()
|
||||
get().boolean()
|
||||
all(instance)
|
||||
give()
|
||||
giveAll()
|
||||
onNoSuchField {}
|
||||
}
|
||||
```
|
||||
|
||||
#### get [method]
|
||||
|
||||
```kotlin
|
||||
fun get(instance: Any?): Instance
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0` `添加`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量实例处理类。
|
||||
> 获得 `Field` 实例处理类。
|
||||
|
||||
若有多个 `Field` 结果只会返回第一个。
|
||||
|
||||
**功能示例**
|
||||
|
||||
@@ -251,6 +335,36 @@ field {
|
||||
}.get().set("something")
|
||||
```
|
||||
|
||||
#### all [method]
|
||||
|
||||
```kotlin
|
||||
fun all(instance: Any?): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Field` 实例处理类数组。
|
||||
|
||||
返回全部查询条件匹配的多个 `Field` 实例结果。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Field`,其变量所在实例用法与 `get` 相同。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.all(instance).forEach { instance ->
|
||||
instance.self
|
||||
}
|
||||
```
|
||||
|
||||
#### give [method]
|
||||
|
||||
```kotlin
|
||||
@@ -263,7 +377,104 @@ fun give(): Field?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量本身。
|
||||
> 得到 `Field` 本身。
|
||||
|
||||
若有多个 Field 结果只会返回第一个。
|
||||
|
||||
在查询条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
#### giveAll [method]
|
||||
|
||||
```kotlin
|
||||
fun giveAll(): HashSet<Field>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Field` 本身数组。
|
||||
|
||||
返回全部查询条件匹配的多个 `Field` 实例。
|
||||
|
||||
在查询条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
#### wait [method]
|
||||
|
||||
```kotlin
|
||||
fun wait(instance: Any?, initiate: Instance.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Field` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Field` 结果只会返回第一个。
|
||||
|
||||
!> 若你设置了 `remedys` 必须使用此方法才能获得结果。
|
||||
|
||||
!> 若你没有设置 `remedys` 此方法将不会被回调。
|
||||
|
||||
#### waitAll [method]
|
||||
|
||||
```kotlin
|
||||
fun waitAll(instance: Any?, initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Field` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查询条件匹配的多个 `Field` 实例结果。
|
||||
|
||||
!> 若你设置了 `remedys` 必须使用此方法才能获得结果。
|
||||
|
||||
!> 若你没有设置 `remedys` 此方法将不会被回调。
|
||||
|
||||
#### remedys [method]
|
||||
|
||||
```kotlin
|
||||
inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建 `Field` 重查找功能。
|
||||
|
||||
**功能示例**
|
||||
|
||||
当你遇到一种 `Field` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchField` 捕获异常二次查找 `Field`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
field {
|
||||
// Your code here.
|
||||
}.remedys {
|
||||
field {
|
||||
// Your code here.
|
||||
}
|
||||
field {
|
||||
// Your code here.
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### onNoSuchField [method]
|
||||
|
||||
@@ -277,7 +488,7 @@ fun onNoSuchField(result: (Throwable) -> Unit): Result
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 监听找不到变量时。
|
||||
> 监听找不到 `Field` 时。
|
||||
|
||||
#### ignoredError [method]
|
||||
|
||||
@@ -298,17 +509,37 @@ fun ignoredError(): Result
|
||||
#### Instance [class]
|
||||
|
||||
```kotlin
|
||||
inner class Instance internal constructor(private val instance: Any?, val self: Any?)
|
||||
inner class Instance internal constructor(private val instance: Any?, private val field: Field?)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0` `添加`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
新增 `field` 参数
|
||||
|
||||
移动 `self` 参数到类变量
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Field` 实例变量处理类。
|
||||
|
||||
##### self [field]
|
||||
|
||||
```kotlin
|
||||
val self: Any?
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获取当前 `Field` 自身的实例化对象。
|
||||
|
||||
##### cast [method]
|
||||
|
||||
```kotlin
|
||||
@@ -327,7 +558,7 @@ fun <T> cast(): T?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量实例。
|
||||
> 得到当前 `Field` 实例。
|
||||
|
||||
##### byte [method]
|
||||
|
||||
@@ -341,7 +572,7 @@ fun byte(): Byte?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Byte 实例。
|
||||
> 得到当前 `Field` Byte 实例。
|
||||
|
||||
##### int [method]
|
||||
|
||||
@@ -361,7 +592,7 @@ fun int(): Int
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Int 实例。
|
||||
> 得到当前 `Field` Int 实例。
|
||||
|
||||
##### long [method]
|
||||
|
||||
@@ -381,7 +612,7 @@ fun long(): Long
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Long 实例。
|
||||
> 得到当前 `Field` Long 实例。
|
||||
|
||||
##### short [method]
|
||||
|
||||
@@ -400,7 +631,7 @@ fun short(): Short
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Short 实例。
|
||||
> 得到当前 `Field` Short 实例。
|
||||
|
||||
##### double [method]
|
||||
|
||||
@@ -420,7 +651,7 @@ fun double(): Double
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Double 实例。
|
||||
> 得到当前 `Field` Double 实例。
|
||||
|
||||
##### float [method]
|
||||
|
||||
@@ -439,7 +670,7 @@ fun float(): Float
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Float 实例。
|
||||
> 得到当前 `Field` Float 实例。
|
||||
|
||||
##### string [method]
|
||||
|
||||
@@ -459,7 +690,7 @@ fun string(): String
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 String 实例。
|
||||
> 得到当前 `Field` String 实例。
|
||||
|
||||
##### char [method]
|
||||
|
||||
@@ -473,7 +704,7 @@ fun char(): Char
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Char 实例。
|
||||
> 得到当前 `Field` Char 实例。
|
||||
|
||||
##### boolean [method]
|
||||
|
||||
@@ -493,7 +724,7 @@ fun boolean(): Boolean
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Boolean 实例。
|
||||
> 得到当前 `Field` Boolean 实例。
|
||||
|
||||
##### any [method]
|
||||
|
||||
@@ -512,7 +743,7 @@ fun any(): Any?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Any 实例。
|
||||
> 得到当前 `Field` Any 实例。
|
||||
|
||||
##### array [method]
|
||||
|
||||
@@ -526,7 +757,7 @@ inline fun <reified T> array(): Array<T>
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 Array 实例。
|
||||
> 得到当前 `Field` Array 实例。
|
||||
|
||||
##### list [method]
|
||||
|
||||
@@ -540,7 +771,7 @@ inline fun <reified T> list(): List<T>
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到变量 List 实例。
|
||||
> 得到当前 `Field` List 实例。
|
||||
|
||||
##### set [method]
|
||||
|
||||
@@ -554,7 +785,7 @@ fun set(any: Any?)
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置变量实例。
|
||||
> 设置当前 `Field` 实例。
|
||||
|
||||
##### setTrue [method]
|
||||
|
||||
@@ -567,7 +798,7 @@ fun setTrue()
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置变量实例为 `true`。
|
||||
> 设置当前 `Field` 实例为 `true`。
|
||||
|
||||
!> 请确保实例对象类型为 `Boolean`。
|
||||
|
||||
@@ -583,7 +814,7 @@ fun setFalse()
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置变量实例为 `false`。
|
||||
> 设置当前 `Field` 实例为 `false`。
|
||||
|
||||
!> 请确保实例对象类型为 `Boolean`。
|
||||
|
||||
@@ -599,4 +830,4 @@ fun setNull()
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置变量实例为 `null`。
|
||||
> 设置当前 `Field` 实例为 `null`。
|
@@ -16,6 +16,8 @@ class MethodFinder internal constructor(override val hookInstance: YukiMemberHoo
|
||||
|
||||
> `Method` 查找类。
|
||||
|
||||
可通过指定类型查找指定方法或一组方法。
|
||||
|
||||
### name [field]
|
||||
|
||||
```kotlin
|
||||
@@ -66,7 +68,7 @@ var returnType: Any?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 返回值,可不填写返回值,默认模糊查找并取第一个匹配的 `Method`。
|
||||
> 设置 `Method` 返回值,可不填写返回值。
|
||||
|
||||
### modifiers [method]
|
||||
|
||||
@@ -86,7 +88,7 @@ inline fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition
|
||||
|
||||
> 设置 `Method` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件,默认模糊查找并取第一个匹配的 `Method`。
|
||||
可不设置筛选条件。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -154,7 +156,7 @@ fun name(value: String): IndexTypeCondition
|
||||
|
||||
> 设置 `Method` 名称。
|
||||
|
||||
!> 若不填写名称则必须存在一个其它条件,默认模糊查找并取第一个匹配的 `Method`。
|
||||
!> 若不填写名称则必须存在一个其它条件。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -172,7 +174,7 @@ inline fun name(initiate: NameConditions.() -> Unit): IndexTypeCondition
|
||||
|
||||
> 设置 `Method` 名称条件。
|
||||
|
||||
!> 若不填写名称则必须存在一个其它条件,默认模糊查找并取第一个匹配的 `Method`。
|
||||
!> 若不填写名称则必须存在一个其它条件。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -196,6 +198,24 @@ fun paramCount(num: Int): IndexTypeCondition
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
### paramCount [method]
|
||||
|
||||
```kotlin
|
||||
fun paramCount(numRange: IntRange): IndexTypeCondition
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 设置 `Method` 参数个数范围。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数范围。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
### returnType [method]
|
||||
|
||||
```kotlin
|
||||
@@ -210,7 +230,7 @@ fun returnType(value: Any): IndexTypeCondition
|
||||
|
||||
> 设置 `Method` 返回值。
|
||||
|
||||
可不填写返回值,默认模糊查找并取第一个匹配的 `Method`。
|
||||
可不填写返回值。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
@@ -262,7 +282,7 @@ inline fun method(initiate: MethodFinder.() -> Unit): Result
|
||||
|
||||
> 创建需要重新查找的 `Method`。
|
||||
|
||||
你可以添加多个备选方法,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
你可以添加多个备选 `Method`,直到成功为止,若最后依然失败,将停止查找并输出错误日志。
|
||||
|
||||
#### Result [class]
|
||||
|
||||
@@ -281,13 +301,17 @@ inner class Result internal constructor()
|
||||
##### onFind [method]
|
||||
|
||||
```kotlin
|
||||
fun onFind(initiate: Method.() -> Unit)
|
||||
fun onFind(initiate: HashSet<Method>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.1` `新增`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
`initiate` 参数 `Method` 变为 `HashSet<Method>`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 当在 `RemedyPlan` 中找到结果时。
|
||||
@@ -309,13 +333,17 @@ method {
|
||||
### Result [class]
|
||||
|
||||
```kotlin
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, private val e: Throwable?)
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, private val throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0` `添加`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
继承到接口 `BaseResult`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Method` 查找结果实现类。
|
||||
@@ -349,6 +377,7 @@ method {
|
||||
// Your code here.
|
||||
}.result {
|
||||
get(instance).call()
|
||||
all(instance)
|
||||
remedys {}
|
||||
onNoSuchMethod {}
|
||||
}
|
||||
@@ -368,6 +397,8 @@ fun get(instance: Any?): Instance
|
||||
|
||||
> 获得 `Method` 实例处理类。
|
||||
|
||||
若有多个 `Method` 结果只会返回第一个。
|
||||
|
||||
!> 若你设置了 `remedys` 请使用 `wait` 回调结果方法。
|
||||
|
||||
**功能示例**
|
||||
@@ -392,6 +423,36 @@ method {
|
||||
}.get().call()
|
||||
```
|
||||
|
||||
#### all [method]
|
||||
|
||||
```kotlin
|
||||
fun all(instance: Any?): ArrayList<Instance>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Method` 实例处理类数组。
|
||||
|
||||
返回全部查询条件匹配的多个 `Method` 实例结果并在 `isBindToHooker` 时设置到 `hookInstance`。
|
||||
|
||||
**功能示例**
|
||||
|
||||
你可以通过此方法来获得当前条件结果中匹配的全部 `Method`,其方法所在实例用法与 `get` 相同。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// Your code here.
|
||||
}.all(instance).forEach { instance ->
|
||||
instance.call(...)
|
||||
}
|
||||
```
|
||||
|
||||
#### give [method]
|
||||
|
||||
```kotlin
|
||||
@@ -404,7 +465,29 @@ fun give(): Method?
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到方法本身。
|
||||
> 得到 `Method` 本身。
|
||||
|
||||
若有多个 `Method` 结果只会返回第一个。
|
||||
|
||||
在查询条件找不到任何结果的时候将返回 `null`。
|
||||
|
||||
#### giveAll [method]
|
||||
|
||||
```kotlin
|
||||
fun giveAll(): HashSet<Method>
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 得到 `Method` 本身数组。
|
||||
|
||||
返回全部查询条件匹配的多个 `Method` 实例。
|
||||
|
||||
在查询条件找不到任何结果的时候将返回空的 `HashSet`。
|
||||
|
||||
#### wait [method]
|
||||
|
||||
@@ -420,6 +503,28 @@ fun wait(instance: Any?, initiate: Instance.() -> Unit)
|
||||
|
||||
> 获得 `Method` 实例处理类,配合 `RemedyPlan` 使用。
|
||||
|
||||
若有多个 `Method` 结果只会返回第一个。
|
||||
|
||||
!> 若你设置了 `remedys` 必须使用此方法才能获得结果。
|
||||
|
||||
!> 若你没有设置 `remedys` 此方法将不会被回调。
|
||||
|
||||
#### waitAll [method]
|
||||
|
||||
```kotlin
|
||||
fun waitAll(instance: Any?, initiate: ArrayList<Instance>.() -> Unit)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.93` `新增`
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 获得 `Method` 实例处理类数组,配合 `RemedyPlan` 使用。
|
||||
|
||||
返回全部查询条件匹配的多个 `Method` 实例结果。
|
||||
|
||||
!> 若你设置了 `remedys` 必须使用此方法才能获得结果。
|
||||
|
||||
!> 若你没有设置 `remedys` 此方法将不会被回调。
|
||||
@@ -440,11 +545,11 @@ inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 创建方法重查找功能。
|
||||
> 创建 `Method` 重查找功能。
|
||||
|
||||
**功能示例**
|
||||
|
||||
当你遇到一种方法可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchMethod` 捕获异常二次查找方法。
|
||||
当你遇到一种 `Method` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchMethod` 捕获异常二次查找 `Method`。
|
||||
|
||||
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
|
||||
|
||||
@@ -479,7 +584,7 @@ inline fun onNoSuchMethod(result: (Throwable) -> Unit): Result
|
||||
|
||||
**功能描述**
|
||||
|
||||
> 监听找不到方法时。
|
||||
> 监听找不到 `Method` 时。
|
||||
|
||||
只会返回第一次的错误信息,不会返回 `RemedyPlan` 的错误信息。
|
||||
|
||||
@@ -502,13 +607,17 @@ fun ignoredError(): Result
|
||||
#### Instance [class]
|
||||
|
||||
```kotlin
|
||||
inner class Instance internal constructor(private val instance: Any?)
|
||||
inner class Instance internal constructor(private val instance: Any?, private val method: Method?)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
||||
`v1.0.2` `新增`
|
||||
|
||||
`v1.0.93` `修改`
|
||||
|
||||
新增 `method` 参数
|
||||
|
||||
**功能描述**
|
||||
|
||||
> `Method` 实例处理类。
|
||||
|
@@ -325,6 +325,58 @@ Test::class.java.method {
|
||||
|
||||
更多用法可参考 [NameConditions](api/document?id=nameconditions-class)。
|
||||
|
||||
### 多重查询
|
||||
|
||||
有些时候,我们可能需要查询一个 `Class` 中具有相同特征的一组方法、构造方法、变量,这个时候,我们就可以利用相对条件匹配来完成。
|
||||
|
||||
在查询条件结果的基础上,我们只需要把 `get` 换为 `all` 即可得到匹配条件的全部字节码。
|
||||
|
||||
假设这次我们要得到 `Class` 中方法参数个数范围在 `1..3` 的全部方法,可以使用如下实现。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 假设这就是这个 Class 的实例
|
||||
val instance = Test()
|
||||
// 使用 YukiHookAPI 调用并执行
|
||||
Test::class.java.method {
|
||||
paramCount(1..3)
|
||||
}.all(instance).forEach { instance ->
|
||||
// 调用执行每个方法
|
||||
instance.call(...)
|
||||
}
|
||||
```
|
||||
|
||||
上述示例可完美匹配到如下 3 个方法。
|
||||
|
||||
`private void doTask(String taskName)`
|
||||
|
||||
`private void release(Release release, Function<boolean, String> function, Task task)`
|
||||
|
||||
`private void b(String a)`
|
||||
|
||||
通过观察 `Class` 中有两个名称为 `b` 的方法,可以使用如下实现。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
// 假设这就是这个 Class 的实例
|
||||
val instance = Test()
|
||||
// 使用 YukiHookAPI 调用并执行
|
||||
Test::class.java.method {
|
||||
name = "b"
|
||||
}.all(instance).forEach { instance ->
|
||||
// 调用执行每个方法
|
||||
instance.call(...)
|
||||
}
|
||||
```
|
||||
|
||||
上述示例可完美匹配到如下 2 个方法。
|
||||
|
||||
`private void b()`
|
||||
|
||||
`private void b(String a)`
|
||||
|
||||
### 静态字节码
|
||||
|
||||
有些方法和变量在 `Class` 中是静态的实现,这个时候,我们不需要传入实例就可以调用它们。
|
||||
@@ -625,7 +677,7 @@ Test::class.java.method {
|
||||
|
||||
!> 特别注意使用了 `RemedyPlan` 的方法查询结果不能再使用 `get` 的方式得到方法实例,应当使用 `wait` 方法。
|
||||
|
||||
更多用法可参考 [Method RemedyPlan](api/document?id=remedyplan-class) 以及 [Constructor RemedyPlan](api/document?id=remedyplan-class-1)。
|
||||
更多用法可参考 [Method RemedyPlan](api/document?id=remedyplan-class)、[Constructor RemedyPlan](api/document?id=remedyplan-class-1)、[Field RemedyPlan](api/document?id=remedyplan-class-2)。
|
||||
|
||||
### 相对匹配
|
||||
|
||||
|
Reference in New Issue
Block a user