Added param, type, returnType conditions functions in FieldFinder, MethodFinder, ConstructorFinder, FieldRules, MethodRules, ConstructorRules and fix some bugs in ReflectionTool

This commit is contained in:
2022-12-31 02:21:00 +08:00
parent 3fe9ec9b0f
commit 449158879c
28 changed files with 745 additions and 57 deletions

View File

@@ -67,6 +67,7 @@ const navigationLinks = {
baseApiPath + 'hook/core/finder/base/rules/CountRules',
baseApiPath + 'hook/core/finder/base/rules/ModifierRules',
baseApiPath + 'hook/core/finder/base/rules/NameRules',
baseApiPath + 'hook/core/finder/base/rules/ObjectRules',
baseApiPath + 'hook/bean/HookClass',
baseApiPath + 'hook/bean/VariousClass',
baseApiPath + 'hook/bean/CurrentClass',

View File

@@ -0,0 +1,27 @@
---
pageClass: code-page
---
::: warning
The English translation of this page has not been completed, you are welcome to contribute translations to us.
You can use the **Chrome Translation Plugin** to translate entire pages for reference.
:::
# ObjectRules <span class="symbol">- class</span>
```kotlin:no-line-numbers
class ObjectRules private constructor(private val instance: Any)
```
**Change Records**
`v1.1.5` `added`
**Function Illustrate**
> 这是一个任意对象条件实现类。
可对 R8 混淆后的 `Class`、`Member` 进行更加详细的定位。

View File

@@ -98,6 +98,28 @@ fun param(vararg paramType: Any)
:::
## param <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun param(conditions: ObjectsConditions)
```
**Change Records**
`v1.1.5` `added`
**Function Illustrate**
> 设置 `Constructor` 参数条件。
::: danger
无参 **Constructor** 请使用 **emptyParam** 设置查找条件。
有参 **Constructor** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
:::
## paramCount <span class="symbol">- method</span>
```kotlin:no-line-numbers

View File

@@ -83,3 +83,19 @@ fun name(conditions: NameConditions)
**Function Illustrate**
> 设置 `Field` 名称条件。
## type <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun type(conditions: ObjectConditions)
```
**Change Records**
`v1.1.5` `added`
**Function Illustrate**
> 设置 `Field` 类型条件。
可不填写类型。

View File

@@ -128,6 +128,28 @@ fun param(vararg paramType: Any)
:::
## param <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun param(conditions: ObjectsConditions)
```
**Change Records**
`v1.1.5` `added`
**Function Illustrate**
> 设置 `Method` 参数条件。
::: danger
无参 **Method** 请使用 **emptyParam** 设置查找条件。
有参 **Method** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
:::
## name <span class="symbol">- method</span>
```kotlin:no-line-numbers
@@ -173,3 +195,19 @@ fun paramCount(conditions: CountConditions)
> 设置 `Method` 参数个数条件。
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数条件。
## returnType <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun returnType(conditions: ObjectConditions)
```
**Change Records**
`v1.1.5` `added`
**Function Illustrate**
> 设置 `Method` 返回值条件。
可不填写返回值。

View File

@@ -124,6 +124,30 @@ fun param(vararg paramType: Any): IndexTypeCondition
:::
## param <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun param(conditions: ObjectsConditions): IndexTypeCondition
```
**Change Records**
`v1.1.5` `added`
**Function Illustrate**
> 设置 `Constructor` 参数条件。
::: danger
无参 **Constructor** 请使用 **emptyParam** 设置查找条件。
有参 **Constructor** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
:::
## paramCount <span class="symbol">- method</span>
```kotlin:no-line-numbers

View File

@@ -188,10 +188,32 @@ fun type(value: Any): IndexTypeCondition
> 设置 `Field` 类型。
可不填写类型。
::: danger
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
:::
## type <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun type(conditions: ObjectConditions): IndexTypeCondition
```
**Change Records**
`v1.1.5` `added`
**Function Illustrate**
> 设置 `Field` 类型条件。
可不填写类型。
::: danger
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
:::

View File

@@ -162,6 +162,30 @@ fun param(vararg paramType: Any): IndexTypeCondition
:::
## param <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun param(conditions: ObjectsConditions): IndexTypeCondition
```
**Change Records**
`v1.1.5` `added`
**Function Illustrate**
> 设置 `Method` 参数条件。
::: danger
无参 **Method** 请使用 **emptyParam** 设置查找条件。
有参 **Method** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
:::
## order <span class="symbol">- method</span>
```kotlin:no-line-numbers
@@ -314,6 +338,28 @@ fun returnType(value: Any): IndexTypeCondition
:::
## returnType <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun returnType(conditions: ObjectConditions): IndexTypeCondition
```
**Change Records**
`v1.1.5` `added`
**Function Illustrate**
> 设置 `Method` 返回值条件。
可不填写返回值。
::: danger
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
:::
## superClass <span class="symbol">- method</span>
```kotlin:no-line-numbers

View File

@@ -0,0 +1,19 @@
---
pageClass: code-page
---
# ObjectRules <span class="symbol">- class</span>
```kotlin:no-line-numbers
class ObjectRules private constructor(private val instance: Any)
```
**变更记录**
`v1.1.5` `新增`
**功能描述**
> 这是一个任意对象条件实现类。
可对 R8 混淆后的 `Class`、`Member` 进行更加详细的定位。

View File

@@ -90,6 +90,28 @@ fun param(vararg paramType: Any)
:::
## param <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun param(conditions: ObjectsConditions)
```
**变更记录**
`v1.1.5` `新增`
**功能描述**
> 设置 `Constructor` 参数条件。
::: danger
无参 **Constructor** 请使用 **emptyParam** 设置查找条件。
有参 **Constructor** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
:::
## paramCount <span class="symbol">- method</span>
```kotlin:no-line-numbers

View File

@@ -75,3 +75,19 @@ fun name(conditions: NameConditions)
**功能描述**
> 设置 `Field` 名称条件。
## type <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun type(conditions: ObjectConditions)
```
**变更记录**
`v1.1.5` `新增`
**功能描述**
> 设置 `Field` 类型条件。
可不填写类型。

View File

@@ -120,6 +120,28 @@ fun param(vararg paramType: Any)
:::
## param <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun param(conditions: ObjectsConditions)
```
**变更记录**
`v1.1.5` `新增`
**功能描述**
> 设置 `Method` 参数条件。
::: danger
无参 **Method** 请使用 **emptyParam** 设置查找条件。
有参 **Method** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
:::
## name <span class="symbol">- method</span>
```kotlin:no-line-numbers
@@ -165,3 +187,19 @@ fun paramCount(conditions: CountConditions)
> 设置 `Method` 参数个数条件。
你可以不使用 `param` 指定参数类型而是仅使用此方法指定参数个数条件。
## returnType <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun returnType(conditions: ObjectConditions)
```
**变更记录**
`v1.1.5` `新增`
**功能描述**
> 设置 `Method` 返回值条件。
可不填写返回值。

View File

@@ -116,6 +116,30 @@ fun param(vararg paramType: Any): IndexTypeCondition
:::
## param <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun param(conditions: ObjectsConditions): IndexTypeCondition
```
**变更记录**
`v1.1.5` `新增`
**功能描述**
> 设置 `Constructor` 参数条件。
::: danger
无参 **Constructor** 请使用 **emptyParam** 设置查找条件。
有参 **Constructor** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
:::
## paramCount <span class="symbol">- method</span>
```kotlin:no-line-numbers

View File

@@ -180,10 +180,32 @@ fun type(value: Any): IndexTypeCondition
> 设置 `Field` 类型。
可不填写类型。
::: danger
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
:::
## type <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun type(conditions: ObjectConditions): IndexTypeCondition
```
**变更记录**
`v1.1.5` `新增`
**功能描述**
> 设置 `Field` 类型条件。
可不填写类型。
::: danger
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
:::

View File

@@ -154,6 +154,30 @@ fun param(vararg paramType: Any): IndexTypeCondition
:::
## param <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun param(conditions: ObjectsConditions): IndexTypeCondition
```
**变更记录**
`v1.1.5` `新增`
**功能描述**
> 设置 `Method` 参数条件。
::: danger
无参 **Method** 请使用 **emptyParam** 设置查找条件。
有参 **Method** 必须使用此方法设定参数或使用 **paramCount** 指定个数。
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
:::
## order <span class="symbol">- method</span>
```kotlin:no-line-numbers
@@ -306,6 +330,28 @@ fun returnType(value: Any): IndexTypeCondition
:::
## returnType <span class="symbol">- method</span>
```kotlin:no-line-numbers
fun returnType(conditions: ObjectConditions): IndexTypeCondition
```
**变更记录**
`v1.1.5` `新增`
**功能描述**
> 设置 `Method` 返回值条件。
可不填写返回值。
::: danger
存在多个 **IndexTypeCondition** 时除了 **order** 只会生效最后一个。
:::
## superClass <span class="symbol">- method</span>
```kotlin:no-line-numbers

View File

@@ -30,9 +30,13 @@ package com.highcapable.yukihookapi.hook.core.finder.base.data
import com.highcapable.yukihookapi.hook.core.finder.base.rules.CountRules
import com.highcapable.yukihookapi.hook.core.finder.base.rules.ModifierRules
import com.highcapable.yukihookapi.hook.core.finder.base.rules.NameRules
import com.highcapable.yukihookapi.hook.core.finder.base.rules.ObjectRules
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ModifierConditions
import com.highcapable.yukihookapi.hook.type.defined.VagueType
import java.lang.reflect.Constructor
import java.lang.reflect.Field
import java.lang.reflect.Member
import java.lang.reflect.Method
/**
* 这是 [Class] 与 [Member] 规则查找数据基本类实现
@@ -78,6 +82,30 @@ internal abstract class BaseRulesData internal constructor(
*/
internal fun Member.cast() = ModifierRules.with(instance = this, uniqueValue)
/**
* [Field.getType] 转换为 [ObjectRules]
* @return [ObjectRules]
*/
internal fun Field.type() = ObjectRules.with(type)
/**
* [Method.getParameterTypes] 转换为 [ObjectRules]
* @return [ObjectRules]
*/
internal fun Method.paramTypes() = ObjectRules.with(parameterTypes)
/**
* [Method.getReturnType] 转换为 [ObjectRules]
* @return [ObjectRules]
*/
internal fun Method.returnType() = ObjectRules.with(returnType)
/**
* [Constructor.getParameterTypes] 转换为 [ObjectRules]
* @return [ObjectRules]
*/
internal fun Constructor<*>.paramTypes() = ObjectRules.with(parameterTypes)
/**
* 获取参数数组文本化内容
* @return [String]

View File

@@ -0,0 +1,55 @@
/*
* YukiHookAPI - An efficient Kotlin version of the Xposed Hook API.
* Copyright (C) 2019-2022 HighCapable
* https://github.com/fankes/YukiHookAPI
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* This file is Created by fankes on 2022/12/30.
*/
@file:Suppress("unused")
package com.highcapable.yukihookapi.hook.core.finder.base.rules
import java.lang.reflect.Member
/**
* 这是一个任意对象条件实现类
*
* 可对 R8 混淆后的 [Class]、[Member] 进行更加详细的定位
* @param instance 当前实例对象
*/
class ObjectRules private constructor(private val instance: Any) {
@PublishedApi
internal companion object {
/**
* 创建实例
* @param instance 实例对象
* @return [ObjectRules]
*/
@PublishedApi
internal fun with(instance: Any) = ObjectRules(instance)
}
override fun toString() = "ObjectRules [$instance]"
}

View File

@@ -35,6 +35,7 @@ import com.highcapable.yukihookapi.hook.core.finder.classes.rules.result.MemberR
import com.highcapable.yukihookapi.hook.core.finder.members.data.ConstructorRulesData
import com.highcapable.yukihookapi.hook.core.finder.type.factory.CountConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ModifierConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectsConditions
import com.highcapable.yukihookapi.hook.type.defined.UndefinedType
import com.highcapable.yukihookapi.hook.type.defined.VagueType
import java.lang.reflect.Constructor
@@ -104,6 +105,24 @@ class ConstructorRules internal constructor(@PublishedApi internal val rulesData
arrayListOf<Class<*>>().apply { paramType.forEach { add(it.compat(tag = "Constructor") ?: UndefinedType) } }.toTypedArray()
}
/**
* 设置 [Constructor] 参数条件
*
* 使用示例如下 ↓
*
* ```kotlin
* param { it[1] == StringClass || it[2].name == "java.lang.String" }
* ```
*
* - ❗无参 [Constructor] 请使用 [emptyParam] 设置查找条件
*
* - ❗有参 [Constructor] 必须使用此方法设定参数或使用 [paramCount] 指定个数
* @param conditions 条件方法体
*/
fun param(conditions: ObjectsConditions) {
rulesData.paramTypesConditions = conditions
}
/**
* 设置 [Constructor] 参数个数范围
*

View File

@@ -33,6 +33,7 @@ import com.highcapable.yukihookapi.hook.core.finder.classes.rules.result.MemberR
import com.highcapable.yukihookapi.hook.core.finder.members.data.FieldRulesData
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ModifierConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.NameConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectConditions
import java.lang.reflect.Field
/**
@@ -83,6 +84,22 @@ class FieldRules internal constructor(@PublishedApi internal val rulesData: Fiel
rulesData.nameConditions = conditions
}
/**
* 设置 [Field] 类型条件
*
* - 可不填写类型
*
* 使用示例如下 ↓
*
* ```kotlin
* type { it == StringClass || it.name == "java.lang.String" }
* ```
* @param conditions 条件方法体
*/
fun type(conditions: ObjectConditions) {
rulesData.typeConditions = conditions
}
/**
* 返回结果实现类
* @return [MemberRulesResult]

View File

@@ -33,9 +33,7 @@ import com.highcapable.yukihookapi.hook.bean.VariousClass
import com.highcapable.yukihookapi.hook.core.finder.classes.rules.base.BaseRules
import com.highcapable.yukihookapi.hook.core.finder.classes.rules.result.MemberRulesResult
import com.highcapable.yukihookapi.hook.core.finder.members.data.MethodRulesData
import com.highcapable.yukihookapi.hook.core.finder.type.factory.CountConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ModifierConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.NameConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.*
import com.highcapable.yukihookapi.hook.type.defined.UndefinedType
import com.highcapable.yukihookapi.hook.type.defined.VagueType
import java.lang.reflect.Method
@@ -129,6 +127,24 @@ class MethodRules internal constructor(@PublishedApi internal val rulesData: Met
arrayListOf<Class<*>>().apply { paramType.forEach { add(it.compat(tag = "Method") ?: UndefinedType) } }.toTypedArray()
}
/**
* 设置 [Method] 参数条件
*
* 使用示例如下 ↓
*
* ```kotlin
* param { it[1] == StringClass || it[2].name == "java.lang.String" }
* ```
*
* - ❗无参 [Method] 请使用 [emptyParam] 设置查找条件
*
* - ❗有参 [Method] 必须使用此方法设定参数或使用 [paramCount] 指定个数
* @param conditions 条件方法体
*/
fun param(conditions: ObjectsConditions) {
rulesData.paramTypesConditions = conditions
}
/**
* 设置 [Method] 名称条件
* @param conditions 条件方法体
@@ -169,6 +185,22 @@ class MethodRules internal constructor(@PublishedApi internal val rulesData: Met
rulesData.paramCountConditions = conditions
}
/**
* 设置 [Method] 返回值条件
*
* - 可不填写返回值
*
* 使用示例如下 ↓
*
* ```kotlin
* returnType { it == StringClass || it.name == "java.lang.String" }
* ```
* @param conditions 条件方法体
*/
fun returnType(conditions: ObjectConditions) {
rulesData.returnTypeConditions = conditions
}
/**
* 返回结果实现类
* @return [MemberRulesResult]

View File

@@ -39,6 +39,7 @@ import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ConstructorConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.CountConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ModifierConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectsConditions
import com.highcapable.yukihookapi.hook.factory.checkingInternal
import com.highcapable.yukihookapi.hook.factory.hasExtends
import com.highcapable.yukihookapi.hook.log.yLoggerW
@@ -136,6 +137,28 @@ class ConstructorFinder @PublishedApi internal constructor(
return IndexTypeCondition(IndexConfigType.MATCH)
}
/**
* 设置 [Constructor] 参数条件
*
* 使用示例如下 ↓
*
* ```kotlin
* param { it[1] == StringClass || it[2].name == "java.lang.String" }
* ```
*
* - ❗无参 [Constructor] 请使用 [emptyParam] 设置查找条件
*
* - ❗有参 [Constructor] 必须使用此方法设定参数或使用 [paramCount] 指定个数
*
* - ❗存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param conditions 条件方法体
* @return [BaseFinder.IndexTypeCondition]
*/
fun param(conditions: ObjectsConditions): IndexTypeCondition {
rulesData.paramTypesConditions = conditions
return IndexTypeCondition(IndexConfigType.MATCH)
}
/**
* 顺序筛选字节码的下标
* @return [BaseFinder.IndexTypeCondition]

View File

@@ -40,6 +40,7 @@ import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool
import com.highcapable.yukihookapi.hook.core.finder.type.factory.FieldConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ModifierConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.NameConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectConditions
import com.highcapable.yukihookapi.hook.factory.checkingInternal
import com.highcapable.yukihookapi.hook.factory.current
import com.highcapable.yukihookapi.hook.factory.hasExtends
@@ -157,6 +158,26 @@ class FieldFinder @PublishedApi internal constructor(
return IndexTypeCondition(IndexConfigType.MATCH)
}
/**
* 设置 [Field] 类型条件
*
* - 可不填写类型
*
* 使用示例如下 ↓
*
* ```kotlin
* type { it == StringClass || it.name == "java.lang.String" }
* ```
*
* - ❗存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param conditions 条件方法体
* @return [BaseFinder.IndexTypeCondition]
*/
fun type(conditions: ObjectConditions): IndexTypeCondition {
rulesData.typeConditions = conditions
return IndexTypeCondition(IndexConfigType.MATCH)
}
/**
* 设置在 [classSet] 的所有父类中查找当前 [Field]
*

View File

@@ -36,10 +36,7 @@ import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder
import com.highcapable.yukihookapi.hook.core.finder.base.MemberBaseFinder
import com.highcapable.yukihookapi.hook.core.finder.members.data.MethodRulesData
import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool
import com.highcapable.yukihookapi.hook.core.finder.type.factory.CountConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.MethodConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ModifierConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.NameConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.*
import com.highcapable.yukihookapi.hook.factory.checkingInternal
import com.highcapable.yukihookapi.hook.factory.hasExtends
import com.highcapable.yukihookapi.hook.log.yLoggerW
@@ -166,6 +163,28 @@ class MethodFinder @PublishedApi internal constructor(
return IndexTypeCondition(IndexConfigType.MATCH)
}
/**
* 设置 [Method] 参数条件
*
* 使用示例如下 ↓
*
* ```kotlin
* param { it[1] == StringClass || it[2].name == "java.lang.String" }
* ```
*
* - ❗无参 [Method] 请使用 [emptyParam] 设置查找条件
*
* - ❗有参 [Method] 必须使用此方法设定参数或使用 [paramCount] 指定个数
*
* - ❗存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param conditions 条件方法体
* @return [BaseFinder.IndexTypeCondition]
*/
fun param(conditions: ObjectsConditions): IndexTypeCondition {
rulesData.paramTypesConditions = conditions
return IndexTypeCondition(IndexConfigType.MATCH)
}
/**
* 顺序筛选字节码的下标
* @return [BaseFinder.IndexTypeCondition]
@@ -270,6 +289,26 @@ class MethodFinder @PublishedApi internal constructor(
return IndexTypeCondition(IndexConfigType.MATCH)
}
/**
* 设置 [Method] 返回值条件
*
* - 可不填写返回值
*
* 使用示例如下 ↓
*
* ```kotlin
* returnType { it == StringClass || it.name == "java.lang.String" }
* ```
*
* - ❗存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param conditions 条件方法体
* @return [BaseFinder.IndexTypeCondition]
*/
fun returnType(conditions: ObjectConditions): IndexTypeCondition {
rulesData.returnTypeConditions = conditions
return IndexTypeCondition(IndexConfigType.MATCH)
}
/**
* 设置在 [classSet] 的所有父类中查找当前 [Method]
*

View File

@@ -28,11 +28,13 @@
package com.highcapable.yukihookapi.hook.core.finder.members.data
import com.highcapable.yukihookapi.hook.core.finder.type.factory.CountConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectsConditions
import java.lang.reflect.Constructor
/**
* [Constructor] 规则查找数据类
* @param paramTypes 参数类型数组
* @param paramTypesConditions 参数类型条件
* @param paramCount 参数个数
* @param paramCountRange 参数个数范围
* @param paramCountConditions 参数个数条件
@@ -40,6 +42,7 @@ import java.lang.reflect.Constructor
@PublishedApi
internal class ConstructorRulesData internal constructor(
var paramTypes: Array<out Class<*>>? = null,
var paramTypesConditions: ObjectsConditions? = null,
var paramCount: Int = -1,
var paramCountRange: IntRange = IntRange.EMPTY,
var paramCountConditions: CountConditions? = null
@@ -50,16 +53,17 @@ internal class ConstructorRulesData internal constructor(
paramCount.takeIf { it >= 0 }?.let { "paramCount:[$it]" } ?: "",
paramCountRange.takeIf { it.isEmpty().not() }?.let { "paramCountRange:[$it]" } ?: "",
paramCountConditions?.let { "paramCountConditions:[existed]" } ?: "",
paramTypes?.typeOfString()?.let { "paramTypes:[$it]" } ?: "", *super.templates
paramTypes?.typeOfString()?.let { "paramTypes:[$it]" } ?: "",
paramTypesConditions?.let { "paramTypesConditions:[existed]" } ?: "", *super.templates
)
override val objectName get() = "Constructor"
override val isInitialize
get() = super.isInitializeOfSuper || paramTypes != null || paramCount >= 0 ||
get() = super.isInitializeOfSuper || paramTypes != null || paramTypesConditions != null || paramCount >= 0 ||
paramCountRange.isEmpty().not() || paramCountConditions != null
override fun hashCode(other: Any?) = super.hashCode(other) + toString().hashCode()
override fun toString() = "[$paramTypes][$paramCount][$paramCountRange]"
override fun toString() = "[$paramTypes][$paramTypesConditions][$paramCount][$paramCountRange]"
}

View File

@@ -28,6 +28,7 @@
package com.highcapable.yukihookapi.hook.core.finder.members.data
import com.highcapable.yukihookapi.hook.core.finder.type.factory.NameConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectConditions
import java.lang.reflect.Field
/**
@@ -35,26 +36,30 @@ import java.lang.reflect.Field
* @param name 名称
* @param nameConditions 名称规则
* @param type 类型
* @param typeConditions 类型条件
*/
@PublishedApi
internal class FieldRulesData internal constructor(
var name: String = "",
var nameConditions: NameConditions? = null,
var type: Any? = null
var type: Any? = null,
var typeConditions: ObjectConditions? = null
) : MemberRulesData() {
override val templates
get() = arrayOf(
name.takeIf { it.isNotBlank() }?.let { "name:[$it]" } ?: "",
nameConditions?.let { "nameConditions:[existed]" } ?: "",
type?.let { "type:[$it]" } ?: "", *super.templates
type?.let { "type:[$it]" } ?: "",
typeConditions?.let { "typeConditions:[existed]" } ?: "", *super.templates
)
override val objectName get() = "Field"
override val isInitialize get() = super.isInitializeOfSuper || name.isNotBlank() || nameConditions != null || type != null
override val isInitialize
get() = super.isInitializeOfSuper || name.isNotBlank() || nameConditions != null || type != null || typeConditions != null
override fun hashCode(other: Any?) = super.hashCode(other) + toString().hashCode()
override fun toString() = "[$name][$nameConditions][$type]"
override fun toString() = "[$name][$nameConditions][$type][$typeConditions]"
}

View File

@@ -29,6 +29,8 @@ package com.highcapable.yukihookapi.hook.core.finder.members.data
import com.highcapable.yukihookapi.hook.core.finder.type.factory.CountConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.NameConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectsConditions
import java.lang.reflect.Method
/**
@@ -36,20 +38,24 @@ import java.lang.reflect.Method
* @param name 名称
* @param nameConditions 名称规则
* @param paramTypes 参数类型数组
* @param paramTypesConditions 参数类型条件
* @param paramCount 参数个数
* @param paramCountRange 参数个数范围
* @param paramCountConditions 参数个数条件
* @param returnType 返回值类型
* @param returnTypeConditions 返回值类型条件
*/
@PublishedApi
internal class MethodRulesData internal constructor(
var name: String = "",
var nameConditions: NameConditions? = null,
var paramTypes: Array<out Class<*>>? = null,
var paramTypesConditions: ObjectsConditions? = null,
var paramCount: Int = -1,
var paramCountRange: IntRange = IntRange.EMPTY,
var paramCountConditions: CountConditions? = null,
var returnType: Any? = null
var returnType: Any? = null,
var returnTypeConditions: ObjectConditions? = null
) : MemberRulesData() {
override val templates
@@ -60,16 +66,20 @@ internal class MethodRulesData internal constructor(
paramCountRange.takeIf { it.isEmpty().not() }?.let { "paramCountRange:[$it]" } ?: "",
paramCountConditions?.let { "paramCountConditions:[existed]" } ?: "",
paramTypes?.typeOfString()?.let { "paramTypes:[$it]" } ?: "",
returnType?.let { "returnType:[$it]" } ?: "", *super.templates
paramTypesConditions?.let { "paramTypesConditions:[existed]" } ?: "",
returnType?.let { "returnType:[$it]" } ?: "",
returnTypeConditions?.let { "returnTypeConditions:[existed]" } ?: "", *super.templates
)
override val objectName get() = "Method"
override val isInitialize
get() = super.isInitializeOfSuper || name.isNotBlank() || nameConditions != null || paramTypes != null ||
paramCount >= 0 || paramCountRange.isEmpty().not() || paramCountConditions != null || returnType != null
get() = super.isInitializeOfSuper || name.isNotBlank() || nameConditions != null || paramTypes != null || paramTypesConditions != null ||
paramCount >= 0 || paramCountRange.isEmpty().not() || paramCountConditions != null ||
returnType != null || returnTypeConditions != null
override fun hashCode(other: Any?) = super.hashCode(other) + toString().hashCode()
override fun toString() = "[$name][$nameConditions][$paramTypes][$paramCount][$paramCountRange][$returnType]"
override fun toString() = "[$name][$nameConditions][$paramTypes][$paramTypesConditions][$paramCount]" +
"[$paramCountRange][$returnType][$returnTypeConditions]"
}

View File

@@ -30,7 +30,6 @@
package com.highcapable.yukihookapi.hook.core.finder.tools
import com.highcapable.yukihookapi.hook.core.finder.base.data.BaseRulesData
import com.highcapable.yukihookapi.hook.core.finder.base.rules.CountRules
import com.highcapable.yukihookapi.hook.core.finder.classes.data.ClassRulesData
import com.highcapable.yukihookapi.hook.core.finder.members.data.ConstructorRulesData
import com.highcapable.yukihookapi.hook.core.finder.members.data.FieldRulesData
@@ -45,9 +44,7 @@ import com.highcapable.yukihookapi.hook.type.java.DalvikBaseDexClassLoader
import com.highcapable.yukihookapi.hook.type.java.NoClassDefFoundErrorClass
import com.highcapable.yukihookapi.hook.type.java.NoSuchFieldErrorClass
import com.highcapable.yukihookapi.hook.type.java.NoSuchMethodErrorClass
import com.highcapable.yukihookapi.hook.utils.conditions
import com.highcapable.yukihookapi.hook.utils.let
import com.highcapable.yukihookapi.hook.utils.takeIf
import com.highcapable.yukihookapi.hook.utils.*
import com.highcapable.yukihookapi.hook.utils.value
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge
import com.highcapable.yukihookapi.hook.xposed.bridge.factory.YukiHookHelper
@@ -134,10 +131,10 @@ internal object ReflectionTool {
fullName?.also { it.equals(instance, it.TYPE_NAME).also { e -> if (it.isOptional) opt(e) else and(e) } }
simpleName?.also { it.equals(instance, it.TYPE_SIMPLE_NAME).also { e -> if (it.isOptional) opt(e) else and(e) } }
singleName?.also { it.equals(instance, it.TYPE_SINGLE_NAME).also { e -> if (it.isOptional) opt(e) else and(e) } }
fullNameConditions?.also { instance.name.also { n -> and(it(n.cast(), n)) } }
simpleNameConditions?.also { instance.simpleName.also { n -> and(it(n.cast(), n)) } }
singleNameConditions?.also { classSingleName(instance).also { n -> and(it(n.cast(), n)) } }
modifiers?.also { and(it(instance.cast())) }
fullNameConditions?.also { instance.name.also { n -> runCatching { and(it(n.cast(), n)) } } }
simpleNameConditions?.also { instance.simpleName.also { n -> runCatching { and(it(n.cast(), n)) } } }
singleNameConditions?.also { classSingleName(instance).also { n -> runCatching { and(it(n.cast(), n)) } } }
modifiers?.also { runCatching { and(it(instance.cast())) } }
extendsClass.takeIf { it.isNotEmpty() }?.also { and(instance.hasExtends && it.contains(instance.superclass.name)) }
implementsClass.takeIf { it.isNotEmpty() }
?.also { and(instance.interfaces.isNotEmpty() && instance.interfaces.any { e -> it.contains(e.name) }) }
@@ -156,7 +153,7 @@ internal object ReflectionTool {
rule.conditions {
value.matchCount.takeIf { it >= 0 }?.also { and(it == size) }
value.matchCountRange.takeIf { it.isEmpty().not() }?.also { and(size in it) }
value.matchCountConditions?.also { and(it(CountRules.with(size), size)) }
value.matchCountConditions?.also { runCatching { and(it(size.cast(), size)) } }
}.finally { result(true) }.without { result(false) }
} ?: result(true)
}
@@ -179,7 +176,7 @@ internal object ReflectionTool {
var numberOfFound = 0
if (rule.isInitializeOfSuper) forEach { member ->
rule.conditions {
value.modifiers?.also { and(it(member.cast())) }
value.modifiers?.also { runCatching { and(it(member.cast())) } }
}.finally { numberOfFound++ }
}.run { rule.matchCount(numberOfFound) { and(it && numberOfFound > 0) } }
else rule.matchCount(size) { and(it) }
@@ -192,8 +189,9 @@ internal object ReflectionTool {
rule.conditions {
value.type?.takeIf { value.exists(it) }?.also { and(it == field.type) }
value.name.takeIf { it.isNotBlank() }?.also { and(it == field.name) }
value.modifiers?.also { and(it(field.cast())) }
value.nameConditions?.also { field.name.also { n -> and(it(n.cast(), n)) } }
value.modifiers?.also { runCatching { and(it(field.cast())) } }
value.nameConditions?.also { field.name.also { n -> runCatching { and(it(n.cast(), n)) } } }
value.typeConditions?.also { field.also { t -> runCatching { and(it(t.type(), t.type)) } } }
}.finally { numberOfFound++ }
}.run { rule.matchCount(numberOfFound) { and(it && numberOfFound > 0) } }
else rule.matchCount(size) { and(it) }
@@ -206,12 +204,17 @@ internal object ReflectionTool {
rule.conditions {
value.name.takeIf { it.isNotBlank() }?.also { and(it == method.name) }
value.returnType?.takeIf { value.exists(it) }?.also { and(it == method.returnType) }
value.returnTypeConditions
?.also { method.also { r -> runCatching { and(it(r.returnType(), r.returnType)) } } }
value.paramCount.takeIf { it >= 0 }?.also { and(method.parameterTypes.size == it) }
value.paramCountRange.takeIf { it.isEmpty().not() }?.also { and(method.parameterTypes.size in it) }
value.paramCountConditions?.also { method.parameterTypes.size.also { s -> and(it(s.cast(), s)) } }
value.paramCountConditions
?.also { method.parameterTypes.size.also { s -> runCatching { and(it(s.cast(), s)) } } }
value.paramTypes?.takeIf { value.exists(*it) }?.also { and(paramTypesEq(it, method.parameterTypes)) }
value.modifiers?.also { and(it(method.cast())) }
value.nameConditions?.also { method.name.also { n -> and(it(n.cast(), n)) } }
value.paramTypesConditions
?.also { method.also { t -> runCatching { and(it(t.paramTypes(), t.parameterTypes)) } } }
value.modifiers?.also { runCatching { and(it(method.cast())) } }
value.nameConditions?.also { method.name.also { n -> runCatching { and(it(n.cast(), n)) } } }
}.finally { numberOfFound++ }
}.run { rule.matchCount(numberOfFound) { and(it && numberOfFound > 0) } }
else rule.matchCount(size) { and(it) }
@@ -224,9 +227,12 @@ internal object ReflectionTool {
rule.conditions {
value.paramCount.takeIf { it >= 0 }?.also { and(constructor.parameterTypes.size == it) }
value.paramCountRange.takeIf { it.isEmpty().not() }?.also { and(constructor.parameterTypes.size in it) }
value.paramCountConditions?.also { constructor.parameterTypes.size.also { s -> and(it(s.cast(), s)) } }
value.paramCountConditions
?.also { constructor.parameterTypes.size.also { s -> runCatching { and(it(s.cast(), s)) } } }
value.paramTypes?.takeIf { value.exists(*it) }?.also { and(paramTypesEq(it, constructor.parameterTypes)) }
value.modifiers?.also { and(it(constructor.cast())) }
value.paramTypesConditions
?.also { constructor.also { t -> runCatching { and(it(t.paramTypes(), t.parameterTypes)) } } }
value.modifiers?.also { runCatching { and(it(constructor.cast())) } }
}.finally { numberOfFound++ }
}.run { rule.matchCount(numberOfFound) { and(it && numberOfFound > 0) } }
else rule.matchCount(size) { and(it) }
@@ -265,10 +271,13 @@ internal object ReflectionTool {
var iName = -1
var iModify = -1
var iNameCds = -1
var iTypeCds = -1
val iLType = type?.let(matchIndex) { e -> declares.filter { e == it.type }.lastIndex } ?: -1
val iLName = name.takeIf(matchIndex) { it.isNotBlank() }?.let { e -> declares.filter { e == it.name }.lastIndex } ?: -1
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { e(it.cast()) }.lastIndex } ?: -1
val iLNameCds = nameConditions?.let(matchIndex) { e -> declares.filter { it.name.let { n -> e(n.cast(), n) } }.lastIndex } ?: -1
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { runOrFalse { e(it.cast()) } }.lastIndex } ?: -1
val iLNameCds = nameConditions
?.let(matchIndex) { e -> declares.filter { it.name.let { n -> runOrFalse { e(n.cast(), n) } } }.lastIndex } ?: -1
val iLTypeCds = typeConditions?.let(matchIndex) { e -> declares.filter { runOrFalse { e(it.type(), it.type) } }.lastIndex } ?: -1
declares.forEachIndexed { index, instance ->
conditions {
type?.also {
@@ -284,17 +293,23 @@ internal object ReflectionTool {
})
}
modifiers?.also {
and(it(instance.cast()).let { hold ->
and(runOrFalse { it(instance.cast()) }.let { hold ->
if (hold) iModify++
hold && matchIndex.compare(iModify, iLModify)
})
}
nameConditions?.also {
and(instance.name.let { n -> it(n.cast(), n) }.let { hold ->
and(instance.name.let { n -> runOrFalse { it(n.cast(), n) } }.let { hold ->
if (hold) iNameCds++
hold && matchIndex.compare(iNameCds, iLNameCds)
})
}
typeConditions?.also {
and(instance.let { t -> runOrFalse { it(t.type(), t.type) } }.let { hold ->
if (hold) iTypeCds++
hold && matchIndex.compare(iTypeCds, iLTypeCds)
})
}
orderIndex.compare(index, declares.lastIndex) { and(it) }
}.finally { fields.add(instance.apply { isAccessible = true }) }
}
@@ -318,7 +333,9 @@ internal object ReflectionTool {
ReflectsCacheStore.findMethods(hashCode(classSet)) ?: hashSetOf<Method>().also { methods ->
classSet.existMethods?.also { declares ->
var iReturnType = -1
var iReturnTypeCds = -1
var iParamTypes = -1
var iParamTypesCds = -1
var iParamCount = -1
var iParamCountRange = -1
var iParamCountCds = -1
@@ -326,16 +343,22 @@ internal object ReflectionTool {
var iModify = -1
var iNameCds = -1
val iLReturnType = returnType?.let(matchIndex) { e -> declares.filter { e == it.returnType }.lastIndex } ?: -1
val iLReturnTypeCds = returnTypeConditions
?.let(matchIndex) { e -> declares.filter { runOrFalse { e(it.returnType(), it.returnType) } }.lastIndex } ?: -1
val iLParamCount = paramCount.takeIf(matchIndex) { it >= 0 }
?.let { e -> declares.filter { e == it.parameterTypes.size }.lastIndex } ?: -1
val iLParamCountRange = paramCountRange.takeIf(matchIndex) { it.isEmpty().not() }
?.let { e -> declares.filter { it.parameterTypes.size in e }.lastIndex } ?: -1
val iLParamCountCds = paramCountConditions
?.let(matchIndex) { e -> declares.filter { it.parameterTypes.size.let { s -> e(s.cast(), s) } }.lastIndex } ?: -1
val iLParamCountCds = paramCountConditions?.let(matchIndex) { e ->
declares.filter { it.parameterTypes.size.let { s -> runOrFalse { e(s.cast(), s) } } }.lastIndex
} ?: -1
val iLParamTypes = paramTypes?.let(matchIndex) { e -> declares.filter { paramTypesEq(e, it.parameterTypes) }.lastIndex } ?: -1
val iLParamTypesCds = paramTypesConditions
?.let(matchIndex) { e -> declares.filter { runOrFalse { e(it.paramTypes(), it.parameterTypes) } }.lastIndex } ?: -1
val iLName = name.takeIf(matchIndex) { it.isNotBlank() }?.let { e -> declares.filter { e == it.name }.lastIndex } ?: -1
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { e(it.cast()) }.lastIndex } ?: -1
val iLNameCds = nameConditions?.let(matchIndex) { e -> declares.filter { it.name.let { n -> e(n.cast(), n) } }.lastIndex } ?: -1
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { runOrFalse { e(it.cast()) } }.lastIndex } ?: -1
val iLNameCds = nameConditions
?.let(matchIndex) { e -> declares.filter { it.name.let { n -> runOrFalse { e(n.cast(), n) } } }.lastIndex } ?: -1
declares.forEachIndexed { index, instance ->
conditions {
name.takeIf { it.isNotBlank() }?.also {
@@ -350,6 +373,12 @@ internal object ReflectionTool {
hold && matchIndex.compare(iReturnType, iLReturnType)
})
}
returnTypeConditions?.also {
and(instance.let { r -> runOrFalse { it(r.returnType(), r.returnType) } }.let { hold ->
if (hold) iReturnTypeCds++
hold && matchIndex.compare(iReturnTypeCds, iLReturnTypeCds)
})
}
paramCount.takeIf { it >= 0 }?.also {
and((instance.parameterTypes.size == it).let { hold ->
if (hold) iParamCount++
@@ -363,7 +392,7 @@ internal object ReflectionTool {
})
}
paramCountConditions?.also {
and(instance.parameterTypes.size.let { s -> it(s.cast(), s) }.let { hold ->
and(instance.parameterTypes.size.let { s -> runOrFalse { it(s.cast(), s) } }.let { hold ->
if (hold) iParamCountCds++
hold && matchIndex.compare(iParamCountCds, iLParamCountCds)
})
@@ -374,14 +403,20 @@ internal object ReflectionTool {
hold && matchIndex.compare(iParamTypes, iLParamTypes)
})
}
paramTypesConditions?.also {
and(instance.let { t -> runOrFalse { it(t.paramTypes(), t.parameterTypes) } }.let { hold ->
if (hold) iParamTypesCds++
hold && matchIndex.compare(iParamTypesCds, iLParamTypesCds)
})
}
modifiers?.also {
and(it(instance.cast()).let { hold ->
and(runOrFalse { it(instance.cast()) }.let { hold ->
if (hold) iModify++
hold && matchIndex.compare(iModify, iLModify)
})
}
nameConditions?.also {
and(instance.name.let { n -> it(n.cast(), n) }.let { hold ->
and(instance.name.let { n -> runOrFalse { it(n.cast(), n) } }.let { hold ->
if (hold) iNameCds++
hold && matchIndex.compare(iNameCds, iLNameCds)
})
@@ -408,6 +443,7 @@ internal object ReflectionTool {
ReflectsCacheStore.findConstructors(hashCode(classSet)) ?: hashSetOf<Constructor<*>>().also { constructors ->
classSet.existConstructors?.also { declares ->
var iParamTypes = -1
var iParamTypesCds = -1
var iParamCount = -1
var iParamCountRange = -1
var iParamCountCds = -1
@@ -416,10 +452,13 @@ internal object ReflectionTool {
?.let { e -> declares.filter { e == it.parameterTypes.size }.lastIndex } ?: -1
val iLParamCountRange = paramCountRange.takeIf(matchIndex) { it.isEmpty().not() }
?.let { e -> declares.filter { it.parameterTypes.size in e }.lastIndex } ?: -1
val iLParamCountCds = paramCountConditions
?.let(matchIndex) { e -> declares.filter { it.parameterTypes.size.let { s -> e(s.cast(), s) } }.lastIndex } ?: -1
val iLParamCountCds = paramCountConditions?.let(matchIndex) { e ->
declares.filter { it.parameterTypes.size.let { s -> runOrFalse { e(s.cast(), s) } } }.lastIndex
} ?: -1
val iLParamTypes = paramTypes?.let(matchIndex) { e -> declares.filter { paramTypesEq(e, it.parameterTypes) }.lastIndex } ?: -1
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { e(it.cast()) }.lastIndex } ?: -1
val iLParamTypesCds = paramTypesConditions
?.let(matchIndex) { e -> declares.filter { runOrFalse { e(it.paramTypes(), it.parameterTypes) } }.lastIndex } ?: -1
val iLModify = modifiers?.let(matchIndex) { e -> declares.filter { runOrFalse { e(it.cast()) } }.lastIndex } ?: -1
declares.forEachIndexed { index, instance ->
conditions {
paramCount.takeIf { it >= 0 }?.also {
@@ -435,7 +474,7 @@ internal object ReflectionTool {
})
}
paramCountConditions?.also {
and(instance.parameterTypes.size.let { s -> it(s.cast(), s) }.let { hold ->
and(instance.parameterTypes.size.let { s -> runOrFalse { it(s.cast(), s) } }.let { hold ->
if (hold) iParamCountCds++
hold && matchIndex.compare(iParamCountCds, iLParamCountCds)
})
@@ -446,8 +485,14 @@ internal object ReflectionTool {
hold && matchIndex.compare(iParamTypes, iLParamTypes)
})
}
paramTypesConditions?.also {
and(instance.let { t -> runOrFalse { it(t.paramTypes(), t.parameterTypes) } }.let { hold ->
if (hold) iParamTypesCds++
hold && matchIndex.compare(iParamTypesCds, iLParamTypesCds)
})
}
modifiers?.also {
and(it(instance.cast()).let { hold ->
and(runOrFalse { it(instance.cast()) }.let { hold ->
if (hold) iModify++
hold && matchIndex.compare(iModify, iLModify)
})

View File

@@ -30,6 +30,7 @@ package com.highcapable.yukihookapi.hook.core.finder.type.factory
import com.highcapable.yukihookapi.hook.core.finder.base.rules.CountRules
import com.highcapable.yukihookapi.hook.core.finder.base.rules.ModifierRules
import com.highcapable.yukihookapi.hook.core.finder.base.rules.NameRules
import com.highcapable.yukihookapi.hook.core.finder.base.rules.ObjectRules
import com.highcapable.yukihookapi.hook.core.finder.classes.DexClassFinder
import com.highcapable.yukihookapi.hook.core.finder.members.ConstructorFinder
import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder
@@ -55,3 +56,9 @@ internal typealias CountConditions = CountRules.(Int) -> Boolean
/** 定义 [ModifierRules] 方法体类型 */
internal typealias ModifierConditions = ModifierRules.() -> Boolean
/** 定义 [ObjectRules] 方法体类型 */
internal typealias ObjectConditions = ObjectRules.(Class<*>) -> Boolean
/** 定义 [ObjectRules] 方法体类型 */
internal typealias ObjectsConditions = ObjectRules.(Array<Class<*>>) -> Boolean