mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 02:35:40 +08:00
Modify merge finder lambda to typealias
This commit is contained in:
@@ -165,7 +165,7 @@ inner class RemedyPlan internal constructor()
|
|||||||
#### constructor [method]
|
#### constructor [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun constructor(initiate: ConstructorFinder.() -> Unit)
|
inline fun constructor(initiate: ConstructorCondition)
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
|
@@ -33,7 +33,7 @@ fun superClass(): SuperClass
|
|||||||
### field [method]
|
### field [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun field(initiate: FieldFinder.() -> Unit): FieldFinder.Result.Instance
|
inline fun field(initiate: FieldCondition): FieldFinder.Result.Instance
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -47,7 +47,7 @@ inline fun field(initiate: FieldFinder.() -> Unit): FieldFinder.Result.Instance
|
|||||||
### method [method]
|
### method [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun method(initiate: MethodFinder.() -> Unit): MethodFinder.Result.Instance
|
inline fun method(initiate: MethodCondition): MethodFinder.Result.Instance
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -75,7 +75,7 @@ inner class SuperClass internal constructor()
|
|||||||
#### field [method]
|
#### field [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun field(initiate: FieldFinder.() -> Unit): FieldFinder.Result.Instance
|
inline fun field(initiate: FieldCondition): FieldFinder.Result.Instance
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -89,7 +89,7 @@ inline fun field(initiate: FieldFinder.() -> Unit): FieldFinder.Result.Instance
|
|||||||
#### method [method]
|
#### method [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun method(initiate: MethodFinder.() -> Unit): MethodFinder.Result.Instance
|
inline fun method(initiate: MethodCondition): MethodFinder.Result.Instance
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
|
@@ -185,7 +185,7 @@ inner class RemedyPlan internal constructor()
|
|||||||
#### field [method]
|
#### field [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun field(initiate: FieldFinder.() -> Unit): Result
|
inline fun field(initiate: FieldCondition): Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
|
@@ -267,7 +267,7 @@ inner class RemedyPlan internal constructor()
|
|||||||
#### method [method]
|
#### method [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun method(initiate: MethodFinder.() -> Unit): Result
|
inline fun method(initiate: MethodCondition): Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
|
@@ -170,7 +170,7 @@ if("com.example.demo.DemoClass".hasClass(customClassloader)) {
|
|||||||
### hasField [method]
|
### hasField [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun Class<*>.hasField(initiate: FieldFinder.() -> Unit): Boolean
|
inline fun Class<*>.hasField(initiate: FieldCondition): Boolean
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -192,7 +192,7 @@ inline fun Class<*>.hasField(initiate: FieldFinder.() -> Unit): Boolean
|
|||||||
### hasMethod [method]
|
### hasMethod [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun Class<*>.hasMethod(initiate: MethodFinder.() -> Unit): Boolean
|
inline fun Class<*>.hasMethod(initiate: MethodCondition): Boolean
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -218,7 +218,7 @@ inline fun Class<*>.hasMethod(initiate: MethodFinder.() -> Unit): Boolean
|
|||||||
### hasConstructor [method]
|
### hasConstructor [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun Class<*>.hasConstructor(initiate: ConstructorFinder.() -> Unit): Boolean
|
inline fun Class<*>.hasConstructor(initiate: ConstructorCondition): Boolean
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -290,7 +290,7 @@ inline fun Member.hasModifiers(initiate: ModifierRules.() -> Unit): Boolean
|
|||||||
### field [method]
|
### field [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun Class<*>.field(initiate: FieldFinder.() -> Unit): FieldFinder.Result
|
inline fun Class<*>.field(initiate: FieldCondition): FieldFinder.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -308,7 +308,7 @@ inline fun Class<*>.field(initiate: FieldFinder.() -> Unit): FieldFinder.Result
|
|||||||
### method [method]
|
### method [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun Class<*>.method(initiate: MethodFinder.() -> Unit): MethodFinder.Result
|
inline fun Class<*>.method(initiate: MethodCondition): MethodFinder.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -336,7 +336,7 @@ inline fun Class<*>.method(initiate: MethodFinder.() -> Unit): MethodFinder.Resu
|
|||||||
### constructor [method]
|
### constructor [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun Class<*>.constructor(initiate: ConstructorFinder.() -> Unit): ConstructorFinder.Result
|
inline fun Class<*>.constructor(initiate: ConstructorCondition): ConstructorFinder.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -408,7 +408,7 @@ inline fun <reified T : Any> T.current(): CurrentClass
|
|||||||
### buildOfAny [method]
|
### buildOfAny [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun Class<*>.buildOfAny(vararg param: Any?, initiate: ConstructorFinder.() -> Unit): Any?
|
inline fun Class<*>.buildOfAny(vararg param: Any?, initiate: ConstructorCondition): Any?
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -426,7 +426,7 @@ inline fun Class<*>.buildOfAny(vararg param: Any?, initiate: ConstructorFinder.(
|
|||||||
### buildOf [method]
|
### buildOf [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun <T> Class<*>.buildOf(vararg param: Any?, initiate: ConstructorFinder.() -> Unit): T?
|
inline fun <T> Class<*>.buildOf(vararg param: Any?, initiate: ConstructorCondition): T?
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
|
@@ -251,7 +251,7 @@ fun allMembers()
|
|||||||
#### method [method]
|
#### method [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun method(initiate: MethodFinder.() -> Unit): MethodFinder.Result
|
inline fun method(initiate: MethodCondition): MethodFinder.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -287,7 +287,7 @@ injectMember {
|
|||||||
#### constructor [method]
|
#### constructor [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun constructor(initiate: ConstructorFinder.() -> Unit): ConstructorFinder.Result
|
inline fun constructor(initiate: ConstructorCondition): ConstructorFinder.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -319,7 +319,7 @@ injectMember {
|
|||||||
#### field [method]
|
#### field [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun HookParam.field(initiate: FieldFinder.() -> Unit): FieldFinder.Result
|
inline fun HookParam.field(initiate: FieldCondition): FieldFinder.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -359,7 +359,7 @@ injectMember {
|
|||||||
#### method [method]
|
#### method [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun HookParam.method(initiate: MethodFinder.() -> Unit): MethodFinder.Result
|
inline fun HookParam.method(initiate: MethodCondition): MethodFinder.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -377,7 +377,7 @@ inline fun HookParam.method(initiate: MethodFinder.() -> Unit): MethodFinder.Res
|
|||||||
#### constructor [method]
|
#### constructor [method]
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun HookParam.constructor(initiate: ConstructorFinder.() -> Unit): ConstructorFinder.Result
|
inline fun HookParam.constructor(initiate: ConstructorCondition): ConstructorFinder.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
|
@@ -29,6 +29,8 @@ package com.highcapable.yukihookapi.hook.bean
|
|||||||
|
|
||||||
import com.highcapable.yukihookapi.hook.core.finder.FieldFinder
|
import com.highcapable.yukihookapi.hook.core.finder.FieldFinder
|
||||||
import com.highcapable.yukihookapi.hook.core.finder.MethodFinder
|
import com.highcapable.yukihookapi.hook.core.finder.MethodFinder
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.FieldCondition
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.MethodCondition
|
||||||
import com.highcapable.yukihookapi.hook.factory.field
|
import com.highcapable.yukihookapi.hook.factory.field
|
||||||
import com.highcapable.yukihookapi.hook.factory.method
|
import com.highcapable.yukihookapi.hook.factory.method
|
||||||
|
|
||||||
@@ -50,14 +52,14 @@ class CurrentClass @PublishedApi internal constructor(@PublishedApi internal val
|
|||||||
* @param initiate 查找方法体
|
* @param initiate 查找方法体
|
||||||
* @return [FieldFinder.Result.Instance]
|
* @return [FieldFinder.Result.Instance]
|
||||||
*/
|
*/
|
||||||
inline fun field(initiate: FieldFinder.() -> Unit) = classSet.field(initiate).get(instance)
|
inline fun field(initiate: FieldCondition) = classSet.field(initiate).get(instance)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用当前实例中的方法
|
* 调用当前实例中的方法
|
||||||
* @param initiate 查找方法体
|
* @param initiate 查找方法体
|
||||||
* @return [MethodFinder.Result.Instance]
|
* @return [MethodFinder.Result.Instance]
|
||||||
*/
|
*/
|
||||||
inline fun method(initiate: MethodFinder.() -> Unit) = classSet.method(initiate).get(instance)
|
inline fun method(initiate: MethodCondition) = classSet.method(initiate).get(instance)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前类的父类实例的类操作对象
|
* 当前类的父类实例的类操作对象
|
||||||
@@ -71,13 +73,13 @@ class CurrentClass @PublishedApi internal constructor(@PublishedApi internal val
|
|||||||
* @param initiate 查找方法体
|
* @param initiate 查找方法体
|
||||||
* @return [FieldFinder.Result.Instance]
|
* @return [FieldFinder.Result.Instance]
|
||||||
*/
|
*/
|
||||||
inline fun field(initiate: FieldFinder.() -> Unit) = classSet.superclass.field(initiate).get(instance)
|
inline fun field(initiate: FieldCondition) = classSet.superclass.field(initiate).get(instance)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用父类实例中的方法
|
* 调用父类实例中的方法
|
||||||
* @param initiate 查找方法体
|
* @param initiate 查找方法体
|
||||||
* @return [MethodFinder.Result.Instance]
|
* @return [MethodFinder.Result.Instance]
|
||||||
*/
|
*/
|
||||||
inline fun method(initiate: MethodFinder.() -> Unit) = classSet.superclass.method(initiate).get(instance)
|
inline fun method(initiate: MethodCondition) = classSet.superclass.method(initiate).get(instance)
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -35,8 +35,7 @@ import com.highcapable.yukihookapi.hook.core.finder.ConstructorFinder
|
|||||||
import com.highcapable.yukihookapi.hook.core.finder.FieldFinder
|
import com.highcapable.yukihookapi.hook.core.finder.FieldFinder
|
||||||
import com.highcapable.yukihookapi.hook.core.finder.MethodFinder
|
import com.highcapable.yukihookapi.hook.core.finder.MethodFinder
|
||||||
import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder
|
import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder
|
||||||
import com.highcapable.yukihookapi.hook.factory.allConstructors
|
import com.highcapable.yukihookapi.hook.factory.*
|
||||||
import com.highcapable.yukihookapi.hook.factory.allMethods
|
|
||||||
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
|
||||||
import com.highcapable.yukihookapi.hook.log.yLoggerW
|
import com.highcapable.yukihookapi.hook.log.yLoggerW
|
||||||
@@ -279,7 +278,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [MethodFinder.Result]
|
* @return [MethodFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun method(initiate: MethodFinder.() -> Unit) = try {
|
inline fun method(initiate: MethodCondition) = try {
|
||||||
isHookMemberSetup = true
|
isHookMemberSetup = true
|
||||||
MethodFinder(hookInstance = this, hookClass.instance).apply(initiate).apply { finder = this }.build(isBind = true)
|
MethodFinder(hookInstance = this, hookClass.instance).apply(initiate).apply { finder = this }.build(isBind = true)
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
@@ -294,7 +293,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [ConstructorFinder.Result]
|
* @return [ConstructorFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun constructor(initiate: ConstructorFinder.() -> Unit = { emptyParam() }) = try {
|
inline fun constructor(initiate: ConstructorCondition = { emptyParam() }) = try {
|
||||||
isHookMemberSetup = true
|
isHookMemberSetup = true
|
||||||
ConstructorFinder(hookInstance = this, hookClass.instance).apply(initiate).apply { finder = this }.build(isBind = true)
|
ConstructorFinder(hookInstance = this, hookClass.instance).apply(initiate).apply { finder = this }.build(isBind = true)
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
@@ -307,7 +306,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [FieldFinder.Result]
|
* @return [FieldFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun HookParam.field(initiate: FieldFinder.() -> Unit) =
|
inline fun HookParam.field(initiate: FieldCondition) =
|
||||||
if (hookClass.instance == null) FieldFinder(hookInstance = this@MemberHookCreater).failure(hookClass.throwable)
|
if (hookClass.instance == null) FieldFinder(hookInstance = this@MemberHookCreater).failure(hookClass.throwable)
|
||||||
else FieldFinder(hookInstance = this@MemberHookCreater, hookClass.instance).apply(initiate).build()
|
else FieldFinder(hookInstance = this@MemberHookCreater, hookClass.instance).apply(initiate).build()
|
||||||
|
|
||||||
@@ -316,7 +315,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [MethodFinder.Result]
|
* @return [MethodFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun HookParam.method(initiate: MethodFinder.() -> Unit) =
|
inline fun HookParam.method(initiate: MethodCondition) =
|
||||||
if (hookClass.instance == null) MethodFinder(hookInstance = this@MemberHookCreater).failure(hookClass.throwable)
|
if (hookClass.instance == null) MethodFinder(hookInstance = this@MemberHookCreater).failure(hookClass.throwable)
|
||||||
else MethodFinder(hookInstance = this@MemberHookCreater, hookClass.instance).apply(initiate).build()
|
else MethodFinder(hookInstance = this@MemberHookCreater, hookClass.instance).apply(initiate).build()
|
||||||
|
|
||||||
@@ -325,7 +324,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [ConstructorFinder.Result]
|
* @return [ConstructorFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun HookParam.constructor(initiate: ConstructorFinder.() -> Unit = { emptyParam() }) =
|
inline fun HookParam.constructor(initiate: ConstructorCondition = { emptyParam() }) =
|
||||||
if (hookClass.instance == null) ConstructorFinder(hookInstance = this@MemberHookCreater).failure(hookClass.throwable)
|
if (hookClass.instance == null) ConstructorFinder(hookInstance = this@MemberHookCreater).failure(hookClass.throwable)
|
||||||
else ConstructorFinder(hookInstance = this@MemberHookCreater, hookClass.instance).apply(initiate).build()
|
else ConstructorFinder(hookInstance = this@MemberHookCreater, hookClass.instance).apply(initiate).build()
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@ import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreater
|
|||||||
import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder
|
import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder
|
||||||
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.hasExtends
|
import com.highcapable.yukihookapi.hook.factory.hasExtends
|
||||||
import com.highcapable.yukihookapi.hook.log.yLoggerW
|
import com.highcapable.yukihookapi.hook.log.yLoggerW
|
||||||
import com.highcapable.yukihookapi.hook.type.defined.UndefinedType
|
import com.highcapable.yukihookapi.hook.type.defined.UndefinedType
|
||||||
@@ -245,7 +246,7 @@ class ConstructorFinder @PublishedApi internal constructor(
|
|||||||
* 若最后依然失败 - 将停止查找并输出错误日志
|
* 若最后依然失败 - 将停止查找并输出错误日志
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
*/
|
*/
|
||||||
inline fun constructor(initiate: ConstructorFinder.() -> Unit) =
|
inline fun constructor(initiate: ConstructorCondition) =
|
||||||
Result().apply { remedyPlans.add(Pair(ConstructorFinder(hookInstance, classSet).apply(initiate), this)) }
|
Result().apply { remedyPlans.add(Pair(ConstructorFinder(hookInstance, classSet).apply(initiate), this)) }
|
||||||
|
|
||||||
/** 开始重查找 */
|
/** 开始重查找 */
|
||||||
|
@@ -36,6 +36,7 @@ import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder
|
|||||||
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
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.FieldCondition
|
||||||
import com.highcapable.yukihookapi.hook.factory.hasExtends
|
import com.highcapable.yukihookapi.hook.factory.hasExtends
|
||||||
import com.highcapable.yukihookapi.hook.log.yLoggerW
|
import com.highcapable.yukihookapi.hook.log.yLoggerW
|
||||||
import com.highcapable.yukihookapi.hook.utils.await
|
import com.highcapable.yukihookapi.hook.utils.await
|
||||||
@@ -236,7 +237,7 @@ class FieldFinder @PublishedApi internal constructor(
|
|||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [Result] 结果
|
* @return [Result] 结果
|
||||||
*/
|
*/
|
||||||
inline fun field(initiate: FieldFinder.() -> Unit) =
|
inline fun field(initiate: FieldCondition) =
|
||||||
Result().apply { remedyPlans.add(Pair(FieldFinder(hookInstance, classSet).apply(initiate), this)) }
|
Result().apply { remedyPlans.add(Pair(FieldFinder(hookInstance, classSet).apply(initiate), this)) }
|
||||||
|
|
||||||
/** 开始重查找 */
|
/** 开始重查找 */
|
||||||
|
@@ -36,6 +36,7 @@ import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder
|
|||||||
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
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.MethodCondition
|
||||||
import com.highcapable.yukihookapi.hook.factory.hasExtends
|
import com.highcapable.yukihookapi.hook.factory.hasExtends
|
||||||
import com.highcapable.yukihookapi.hook.log.yLoggerW
|
import com.highcapable.yukihookapi.hook.log.yLoggerW
|
||||||
import com.highcapable.yukihookapi.hook.type.defined.UndefinedType
|
import com.highcapable.yukihookapi.hook.type.defined.UndefinedType
|
||||||
@@ -313,7 +314,7 @@ class MethodFinder @PublishedApi internal constructor(
|
|||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [Result] 结果
|
* @return [Result] 结果
|
||||||
*/
|
*/
|
||||||
inline fun method(initiate: MethodFinder.() -> Unit) =
|
inline fun method(initiate: MethodCondition) =
|
||||||
Result().apply { remedyPlans.add(Pair(MethodFinder(hookInstance, classSet).apply(initiate), this)) }
|
Result().apply { remedyPlans.add(Pair(MethodFinder(hookInstance, classSet).apply(initiate), this)) }
|
||||||
|
|
||||||
/** 开始重查找 */
|
/** 开始重查找 */
|
||||||
|
@@ -42,6 +42,15 @@ import java.lang.reflect.Field
|
|||||||
import java.lang.reflect.Member
|
import java.lang.reflect.Member
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
|
|
||||||
|
/** 定义 [FieldFinder] 方法体类型 */
|
||||||
|
internal typealias FieldCondition = FieldFinder.() -> Unit
|
||||||
|
|
||||||
|
/** 定义 [MethodFinder] 方法体类型 */
|
||||||
|
internal typealias MethodCondition = MethodFinder.() -> Unit
|
||||||
|
|
||||||
|
/** 定义 [ConstructorFinder] 方法体类型 */
|
||||||
|
internal typealias ConstructorCondition = ConstructorFinder.() -> Unit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前 [Class] 是否有继承关系 - 父类是 [Any] 将被认为没有继承关系
|
* 当前 [Class] 是否有继承关系 - 父类是 [Any] 将被认为没有继承关系
|
||||||
* @return [Boolean]
|
* @return [Boolean]
|
||||||
@@ -96,21 +105,21 @@ fun String.hasClass(loader: ClassLoader? = null) = try {
|
|||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [Boolean] 是否存在
|
* @return [Boolean] 是否存在
|
||||||
*/
|
*/
|
||||||
inline fun Class<*>.hasField(initiate: FieldFinder.() -> Unit) = field(initiate).ignored().isNoSuch.not()
|
inline fun Class<*>.hasField(initiate: FieldCondition) = field(initiate).ignored().isNoSuch.not()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找方法是否存在
|
* 查找方法是否存在
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [Boolean] 是否存在
|
* @return [Boolean] 是否存在
|
||||||
*/
|
*/
|
||||||
inline fun Class<*>.hasMethod(initiate: MethodFinder.() -> Unit) = method(initiate).ignored().isNoSuch.not()
|
inline fun Class<*>.hasMethod(initiate: MethodCondition) = method(initiate).ignored().isNoSuch.not()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找构造方法是否存在
|
* 查找构造方法是否存在
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [Boolean] 是否存在
|
* @return [Boolean] 是否存在
|
||||||
*/
|
*/
|
||||||
inline fun Class<*>.hasConstructor(initiate: ConstructorFinder.() -> Unit = { emptyParam() }) = constructor(initiate).ignored().isNoSuch.not()
|
inline fun Class<*>.hasConstructor(initiate: ConstructorCondition = { emptyParam() }) = constructor(initiate).ignored().isNoSuch.not()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询 [Member] 中匹配的描述符
|
* 查询 [Member] 中匹配的描述符
|
||||||
@@ -124,22 +133,21 @@ inline fun Member.hasModifiers(initiate: ModifierRules.() -> Unit) = ModifierRul
|
|||||||
* @param initiate 查找方法体
|
* @param initiate 查找方法体
|
||||||
* @return [FieldFinder.Result]
|
* @return [FieldFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun Class<*>.field(initiate: FieldFinder.() -> Unit) = FieldFinder(classSet = this).apply(initiate).build()
|
inline fun Class<*>.field(initiate: FieldCondition) = FieldFinder(classSet = this).apply(initiate).build()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找并得到方法
|
* 查找并得到方法
|
||||||
* @param initiate 查找方法体
|
* @param initiate 查找方法体
|
||||||
* @return [MethodFinder.Result]
|
* @return [MethodFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun Class<*>.method(initiate: MethodFinder.() -> Unit) = MethodFinder(classSet = this).apply(initiate).build()
|
inline fun Class<*>.method(initiate: MethodCondition) = MethodFinder(classSet = this).apply(initiate).build()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找并得到构造方法
|
* 查找并得到构造方法
|
||||||
* @param initiate 查找方法体
|
* @param initiate 查找方法体
|
||||||
* @return [ConstructorFinder.Result]
|
* @return [ConstructorFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun Class<*>.constructor(initiate: ConstructorFinder.() -> Unit = { emptyParam() }) =
|
inline fun Class<*>.constructor(initiate: ConstructorCondition = { emptyParam() }) = ConstructorFinder(classSet = this).apply(initiate).build()
|
||||||
ConstructorFinder(classSet = this).apply(initiate).build()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得当前实例的类操作对象
|
* 获得当前实例的类操作对象
|
||||||
@@ -167,7 +175,7 @@ inline fun <reified T : Any> T.current(): CurrentClass {
|
|||||||
* @param initiate 查找方法体
|
* @param initiate 查找方法体
|
||||||
* @return [Any] or null
|
* @return [Any] or null
|
||||||
*/
|
*/
|
||||||
inline fun Class<*>.buildOfAny(vararg param: Any?, initiate: ConstructorFinder.() -> Unit = { emptyParam() }) =
|
inline fun Class<*>.buildOfAny(vararg param: Any?, initiate: ConstructorCondition = { emptyParam() }) =
|
||||||
constructor(initiate).get().call(*param)
|
constructor(initiate).get().call(*param)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,7 +184,7 @@ inline fun Class<*>.buildOfAny(vararg param: Any?, initiate: ConstructorFinder.(
|
|||||||
* @param initiate 查找方法体
|
* @param initiate 查找方法体
|
||||||
* @return [T] or null
|
* @return [T] or null
|
||||||
*/
|
*/
|
||||||
inline fun <T> Class<*>.buildOf(vararg param: Any?, initiate: ConstructorFinder.() -> Unit = { emptyParam() }) =
|
inline fun <T> Class<*>.buildOf(vararg param: Any?, initiate: ConstructorCondition = { emptyParam() }) =
|
||||||
constructor(initiate).get().newInstance<T>(*param)
|
constructor(initiate).get().newInstance<T>(*param)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user