Modify move Result to Process for Hooker in MethodFinder, ConstructorFinder and YukiMemberHookCreater

This commit is contained in:
2022-08-28 22:39:45 +08:00
parent 0f0bd40916
commit c93e6a563e
8 changed files with 506 additions and 149 deletions

View File

@@ -228,6 +228,115 @@ constructor {
}
```
### Process *- class*
```kotlin
inner class Process internal constructor(internal val isNoSuch: Boolean, internal val throwable: Throwable?) : BaseResult
```
**变更记录**
`v1.0.93` `新增`
**功能描述**
> `Constructor` 查找结果处理类,为 `hookInstance` 提供。
#### result *- method*
```kotlin
inline fun result(initiate: Process.() -> Unit): Process
```
**变更记录**
`v1.0.93` `新增`
**功能描述**
> 创建监听结果事件方法体。
**功能示例**
你可以使用 `lambda` 形式创建 `Result` 类。
> 示例如下
```kotlin
constructor {
// Your code here.
}.result {
all()
remedys {}
onNoSuchConstructor {}
}
```
#### all *- method*
```kotlin
fun all(): Process
```
**变更记录**
`v1.0.93` `新增`
**功能描述**
> 设置全部查询条件匹配的多个 `Constructor` 实例结果到 `hookInstance`。
#### remedys *- method*
```kotlin
inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
```
**变更记录**
`v1.0.93` `新增`
**功能描述**
> 创建 `Constructor` 重查找功能。
**功能示例**
当你遇到一种 `Constructor` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchConstructor` 捕获异常二次查找 `Constructor`
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
> 示例如下
```kotlin
constructor {
// Your code here.
}.remedys {
constructor {
// Your code here.
}
constructor {
// Your code here.
}
}
```
#### onNoSuchConstructor *- method*
```kotlin
inline fun onNoSuchConstructor(result: (Throwable) -> Unit): Result
```
**变更记录**
`v1.0.93` `新增`
**功能描述**
> 监听找不到 `Constructor` 时。
只会返回第一次的错误信息,不会返回 `RemedyPlan` 的错误信息。
### Result *- class*
```kotlin
@@ -345,7 +454,7 @@ fun all(): ArrayList<Instance>
> 获得 `Constructor` 实例处理类数组。
返回全部查询条件匹配的多个 `Constructor` 实例结果并在 `isBindToHooker` 时设置到 `hookInstance`
返回全部查询条件匹配的多个 `Constructor` 实例结果。
**功能示例**

View File

@@ -330,6 +330,115 @@ method {
}
```
### Process *- class*
```kotlin
inner class Process internal constructor(internal val isNoSuch: Boolean, internal val throwable: Throwable?) : BaseResult
```
**变更记录**
`v1.0.93` `新增`
**功能描述**
> `Method` 查找结果处理类,为 `hookInstance` 提供。
#### result *- method*
```kotlin
inline fun result(initiate: Process.() -> Unit): Process
```
**变更记录**
`v1.0.93` `新增`
**功能描述**
> 创建监听结果事件方法体。
**功能示例**
你可以使用 `lambda` 形式创建 `Result` 类。
> 示例如下
```kotlin
method {
// Your code here.
}.result {
all()
remedys {}
onNoSuchMethod {}
}
```
#### all *- method*
```kotlin
fun all(): Process
```
**变更记录**
`v1.0.93` `新增`
**功能描述**
> 设置全部查询条件匹配的多个 `Method` 实例结果到 `hookInstance`。
#### remedys *- method*
```kotlin
inline fun remedys(initiate: RemedyPlan.() -> Unit): Result
```
**变更记录**
`v1.0.93` `新增`
**功能描述**
> 创建 `Method` 重查找功能。
**功能示例**
当你遇到一种 `Method` 可能存在不同形式的存在时,可以使用 `RemedyPlan` 重新查找它,而没有必要使用 `onNoSuchMethod` 捕获异常二次查找 `Method`
若第一次查找失败了,你还可以在这里继续添加此方法体直到成功为止。
> 示例如下
```kotlin
method {
// Your code here.
}.remedys {
method {
// Your code here.
}
method {
// Your code here.
}
}
```
#### onNoSuchMethod *- method*
```kotlin
inline fun onNoSuchMethod(result: (Throwable) -> Unit): Result
```
**变更记录**
`v1.0.93` `新增`
**功能描述**
> 监听找不到 `Method` 时。
只会返回第一次的错误信息,不会返回 `RemedyPlan` 的错误信息。
### Result *- class*
```kotlin
@@ -437,7 +546,7 @@ fun all(instance: Any?): ArrayList<Instance>
> 获得 `Method` 实例处理类数组。
返回全部查询条件匹配的多个 `Method` 实例结果并在 `isBindToHooker` 时设置到 `hookInstance`
返回全部查询条件匹配的多个 `Method` 实例结果。
**功能示例**

View File

@@ -96,11 +96,11 @@ inline fun injectMember(priority: Int, tag: String, initiate: MemberHookCreater.
**功能描述**
> 注入要 Hook 的方法、构造方法
> 注入要 Hook 的 `Method`、`Constructor`
**功能示例**
你可以注入任意方法与构造方法,使用 `injectMember` 即可创建一个 `Hook` 对象。
你可以注入任意 `Method``Constructor`,使用 `injectMember` 即可创建一个 `Hook` 对象。
> 示例如下
@@ -176,7 +176,7 @@ inner class MemberHookCreater internal constructor(private val priority: Int, in
**功能描述**
> Hook 核心功能实现类,查找和处理需要 Hook 的方法、构造方法
> Hook 核心功能实现类,查找和处理需要 Hook 的 `Method`、`Constructor`
#### ~~member *- field*~~ <!-- {docsify-ignore} -->
@@ -200,13 +200,13 @@ fun members(vararg member: Member?)
**功能描述**
> 手动指定要 Hook 的方法、构造方法
> 手动指定要 Hook 的 `Method`、`Constructor`
!> 不建议使用此方法设置目标需要 Hook 的 `Member` 对象,你可以使用 `method``constructor` 方法。
**功能示例**
你可以调用 `instanceClass` 来手动查询要 Hook 的方法
你可以调用 `instanceClass` 来手动查询要 Hook 的 `Method``Constructor`
> 示例如下
@@ -218,7 +218,7 @@ injectMember {
}
```
同样地,你也可以传入一组方法同时进行 Hook。
同样地,你也可以传入一组 `Member` 同时进行 Hook。
> 示例如下
@@ -266,9 +266,9 @@ fun allMembers(type: MembersType)
**功能描述**
> 查找并 Hook `hookClass` 中的全部方法、构造方法
> 查找并 Hook `hookClass` 中的全部 `Method`、`Constructor`
!> 警告:无法准确处理每个方法的返回值和 `param`,建议使用 `method` or `constructor` 对每个方法单独 Hook。
!> 警告:无法准确处理每个 `Member` 的返回值和 `param`,建议使用 `method` or `constructor` 对每个 `Member` 单独 Hook。
#### method *- method*
@@ -286,7 +286,7 @@ inline fun method(initiate: MethodCondition): MethodFinder.Result
**功能描述**
> 查找当前 `Class` 需要 Hook 的方法
> 查找当前 `Class` 需要 Hook 的 `Method`
**功能示例**
@@ -341,7 +341,7 @@ inline fun constructor(initiate: ConstructorCondition): ConstructorFinder.Result
**功能描述**
> 查找当前 `Class` 需要 Hook 的构造方法
> 查找当前 `Class` 需要 Hook 的 `Constructor`
**功能示例**
@@ -389,7 +389,7 @@ inline fun HookParam.field(initiate: FieldCondition): FieldFinder.Result
**功能描述**
> 使用当前 `instanceClass` 查找并得到 `Field`。
> 使用当前 `hookClass` 查找并得到 `Field`。
**功能示例**
@@ -430,7 +430,7 @@ inline fun HookParam.method(initiate: MethodCondition): MethodFinder.Result
**功能描述**
> 使用当前 `instanceClass` 查找并得到方法
> 使用当前 `hookClass` 查找并得到 `Method`
#### HookParam.constructor *- i-ext-method*
@@ -448,7 +448,7 @@ inline fun HookParam.constructor(initiate: ConstructorCondition): ConstructorFin
**功能描述**
> 使用当前 `instanceClass` 查找并得到构造方法
> 使用当前 `hookClass` 查找并得到 `Constructor`
#### HookParam.injectMember *- i-ext-method*
@@ -462,7 +462,7 @@ inline fun HookParam.injectMember(priority: Int, tag: String, initiate: MemberHo
**功能描述**
> 注入要 Hook 的方法、构造方法 (嵌套 Hook)。
> 注入要 Hook 的 `Method`、`Constructor` (嵌套 Hook)。
#### beforeHook *- method*
@@ -480,7 +480,7 @@ fun beforeHook(initiate: HookParam.() -> Unit): HookCallback
**功能描述**
> 方法执行完成前 Hook。
> `Member` 执行完成前 Hook。
#### afterHook *- method*
@@ -498,7 +498,7 @@ fun afterHook(initiate: HookParam.() -> Unit): HookCallback
**功能描述**
> 方法执行完成后 Hook。
> `Member` 执行完成后 Hook。
#### replaceAny *- method*
@@ -512,7 +512,7 @@ fun replaceAny(initiate: HookParam.() -> Any?)
**功能描述**
> 拦截并替换此方法内容,给出返回值。
> 拦截并替换此 `Member` 内容,给出返回值。
#### replaceUnit *- method*
@@ -526,7 +526,7 @@ fun replaceUnit(initiate: HookParam.() -> Unit)
**功能描述**
> 拦截并替换此方法内容,没有返回值,可以称为 `Void`。
> 拦截并替换此 `Member` 内容,没有返回值,可以称为 `Void`。
#### replaceTo *- method*
@@ -540,7 +540,7 @@ fun replaceTo(any: Any?)
**功能描述**
> 拦截并替换方法返回值。
> 拦截并替 `Member` 返回值。
#### replaceToTrue *- method*
@@ -554,9 +554,9 @@ fun replaceToTrue()
**功能描述**
> 拦截并替换方法返回值为 `true`。
> 拦截并替换 `Member` 返回值为 `true`。
!> 确保替换方法的返回对象为 `Boolean`
!> 确保替换 `Member` 的返回对象为 `Boolean`
#### replaceToFalse *- method*
@@ -570,9 +570,9 @@ fun replaceToFalse()
**功能描述**
> 拦截并替换方法返回值为 `false`。
> 拦截并替换 `Member` 返回值为 `false`。
!> 确保替换方法的返回对象为 `Boolean`
!> 确保替换 `Member` 的返回对象为 `Boolean`
#### intercept *- method*
@@ -586,11 +586,11 @@ fun intercept()
**功能描述**
> 拦截此方法
> 拦截此 `Member`
!> 这将会禁止此方法执行并返回 `null`
!> 这将会禁止此 `Member` 执行并返回 `null`
!> 注意:例如 `Int``Long``Boolean` 常量返回值的方法一旦被设置为 null 可能会造成 Hook APP 抛出异常。
!> 注意:例如 `Int``Long``Boolean` 常量返回值的 `Member` 一旦被设置为 null 可能会造成 Hook APP 抛出异常。
#### removeSelf *- method*
@@ -604,7 +604,7 @@ fun removeSelf(result: (Boolean) -> Unit)
**功能描述**
> 移除当前注入的 Hook 方法、构造方法 (解除 Hook)。
> 移除当前注入的 Hook `Method`、`Constructor` (解除 Hook)。
!> 你只能在 Hook 回调方法中使用此功能。
@@ -866,7 +866,7 @@ fun remove(result: (Boolean) -> Unit)
**功能描述**
> 移除当前注入的 Hook 方法、构造方法 (解除 Hook)。
> 移除当前注入的 Hook `Method`、`Constructor` (解除 Hook)。
!> 你只能在 Hook 成功后才能解除 Hook可监听 `onHooked` 事件。