mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 17:55:24 +08:00
Changed Finder function
This commit is contained in:
@@ -73,6 +73,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
injectMember {
|
||||
method {
|
||||
name = "getFirstText"
|
||||
emptyParam()
|
||||
returnType = StringType
|
||||
}
|
||||
// 执行替换 Hook
|
||||
@@ -122,6 +123,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
injectMember {
|
||||
method {
|
||||
name = "toast"
|
||||
emptyParam()
|
||||
returnType = UnitType
|
||||
}
|
||||
// 拦截整个方法
|
||||
@@ -137,6 +139,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
injectMember {
|
||||
method {
|
||||
name = "getDataText"
|
||||
emptyParam()
|
||||
returnType = StringType
|
||||
}
|
||||
// 执行替换 Hook
|
||||
|
@@ -28,7 +28,7 @@ var paramCount: Int
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Constructor` 参数个数。
|
||||
> 设置 `Constructor` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此变量指定参数个数。
|
||||
|
||||
@@ -46,12 +46,26 @@ fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Constructor` 筛选条件。
|
||||
> 设置 `Constructor` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件,默认模糊查找并取第一个匹配的 `Constructor`。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
### emptyParam [method]
|
||||
|
||||
```kotlin
|
||||
fun emptyParam(): IndexTypeCondition
|
||||
```
|
||||
|
||||
<b>变更记录</b>
|
||||
|
||||
`v1.0.75` `新增`
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> 设置 `Constructor` 空参数、无参数。
|
||||
|
||||
### param [method]
|
||||
|
||||
```kotlin
|
||||
@@ -64,16 +78,36 @@ fun param(vararg paramType: Any): IndexTypeCondition
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Constructor` 参数。
|
||||
> 设置 `Constructor` 参数。
|
||||
|
||||
如果同时使用了 `paramCount` 则 `paramTypes` 的数量必须与 `paramCount` 完全匹配。
|
||||
|
||||
!> 无参 `Constructor` 不要使用此方法。
|
||||
!> 无参 `Constructor` 请使用 `emptyParam` 设置查询条件。
|
||||
|
||||
!> 有参 `Constructor` 必须使用此方法设定参数或使用 `paramCount` 指定个数。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
### paramCount [method]
|
||||
|
||||
```kotlin
|
||||
fun paramCount(num: Int): IndexTypeCondition
|
||||
```
|
||||
|
||||
<b>变更记录</b>
|
||||
|
||||
`v1.0.70` `新增`
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> 设置 `Constructor` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数。
|
||||
|
||||
若参数个数小于零则忽略并使用 `param`。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
### RemedyPlan [class]
|
||||
|
||||
```kotlin
|
||||
|
@@ -40,7 +40,7 @@ var name: String
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Field` 名称。
|
||||
> 设置 `Field` 名称。
|
||||
|
||||
!> 若不填写名称则必须存在一个其它条件。
|
||||
|
||||
@@ -56,7 +56,7 @@ var type: Any?
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Field` 类型。
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
可不填写类型,默认模糊查找并取第一个匹配的 `Field`。
|
||||
|
||||
@@ -72,7 +72,7 @@ fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Field` 筛选条件。
|
||||
> 设置 `Field` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件,默认模糊查找并取第一个匹配的 `Field`。
|
||||
|
||||
@@ -104,7 +104,7 @@ fun name(value: String): IndexTypeCondition
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Field` 名称。
|
||||
> 设置 `Field` 名称。
|
||||
|
||||
!> 若不填写名称则必须存在一个其它条件,默认模糊查找并取第一个匹配的 `Field`。
|
||||
|
||||
@@ -122,7 +122,7 @@ fun type(value: Any): IndexTypeCondition
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Field` 类型。
|
||||
> 设置 `Field` 类型。
|
||||
|
||||
!> 可不填写类型,默认模糊查找并取第一个匹配的 `Field`。
|
||||
|
||||
|
@@ -26,7 +26,7 @@ val args: Array<Any?>
|
||||
|
||||
> 获取当前 Hook 对象 `member` 或 `constructor` 的参数对象数组。
|
||||
|
||||
### ~~firstArgs [field]~~
|
||||
### ~~firstArgs [field]~~ <!-- {docsify-ignore} -->
|
||||
|
||||
<b>变更记录</b>
|
||||
|
||||
@@ -36,7 +36,7 @@ val args: Array<Any?>
|
||||
|
||||
请使用 `args(index = 0)` 或 `args().first()`
|
||||
|
||||
### ~~lastArgs [field]~~
|
||||
### ~~lastArgs [field]~~ <!-- {docsify-ignore} -->
|
||||
|
||||
<b>变更记录</b>
|
||||
|
||||
@@ -132,7 +132,7 @@ inline fun <reified T> result(): T?
|
||||
|
||||
> 获取当前 Hook 对象的 `method` 或 `constructor` 的返回值 `T`。
|
||||
|
||||
### ~~firstArgs [method]~~
|
||||
### ~~firstArgs [method]~~ <!-- {docsify-ignore} -->
|
||||
|
||||
<b>变更记录</b>
|
||||
|
||||
@@ -140,7 +140,7 @@ inline fun <reified T> result(): T?
|
||||
|
||||
`v1.0.75` `移除`
|
||||
|
||||
### ~~lastArgs [method]~~
|
||||
### ~~lastArgs [method]~~ <!-- {docsify-ignore} -->
|
||||
|
||||
<b>变更记录</b>
|
||||
|
||||
|
@@ -32,7 +32,7 @@ var name: String
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Method` 名称。
|
||||
> 设置 `Method` 名称。
|
||||
|
||||
!> 若不填写名称则必须存在一个其它条件。
|
||||
|
||||
@@ -48,7 +48,7 @@ var paramCount: Int
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Method` 参数个数。
|
||||
> 设置 `Method` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此变量指定参数个数。
|
||||
|
||||
@@ -66,7 +66,7 @@ var returnType: Any?
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Method` 返回值,可不填写返回值,默认模糊查找并取第一个匹配的 `Method`。
|
||||
> 设置 `Method` 返回值,可不填写返回值,默认模糊查找并取第一个匹配的 `Method`。
|
||||
|
||||
### modifiers [method]
|
||||
|
||||
@@ -80,12 +80,26 @@ fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Method` 筛选条件。
|
||||
> 设置 `Method` 标识符筛选条件。
|
||||
|
||||
可不设置筛选条件,默认模糊查找并取第一个匹配的 `Method`。
|
||||
|
||||
!> 存在多个 `IndexTypeCondition` 时除了 `order` 只会生效最后一个。
|
||||
|
||||
### emptyParam [method]
|
||||
|
||||
```kotlin
|
||||
fun emptyParam(): IndexTypeCondition
|
||||
```
|
||||
|
||||
<b>变更记录</b>
|
||||
|
||||
`v1.0.75` `新增`
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> 设置 `Method` 空参数、无参数。
|
||||
|
||||
### param [method]
|
||||
|
||||
```kotlin
|
||||
@@ -98,11 +112,11 @@ fun param(vararg paramType: Any): IndexTypeCondition
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Method` 参数。
|
||||
> 设置 `Method` 参数。
|
||||
|
||||
如果同时使用了 `paramCount` 则 `paramTypes` 的数量必须与 `paramCount` 完全匹配。
|
||||
|
||||
!> 无参 `Method` 不要使用此方法。
|
||||
!> 无参 `Method` 请使用 `emptyParam` 设置查询条件。
|
||||
|
||||
!> 有参 `Method` 必须使用此方法设定参数或使用 `paramCount` 指定个数。
|
||||
|
||||
@@ -134,7 +148,7 @@ fun name(value: String): IndexTypeCondition
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Method` 名称。
|
||||
> 设置 `Method` 名称。
|
||||
|
||||
!> 若不填写名称则必须存在一个其它条件,默认模糊查找并取第一个匹配的 `Method`。
|
||||
|
||||
@@ -152,7 +166,7 @@ fun paramCount(num: Int): IndexTypeCondition
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Method` 参数个数。
|
||||
> 设置 `Method` 参数个数。
|
||||
|
||||
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数。
|
||||
|
||||
@@ -172,7 +186,7 @@ fun returnType(value: Any): IndexTypeCondition
|
||||
|
||||
<b>功能描述</b>
|
||||
|
||||
> `Method` 返回值。
|
||||
> 设置 `Method` 返回值。
|
||||
|
||||
可不填写返回值,默认模糊查找并取第一个匹配的 `Method`。
|
||||
|
||||
|
@@ -683,7 +683,7 @@ TargetClass.hook {
|
||||
|
||||
你必须在 `hook` 方法体内加入至少一个 `injectMember` 方法。
|
||||
|
||||
!> `IllegalStateException` paramTypes is empty, please delete param() method
|
||||
!> `IllegalStateException` paramTypes is empty, please use emptyParam() instead
|
||||
|
||||
<b>异常原因</b>
|
||||
|
||||
@@ -693,11 +693,34 @@ TargetClass.hook {
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
// 没有填写任何参数
|
||||
name = "test"
|
||||
// 括号内没有填写任何参数
|
||||
param()
|
||||
}
|
||||
```
|
||||
|
||||
<b>解决方案</b>
|
||||
|
||||
若要标识此方法、构造方法没有参数,你可以什么都不写或设置 `paramCount = 0` 即可。
|
||||
若要标识此方法、构造方法没有参数,你可以有如下设置方法。
|
||||
|
||||
第一种,设置 `emptyParam` (推荐)
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
emptyParam()
|
||||
}
|
||||
```
|
||||
|
||||
第二种,设置 `paramCount = 0`
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
method {
|
||||
name = "test"
|
||||
paramCount = 0
|
||||
}
|
||||
```
|
@@ -65,7 +65,7 @@ class ConstructorFinder(
|
||||
private var modifiers: ModifierRules? = null
|
||||
|
||||
/**
|
||||
* [Constructor] 参数个数
|
||||
* 设置 [Constructor] 参数个数
|
||||
*
|
||||
* 你可以不使用 [param] 指定参数类型而是仅使用此变量指定参数个数
|
||||
*
|
||||
@@ -74,7 +74,7 @@ class ConstructorFinder(
|
||||
var paramCount = -1
|
||||
|
||||
/**
|
||||
* [Constructor] 筛选条件
|
||||
* 设置 [Constructor] 标识符筛选条件
|
||||
*
|
||||
* - ❗存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
|
||||
* @param initiate 方法体
|
||||
@@ -86,11 +86,18 @@ class ConstructorFinder(
|
||||
}
|
||||
|
||||
/**
|
||||
* [Constructor] 参数
|
||||
* 设置 [Constructor] 空参数、无参数
|
||||
*
|
||||
* @return [BaseFinder.IndexTypeCondition]
|
||||
*/
|
||||
fun emptyParam() = paramCount(num = 0)
|
||||
|
||||
/**
|
||||
* 设置 [Constructor] 参数
|
||||
*
|
||||
* 如果同时使用了 [paramCount] 则 [paramTypes] 的数量必须与 [paramCount] 完全匹配
|
||||
*
|
||||
* - ❗无参 [Constructor] 不要使用此方法
|
||||
* - ❗无参 [Constructor] 请使用 [emptyParam] 设置查询条件
|
||||
*
|
||||
* - ❗有参 [Constructor] 必须使用此方法设定参数或使用 [paramCount] 指定个数
|
||||
*
|
||||
@@ -99,7 +106,7 @@ class ConstructorFinder(
|
||||
* @return [BaseFinder.IndexTypeCondition]
|
||||
*/
|
||||
fun param(vararg paramType: Any): IndexTypeCondition {
|
||||
if (paramType.isEmpty()) error("paramTypes is empty, please delete param() method")
|
||||
if (paramType.isEmpty()) error("paramTypes is empty, please use emptyParam() instead")
|
||||
paramTypes = ArrayList<Class<*>>().apply { paramType.forEach { add(it.compat() ?: UndefinedType) } }.toTypedArray()
|
||||
return IndexTypeCondition(IndexConfigType.MATCH)
|
||||
}
|
||||
@@ -111,7 +118,7 @@ class ConstructorFinder(
|
||||
fun order() = IndexTypeCondition(IndexConfigType.ORDER)
|
||||
|
||||
/**
|
||||
* [Constructor] 参数个数
|
||||
* 设置 [Constructor] 参数个数
|
||||
*
|
||||
* 你可以不使用 [param] 指定参数类型而是仅使用此方法指定参数个数
|
||||
*
|
||||
|
@@ -55,14 +55,14 @@ class FieldFinder(
|
||||
private var modifiers: ModifierRules? = null
|
||||
|
||||
/**
|
||||
* [Field] 名称
|
||||
* 设置 [Field] 名称
|
||||
*
|
||||
* - ❗若不填写名称则必须存在一个其它条件 - 默认模糊查找并取第一个匹配的 [Field]
|
||||
*/
|
||||
var name = ""
|
||||
|
||||
/**
|
||||
* [Field] 类型
|
||||
* 设置 [Field] 类型
|
||||
*
|
||||
* - ❗只能是 [Class]、[String]、[VariousClass]
|
||||
*
|
||||
@@ -71,7 +71,7 @@ class FieldFinder(
|
||||
var type: Any? = null
|
||||
|
||||
/**
|
||||
* [Field] 筛选条件
|
||||
* 设置 [Field] 标识符筛选条件
|
||||
*
|
||||
* 可不设置筛选条件 - 默认模糊查找并取第一个匹配的 [Field]
|
||||
*
|
||||
@@ -91,7 +91,7 @@ class FieldFinder(
|
||||
fun order() = IndexTypeCondition(IndexConfigType.ORDER)
|
||||
|
||||
/**
|
||||
* [Field] 名称
|
||||
* 设置 [Field] 名称
|
||||
*
|
||||
* - ❗若不填写名称则必须存在一个其它条件 - 默认模糊查找并取第一个匹配的 [Field]
|
||||
*
|
||||
@@ -105,7 +105,7 @@ class FieldFinder(
|
||||
}
|
||||
|
||||
/**
|
||||
* [Field] 类型
|
||||
* 设置 [Field] 类型
|
||||
*
|
||||
* - 可不填写类型 - 默认模糊查找并取第一个匹配的 [Field]
|
||||
*
|
||||
|
@@ -65,14 +65,14 @@ class MethodFinder(
|
||||
private var modifiers: ModifierRules? = null
|
||||
|
||||
/**
|
||||
* [Method] 名称
|
||||
* 设置 [Method] 名称
|
||||
*
|
||||
* - ❗若不填写名称则必须存在一个其它条件 - 默认模糊查找并取第一个匹配的 [Method]
|
||||
*/
|
||||
var name = ""
|
||||
|
||||
/**
|
||||
* [Method] 参数个数
|
||||
* 设置 [Method] 参数个数
|
||||
*
|
||||
* 你可以不使用 [param] 指定参数类型而是仅使用此变量指定参数个数
|
||||
*
|
||||
@@ -90,7 +90,7 @@ class MethodFinder(
|
||||
var returnType: Any? = null
|
||||
|
||||
/**
|
||||
* [Method] 筛选条件
|
||||
* 设置 [Method] 标识符筛选条件
|
||||
*
|
||||
* 可不设置筛选条件 - 默认模糊查找并取第一个匹配的 [Method]
|
||||
*
|
||||
@@ -104,11 +104,18 @@ class MethodFinder(
|
||||
}
|
||||
|
||||
/**
|
||||
* [Method] 参数
|
||||
* 设置 [Method] 空参数、无参数
|
||||
*
|
||||
* @return [BaseFinder.IndexTypeCondition]
|
||||
*/
|
||||
fun emptyParam() = paramCount(num = 0)
|
||||
|
||||
/**
|
||||
* 设置 [Method] 参数
|
||||
*
|
||||
* 如果同时使用了 [paramCount] 则 [paramTypes] 的数量必须与 [paramCount] 完全匹配
|
||||
*
|
||||
* - ❗无参 [Method] 不要使用此方法
|
||||
* - ❗无参 [Method] 请使用 [emptyParam] 设置查询条件
|
||||
*
|
||||
* - ❗有参 [Method] 必须使用此方法设定参数或使用 [paramCount] 指定个数
|
||||
*
|
||||
@@ -117,7 +124,7 @@ class MethodFinder(
|
||||
* @return [BaseFinder.IndexTypeCondition]
|
||||
*/
|
||||
fun param(vararg paramType: Any): IndexTypeCondition {
|
||||
if (paramType.isEmpty()) error("paramTypes is empty, please delete param() method")
|
||||
if (paramType.isEmpty()) error("paramTypes is empty, please use emptyParam() instead")
|
||||
paramTypes = ArrayList<Class<*>>().apply { paramType.forEach { add(it.compat() ?: UndefinedType) } }.toTypedArray()
|
||||
return IndexTypeCondition(IndexConfigType.MATCH)
|
||||
}
|
||||
@@ -129,7 +136,7 @@ class MethodFinder(
|
||||
fun order() = IndexTypeCondition(IndexConfigType.ORDER)
|
||||
|
||||
/**
|
||||
* [Method] 名称
|
||||
* 设置 [Method] 名称
|
||||
*
|
||||
* - ❗若不填写名称则必须存在一个其它条件 - 默认模糊查找并取第一个匹配的 [Method]
|
||||
*
|
||||
@@ -143,7 +150,7 @@ class MethodFinder(
|
||||
}
|
||||
|
||||
/**
|
||||
* [Method] 参数个数
|
||||
* 设置 [Method] 参数个数
|
||||
*
|
||||
* 你可以不使用 [param] 指定参数类型而是仅使用此方法指定参数个数
|
||||
*
|
||||
@@ -159,7 +166,7 @@ class MethodFinder(
|
||||
}
|
||||
|
||||
/**
|
||||
* [Method] 返回值
|
||||
* 设置 [Method] 返回值
|
||||
*
|
||||
* 可不填写返回值 - 默认模糊查找并取第一个匹配的 [Method]
|
||||
*
|
||||
|
Reference in New Issue
Block a user