mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 17:55:24 +08:00
Fix name misspellings Creater/creater to Creator/creator
This commit is contained in:
@@ -54,9 +54,9 @@
|
|||||||
|
|
||||||
[filename](public/YukiBaseHooker.md ':include')
|
[filename](public/YukiBaseHooker.md ':include')
|
||||||
|
|
||||||
[filename](public/YukiMemberHookCreater.md ':include')
|
[filename](public/YukiMemberHookCreator.md ':include')
|
||||||
|
|
||||||
[filename](public/YukiResourcesHookCreater.md ':include')
|
[filename](public/YukiResourcesHookCreator.md ':include')
|
||||||
|
|
||||||
[filename](public/MethodFinder.md ':include')
|
[filename](public/MethodFinder.md ':include')
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
## ConstructorFinder *- class*
|
## ConstructorFinder *- class*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class ConstructorFinder internal constructor(override val hookInstance: YukiMemberHookCreater.MemberHookCreater?, override val classSet: Class<*>) : BaseFinder()
|
class ConstructorFinder internal constructor(override val hookInstance: YukiMemberHookCreator.MemberHookCreator?, override val classSet: Class<*>) : BaseFinder()
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -12,6 +12,10 @@ class ConstructorFinder internal constructor(override val hookInstance: YukiMemb
|
|||||||
|
|
||||||
合并到 `BaseFinder`
|
合并到 `BaseFinder`
|
||||||
|
|
||||||
|
`v1.0.93` `修改`
|
||||||
|
|
||||||
|
修正拼写错误的 **Creater** 命名到 **Creator**
|
||||||
|
|
||||||
**功能描述**
|
**功能描述**
|
||||||
|
|
||||||
> `Constructor` 查找类。
|
> `Constructor` 查找类。
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
## FieldFinder *- class*
|
## FieldFinder *- class*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class FieldFinder internal constructor(override val hookInstance: YukiMemberHookCreater.MemberHookCreater?, override val classSet: Class<*>?) : BaseFinder()
|
class FieldFinder internal constructor(override val hookInstance: YukiMemberHookCreator.MemberHookCreator?, override val classSet: Class<*>?) : BaseFinder()
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
## HookParam *- class*
|
## HookParam *- class*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class HookParam internal constructor(private val createrInstance: YukiMemberHookCreater, private var param: YukiHookCallback.Param?)
|
class HookParam internal constructor(private val creatorInstance: YukiMemberHookCreator, private var param: YukiHookCallback.Param?)
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -12,6 +12,10 @@ class HookParam internal constructor(private val createrInstance: YukiMemberHook
|
|||||||
|
|
||||||
移动 `HookParamWrapper` 到 `YukiHookCallback.Param`
|
移动 `HookParamWrapper` 到 `YukiHookCallback.Param`
|
||||||
|
|
||||||
|
`v1.0.93` `修改`
|
||||||
|
|
||||||
|
修正拼写错误的 **creater** 命名到 **creator**
|
||||||
|
|
||||||
**功能描述**
|
**功能描述**
|
||||||
|
|
||||||
> Hook 方法、构造方法的目标对象实现类。
|
> Hook 方法、构造方法的目标对象实现类。
|
||||||
@@ -186,7 +190,7 @@ fun Throwable.throwToApp()
|
|||||||
|
|
||||||
使用 `throwable` 获取当前设置的方法调用抛出异常。
|
使用 `throwable` 获取当前设置的方法调用抛出异常。
|
||||||
|
|
||||||
仅会在回调方法的 `MemberHookCreater.beforeHook` or `MemberHookCreater.afterHook` 中生效。
|
仅会在回调方法的 `MemberHookCreator.beforeHook` or `MemberHookCreator.afterHook` 中生效。
|
||||||
|
|
||||||
!> 设置后会同时执行 `resultNull` 方法并将异常抛出给当前 Hook APP。
|
!> 设置后会同时执行 `resultNull` 方法并将异常抛出给当前 Hook APP。
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
## MethodFinder *- class*
|
## MethodFinder *- class*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class MethodFinder internal constructor(override val hookInstance: YukiMemberHookCreater.MemberHookCreater?, override val classSet: Class<*>) : BaseFinder()
|
class MethodFinder internal constructor(override val hookInstance: YukiMemberHookCreator.MemberHookCreator?, override val classSet: Class<*>) : BaseFinder()
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
|
@@ -642,19 +642,19 @@ customClassLoader?.fetching { clazz, resolve ->
|
|||||||
### String+Class+VariousClass+HookClass.hook *- i-ext-method*
|
### String+Class+VariousClass+HookClass.hook *- i-ext-method*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun String.hook(initiate: YukiMemberHookCreater.() -> Unit): YukiMemberHookCreater.Result
|
inline fun String.hook(initiate: YukiMemberHookCreator.() -> Unit): YukiMemberHookCreator.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun Class<*>.hook(initiate: YukiMemberHookCreater.() -> Unit): YukiMemberHookCreater.Result
|
inline fun Class<*>.hook(initiate: YukiMemberHookCreator.() -> Unit): YukiMemberHookCreator.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun VariousClass.hook(initiate: YukiMemberHookCreater.() -> Unit): YukiMemberHookCreater.Result
|
inline fun VariousClass.hook(initiate: YukiMemberHookCreator.() -> Unit): YukiMemberHookCreator.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun HookClass.hook(initiate: YukiMemberHookCreater.() -> Unit): YukiMemberHookCreater.Result
|
inline fun HookClass.hook(initiate: YukiMemberHookCreator.() -> Unit): YukiMemberHookCreator.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -671,7 +671,7 @@ inline fun HookClass.hook(initiate: YukiMemberHookCreater.() -> Unit): YukiMembe
|
|||||||
|
|
||||||
`v1.0.3` `修改`
|
`v1.0.3` `修改`
|
||||||
|
|
||||||
新增 `YukiMemberHookCreater.Result` 返回值
|
新增 `YukiMemberHookCreator.Result` 返回值
|
||||||
|
|
||||||
`v1.0.70` `修改`
|
`v1.0.70` `修改`
|
||||||
|
|
||||||
@@ -748,7 +748,7 @@ findClass("com.example.demo.DemoClass1", "com.example.demo.DemoClass2").hook {
|
|||||||
### HookResources.hook *- i-ext-method*
|
### HookResources.hook *- i-ext-method*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun HookResources.hook(initiate: YukiResourcesHookCreater.() -> Unit)
|
inline fun HookResources.hook(initiate: YukiResourcesHookCreator.() -> Unit)
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
## YukiMemberHookCreater *- class*
|
## YukiMemberHookCreator *- class*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class YukiMemberHookCreater(internal val packageParam: PackageParam, internal val hookClass: HookClass)
|
class YukiMemberHookCreator(internal val packageParam: PackageParam, internal val hookClass: HookClass)
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -12,6 +12,10 @@ class YukiMemberHookCreater(internal val packageParam: PackageParam, internal va
|
|||||||
|
|
||||||
对 `hookClass` 进行 inline 处理
|
对 `hookClass` 进行 inline 处理
|
||||||
|
|
||||||
|
`v1.0.93` `修改`
|
||||||
|
|
||||||
|
修正拼写错误的 **Creater** 命名到 **Creator**
|
||||||
|
|
||||||
**功能描述**
|
**功能描述**
|
||||||
|
|
||||||
> `YukiHookAPI` 的 `Member` 核心 Hook 实现类。
|
> `YukiHookAPI` 的 `Member` 核心 Hook 实现类。
|
||||||
@@ -81,7 +85,7 @@ val instanceClass: Class<*>
|
|||||||
### injectMember *- method*
|
### injectMember *- method*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun injectMember(priority: Int, tag: String, initiate: MemberHookCreater.() -> Unit): MemberHookCreater.Result
|
inline fun injectMember(priority: Int, tag: String, initiate: MemberHookCreator.() -> Unit): MemberHookCreator.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -152,10 +156,10 @@ fun useDangerousOperation(option: String)
|
|||||||
|
|
||||||
!> 若你不知道允许此功能会带来何种后果,请勿使用。
|
!> 若你不知道允许此功能会带来何种后果,请勿使用。
|
||||||
|
|
||||||
### MemberHookCreater *- class*
|
### MemberHookCreator *- class*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inner class MemberHookCreater internal constructor(private val priority: Int, internal val tag: String)
|
inner class MemberHookCreator internal constructor(private val priority: Int, internal val tag: String)
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -174,6 +178,8 @@ inner class MemberHookCreater internal constructor(private val priority: Int, in
|
|||||||
|
|
||||||
移除 `packageName`
|
移除 `packageName`
|
||||||
|
|
||||||
|
修正拼写错误的 **Creater** 命名到 **Creator**
|
||||||
|
|
||||||
**功能描述**
|
**功能描述**
|
||||||
|
|
||||||
> Hook 核心功能实现类,查找和处理需要 Hook 的 `Method`、`Constructor`。
|
> Hook 核心功能实现类,查找和处理需要 Hook 的 `Method`、`Constructor`。
|
||||||
@@ -453,7 +459,7 @@ inline fun HookParam.constructor(initiate: ConstructorCondition): ConstructorFin
|
|||||||
#### HookParam.injectMember *- i-ext-method*
|
#### HookParam.injectMember *- i-ext-method*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun HookParam.injectMember(priority: Int, tag: String, initiate: MemberHookCreater.() -> Unit): MemberHookCreater.Result
|
inline fun HookParam.injectMember(priority: Int, tag: String, initiate: MemberHookCreator.() -> Unit): MemberHookCreator.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
@@ -1,13 +1,17 @@
|
|||||||
## YukiResourcesHookCreater *- class*
|
## YukiResourcesHookCreator *- class*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class YukiResourcesHookCreater(internal val packageParam: PackageParam, internal val hookResources: HookResources)
|
class YukiResourcesHookCreator(internal val packageParam: PackageParam, internal val hookResources: HookResources)
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
|
|
||||||
`v1.0.80` `新增`
|
`v1.0.80` `新增`
|
||||||
|
|
||||||
|
`v1.0.93` `修改`
|
||||||
|
|
||||||
|
修正拼写错误的 **Creater** 命名到 **Creator**
|
||||||
|
|
||||||
**功能描述**
|
**功能描述**
|
||||||
|
|
||||||
> `YukiHookAPI` 的 `Resources` 核心 Hook 实现类。
|
> `YukiHookAPI` 的 `Resources` 核心 Hook 实现类。
|
||||||
@@ -15,7 +19,7 @@ class YukiResourcesHookCreater(internal val packageParam: PackageParam, internal
|
|||||||
### injectResource *- method*
|
### injectResource *- method*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inline fun injectResource(tag: String, initiate: ResourceHookCreater.() -> Unit): ResourceHookCreater.Result
|
inline fun injectResource(tag: String, initiate: ResourceHookCreator.() -> Unit): ResourceHookCreator.Result
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -48,10 +52,10 @@ injectResource(tag = "KuriharaYuki") {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### ResourcesHookCreater *- class*
|
### ResourcesHookCreator *- class*
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
inner class ResourcesHookCreater internal constructor(private val tag: String)
|
inner class ResourcesHookCreator internal constructor(private val tag: String)
|
||||||
```
|
```
|
||||||
|
|
||||||
**变更记录**
|
**变更记录**
|
||||||
@@ -62,6 +66,8 @@ inner class ResourcesHookCreater internal constructor(private val tag: String)
|
|||||||
|
|
||||||
移除 `packageName`
|
移除 `packageName`
|
||||||
|
|
||||||
|
修正拼写错误的 **Creater** 命名到 **Creator**
|
||||||
|
|
||||||
**功能描述**
|
**功能描述**
|
||||||
|
|
||||||
> Hook 核心功能实现类。
|
> Hook 核心功能实现类。
|
@@ -879,7 +879,7 @@ loadZygote {
|
|||||||
|
|
||||||
**异常原因**
|
**异常原因**
|
||||||
|
|
||||||
在 `MemberHookCreater` 中调用 `members()` 但是未设置需要 Hook 的 `Member` 实例。
|
在 `MemberHookCreator` 中调用 `members()` 但是未设置需要 Hook 的 `Member` 实例。
|
||||||
|
|
||||||
> 示例如下
|
> 示例如下
|
||||||
|
|
||||||
|
@@ -8,23 +8,23 @@
|
|||||||
|
|
||||||
```
|
```
|
||||||
Host Environment
|
Host Environment
|
||||||
└── YukiMemberHookCreater
|
└── YukiMemberHookCreator
|
||||||
└── Class
|
└── Class
|
||||||
└── MemberHookCreater
|
└── MemberHookCreator
|
||||||
└── Member
|
└── Member
|
||||||
├── Before
|
├── Before
|
||||||
└── After
|
└── After
|
||||||
MemberHookCreater
|
MemberHookCreator
|
||||||
└── Member
|
└── Member
|
||||||
├── Before
|
├── Before
|
||||||
└── After
|
└── After
|
||||||
...
|
...
|
||||||
YukiResourcesHookCreater
|
YukiResourcesHookCreator
|
||||||
└── Resources
|
└── Resources
|
||||||
└── ResourcesHookCreater
|
└── ResourcesHookCreator
|
||||||
└── Drawable
|
└── Drawable
|
||||||
└── Replace
|
└── Replace
|
||||||
ResourcesHookCreater
|
ResourcesHookCreator
|
||||||
└── Layout
|
└── Layout
|
||||||
└── Inject
|
└── Inject
|
||||||
...
|
...
|
||||||
@@ -192,7 +192,7 @@ TestClass.hook {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
更多功能请参考 [MemberHookCreater](api/document?id=memberhookcreater-class)。
|
更多功能请参考 [MemberHookCreator](api/document?id=memberhookcreator-class)。
|
||||||
|
|
||||||
### Hook Zygote
|
### Hook Zygote
|
||||||
|
|
||||||
@@ -304,7 +304,7 @@ loadZygote {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
更多功能请参考 [ResourcesHookCreater](api/document?id=resourceshookcreater-class)。
|
更多功能请参考 [ResourcesHookCreator](api/document?id=resourceshookcreator-class)。
|
||||||
|
|
||||||
### 解除 Hook
|
### 解除 Hook
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ injectMember {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
更多功能请参考 [MemberHookCreater](api/document?id=memberhookcreater-class)。
|
更多功能请参考 [MemberHookCreator](api/document?id=memberhookcreator-class)。
|
||||||
|
|
||||||
## 异常处理
|
## 异常处理
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ method {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
更多功能请参考 [MemberHookCreater.Result](api/document?id=result-class) 与 [ResourcesHookCreater.Result](api/document?id=result-class-2)。
|
更多功能请参考 [MemberHookCreator.Result](api/document?id=result-class) 与 [ResourcesHookCreator.Result](api/document?id=result-class-2)。
|
||||||
|
|
||||||
这里介绍了可能发生的常见异常,若要了解更多请参考 [API 异常处理](config/api-exception.md)。
|
这里介绍了可能发生的常见异常,若要了解更多请参考 [API 异常处理](config/api-exception.md)。
|
||||||
|
|
||||||
|
@@ -62,7 +62,7 @@ import java.lang.reflect.Method
|
|||||||
* @param packageParam 需要传入 [PackageParam] 实现方法调用
|
* @param packageParam 需要传入 [PackageParam] 实现方法调用
|
||||||
* @param hookClass 要 Hook 的 [HookClass] 实例
|
* @param hookClass 要 Hook 的 [HookClass] 实例
|
||||||
*/
|
*/
|
||||||
class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackageParam, @PublishedApi internal val hookClass: HookClass) {
|
class YukiMemberHookCreator(@PublishedApi internal val packageParam: PackageParam, @PublishedApi internal val hookClass: HookClass) {
|
||||||
|
|
||||||
/** 默认 Hook 回调优先级 */
|
/** 默认 Hook 回调优先级 */
|
||||||
val PRIORITY_DEFAULT = YukiHookPriority.PRIORITY_DEFAULT
|
val PRIORITY_DEFAULT = YukiHookPriority.PRIORITY_DEFAULT
|
||||||
@@ -79,13 +79,13 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
/** [hookClass] 找不到时出现的错误回调 */
|
/** [hookClass] 找不到时出现的错误回调 */
|
||||||
private var onHookClassNotFoundFailureCallback: ((Throwable) -> Unit)? = null
|
private var onHookClassNotFoundFailureCallback: ((Throwable) -> Unit)? = null
|
||||||
|
|
||||||
/** 是否对当前 [YukiMemberHookCreater] 禁止执行 Hook 操作 */
|
/** 是否对当前 [YukiMemberHookCreator] 禁止执行 Hook 操作 */
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal var isDisableCreaterRunHook = false
|
internal var isDisableCreatorRunHook = false
|
||||||
|
|
||||||
/** 设置要 Hook 的 [Method]、[Constructor] */
|
/** 设置要 Hook 的 [Method]、[Constructor] */
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal var preHookMembers = HashMap<String, MemberHookCreater>()
|
internal var preHookMembers = HashMap<String, MemberHookCreator>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 得到当前被 Hook 的 [Class]
|
* 得到当前被 Hook 的 [Class]
|
||||||
@@ -102,10 +102,10 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @param priority Hook 优先级 - 默认 [PRIORITY_DEFAULT]
|
* @param priority Hook 优先级 - 默认 [PRIORITY_DEFAULT]
|
||||||
* @param tag 可设置标签 - 在发生错误时方便进行调试
|
* @param tag 可设置标签 - 在发生错误时方便进行调试
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [MemberHookCreater.Result]
|
* @return [MemberHookCreator.Result]
|
||||||
*/
|
*/
|
||||||
inline fun injectMember(priority: Int = PRIORITY_DEFAULT, tag: String = "Default", initiate: MemberHookCreater.() -> Unit) =
|
inline fun injectMember(priority: Int = PRIORITY_DEFAULT, tag: String = "Default", initiate: MemberHookCreator.() -> Unit) =
|
||||||
MemberHookCreater(priority, tag).apply(initiate).apply { preHookMembers[toString()] = this }.build()
|
MemberHookCreator(priority, tag).apply(initiate).apply { preHookMembers[toString()] = this }.build()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 允许 Hook 过程中的所有危险行为
|
* 允许 Hook 过程中的所有危险行为
|
||||||
@@ -134,7 +134,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
preHookMembers.isEmpty() -> Result().also { yLoggerW(msg = "Hook Members is empty in [${hookClass.name}], hook aborted") }
|
preHookMembers.isEmpty() -> Result().also { yLoggerW(msg = "Hook Members is empty in [${hookClass.name}], hook aborted") }
|
||||||
else -> Result().await {
|
else -> Result().await {
|
||||||
when {
|
when {
|
||||||
isDisableCreaterRunHook.not() && hookClass.instance != null -> runCatching {
|
isDisableCreatorRunHook.not() && hookClass.instance != null -> runCatching {
|
||||||
hookClass.instance?.apply { checkingInternal(); checkingDangerous() }
|
hookClass.instance?.apply { checkingInternal(); checkingDangerous() }
|
||||||
it.onPrepareHook?.invoke()
|
it.onPrepareHook?.invoke()
|
||||||
preHookMembers.forEach { (_, m) -> m.hook() }
|
preHookMembers.forEach { (_, m) -> m.hook() }
|
||||||
@@ -143,7 +143,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
yLoggerE(msg = "Hook initialization failed because got an Exception", e = it)
|
yLoggerE(msg = "Hook initialization failed because got an Exception", e = it)
|
||||||
else onHookClassNotFoundFailureCallback?.invoke(it)
|
else onHookClassNotFoundFailureCallback?.invoke(it)
|
||||||
}
|
}
|
||||||
isDisableCreaterRunHook.not() && hookClass.instance == null ->
|
isDisableCreatorRunHook.not() && hookClass.instance == null ->
|
||||||
if (onHookClassNotFoundFailureCallback == null)
|
if (onHookClassNotFoundFailureCallback == null)
|
||||||
yLoggerE(msg = "HookClass [${hookClass.name}] not found", e = hookClass.throwable)
|
yLoggerE(msg = "HookClass [${hookClass.name}] not found", e = hookClass.throwable)
|
||||||
else onHookClassNotFoundFailureCallback?.invoke(hookClass.throwable ?: Throwable("[${hookClass.name}] not found"))
|
else onHookClassNotFoundFailureCallback?.invoke(hookClass.throwable ?: Throwable("[${hookClass.name}] not found"))
|
||||||
@@ -193,7 +193,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @param priority Hook 优先级
|
* @param priority Hook 优先级
|
||||||
* @param tag 当前设置的标签
|
* @param tag 当前设置的标签
|
||||||
*/
|
*/
|
||||||
inner class MemberHookCreater @PublishedApi internal constructor(private val priority: Int, internal val tag: String) {
|
inner class MemberHookCreator @PublishedApi internal constructor(private val priority: Int, internal val tag: String) {
|
||||||
|
|
||||||
/** Hook 结果实例 */
|
/** Hook 结果实例 */
|
||||||
private var result: Result? = null
|
private var result: Result? = null
|
||||||
@@ -234,7 +234,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
/** 是否为替换 Hook 模式 */
|
/** 是否为替换 Hook 模式 */
|
||||||
private var isReplaceHookMode = false
|
private var isReplaceHookMode = false
|
||||||
|
|
||||||
/** 是否对当前 [MemberHookCreater] 禁止执行 Hook 操作 */
|
/** 是否对当前 [MemberHookCreator] 禁止执行 Hook 操作 */
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal var isDisableMemberRunHook = false
|
internal var isDisableMemberRunHook = false
|
||||||
|
|
||||||
@@ -354,8 +354,8 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @return [FieldFinder.Result]
|
* @return [FieldFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun HookParam.field(initiate: FieldCondition) =
|
inline fun HookParam.field(initiate: FieldCondition) =
|
||||||
if (hookClass.instance == null) FieldFinder(hookInstance = this@MemberHookCreater).failure(hookClass.throwable)
|
if (hookClass.instance == null) FieldFinder(hookInstance = this@MemberHookCreator).failure(hookClass.throwable)
|
||||||
else FieldFinder(hookInstance = this@MemberHookCreater, hookClass.instance).apply(initiate).build()
|
else FieldFinder(hookInstance = this@MemberHookCreator, hookClass.instance).apply(initiate).build()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用当前 [hookClass] 查找并得到 [Method]
|
* 使用当前 [hookClass] 查找并得到 [Method]
|
||||||
@@ -363,8 +363,8 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @return [MethodFinder.Result]
|
* @return [MethodFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun HookParam.method(initiate: MethodCondition) =
|
inline fun HookParam.method(initiate: MethodCondition) =
|
||||||
if (hookClass.instance == null) MethodFinder(hookInstance = this@MemberHookCreater).failure(hookClass.throwable)
|
if (hookClass.instance == null) MethodFinder(hookInstance = this@MemberHookCreator).failure(hookClass.throwable)
|
||||||
else MethodFinder(hookInstance = this@MemberHookCreater, hookClass.instance).apply(initiate).build()
|
else MethodFinder(hookInstance = this@MemberHookCreator, hookClass.instance).apply(initiate).build()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用当前 [hookClass] 查找并得到 [Constructor]
|
* 使用当前 [hookClass] 查找并得到 [Constructor]
|
||||||
@@ -372,21 +372,21 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @return [ConstructorFinder.Result]
|
* @return [ConstructorFinder.Result]
|
||||||
*/
|
*/
|
||||||
inline fun HookParam.constructor(initiate: ConstructorCondition = { 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@MemberHookCreator).failure(hookClass.throwable)
|
||||||
else ConstructorFinder(hookInstance = this@MemberHookCreater, hookClass.instance).apply(initiate).build()
|
else ConstructorFinder(hookInstance = this@MemberHookCreator, hookClass.instance).apply(initiate).build()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注入要 Hook 的 [Method]、[Constructor] (嵌套 Hook)
|
* 注入要 Hook 的 [Method]、[Constructor] (嵌套 Hook)
|
||||||
* @param priority Hook 优先级 - 默认 [PRIORITY_DEFAULT]
|
* @param priority Hook 优先级 - 默认 [PRIORITY_DEFAULT]
|
||||||
* @param tag 可设置标签 - 在发生错误时方便进行调试
|
* @param tag 可设置标签 - 在发生错误时方便进行调试
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [MemberHookCreater.Result]
|
* @return [MemberHookCreator.Result]
|
||||||
*/
|
*/
|
||||||
inline fun HookParam.injectMember(
|
inline fun HookParam.injectMember(
|
||||||
priority: Int = PRIORITY_DEFAULT,
|
priority: Int = PRIORITY_DEFAULT,
|
||||||
tag: String = "InnerDefault",
|
tag: String = "InnerDefault",
|
||||||
initiate: MemberHookCreater.() -> Unit
|
initiate: MemberHookCreator.() -> Unit
|
||||||
) = this@YukiMemberHookCreater.injectMember(priority, tag, initiate).also { this@YukiMemberHookCreater.hook() }
|
) = this@YukiMemberHookCreator.injectMember(priority, tag, initiate).also { this@YukiMemberHookCreator.hook() }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在 [Member] 执行完成前 Hook
|
* 在 [Member] 执行完成前 Hook
|
||||||
@@ -550,7 +550,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
*/
|
*/
|
||||||
private fun Member.hook(): Pair<YukiMemberHook.Unhook?, Boolean> {
|
private fun Member.hook(): Pair<YukiMemberHook.Unhook?, Boolean> {
|
||||||
/** 定义替换 Hook 的 [HookParam] */
|
/** 定义替换 Hook 的 [HookParam] */
|
||||||
val replaceHookParam = HookParam(createrInstance = this@YukiMemberHookCreater)
|
val replaceHookParam = HookParam(creatorInstance = this@YukiMemberHookCreator)
|
||||||
|
|
||||||
/** 定义替换 Hook 回调方法体 */
|
/** 定义替换 Hook 回调方法体 */
|
||||||
val replaceMent = object : YukiMemberReplacement(priority) {
|
val replaceMent = object : YukiMemberReplacement(priority) {
|
||||||
@@ -573,10 +573,10 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 定义前 Hook 的 [HookParam] */
|
/** 定义前 Hook 的 [HookParam] */
|
||||||
val beforeHookParam = HookParam(createrInstance = this@YukiMemberHookCreater)
|
val beforeHookParam = HookParam(creatorInstance = this@YukiMemberHookCreator)
|
||||||
|
|
||||||
/** 定义后 Hook 的 [HookParam] */
|
/** 定义后 Hook 的 [HookParam] */
|
||||||
val afterHookParam = HookParam(createrInstance = this@YukiMemberHookCreater)
|
val afterHookParam = HookParam(creatorInstance = this@YukiMemberHookCreator)
|
||||||
|
|
||||||
/** 定义前后 Hook 回调方法体 */
|
/** 定义前后 Hook 回调方法体 */
|
||||||
val beforeAfterHook = object : YukiMemberHook(priority) {
|
val beforeAfterHook = object : YukiMemberHook(priority) {
|
||||||
@@ -814,7 +814,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
it.remove()
|
it.remove()
|
||||||
onHookLogMsg(msg = "Remove Hooked Member [${it.member}] done [$tag]")
|
onHookLogMsg(msg = "Remove Hooked Member [${it.member}] done [$tag]")
|
||||||
}
|
}
|
||||||
runCatching { preHookMembers.remove(this@MemberHookCreater.toString()) }
|
runCatching { preHookMembers.remove(this@MemberHookCreator.toString()) }
|
||||||
clear()
|
clear()
|
||||||
result(true)
|
result(true)
|
||||||
} ?: result(false)
|
} ?: result(false)
|
||||||
@@ -847,7 +847,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @return [Result] 可继续向下监听
|
* @return [Result] 可继续向下监听
|
||||||
*/
|
*/
|
||||||
inline fun by(condition: () -> Boolean): Result {
|
inline fun by(condition: () -> Boolean): Result {
|
||||||
isDisableCreaterRunHook = (runCatching { condition() }.getOrNull() ?: false).not()
|
isDisableCreatorRunHook = (runCatching { condition() }.getOrNull() ?: false).not()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
@@ -46,20 +46,20 @@ import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiResources
|
|||||||
* @param packageParam 需要传入 [PackageParam] 实现方法调用
|
* @param packageParam 需要传入 [PackageParam] 实现方法调用
|
||||||
* @param hookResources 要 Hook 的 [HookResources] 实例
|
* @param hookResources 要 Hook 的 [HookResources] 实例
|
||||||
*/
|
*/
|
||||||
class YukiResourcesHookCreater(@PublishedApi internal val packageParam: PackageParam, @PublishedApi internal val hookResources: HookResources) {
|
class YukiResourcesHookCreator(@PublishedApi internal val packageParam: PackageParam, @PublishedApi internal val hookResources: HookResources) {
|
||||||
|
|
||||||
/** 设置要 Hook 的 Resources */
|
/** 设置要 Hook 的 Resources */
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal var preHookResources = HashMap<String, ResourcesHookCreater>()
|
internal var preHookResources = HashMap<String, ResourcesHookCreator>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注入要 Hook 的 Resources
|
* 注入要 Hook 的 Resources
|
||||||
* @param tag 可设置标签 - 在发生错误时方便进行调试
|
* @param tag 可设置标签 - 在发生错误时方便进行调试
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [ResourcesHookCreater.Result]
|
* @return [ResourcesHookCreator.Result]
|
||||||
*/
|
*/
|
||||||
inline fun injectResource(tag: String = "Default", initiate: ResourcesHookCreater.() -> Unit) =
|
inline fun injectResource(tag: String = "Default", initiate: ResourcesHookCreator.() -> Unit) =
|
||||||
ResourcesHookCreater(tag).apply(initiate).apply { preHookResources[toString()] = this }.build()
|
ResourcesHookCreator(tag).apply(initiate).apply { preHookResources[toString()] = this }.build()
|
||||||
|
|
||||||
/** Hook 执行入口 */
|
/** Hook 执行入口 */
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
@@ -77,7 +77,7 @@ class YukiResourcesHookCreater(@PublishedApi internal val packageParam: PackageP
|
|||||||
* 查找和处理需要 Hook 的 Resources
|
* 查找和处理需要 Hook 的 Resources
|
||||||
* @param tag 当前设置的标签
|
* @param tag 当前设置的标签
|
||||||
*/
|
*/
|
||||||
inner class ResourcesHookCreater @PublishedApi internal constructor(private val tag: String) {
|
inner class ResourcesHookCreator @PublishedApi internal constructor(private val tag: String) {
|
||||||
|
|
||||||
/** 是否已经执行 Hook */
|
/** 是否已经执行 Hook */
|
||||||
private var isHooked = false
|
private var isHooked = false
|
||||||
@@ -88,9 +88,9 @@ class YukiResourcesHookCreater(@PublishedApi internal val packageParam: PackageP
|
|||||||
*/
|
*/
|
||||||
private inner class ModuleResFwd(var resId: Int)
|
private inner class ModuleResFwd(var resId: Int)
|
||||||
|
|
||||||
/** 是否对当前 [ResourcesHookCreater] 禁止执行 Hook 操作 */
|
/** 是否对当前 [ResourcesHookCreator] 禁止执行 Hook 操作 */
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal var isDisableCreaterRunHook = false
|
internal var isDisableCreatorRunHook = false
|
||||||
|
|
||||||
/** 当前的查找条件 */
|
/** 当前的查找条件 */
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
@@ -177,7 +177,7 @@ class YukiResourcesHookCreater(@PublishedApi internal val packageParam: PackageP
|
|||||||
internal fun hook() {
|
internal fun hook() {
|
||||||
if (isHooked) return
|
if (isHooked) return
|
||||||
isHooked = true
|
isHooked = true
|
||||||
if (isDisableCreaterRunHook.not()) runCatching {
|
if (isDisableCreatorRunHook.not()) runCatching {
|
||||||
when {
|
when {
|
||||||
conditions == null -> yLoggerE(msg = "You must set the conditions before hook a Resources [$tag]")
|
conditions == null -> yLoggerE(msg = "You must set the conditions before hook a Resources [$tag]")
|
||||||
replaceInstance == null && layoutInstance == null -> yLoggerE(msg = "Resources Hook got null replaceInstance [$tag]")
|
replaceInstance == null && layoutInstance == null -> yLoggerE(msg = "Resources Hook got null replaceInstance [$tag]")
|
||||||
@@ -347,7 +347,7 @@ class YukiResourcesHookCreater(@PublishedApi internal val packageParam: PackageP
|
|||||||
* @return [Result] 可继续向下监听
|
* @return [Result] 可继续向下监听
|
||||||
*/
|
*/
|
||||||
inline fun by(condition: () -> Boolean): Result {
|
inline fun by(condition: () -> Boolean): Result {
|
||||||
isDisableCreaterRunHook = (runCatching { condition() }.getOrNull() ?: false).not()
|
isDisableCreatorRunHook = (runCatching { condition() }.getOrNull() ?: false).not()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
@@ -31,7 +31,7 @@ package com.highcapable.yukihookapi.hook.core.finder
|
|||||||
|
|
||||||
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.YukiMemberHookCreater
|
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
|
||||||
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
|
||||||
@@ -49,12 +49,12 @@ import java.lang.reflect.Member
|
|||||||
* [Constructor] 查找类
|
* [Constructor] 查找类
|
||||||
*
|
*
|
||||||
* 可通过指定类型查找指定构造方法或一组构造方法
|
* 可通过指定类型查找指定构造方法或一组构造方法
|
||||||
* @param hookInstance 当前 Hook 实例 - 填写后将自动设置 [YukiMemberHookCreater.MemberHookCreater.members]
|
* @param hookInstance 当前 Hook 实例 - 填写后将自动设置 [YukiMemberHookCreator.MemberHookCreator.members]
|
||||||
* @param classSet 当前需要查找的 [Class] 实例
|
* @param classSet 当前需要查找的 [Class] 实例
|
||||||
*/
|
*/
|
||||||
class ConstructorFinder @PublishedApi internal constructor(
|
class ConstructorFinder @PublishedApi internal constructor(
|
||||||
@property:YukiPrivateApi
|
@property:YukiPrivateApi
|
||||||
override val hookInstance: YukiMemberHookCreater.MemberHookCreater? = 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) {
|
) : BaseFinder(tag = "Constructor", hookInstance, classSet) {
|
||||||
@@ -185,7 +185,7 @@ class ConstructorFinder @PublishedApi internal constructor(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置实例
|
* 设置实例
|
||||||
* @param isBind 是否将结果设置到目标 [YukiMemberHookCreater.MemberHookCreater]
|
* @param isBind 是否将结果设置到目标 [YukiMemberHookCreator.MemberHookCreator]
|
||||||
* @param constructors 当前找到的 [Constructor] 数组
|
* @param constructors 当前找到的 [Constructor] 数组
|
||||||
*/
|
*/
|
||||||
private fun setInstance(isBind: Boolean, constructors: HashSet<Constructor<*>>) {
|
private fun setInstance(isBind: Boolean, constructors: HashSet<Constructor<*>>) {
|
||||||
@@ -199,7 +199,7 @@ class ConstructorFinder @PublishedApi internal constructor(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 得到 [Constructor] 结果
|
* 得到 [Constructor] 结果
|
||||||
* @param isBind 是否将结果设置到目标 [YukiMemberHookCreater.MemberHookCreater]
|
* @param isBind 是否将结果设置到目标 [YukiMemberHookCreator.MemberHookCreator]
|
||||||
*/
|
*/
|
||||||
private fun build(isBind: Boolean) {
|
private fun build(isBind: Boolean) {
|
||||||
if (classSet == null) error("classSet is null")
|
if (classSet == null) error("classSet is null")
|
||||||
|
@@ -32,7 +32,7 @@ package com.highcapable.yukihookapi.hook.core.finder
|
|||||||
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.YukiMemberHookCreater
|
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
|
||||||
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.finder.type.NameConditions
|
import com.highcapable.yukihookapi.hook.core.finder.type.NameConditions
|
||||||
@@ -55,7 +55,7 @@ import java.lang.reflect.Field
|
|||||||
*/
|
*/
|
||||||
class FieldFinder @PublishedApi internal constructor(
|
class FieldFinder @PublishedApi internal constructor(
|
||||||
@property:YukiPrivateApi
|
@property:YukiPrivateApi
|
||||||
override val hookInstance: YukiMemberHookCreater.MemberHookCreater? = 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) {
|
) : BaseFinder(tag = "Field", hookInstance, classSet) {
|
||||||
|
@@ -31,7 +31,7 @@ package com.highcapable.yukihookapi.hook.core.finder
|
|||||||
|
|
||||||
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.YukiMemberHookCreater
|
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
|
||||||
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.finder.type.NameConditions
|
import com.highcapable.yukihookapi.hook.core.finder.type.NameConditions
|
||||||
@@ -51,12 +51,12 @@ import java.lang.reflect.Method
|
|||||||
* [Method] 查找类
|
* [Method] 查找类
|
||||||
*
|
*
|
||||||
* 可通过指定类型查找指定方法或一组方法
|
* 可通过指定类型查找指定方法或一组方法
|
||||||
* @param hookInstance 当前 Hook 实例 - 填写后将自动设置 [YukiMemberHookCreater.MemberHookCreater.members]
|
* @param hookInstance 当前 Hook 实例 - 填写后将自动设置 [YukiMemberHookCreator.MemberHookCreator.members]
|
||||||
* @param classSet 当前需要查找的 [Class] 实例
|
* @param classSet 当前需要查找的 [Class] 实例
|
||||||
*/
|
*/
|
||||||
class MethodFinder @PublishedApi internal constructor(
|
class MethodFinder @PublishedApi internal constructor(
|
||||||
@property:YukiPrivateApi
|
@property:YukiPrivateApi
|
||||||
override val hookInstance: YukiMemberHookCreater.MemberHookCreater? = 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) {
|
) : BaseFinder(tag = "Method", hookInstance, classSet) {
|
||||||
@@ -252,7 +252,7 @@ class MethodFinder @PublishedApi internal constructor(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置实例
|
* 设置实例
|
||||||
* @param isBind 是否将结果设置到目标 [YukiMemberHookCreater.MemberHookCreater]
|
* @param isBind 是否将结果设置到目标 [YukiMemberHookCreator.MemberHookCreator]
|
||||||
* @param methods 当前找到的 [Method] 数组
|
* @param methods 当前找到的 [Method] 数组
|
||||||
*/
|
*/
|
||||||
private fun setInstance(isBind: Boolean, methods: HashSet<Method>) {
|
private fun setInstance(isBind: Boolean, methods: HashSet<Method>) {
|
||||||
@@ -266,7 +266,7 @@ class MethodFinder @PublishedApi internal constructor(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 得到 [Method] 结果
|
* 得到 [Method] 结果
|
||||||
* @param isBind 是否将结果设置到目标 [YukiMemberHookCreater.MemberHookCreater]
|
* @param isBind 是否将结果设置到目标 [YukiMemberHookCreator.MemberHookCreator]
|
||||||
*/
|
*/
|
||||||
private fun build(isBind: Boolean) {
|
private fun build(isBind: Boolean) {
|
||||||
if (classSet == null) error("classSet is null")
|
if (classSet == null) error("classSet is null")
|
||||||
|
@@ -29,8 +29,8 @@
|
|||||||
|
|
||||||
package com.highcapable.yukihookapi.hook.param
|
package com.highcapable.yukihookapi.hook.param
|
||||||
|
|
||||||
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreater
|
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
|
||||||
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreater.MemberHookCreater
|
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator.MemberHookCreator
|
||||||
import com.highcapable.yukihookapi.hook.factory.classOf
|
import com.highcapable.yukihookapi.hook.factory.classOf
|
||||||
import com.highcapable.yukihookapi.hook.log.yLoggerE
|
import com.highcapable.yukihookapi.hook.log.yLoggerE
|
||||||
import com.highcapable.yukihookapi.hook.xposed.bridge.factory.YukiHookCallback
|
import com.highcapable.yukihookapi.hook.xposed.bridge.factory.YukiHookCallback
|
||||||
@@ -41,10 +41,10 @@ import java.lang.reflect.Method
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook 方法、构造方法的目标对象实现类
|
* Hook 方法、构造方法的目标对象实现类
|
||||||
* @param createrInstance [YukiMemberHookCreater] 的实例对象
|
* @param creatorInstance [YukiMemberHookCreator] 的实例对象
|
||||||
* @param param Hook 结果回调接口
|
* @param param Hook 结果回调接口
|
||||||
*/
|
*/
|
||||||
class HookParam internal constructor(private val createrInstance: YukiMemberHookCreater, private var param: YukiHookCallback.Param? = null) {
|
class HookParam internal constructor(private val creatorInstance: YukiMemberHookCreator, private var param: YukiHookCallback.Param? = null) {
|
||||||
|
|
||||||
internal companion object {
|
internal companion object {
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ class HookParam internal constructor(private val createrInstance: YukiMemberHook
|
|||||||
* 获取当前 Hook 实例的类对象
|
* 获取当前 Hook 实例的类对象
|
||||||
* @return [Class]
|
* @return [Class]
|
||||||
*/
|
*/
|
||||||
val instanceClass get() = param?.instance?.javaClass ?: createrInstance.instanceClass
|
val instanceClass get() = param?.instance?.javaClass ?: creatorInstance.instanceClass
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前 Hook 对象的 [Member]
|
* 获取当前 Hook 对象的 [Member]
|
||||||
@@ -143,7 +143,7 @@ class HookParam internal constructor(private val createrInstance: YukiMemberHook
|
|||||||
*
|
*
|
||||||
* 使用 [throwable] 获取当前设置的方法调用抛出异常
|
* 使用 [throwable] 获取当前设置的方法调用抛出异常
|
||||||
*
|
*
|
||||||
* - 仅会在回调方法的 [MemberHookCreater.beforeHook] or [MemberHookCreater.afterHook] 中生效
|
* - 仅会在回调方法的 [MemberHookCreator.beforeHook] or [MemberHookCreator.afterHook] 中生效
|
||||||
*
|
*
|
||||||
* - ❗设置后会同时执行 [resultNull] 方法并将异常抛出给当前 Hook APP
|
* - ❗设置后会同时执行 [resultNull] 方法并将异常抛出给当前 Hook APP
|
||||||
* @return [Throwable] or null
|
* @return [Throwable] or null
|
||||||
|
@@ -40,8 +40,8 @@ import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
|
|||||||
import com.highcapable.yukihookapi.hook.bean.HookClass
|
import com.highcapable.yukihookapi.hook.bean.HookClass
|
||||||
import com.highcapable.yukihookapi.hook.bean.HookResources
|
import com.highcapable.yukihookapi.hook.bean.HookResources
|
||||||
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
||||||
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreater
|
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
|
||||||
import com.highcapable.yukihookapi.hook.core.YukiResourcesHookCreater
|
import com.highcapable.yukihookapi.hook.core.YukiResourcesHookCreator
|
||||||
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
|
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
|
||||||
import com.highcapable.yukihookapi.hook.factory.classOf
|
import com.highcapable.yukihookapi.hook.factory.classOf
|
||||||
import com.highcapable.yukihookapi.hook.factory.hasClass
|
import com.highcapable.yukihookapi.hook.factory.hasClass
|
||||||
@@ -366,18 +366,18 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
|||||||
*
|
*
|
||||||
* - ❗为防止任何字符串都被当做 [Class] 进行 Hook - 推荐优先使用 [findClass]
|
* - ❗为防止任何字符串都被当做 [Class] 进行 Hook - 推荐优先使用 [findClass]
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [YukiMemberHookCreater.Result]
|
* @return [YukiMemberHookCreator.Result]
|
||||||
*/
|
*/
|
||||||
inline fun String.hook(initiate: YukiMemberHookCreater.() -> Unit) = findClass(name = this).hook(initiate)
|
inline fun String.hook(initiate: YukiMemberHookCreator.() -> Unit) = findClass(name = this).hook(initiate)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook 方法、构造方法
|
* Hook 方法、构造方法
|
||||||
*
|
*
|
||||||
* - 自动选择与当前 [Class] 相匹配的 [ClassLoader] - 优先使用 [appClassLoader]
|
* - 自动选择与当前 [Class] 相匹配的 [ClassLoader] - 优先使用 [appClassLoader]
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [YukiMemberHookCreater.Result]
|
* @return [YukiMemberHookCreator.Result]
|
||||||
*/
|
*/
|
||||||
inline fun Class<*>.hook(initiate: YukiMemberHookCreater.() -> Unit) = when {
|
inline fun Class<*>.hook(initiate: YukiMemberHookCreator.() -> Unit) = when {
|
||||||
name.hasClass(appClassLoader) -> findClass(name)
|
name.hasClass(appClassLoader) -> findClass(name)
|
||||||
else -> hookClass
|
else -> hookClass
|
||||||
}.hook(initiate)
|
}.hook(initiate)
|
||||||
@@ -387,17 +387,17 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
|||||||
*
|
*
|
||||||
* - 使用当前 [appClassLoader] 装载目标 [Class]
|
* - 使用当前 [appClassLoader] 装载目标 [Class]
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [YukiMemberHookCreater.Result]
|
* @return [YukiMemberHookCreator.Result]
|
||||||
*/
|
*/
|
||||||
inline fun VariousClass.hook(initiate: YukiMemberHookCreater.() -> Unit) = hookClass(appClassLoader).hook(initiate)
|
inline fun VariousClass.hook(initiate: YukiMemberHookCreator.() -> Unit) = hookClass(appClassLoader).hook(initiate)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook 方法、构造方法
|
* Hook 方法、构造方法
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
* @return [YukiMemberHookCreater.Result]
|
* @return [YukiMemberHookCreator.Result]
|
||||||
*/
|
*/
|
||||||
inline fun HookClass.hook(initiate: YukiMemberHookCreater.() -> Unit) =
|
inline fun HookClass.hook(initiate: YukiMemberHookCreator.() -> Unit) =
|
||||||
YukiMemberHookCreater(packageParam = this@PackageParam, hookClass = this).apply(initiate).hook()
|
YukiMemberHookCreator(packageParam = this@PackageParam, hookClass = this).apply(initiate).hook()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook APP 的 Resources
|
* Hook APP 的 Resources
|
||||||
@@ -405,8 +405,8 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
|||||||
* - ❗请注意你需要确保当前 Hook Framework 支持且 [InjectYukiHookWithXposed.isUsingResourcesHook] 已启用
|
* - ❗请注意你需要确保当前 Hook Framework 支持且 [InjectYukiHookWithXposed.isUsingResourcesHook] 已启用
|
||||||
* @param initiate 方法体
|
* @param initiate 方法体
|
||||||
*/
|
*/
|
||||||
inline fun HookResources.hook(initiate: YukiResourcesHookCreater.() -> Unit) =
|
inline fun HookResources.hook(initiate: YukiResourcesHookCreator.() -> Unit) =
|
||||||
YukiResourcesHookCreater(packageParam = this@PackageParam, hookResources = this).apply(initiate).hook()
|
YukiResourcesHookCreator(packageParam = this@PackageParam, hookResources = this).apply(initiate).hook()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [VariousClass] 转换为 [HookClass]
|
* [VariousClass] 转换为 [HookClass]
|
||||||
|
Reference in New Issue
Block a user