Modify change BaseFinder to MemberBaseFinder and move members finder to members

This commit is contained in:
2022-09-04 20:13:44 +08:00
parent be0813da7e
commit 43e1d5b2ae
11 changed files with 71 additions and 67 deletions

View File

@@ -64,7 +64,7 @@
[filename](public/FieldFinder.md ':include') [filename](public/FieldFinder.md ':include')
[filename](public/BaseFinder-IndexTypeCondition.md ':include') [filename](public/MemberBaseFinder-IndexTypeCondition.md ':include')
[filename](public/ModifierRules.md ':include') [filename](public/ModifierRules.md ':include')

View File

@@ -1,4 +1,4 @@
## BaseFinder.IndexTypeCondition *- class* ## MemberBaseFinder.IndexTypeCondition *- class*
```kotlin ```kotlin
inner class IndexTypeCondition internal constructor(private val type: IndexConfigType) inner class IndexTypeCondition internal constructor(private val type: IndexConfigType)
@@ -8,6 +8,10 @@ inner class IndexTypeCondition internal constructor(private val type: IndexConfi
`v1.0.70` `新增` `v1.0.70` `新增`
`v1.0.93` `修改`
重命名 `BaseFinder``MemberBaseFinder`
**功能描述** **功能描述**
> 字节码下标筛选实现类。 > 字节码下标筛选实现类。

View File

@@ -36,9 +36,9 @@ import android.content.res.Resources
import com.highcapable.yukihookapi.YukiHookAPI.configs import com.highcapable.yukihookapi.YukiHookAPI.configs
import com.highcapable.yukihookapi.YukiHookAPI.encase import com.highcapable.yukihookapi.YukiHookAPI.encase
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
import com.highcapable.yukihookapi.hook.core.finder.ConstructorFinder import com.highcapable.yukihookapi.hook.core.finder.members.ConstructorFinder
import com.highcapable.yukihookapi.hook.core.finder.FieldFinder import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder
import com.highcapable.yukihookapi.hook.core.finder.MethodFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.isTaiChiModuleActive import com.highcapable.yukihookapi.hook.factory.isTaiChiModuleActive
import com.highcapable.yukihookapi.hook.factory.processName import com.highcapable.yukihookapi.hook.factory.processName

View File

@@ -29,8 +29,8 @@
package com.highcapable.yukihookapi.hook.bean package com.highcapable.yukihookapi.hook.bean
import com.highcapable.yukihookapi.hook.core.finder.FieldFinder import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder
import com.highcapable.yukihookapi.hook.core.finder.MethodFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder
import com.highcapable.yukihookapi.hook.factory.FieldCondition import com.highcapable.yukihookapi.hook.factory.FieldCondition
import com.highcapable.yukihookapi.hook.factory.MethodCondition import com.highcapable.yukihookapi.hook.factory.MethodCondition
import com.highcapable.yukihookapi.hook.factory.field import com.highcapable.yukihookapi.hook.factory.field

View File

@@ -32,10 +32,10 @@ package com.highcapable.yukihookapi.hook.core
import com.highcapable.yukihookapi.YukiHookAPI import com.highcapable.yukihookapi.YukiHookAPI
import com.highcapable.yukihookapi.annotation.CauseProblemsApi import com.highcapable.yukihookapi.annotation.CauseProblemsApi
import com.highcapable.yukihookapi.hook.bean.HookClass import com.highcapable.yukihookapi.hook.bean.HookClass
import com.highcapable.yukihookapi.hook.core.finder.ConstructorFinder import com.highcapable.yukihookapi.hook.core.finder.members.ConstructorFinder
import com.highcapable.yukihookapi.hook.core.finder.FieldFinder import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder
import com.highcapable.yukihookapi.hook.core.finder.MethodFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder
import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder import com.highcapable.yukihookapi.hook.core.finder.base.MemberBaseFinder
import com.highcapable.yukihookapi.hook.factory.* import com.highcapable.yukihookapi.hook.factory.*
import com.highcapable.yukihookapi.hook.log.yLoggerE import com.highcapable.yukihookapi.hook.log.yLoggerE
import com.highcapable.yukihookapi.hook.log.yLoggerI import com.highcapable.yukihookapi.hook.log.yLoggerI
@@ -248,7 +248,7 @@ class YukiMemberHookCreator(@PublishedApi internal val packageParam: PackagePara
/** 当前的查找实例 */ /** 当前的查找实例 */
@PublishedApi @PublishedApi
internal var finder: BaseFinder? = null internal var finder: MemberBaseFinder? = null
/** 当前被 Hook 的 [Method]、[Constructor] 实例数组 */ /** 当前被 Hook 的 [Method]、[Constructor] 实例数组 */
private val memberUnhooks = HashSet<YukiMemberHook.Unhook>() private val memberUnhooks = HashSet<YukiMemberHook.Unhook>()

View File

@@ -45,12 +45,12 @@ import java.lang.reflect.Method
import kotlin.math.abs import kotlin.math.abs
/** /**
* 这是查找类功能的基本类实现 * 这是 [Member] 查找类功能的基本类实现
* @param tag 当前查找类的标识 * @param tag 当前查找类的标识
* @param hookInstance 当前 Hook 实例 * @param hookInstance 当前 Hook 实例
* @param classSet 当前需要查找的 [Class] 实例 * @param classSet 当前需要查找的 [Class] 实例
*/ */
abstract class BaseFinder internal constructor( abstract class MemberBaseFinder internal constructor(
private val tag: String, private val tag: String,
open val hookInstance: YukiMemberHookCreator.MemberHookCreator? = null, open val hookInstance: YukiMemberHookCreator.MemberHookCreator? = null,
open val classSet: Class<*>? = null open val classSet: Class<*>? = null

View File

@@ -27,12 +27,12 @@
*/ */
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "KotlinConstantConditions") @file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "KotlinConstantConditions")
package com.highcapable.yukihookapi.hook.core.finder package com.highcapable.yukihookapi.hook.core.finder.members
import com.highcapable.yukihookapi.annotation.YukiPrivateApi import com.highcapable.yukihookapi.annotation.YukiPrivateApi
import com.highcapable.yukihookapi.hook.bean.VariousClass import com.highcapable.yukihookapi.hook.bean.VariousClass
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
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.type.ModifierRules import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules
import com.highcapable.yukihookapi.hook.core.reflex.tools.ReflectionTool import com.highcapable.yukihookapi.hook.core.reflex.tools.ReflectionTool
import com.highcapable.yukihookapi.hook.factory.ConstructorCondition import com.highcapable.yukihookapi.hook.factory.ConstructorCondition
@@ -57,7 +57,7 @@ class ConstructorFinder @PublishedApi internal constructor(
override val hookInstance: YukiMemberHookCreator.MemberHookCreator? = null, override val hookInstance: YukiMemberHookCreator.MemberHookCreator? = null,
@property:YukiPrivateApi @property:YukiPrivateApi
override val classSet: Class<*>? = null override val classSet: Class<*>? = null
) : BaseFinder(tag = "Constructor", hookInstance, classSet) { ) : MemberBaseFinder(tag = "Constructor", hookInstance, classSet) {
/** 当前使用的 [classSet] */ /** 当前使用的 [classSet] */
private var usedClassSet = classSet private var usedClassSet = classSet
@@ -90,9 +90,9 @@ class ConstructorFinder @PublishedApi internal constructor(
/** /**
* 设置 [Constructor] 标识符筛选条件 * 设置 [Constructor] 标识符筛选条件
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param initiate 方法体 * @param initiate 方法体
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
inline fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition { inline fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition {
modifiers = ModifierRules().apply(initiate) modifiers = ModifierRules().apply(initiate)
@@ -102,7 +102,7 @@ class ConstructorFinder @PublishedApi internal constructor(
/** /**
* 设置 [Constructor] 空参数无参数 * 设置 [Constructor] 空参数无参数
* *
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun emptyParam() = paramCount(num = 0) fun emptyParam() = paramCount(num = 0)
@@ -115,9 +115,9 @@ class ConstructorFinder @PublishedApi internal constructor(
* *
* - 有参 [Constructor] 必须使用此方法设定参数或使用 [paramCount] 指定个数 * - 有参 [Constructor] 必须使用此方法设定参数或使用 [paramCount] 指定个数
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param paramType 参数类型数组 - 只能是 [Class][String][VariousClass] * @param paramType 参数类型数组 - 只能是 [Class][String][VariousClass]
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun param(vararg paramType: Any): IndexTypeCondition { fun param(vararg paramType: Any): IndexTypeCondition {
if (paramType.isEmpty()) error("paramTypes is empty, please use emptyParam() instead") if (paramType.isEmpty()) error("paramTypes is empty, please use emptyParam() instead")
@@ -127,7 +127,7 @@ class ConstructorFinder @PublishedApi internal constructor(
/** /**
* 顺序筛选字节码的下标 * 顺序筛选字节码的下标
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun order() = IndexTypeCondition(IndexConfigType.ORDER) fun order() = IndexTypeCondition(IndexConfigType.ORDER)
@@ -138,9 +138,9 @@ class ConstructorFinder @PublishedApi internal constructor(
* *
* 若参数个数小于零则忽略并使用 [param] * 若参数个数小于零则忽略并使用 [param]
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param num 个数 * @param num 个数
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun paramCount(num: Int): IndexTypeCondition { fun paramCount(num: Int): IndexTypeCondition {
paramCount = num paramCount = num
@@ -152,9 +152,9 @@ class ConstructorFinder @PublishedApi internal constructor(
* *
* 你可以不使用 [param] 指定参数类型而是仅使用此方法指定参数个数范围 * 你可以不使用 [param] 指定参数类型而是仅使用此方法指定参数个数范围
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param numRange 个数范围 * @param numRange 个数范围
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun paramCount(numRange: IntRange): IndexTypeCondition { fun paramCount(numRange: IntRange): IndexTypeCondition {
paramCountRange = numRange paramCountRange = numRange

View File

@@ -27,13 +27,13 @@
*/ */
@file:Suppress("unused", "UNCHECKED_CAST", "MemberVisibilityCanBePrivate") @file:Suppress("unused", "UNCHECKED_CAST", "MemberVisibilityCanBePrivate")
package com.highcapable.yukihookapi.hook.core.finder package com.highcapable.yukihookapi.hook.core.finder.members
import com.highcapable.yukihookapi.annotation.YukiPrivateApi import com.highcapable.yukihookapi.annotation.YukiPrivateApi
import com.highcapable.yukihookapi.hook.bean.CurrentClass import com.highcapable.yukihookapi.hook.bean.CurrentClass
import com.highcapable.yukihookapi.hook.bean.VariousClass import com.highcapable.yukihookapi.hook.bean.VariousClass
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
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.type.ModifierRules import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules
import com.highcapable.yukihookapi.hook.core.finder.type.NameConditions import com.highcapable.yukihookapi.hook.core.finder.type.NameConditions
import com.highcapable.yukihookapi.hook.core.reflex.tools.ReflectionTool import com.highcapable.yukihookapi.hook.core.reflex.tools.ReflectionTool
@@ -58,7 +58,7 @@ class FieldFinder @PublishedApi internal constructor(
override val hookInstance: YukiMemberHookCreator.MemberHookCreator? = null, override val hookInstance: YukiMemberHookCreator.MemberHookCreator? = null,
@property:YukiPrivateApi @property:YukiPrivateApi
override val classSet: Class<*>? = null override val classSet: Class<*>? = null
) : BaseFinder(tag = "Field", hookInstance, classSet) { ) : MemberBaseFinder(tag = "Field", hookInstance, classSet) {
/** 当前使用的 [classSet] */ /** 当前使用的 [classSet] */
private var usedClassSet = classSet private var usedClassSet = classSet
@@ -98,9 +98,9 @@ class FieldFinder @PublishedApi internal constructor(
* *
* - 可不设置筛选条件 * - 可不设置筛选条件
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param initiate 方法体 * @param initiate 方法体
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
inline fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition { inline fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition {
modifiers = ModifierRules().apply(initiate) modifiers = ModifierRules().apply(initiate)
@@ -109,7 +109,7 @@ class FieldFinder @PublishedApi internal constructor(
/** /**
* 顺序筛选字节码的下标 * 顺序筛选字节码的下标
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun order() = IndexTypeCondition(IndexConfigType.ORDER) fun order() = IndexTypeCondition(IndexConfigType.ORDER)
@@ -118,9 +118,9 @@ class FieldFinder @PublishedApi internal constructor(
* *
* - 若不填写名称则必须存在一个其它条件 * - 若不填写名称则必须存在一个其它条件
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param value 名称 * @param value 名称
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun name(value: String): IndexTypeCondition { fun name(value: String): IndexTypeCondition {
name = value name = value
@@ -132,9 +132,9 @@ class FieldFinder @PublishedApi internal constructor(
* *
* - 若不填写名称则必须存在一个其它条件 * - 若不填写名称则必须存在一个其它条件
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param initiate 方法体 * @param initiate 方法体
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
inline fun name(initiate: NameConditions.() -> Unit): IndexTypeCondition { inline fun name(initiate: NameConditions.() -> Unit): IndexTypeCondition {
nameConditions = NameConditions().apply(initiate) nameConditions = NameConditions().apply(initiate)
@@ -146,9 +146,9 @@ class FieldFinder @PublishedApi internal constructor(
* *
* - 可不填写类型 * - 可不填写类型
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param value 类型 - 只能是 [Class][String][VariousClass] * @param value 类型 - 只能是 [Class][String][VariousClass]
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun type(value: Any): IndexTypeCondition { fun type(value: Any): IndexTypeCondition {
type = value type = value

View File

@@ -27,12 +27,12 @@
*/ */
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "KotlinConstantConditions") @file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "KotlinConstantConditions")
package com.highcapable.yukihookapi.hook.core.finder package com.highcapable.yukihookapi.hook.core.finder.members
import com.highcapable.yukihookapi.annotation.YukiPrivateApi import com.highcapable.yukihookapi.annotation.YukiPrivateApi
import com.highcapable.yukihookapi.hook.bean.VariousClass import com.highcapable.yukihookapi.hook.bean.VariousClass
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
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.type.ModifierRules import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules
import com.highcapable.yukihookapi.hook.core.finder.type.NameConditions import com.highcapable.yukihookapi.hook.core.finder.type.NameConditions
import com.highcapable.yukihookapi.hook.core.reflex.tools.ReflectionTool import com.highcapable.yukihookapi.hook.core.reflex.tools.ReflectionTool
@@ -59,7 +59,7 @@ class MethodFinder @PublishedApi internal constructor(
override val hookInstance: YukiMemberHookCreator.MemberHookCreator? = null, override val hookInstance: YukiMemberHookCreator.MemberHookCreator? = null,
@property:YukiPrivateApi @property:YukiPrivateApi
override val classSet: Class<*>? = null override val classSet: Class<*>? = null
) : BaseFinder(tag = "Method", hookInstance, classSet) { ) : MemberBaseFinder(tag = "Method", hookInstance, classSet) {
/** 当前使用的 [classSet] */ /** 当前使用的 [classSet] */
private var usedClassSet = classSet private var usedClassSet = classSet
@@ -114,9 +114,9 @@ class MethodFinder @PublishedApi internal constructor(
* *
* - 可不设置筛选条件 * - 可不设置筛选条件
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param initiate 方法体 * @param initiate 方法体
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
inline fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition { inline fun modifiers(initiate: ModifierRules.() -> Unit): IndexTypeCondition {
modifiers = ModifierRules().apply(initiate) modifiers = ModifierRules().apply(initiate)
@@ -126,7 +126,7 @@ class MethodFinder @PublishedApi internal constructor(
/** /**
* 设置 [Method] 空参数无参数 * 设置 [Method] 空参数无参数
* *
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun emptyParam() = paramCount(num = 0) fun emptyParam() = paramCount(num = 0)
@@ -139,9 +139,9 @@ class MethodFinder @PublishedApi internal constructor(
* *
* - 有参 [Method] 必须使用此方法设定参数或使用 [paramCount] 指定个数 * - 有参 [Method] 必须使用此方法设定参数或使用 [paramCount] 指定个数
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param paramType 参数类型数组 - 只能是 [Class][String][VariousClass] * @param paramType 参数类型数组 - 只能是 [Class][String][VariousClass]
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun param(vararg paramType: Any): IndexTypeCondition { fun param(vararg paramType: Any): IndexTypeCondition {
if (paramType.isEmpty()) error("paramTypes is empty, please use emptyParam() instead") if (paramType.isEmpty()) error("paramTypes is empty, please use emptyParam() instead")
@@ -151,7 +151,7 @@ class MethodFinder @PublishedApi internal constructor(
/** /**
* 顺序筛选字节码的下标 * 顺序筛选字节码的下标
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun order() = IndexTypeCondition(IndexConfigType.ORDER) fun order() = IndexTypeCondition(IndexConfigType.ORDER)
@@ -160,9 +160,9 @@ class MethodFinder @PublishedApi internal constructor(
* *
* - 若不填写名称则必须存在一个其它条件 * - 若不填写名称则必须存在一个其它条件
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param value 名称 * @param value 名称
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun name(value: String): IndexTypeCondition { fun name(value: String): IndexTypeCondition {
name = value name = value
@@ -174,9 +174,9 @@ class MethodFinder @PublishedApi internal constructor(
* *
* - 若不填写名称则必须存在一个其它条件 * - 若不填写名称则必须存在一个其它条件
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param initiate 方法体 * @param initiate 方法体
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
inline fun name(initiate: NameConditions.() -> Unit): IndexTypeCondition { inline fun name(initiate: NameConditions.() -> Unit): IndexTypeCondition {
nameConditions = NameConditions().apply(initiate) nameConditions = NameConditions().apply(initiate)
@@ -190,9 +190,9 @@ class MethodFinder @PublishedApi internal constructor(
* *
* 若参数个数小于零则忽略并使用 [param] * 若参数个数小于零则忽略并使用 [param]
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param num 个数 * @param num 个数
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun paramCount(num: Int): IndexTypeCondition { fun paramCount(num: Int): IndexTypeCondition {
paramCount = num paramCount = num
@@ -204,9 +204,9 @@ class MethodFinder @PublishedApi internal constructor(
* *
* 你可以不使用 [param] 指定参数类型而是仅使用此方法指定参数个数范围 * 你可以不使用 [param] 指定参数类型而是仅使用此方法指定参数个数范围
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param numRange 个数范围 * @param numRange 个数范围
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun paramCount(numRange: IntRange): IndexTypeCondition { fun paramCount(numRange: IntRange): IndexTypeCondition {
paramCountRange = numRange paramCountRange = numRange
@@ -218,9 +218,9 @@ class MethodFinder @PublishedApi internal constructor(
* *
* - 可不填写返回值 * - 可不填写返回值
* *
* - 存在多个 [BaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个 * - 存在多个 [MemberBaseFinder.IndexTypeCondition] 时除了 [order] 只会生效最后一个
* @param value 个数 * @param value 个数
* @return [BaseFinder.IndexTypeCondition] * @return [MemberBaseFinder.IndexTypeCondition]
*/ */
fun returnType(value: Any): IndexTypeCondition { fun returnType(value: Any): IndexTypeCondition {
returnType = value returnType = value

View File

@@ -31,9 +31,9 @@ package com.highcapable.yukihookapi.hook.factory
import com.highcapable.yukihookapi.YukiHookAPI import com.highcapable.yukihookapi.YukiHookAPI
import com.highcapable.yukihookapi.hook.bean.CurrentClass import com.highcapable.yukihookapi.hook.bean.CurrentClass
import com.highcapable.yukihookapi.hook.core.finder.ConstructorFinder import com.highcapable.yukihookapi.hook.core.finder.members.ConstructorFinder
import com.highcapable.yukihookapi.hook.core.finder.FieldFinder import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder
import com.highcapable.yukihookapi.hook.core.finder.MethodFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder
import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules
import com.highcapable.yukihookapi.hook.store.MemberCacheStore import com.highcapable.yukihookapi.hook.store.MemberCacheStore
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge

View File

@@ -29,9 +29,9 @@
package com.highcapable.yukihookapi.hook.xposed.bridge.factory package com.highcapable.yukihookapi.hook.xposed.bridge.factory
import com.highcapable.yukihookapi.hook.core.finder.ConstructorFinder import com.highcapable.yukihookapi.hook.core.finder.members.ConstructorFinder
import com.highcapable.yukihookapi.hook.core.finder.MethodFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder
import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder import com.highcapable.yukihookapi.hook.core.finder.base.MemberBaseFinder
import com.highcapable.yukihookapi.hook.log.yLoggerE import com.highcapable.yukihookapi.hook.log.yLoggerE
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge
import de.robv.android.xposed.XC_MethodHook import de.robv.android.xposed.XC_MethodHook
@@ -81,12 +81,12 @@ internal object YukiHookHelper {
if (YukiHookBridge.hasXposedBridge) XposedHelpers.findClass(name, loader) else null if (YukiHookBridge.hasXposedBridge) XposedHelpers.findClass(name, loader) else null
/** /**
* Hook [BaseFinder.BaseResult] * Hook [MemberBaseFinder.BaseResult]
* @param traction 直接调用 [BaseFinder.BaseResult] * @param traction 直接调用 [MemberBaseFinder.BaseResult]
* @param callback 回调 * @param callback 回调
* @return [Pair] - ([YukiMemberHook.Unhook] or null,[Boolean] 是否已经 Hook) * @return [Pair] - ([YukiMemberHook.Unhook] or null,[Boolean] 是否已经 Hook)
*/ */
internal fun hook(traction: BaseFinder.BaseResult, callback: YukiHookCallback) = runCatching { internal fun hook(traction: MemberBaseFinder.BaseResult, callback: YukiHookCallback) = runCatching {
hookMember( hookMember(
when (traction) { when (traction) {
is MethodFinder.Result -> traction.ignored().give() is MethodFinder.Result -> traction.ignored().give()