mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 01:35:17 +08:00
refactor: use magic to hide lint on non-public, inline api
- remove all YukiGenerateApi, YukiPrivateApi and @PublishedApi
This commit is contained in:
@@ -13,7 +13,7 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe
|
||||
# CurrentClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class CurrentClass internal constructor(internal val classSet: Class<*>, internal val instance: Any)
|
||||
class CurrentClass internal constructor(private val classSet: Class<*>, internal val instance: Any)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
@@ -133,7 +133,7 @@ inline fun method(initiate: MethodConditions): MethodFinder.Result.Instance
|
||||
## SuperClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class SuperClass internal constructor(internal val superClassSet: Class<*>)
|
||||
inner class SuperClass internal constructor(private val superClassSet: Class<*>)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
@@ -13,7 +13,7 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe
|
||||
# YukiMemberHookCreator <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class YukiMemberHookCreator internal constructor(internal val packageParam: PackageParam, internal val hookClass: HookClass)
|
||||
class YukiMemberHookCreator internal constructor(private val packageParam: PackageParam, private val hookClass: HookClass)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
@@ -13,7 +13,7 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe
|
||||
# ConstructorRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class ConstructorRules internal constructor(internal val rulesData: ConstructorRulesData) : BaseRules
|
||||
class ConstructorRules internal constructor(private val rulesData: ConstructorRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
@@ -13,7 +13,7 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe
|
||||
# FieldRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class FieldRules internal constructor(internal val rulesData: FieldRulesData) : BaseRules
|
||||
class FieldRules internal constructor(private val rulesData: FieldRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
@@ -13,7 +13,7 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe
|
||||
# MemberRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MemberRules internal constructor(internal val rulesData: MemberRulesData) : BaseRules
|
||||
class MemberRules internal constructor(private val rulesData: MemberRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
@@ -13,7 +13,7 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe
|
||||
# MethodRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MethodRules internal constructor(internal val rulesData: MethodRulesData) : BaseRules
|
||||
class MethodRules internal constructor(private val rulesData: MethodRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
@@ -317,7 +317,7 @@ field {
|
||||
## Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, private val throwable: Throwable?) : BaseResult
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, internal val throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
@@ -27,7 +27,7 @@ class YukiResources private constructor(private val baseInstance: XResources) :
|
||||
## LayoutInflatedParam <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class LayoutInflatedParam(internal val baseParam: XC_LayoutInflated.LayoutInflatedParam)
|
||||
class LayoutInflatedParam(private val baseParam: XC_LayoutInflated.LayoutInflatedParam)
|
||||
```
|
||||
|
||||
**Change Records**
|
||||
|
@@ -5,7 +5,7 @@ pageClass: code-page
|
||||
# CurrentClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class CurrentClass internal constructor(internal val classSet: Class<*>, internal val instance: Any)
|
||||
class CurrentClass internal constructor(private val classSet: Class<*>, internal val instance: Any)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
@@ -125,7 +125,7 @@ inline fun method(initiate: MethodConditions): MethodFinder.Result.Instance
|
||||
## SuperClass <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class SuperClass internal constructor(internal val superClassSet: Class<*>)
|
||||
inner class SuperClass internal constructor(private val superClassSet: Class<*>)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
@@ -5,7 +5,7 @@ pageClass: code-page
|
||||
# YukiMemberHookCreator <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class YukiMemberHookCreator internal constructor(internal val packageParam: PackageParam, internal val hookClass: HookClass)
|
||||
class YukiMemberHookCreator internal constructor(private val packageParam: PackageParam, private val hookClass: HookClass)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
@@ -5,7 +5,7 @@ pageClass: code-page
|
||||
# ConstructorRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class ConstructorRules internal constructor(internal val rulesData: ConstructorRulesData) : BaseRules
|
||||
class ConstructorRules internal constructor(private val rulesData: ConstructorRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
@@ -5,7 +5,7 @@ pageClass: code-page
|
||||
# FieldRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class FieldRules internal constructor(internal val rulesData: FieldRulesData) : BaseRules
|
||||
class FieldRules internal constructor(private val rulesData: FieldRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
@@ -5,7 +5,7 @@ pageClass: code-page
|
||||
# MemberRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MemberRules internal constructor(internal val rulesData: MemberRulesData) : BaseRules
|
||||
class MemberRules internal constructor(private val rulesData: MemberRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
@@ -5,7 +5,7 @@ pageClass: code-page
|
||||
# MethodRules <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class MethodRules internal constructor(internal val rulesData: MethodRulesData) : BaseRules
|
||||
class MethodRules internal constructor(private val rulesData: MethodRulesData) : BaseRules
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
@@ -309,7 +309,7 @@ field {
|
||||
## Result <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, private val throwable: Throwable?) : BaseResult
|
||||
inner class Result internal constructor(internal val isNoSuch: Boolean, internal val throwable: Throwable?) : BaseResult
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
@@ -19,7 +19,7 @@ class YukiResources private constructor(private val baseInstance: XResources) :
|
||||
## LayoutInflatedParam <span class="symbol">- class</span>
|
||||
|
||||
```kotlin:no-line-numbers
|
||||
class LayoutInflatedParam(internal val baseParam: XC_LayoutInflated.LayoutInflatedParam)
|
||||
class LayoutInflatedParam(private val baseParam: XC_LayoutInflated.LayoutInflatedParam)
|
||||
```
|
||||
|
||||
**变更记录**
|
||||
|
@@ -11,8 +11,6 @@ project.url=https://github.com/fankes/YukiHookAPI
|
||||
project.groupName=com.highcapable.yukihookapi
|
||||
project.yukihookapi-core.moduleName=api
|
||||
project.yukihookapi-core.version="1.0.11"
|
||||
project.yukihookapi-core.kotlin-optIn.YukiPrivateApi=${project.groupName}.annotation.YukiPrivateApi
|
||||
project.yukihookapi-core.kotlin-optIn.YukiGenerateApi=${project.groupName}.annotation.YukiGenerateApi
|
||||
project.yukihookapi-ksp-xposed.moduleName=ksp-xposed
|
||||
project.yukihookapi-ksp-xposed.version=${project.yukihookapi-core.version}
|
||||
project.licence.name=MIT
|
||||
|
@@ -25,8 +25,6 @@ android {
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
freeCompilerArgs = listOf(
|
||||
"-opt-in=${property.project.yukihookapi.core.kotlin.optIn.yukiPrivateApi}",
|
||||
"-opt-in=${property.project.yukihookapi.core.kotlin.optIn.yukiGenerateApi}",
|
||||
"-Xno-param-assertions",
|
||||
"-Xno-call-assertions",
|
||||
"-Xno-receiver-assertions"
|
||||
@@ -35,17 +33,6 @@ android {
|
||||
lint { checkReleaseBuilds = false }
|
||||
}
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
all {
|
||||
languageSettings {
|
||||
optIn(property.project.yukihookapi.core.kotlin.optIn.yukiPrivateApi)
|
||||
optIn(property.project.yukihookapi.core.kotlin.optIn.yukiGenerateApi)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(de.robv.android.xposed.api)
|
||||
compileOnly(projects.yukihookapiStub)
|
||||
|
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/2/2.
|
||||
*/
|
||||
@file:Suppress("MemberVisibilityCanBePrivate", "unused")
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi
|
||||
|
||||
|
@@ -52,4 +52,4 @@ package com.highcapable.yukihookapi.annotation
|
||||
*
|
||||
* 此功能除继承和接口外不应该在这里被调用
|
||||
*/
|
||||
annotation class CauseProblemsApi
|
||||
internal annotation class CauseProblemsApi
|
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* YukiHookAPI - An efficient Hook API and Xposed Module solution built in Kotlin.
|
||||
* Copyright (C) 2019-2023 HighCapable
|
||||
* https://github.com/fankes/YukiHookAPI
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* This file is created by fankes on 2022/4/3.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.yukihookapi.annotation
|
||||
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
||||
@MustBeDocumented
|
||||
@Target(
|
||||
AnnotationTarget.CLASS,
|
||||
AnnotationTarget.CONSTRUCTOR,
|
||||
AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.ANNOTATION_CLASS,
|
||||
AnnotationTarget.PROPERTY,
|
||||
AnnotationTarget.FIELD,
|
||||
AnnotationTarget.LOCAL_VARIABLE,
|
||||
AnnotationTarget.VALUE_PARAMETER,
|
||||
AnnotationTarget.PROPERTY_GETTER,
|
||||
AnnotationTarget.PROPERTY_SETTER,
|
||||
AnnotationTarget.TYPEALIAS
|
||||
)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
/**
|
||||
* - ❗标记为自动生成调用的 API
|
||||
*
|
||||
* 此功能除继承和接口外不应该在这里被调用
|
||||
*/
|
||||
annotation class YukiGenerateApi
|
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* YukiHookAPI - An efficient Hook API and Xposed Module solution built in Kotlin.
|
||||
* Copyright (C) 2019-2023 HighCapable
|
||||
* https://github.com/fankes/YukiHookAPI
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* This file is created by fankes on 2022/4/3.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.yukihookapi.annotation
|
||||
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
||||
@MustBeDocumented
|
||||
@Target(
|
||||
AnnotationTarget.CLASS,
|
||||
AnnotationTarget.CONSTRUCTOR,
|
||||
AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.ANNOTATION_CLASS,
|
||||
AnnotationTarget.PROPERTY,
|
||||
AnnotationTarget.FIELD,
|
||||
AnnotationTarget.LOCAL_VARIABLE,
|
||||
AnnotationTarget.VALUE_PARAMETER,
|
||||
AnnotationTarget.PROPERTY_GETTER,
|
||||
AnnotationTarget.PROPERTY_SETTER,
|
||||
AnnotationTarget.TYPEALIAS
|
||||
)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
/**
|
||||
* - ❗标记功能为私有功能性 API
|
||||
*
|
||||
* 此功能除继承和接口外不应该在这里被调用
|
||||
*/
|
||||
internal annotation class YukiPrivateApi
|
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/4/4.
|
||||
*/
|
||||
@file:Suppress("unused")
|
||||
@file:Suppress("unused", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.bean
|
||||
|
||||
@@ -42,11 +42,10 @@ import com.highcapable.yukihookapi.hook.factory.method
|
||||
* @param classSet 当前实例的 [Class]
|
||||
* @param instance 当前实例本身
|
||||
*/
|
||||
class CurrentClass @PublishedApi internal constructor(@PublishedApi internal val classSet: Class<*>, @PublishedApi internal val instance: Any) {
|
||||
class CurrentClass internal constructor(private val classSet: Class<*>, internal val instance: Any) {
|
||||
|
||||
/** 是否开启忽略错误警告功能 */
|
||||
@PublishedApi
|
||||
internal var isShutErrorPrinting = false
|
||||
internal var isIgnoreErrorLogs = false
|
||||
|
||||
/**
|
||||
* 获得当前 [classSet] 的 [Class.getName]
|
||||
@@ -88,14 +87,14 @@ class CurrentClass @PublishedApi internal constructor(@PublishedApi internal val
|
||||
* @param initiate 查找方法体
|
||||
* @return [FieldFinder.Result.Instance]
|
||||
*/
|
||||
inline fun field(initiate: FieldConditions) = classSet.field(initiate).result { if (isShutErrorPrinting) ignored() }.get(instance)
|
||||
inline fun field(initiate: FieldConditions) = classSet.field(initiate).result { if (isIgnoreErrorLogs) ignored() }.get(instance)
|
||||
|
||||
/**
|
||||
* 调用当前实例中的方法
|
||||
* @param initiate 查找方法体
|
||||
* @return [MethodFinder.Result.Instance]
|
||||
*/
|
||||
inline fun method(initiate: MethodConditions) = classSet.method(initiate).result { if (isShutErrorPrinting) ignored() }.get(instance)
|
||||
inline fun method(initiate: MethodConditions) = classSet.method(initiate).result { if (isIgnoreErrorLogs) ignored() }.get(instance)
|
||||
|
||||
/**
|
||||
* 当前类的父类实例的类操作对象
|
||||
@@ -103,7 +102,7 @@ class CurrentClass @PublishedApi internal constructor(@PublishedApi internal val
|
||||
* - ❗请使用 [superClass] 方法来获取 [SuperClass]
|
||||
* @param superClassSet 父类 [Class] 对象
|
||||
*/
|
||||
inner class SuperClass internal constructor(@PublishedApi internal val superClassSet: Class<*>) {
|
||||
inner class SuperClass internal constructor(private val superClassSet: Class<*>) {
|
||||
|
||||
/**
|
||||
* 获得当前 [classSet] 中父类的 [Class.getName]
|
||||
@@ -139,7 +138,7 @@ class CurrentClass @PublishedApi internal constructor(@PublishedApi internal val
|
||||
* @param initiate 查找方法体
|
||||
* @return [FieldFinder.Result.Instance]
|
||||
*/
|
||||
inline fun field(initiate: FieldConditions) = superClassSet.field(initiate).result { if (isShutErrorPrinting) ignored() }.get(instance)
|
||||
inline fun field(initiate: FieldConditions) = superClassSet.field(initiate).result { if (isIgnoreErrorLogs) ignored() }.get(instance)
|
||||
|
||||
/**
|
||||
* 调用父类实例中的方法
|
||||
@@ -147,7 +146,7 @@ class CurrentClass @PublishedApi internal constructor(@PublishedApi internal val
|
||||
* @return [MethodFinder.Result.Instance]
|
||||
*/
|
||||
inline fun method(initiate: MethodConditions) =
|
||||
superClassSet.method(initiate).result { if (isShutErrorPrinting) ignored() }.get(instance)
|
||||
superClassSet.method(initiate).result { if (isIgnoreErrorLogs) ignored() }.get(instance)
|
||||
|
||||
override fun toString() = "CurrentClass super [$superClassSet]"
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/9/20.
|
||||
*/
|
||||
@file:Suppress("unused", "UNCHECKED_CAST")
|
||||
@file:Suppress("unused", "UNCHECKED_CAST", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.bean
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.lang.reflect.ParameterizedType
|
||||
* 当前 [Class] 的泛型父类操作对象
|
||||
* @param type 类型声明实例
|
||||
*/
|
||||
class GenericClass internal constructor(@PublishedApi internal val type: ParameterizedType) {
|
||||
class GenericClass internal constructor(private val type: ParameterizedType) {
|
||||
|
||||
/**
|
||||
* 获得泛型参数数组下标的 [Class] 实例
|
||||
|
@@ -34,9 +34,9 @@ package com.highcapable.yukihookapi.hook.bean
|
||||
* @param throwable 异常
|
||||
*/
|
||||
class HookClass internal constructor(
|
||||
@PublishedApi internal var instance: Class<*>? = null,
|
||||
@PublishedApi internal var name: String,
|
||||
@PublishedApi internal var throwable: Throwable? = null
|
||||
internal var instance: Class<*>? = null,
|
||||
internal var name: String,
|
||||
internal var throwable: Throwable? = null
|
||||
) {
|
||||
|
||||
override fun toString() = "[class] $name [throwable] $throwable [instance] $instance"
|
||||
|
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/2/2.
|
||||
*/
|
||||
@file:Suppress("MemberVisibilityCanBePrivate", "UnusedReceiverParameter", "unused", "PropertyName")
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UnusedReceiverParameter", "PropertyName", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.core
|
||||
|
||||
@@ -81,10 +81,7 @@ import java.lang.reflect.Method
|
||||
* @param packageParam 需要传入 [PackageParam] 实现方法调用
|
||||
* @param hookClass 要 Hook 的 [HookClass] 实例
|
||||
*/
|
||||
class YukiMemberHookCreator @PublishedApi internal constructor(
|
||||
@PublishedApi internal val packageParam: PackageParam,
|
||||
@PublishedApi internal val hookClass: HookClass
|
||||
) {
|
||||
class YukiMemberHookCreator internal constructor(private val packageParam: PackageParam, private val hookClass: HookClass) {
|
||||
|
||||
/** 默认 Hook 回调优先级 */
|
||||
val PRIORITY_DEFAULT = 0x0
|
||||
@@ -108,15 +105,13 @@ class YukiMemberHookCreator @PublishedApi internal constructor(
|
||||
private var isDisableCreatorRunHook = false
|
||||
|
||||
/** 设置要 Hook 的 [Method]、[Constructor] */
|
||||
@PublishedApi
|
||||
internal var preHookMembers = ArrayMap<String, MemberHookCreator>()
|
||||
private var preHookMembers = ArrayMap<String, MemberHookCreator>()
|
||||
|
||||
/**
|
||||
* 更新当前 [YukiMemberHookCreator] 禁止执行 Hook 操作的条件
|
||||
* @param reason 当前条件
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun updateDisableCreatorRunHookReasons(reason: Boolean) {
|
||||
private fun updateDisableCreatorRunHookReasons(reason: Boolean) {
|
||||
disableCreatorRunHookReasons.add(reason)
|
||||
conditions {
|
||||
disableCreatorRunHookReasons.forEach { and(it) }
|
||||
@@ -162,7 +157,6 @@ class YukiMemberHookCreator @PublishedApi internal constructor(
|
||||
* Hook 执行入口
|
||||
* @return [Result]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun hook() = when {
|
||||
HookApiCategoryHelper.hasAvailableHookApi.not() -> Result()
|
||||
/** 过滤 [HookEntryType.ZYGOTE] and [HookEntryType.PACKAGE] or [HookParam.isCallbackCalled] 已被执行 */
|
||||
@@ -241,7 +235,7 @@ class YukiMemberHookCreator @PublishedApi internal constructor(
|
||||
* @param priority Hook 优先级
|
||||
* @param tag 当前设置的标签
|
||||
*/
|
||||
inner class MemberHookCreator @PublishedApi internal constructor(private val priority: Int, internal val tag: String) {
|
||||
inner class MemberHookCreator internal constructor(private val priority: Int, internal val tag: String) {
|
||||
|
||||
/** Hook 结果实例 */
|
||||
private var result: Result? = null
|
||||
@@ -292,16 +286,13 @@ class YukiMemberHookCreator @PublishedApi internal constructor(
|
||||
private var isReplaceHookMode = false
|
||||
|
||||
/** 是否对当前 [MemberHookCreator] 禁止执行 Hook 操作 */
|
||||
@PublishedApi
|
||||
internal var isDisableMemberRunHook = false
|
||||
private var isDisableMemberRunHook = false
|
||||
|
||||
/** 查找过程中发生的异常 */
|
||||
@PublishedApi
|
||||
internal var findingThrowable: Throwable? = null
|
||||
private var findingThrowable: Throwable? = null
|
||||
|
||||
/** 标识是否已经设置了要 Hook 的 [members] */
|
||||
@PublishedApi
|
||||
internal var isHookMemberSetup = false
|
||||
private var isHookMemberSetup = false
|
||||
|
||||
/** 当前被 Hook 的 [Method]、[Constructor] 实例数组 */
|
||||
private val hookedMembers = HashSet<YukiMemberHook.HookedMember>()
|
||||
@@ -550,11 +541,9 @@ class YukiMemberHookCreator @PublishedApi internal constructor(
|
||||
* Hook 创建入口
|
||||
* @return [Result]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun build() = Result().apply { result = this }
|
||||
|
||||
/** Hook 执行入口 */
|
||||
@PublishedApi
|
||||
internal fun hook() {
|
||||
if (HookApiCategoryHelper.hasAvailableHookApi.not() || isHooked || isDisableMemberRunHook) return
|
||||
isHooked = true
|
||||
|
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/5/1.
|
||||
*/
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.core
|
||||
|
||||
@@ -47,14 +47,10 @@ import com.highcapable.yukihookapi.hook.xposed.bridge.type.HookEntryType
|
||||
* @param packageParam 需要传入 [PackageParam] 实现方法调用
|
||||
* @param hookResources 要 Hook 的 [HookResources] 实例
|
||||
*/
|
||||
class YukiResourcesHookCreator @PublishedApi internal constructor(
|
||||
@PublishedApi internal val packageParam: PackageParam,
|
||||
@PublishedApi internal val hookResources: HookResources
|
||||
) {
|
||||
class YukiResourcesHookCreator internal constructor(internal val packageParam: PackageParam, internal val hookResources: HookResources) {
|
||||
|
||||
/** 设置要 Hook 的 Resources */
|
||||
@PublishedApi
|
||||
internal var preHookResources = ArrayMap<String, ResourcesHookCreator>()
|
||||
private var preHookResources = ArrayMap<String, ResourcesHookCreator>()
|
||||
|
||||
/**
|
||||
* 注入要 Hook 的 Resources
|
||||
@@ -66,7 +62,6 @@ class YukiResourcesHookCreator @PublishedApi internal constructor(
|
||||
ResourcesHookCreator(tag).apply(initiate).apply { preHookResources[toString()] = this }.build()
|
||||
|
||||
/** Hook 执行入口 */
|
||||
@PublishedApi
|
||||
internal fun hook() {
|
||||
if (HookApiCategoryHelper.hasAvailableHookApi.not()) return
|
||||
/** 过滤 [HookEntryType.ZYGOTE] 与 [HookEntryType.RESOURCES] */
|
||||
@@ -81,7 +76,7 @@ class YukiResourcesHookCreator @PublishedApi internal constructor(
|
||||
* 查找和处理需要 Hook 的 Resources
|
||||
* @param tag 当前设置的标签
|
||||
*/
|
||||
inner class ResourcesHookCreator @PublishedApi internal constructor(private val tag: String) {
|
||||
inner class ResourcesHookCreator internal constructor(private val tag: String) {
|
||||
|
||||
/** 是否已经执行 Hook */
|
||||
private var isHooked = false
|
||||
@@ -93,12 +88,10 @@ class YukiResourcesHookCreator @PublishedApi internal constructor(
|
||||
private inner class ModuleResFwd(var resId: Int)
|
||||
|
||||
/** 是否对当前 [ResourcesHookCreator] 禁止执行 Hook 操作 */
|
||||
@PublishedApi
|
||||
internal var isDisableCreatorRunHook = false
|
||||
private var isDisableCreatorRunHook = false
|
||||
|
||||
/** 当前的查找条件 */
|
||||
@PublishedApi
|
||||
internal var conditions: ConditionFinder? = null
|
||||
private var conditions: ConditionFinder? = null
|
||||
|
||||
/** Hook 出现错误回调 */
|
||||
private var onHookFailureCallback: ((Throwable) -> Unit)? = null
|
||||
@@ -173,11 +166,9 @@ class YukiResourcesHookCreator @PublishedApi internal constructor(
|
||||
* Hook 创建入口
|
||||
* @return [Result]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun build() = Result()
|
||||
|
||||
/** Hook 执行入口 */
|
||||
@PublishedApi
|
||||
internal fun hook() {
|
||||
if (isHooked) return
|
||||
isHooked = true
|
||||
@@ -243,7 +234,7 @@ class YukiResourcesHookCreator @PublishedApi internal constructor(
|
||||
/**
|
||||
* Resources 查找条件实现类
|
||||
*/
|
||||
inner class ConditionFinder @PublishedApi internal constructor() {
|
||||
inner class ConditionFinder internal constructor() {
|
||||
|
||||
/** Resources 类型 */
|
||||
internal var type = ""
|
||||
@@ -321,7 +312,6 @@ class YukiResourcesHookCreator @PublishedApi internal constructor(
|
||||
* @return [ConditionFinder]
|
||||
* @throws IllegalStateException 如果没有设置 [name] or [type]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun build(): ConditionFinder {
|
||||
when {
|
||||
name.isBlank() -> error("Resources Hook condition name cannot be empty [$tag]")
|
||||
|
@@ -27,7 +27,6 @@
|
||||
*/
|
||||
package com.highcapable.yukihookapi.hook.core.finder.base
|
||||
|
||||
import com.highcapable.yukihookapi.annotation.YukiPrivateApi
|
||||
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
||||
import com.highcapable.yukihookapi.hook.core.finder.base.data.BaseRulesData
|
||||
import com.highcapable.yukihookapi.hook.factory.toClass
|
||||
@@ -41,20 +40,18 @@ import kotlin.math.abs
|
||||
abstract class BaseFinder {
|
||||
|
||||
/** 当前查找条件规则数据 */
|
||||
@PublishedApi
|
||||
internal abstract val rulesData: BaseRulesData
|
||||
|
||||
/**
|
||||
* 字节码、数组下标筛选数据类型
|
||||
*/
|
||||
@PublishedApi
|
||||
internal enum class IndexConfigType { ORDER, MATCH }
|
||||
|
||||
/**
|
||||
* 字节码、数组下标筛选实现类
|
||||
* @param type 类型
|
||||
*/
|
||||
inner class IndexTypeCondition @PublishedApi internal constructor(private val type: IndexConfigType) {
|
||||
inner class IndexTypeCondition internal constructor(private val type: IndexConfigType) {
|
||||
|
||||
/**
|
||||
* 设置下标
|
||||
@@ -123,8 +120,7 @@ abstract class BaseFinder {
|
||||
* - ❗此功能交由方法体自动完成 - 你不应该手动调用此方法
|
||||
* @return [BaseResult]
|
||||
*/
|
||||
@YukiPrivateApi
|
||||
abstract fun build(): BaseResult
|
||||
internal abstract fun build(): BaseResult
|
||||
|
||||
/**
|
||||
* 返回只有异常的结果实现类
|
||||
@@ -133,14 +129,12 @@ abstract class BaseFinder {
|
||||
* @param throwable 异常
|
||||
* @return [BaseResult]
|
||||
*/
|
||||
@YukiPrivateApi
|
||||
abstract fun failure(throwable: Throwable?): BaseResult
|
||||
internal abstract fun failure(throwable: Throwable?): BaseResult
|
||||
|
||||
/**
|
||||
* 查找结果实现、处理类接口
|
||||
*
|
||||
* - ❗此功能交由方法体自动完成 - 你不应该手动继承此接口
|
||||
*/
|
||||
@YukiPrivateApi
|
||||
interface BaseResult
|
||||
internal interface BaseResult
|
||||
}
|
@@ -28,7 +28,6 @@
|
||||
package com.highcapable.yukihookapi.hook.core.finder.base
|
||||
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.annotation.YukiPrivateApi
|
||||
import com.highcapable.yukihookapi.hook.core.api.compat.HookApiCategoryHelper
|
||||
import com.highcapable.yukihookapi.hook.log.yLoggerD
|
||||
import com.highcapable.yukihookapi.hook.log.yLoggerE
|
||||
@@ -78,6 +77,5 @@ abstract class ClassBaseFinder internal constructor(internal open val loaderSet:
|
||||
yLoggerE(msg = "NoClassDefFound happend in [$loaderSet]", e = e)
|
||||
}
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun failure(throwable: Throwable?) = error("DexClassFinder does not contain this usage")
|
||||
}
|
@@ -28,7 +28,6 @@
|
||||
package com.highcapable.yukihookapi.hook.core.finder.base
|
||||
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.annotation.YukiPrivateApi
|
||||
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
|
||||
import com.highcapable.yukihookapi.hook.core.api.compat.HookApiCategoryHelper
|
||||
import com.highcapable.yukihookapi.hook.log.yLoggerD
|
||||
@@ -44,10 +43,7 @@ import java.lang.reflect.Method
|
||||
* @param tag 当前查找类的标识
|
||||
* @param classSet 当前需要查找的 [Class] 实例
|
||||
*/
|
||||
abstract class MemberBaseFinder internal constructor(
|
||||
private val tag: String,
|
||||
@PublishedApi internal open val classSet: Class<*>? = null
|
||||
) : BaseFinder() {
|
||||
abstract class MemberBaseFinder internal constructor(private val tag: String, internal open val classSet: Class<*>? = null) : BaseFinder() {
|
||||
|
||||
internal companion object {
|
||||
|
||||
@@ -56,11 +52,9 @@ abstract class MemberBaseFinder internal constructor(
|
||||
}
|
||||
|
||||
/** 当前 [MemberHookerManager] */
|
||||
@PublishedApi
|
||||
internal var hookerManager = MemberHookerManager()
|
||||
|
||||
/** 是否使用了重查找功能 */
|
||||
@PublishedApi
|
||||
internal var isUsingRemedyPlan = false
|
||||
|
||||
/** 是否开启忽略错误警告功能 */
|
||||
@@ -129,8 +123,7 @@ abstract class MemberBaseFinder internal constructor(
|
||||
* - ❗此功能交由方法体自动完成 - 你不应该手动调用此方法
|
||||
* @return [BaseFinder.BaseResult]
|
||||
*/
|
||||
@YukiPrivateApi
|
||||
abstract fun process(): BaseResult
|
||||
internal abstract fun process(): BaseResult
|
||||
|
||||
/**
|
||||
* 返回只有异常的结果处理类并作用于目标 [YukiMemberHookCreator.MemberHookCreator]
|
||||
@@ -139,8 +132,7 @@ abstract class MemberBaseFinder internal constructor(
|
||||
* @param throwable 异常
|
||||
* @return [BaseFinder.BaseResult]
|
||||
*/
|
||||
@YukiPrivateApi
|
||||
abstract fun denied(throwable: Throwable?): BaseResult
|
||||
internal abstract fun denied(throwable: Throwable?): BaseResult
|
||||
|
||||
/**
|
||||
* 当前 Hooker 管理实现类
|
||||
|
@@ -44,7 +44,6 @@ import java.lang.reflect.Method
|
||||
* @param orderIndex 字节码、数组顺序下标
|
||||
* @param matchIndex 字节码、数组筛选下标
|
||||
*/
|
||||
@PublishedApi
|
||||
internal abstract class BaseRulesData internal constructor(
|
||||
var modifiers: ModifierConditions? = null,
|
||||
var orderIndex: Pair<Int, Boolean>? = null,
|
||||
|
@@ -39,7 +39,6 @@ import java.lang.reflect.Member
|
||||
*/
|
||||
class CountRules private constructor(private val instance: Int) {
|
||||
|
||||
@PublishedApi
|
||||
internal companion object {
|
||||
|
||||
/**
|
||||
@@ -47,7 +46,6 @@ class CountRules private constructor(private val instance: Int) {
|
||||
* @param instance 实例对象
|
||||
* @return [CountRules]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun with(instance: Int) = CountRules(instance)
|
||||
}
|
||||
|
||||
|
@@ -44,7 +44,6 @@ import java.lang.reflect.Modifier
|
||||
*/
|
||||
class ModifierRules private constructor(private val instance: Any) {
|
||||
|
||||
@PublishedApi
|
||||
internal companion object {
|
||||
|
||||
/** 当前实例数组 */
|
||||
@@ -63,7 +62,6 @@ class ModifierRules private constructor(private val instance: Any) {
|
||||
* @param value 唯一标识值 - 默认 0
|
||||
* @return [ModifierRules]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun with(instance: Any, value: Long = 0) = ModifierRules(instance).apply { instances[value] = this }
|
||||
}
|
||||
|
||||
|
@@ -40,7 +40,6 @@ import java.lang.reflect.Member
|
||||
*/
|
||||
class NameRules private constructor(private val instance: String) {
|
||||
|
||||
@PublishedApi
|
||||
internal companion object {
|
||||
|
||||
/**
|
||||
@@ -48,7 +47,6 @@ class NameRules private constructor(private val instance: String) {
|
||||
* @param instance 实例对象
|
||||
* @return [NameRules]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun with(instance: String) = NameRules(instance)
|
||||
}
|
||||
|
||||
|
@@ -39,7 +39,6 @@ import java.lang.reflect.Member
|
||||
*/
|
||||
class ObjectRules private constructor(private val instance: Any) {
|
||||
|
||||
@PublishedApi
|
||||
internal companion object {
|
||||
|
||||
/**
|
||||
@@ -47,7 +46,6 @@ class ObjectRules private constructor(private val instance: Any) {
|
||||
* @param instance 实例对象
|
||||
* @return [ObjectRules]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun with(instance: Any) = ObjectRules(instance)
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/9/4.
|
||||
*/
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.core.finder.classes
|
||||
|
||||
@@ -34,7 +34,6 @@ import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.SystemClock
|
||||
import androidx.core.content.pm.PackageInfoCompat
|
||||
import com.highcapable.yukihookapi.annotation.YukiPrivateApi
|
||||
import com.highcapable.yukihookapi.hook.core.finder.base.ClassBaseFinder
|
||||
import com.highcapable.yukihookapi.hook.core.finder.classes.data.ClassRulesData
|
||||
import com.highcapable.yukihookapi.hook.core.finder.classes.rules.ConstructorRules
|
||||
@@ -70,7 +69,7 @@ import java.lang.reflect.Method
|
||||
* @param async 是否启用异步
|
||||
* @param loaderSet 当前使用的 [ClassLoader] 实例
|
||||
*/
|
||||
class DexClassFinder @PublishedApi internal constructor(
|
||||
class DexClassFinder internal constructor(
|
||||
internal var name: String,
|
||||
internal var async: Boolean,
|
||||
override val loaderSet: ClassLoader?
|
||||
@@ -114,7 +113,6 @@ class DexClassFinder @PublishedApi internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
override var rulesData = ClassRulesData()
|
||||
|
||||
/**
|
||||
@@ -477,7 +475,6 @@ class DexClassFinder @PublishedApi internal constructor(
|
||||
classes.takeIf { it.isNotEmpty() }?.forEach { classInstances.add(it) }
|
||||
}
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun build() = runCatching {
|
||||
if (loaderSet != null) {
|
||||
/** 开始任务 */
|
||||
@@ -510,8 +507,8 @@ class DexClassFinder @PublishedApi internal constructor(
|
||||
* @param throwable 错误信息
|
||||
*/
|
||||
inner class Result internal constructor(
|
||||
@PublishedApi internal var isNotFound: Boolean = false,
|
||||
@PublishedApi internal var throwable: Throwable? = null
|
||||
internal var isNotFound: Boolean = false,
|
||||
internal var throwable: Throwable? = null
|
||||
) : BaseResult {
|
||||
|
||||
/** 异步方法体回调结果 */
|
||||
|
@@ -61,7 +61,6 @@ import java.lang.reflect.Method
|
||||
* @param methodRules [Method] 查找条件数据数组
|
||||
* @param constroctorRules [Constructor] 查找条件数据数组
|
||||
*/
|
||||
@PublishedApi
|
||||
internal class ClassRulesData internal constructor(
|
||||
var fromPackages: ArrayList<PackageRulesData> = arrayListOf(),
|
||||
var fullName: NameRulesData? = null,
|
||||
|
@@ -44,7 +44,7 @@ import java.lang.reflect.Constructor
|
||||
* [Constructor] 查找条件实现类
|
||||
* @param rulesData 当前查找条件规则数据
|
||||
*/
|
||||
class ConstructorRules internal constructor(@PublishedApi internal val rulesData: ConstructorRulesData) : BaseRules() {
|
||||
class ConstructorRules internal constructor(private val rulesData: ConstructorRulesData) : BaseRules() {
|
||||
|
||||
/**
|
||||
* 设置 [Constructor] 参数个数
|
||||
@@ -159,6 +159,5 @@ class ConstructorRules internal constructor(@PublishedApi internal val rulesData
|
||||
* 返回结果实现类
|
||||
* @return [MemberRulesResult]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun build() = MemberRulesResult(rulesData)
|
||||
}
|
@@ -40,7 +40,7 @@ import java.lang.reflect.Field
|
||||
* [Field] 查找条件实现类
|
||||
* @param rulesData 当前查找条件规则数据
|
||||
*/
|
||||
class FieldRules internal constructor(@PublishedApi internal val rulesData: FieldRulesData) : BaseRules() {
|
||||
class FieldRules internal constructor(private val rulesData: FieldRulesData) : BaseRules() {
|
||||
|
||||
/**
|
||||
* 设置 [Field] 名称
|
||||
@@ -104,6 +104,5 @@ class FieldRules internal constructor(@PublishedApi internal val rulesData: Fiel
|
||||
* 返回结果实现类
|
||||
* @return [MemberRulesResult]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun build() = MemberRulesResult(rulesData)
|
||||
}
|
@@ -37,7 +37,7 @@ import java.lang.reflect.Member
|
||||
* [Member] 查找条件实现类
|
||||
* @param rulesData 当前查找条件规则数据
|
||||
*/
|
||||
class MemberRules internal constructor(@PublishedApi internal val rulesData: MemberRulesData) : BaseRules() {
|
||||
class MemberRules internal constructor(private val rulesData: MemberRulesData) : BaseRules() {
|
||||
|
||||
/**
|
||||
* 设置 [Member] 标识符筛选条件
|
||||
@@ -53,6 +53,5 @@ class MemberRules internal constructor(@PublishedApi internal val rulesData: Mem
|
||||
* 返回结果实现类
|
||||
* @return [MemberRulesResult]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun build() = MemberRulesResult(rulesData)
|
||||
}
|
@@ -33,7 +33,11 @@ import com.highcapable.yukihookapi.hook.bean.VariousClass
|
||||
import com.highcapable.yukihookapi.hook.core.finder.classes.rules.base.BaseRules
|
||||
import com.highcapable.yukihookapi.hook.core.finder.classes.rules.result.MemberRulesResult
|
||||
import com.highcapable.yukihookapi.hook.core.finder.members.data.MethodRulesData
|
||||
import com.highcapable.yukihookapi.hook.core.finder.type.factory.*
|
||||
import com.highcapable.yukihookapi.hook.core.finder.type.factory.CountConditions
|
||||
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ModifierConditions
|
||||
import com.highcapable.yukihookapi.hook.core.finder.type.factory.NameConditions
|
||||
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectConditions
|
||||
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectsConditions
|
||||
import com.highcapable.yukihookapi.hook.type.defined.UndefinedType
|
||||
import com.highcapable.yukihookapi.hook.type.defined.VagueType
|
||||
import java.lang.reflect.Method
|
||||
@@ -42,7 +46,7 @@ import java.lang.reflect.Method
|
||||
* [Method] 查找条件实现类
|
||||
* @param rulesData 当前查找条件规则数据
|
||||
*/
|
||||
class MethodRules internal constructor(@PublishedApi internal val rulesData: MethodRulesData) : BaseRules() {
|
||||
class MethodRules internal constructor(private val rulesData: MethodRulesData) : BaseRules() {
|
||||
|
||||
/**
|
||||
* 设置 [Method] 名称
|
||||
@@ -205,6 +209,5 @@ class MethodRules internal constructor(@PublishedApi internal val rulesData: Met
|
||||
* 返回结果实现类
|
||||
* @return [MemberRulesResult]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun build() = MemberRulesResult(rulesData)
|
||||
}
|
@@ -44,7 +44,6 @@ import java.lang.reflect.Member
|
||||
*/
|
||||
open class BaseRules internal constructor(internal var instance: DexClassFinder? = null) {
|
||||
|
||||
@PublishedApi
|
||||
internal companion object {
|
||||
|
||||
/**
|
||||
@@ -52,7 +51,6 @@ open class BaseRules internal constructor(internal var instance: DexClassFinder?
|
||||
* @param instance 当前查找类实例
|
||||
* @return [MemberRulesData]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun createMemberRules(instance: DexClassFinder) =
|
||||
MemberRules(MemberRulesData().apply { instance.rulesData.memberRules.add(this) }).apply { this.instance = instance }
|
||||
|
||||
@@ -60,7 +58,6 @@ open class BaseRules internal constructor(internal var instance: DexClassFinder?
|
||||
* 创建查找条件规则数据
|
||||
* @return [FieldRulesData]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun createFieldRules(instance: DexClassFinder) =
|
||||
FieldRules(FieldRulesData().apply { instance.rulesData.fieldRules.add(this) }).apply { this.instance = instance }
|
||||
|
||||
@@ -68,7 +65,6 @@ open class BaseRules internal constructor(internal var instance: DexClassFinder?
|
||||
* 创建查找条件规则数据
|
||||
* @return [MethodRulesData]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun createMethodRules(instance: DexClassFinder) =
|
||||
MethodRules(MethodRulesData().apply { instance.rulesData.methodRules.add(this) }).apply { this.instance = instance }
|
||||
|
||||
@@ -76,7 +72,6 @@ open class BaseRules internal constructor(internal var instance: DexClassFinder?
|
||||
* 创建查找条件规则数据
|
||||
* @return [ConstructorRulesData]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun createConstructorRules(instance: DexClassFinder) =
|
||||
ConstructorRules(ConstructorRulesData().apply { instance.rulesData.constroctorRules.add(this) }).apply { this.instance = instance }
|
||||
}
|
||||
|
@@ -25,11 +25,10 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/2/4.
|
||||
*/
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "KotlinConstantConditions")
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "KotlinConstantConditions", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.core.finder.members
|
||||
|
||||
import com.highcapable.yukihookapi.annotation.YukiPrivateApi
|
||||
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
||||
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
|
||||
import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder
|
||||
@@ -55,10 +54,8 @@ import java.lang.reflect.Member
|
||||
* 可通过指定类型查找指定 [Constructor] 或一组 [Constructor]
|
||||
* @param classSet 当前需要查找的 [Class] 实例
|
||||
*/
|
||||
class ConstructorFinder @PublishedApi internal constructor(@PublishedApi override val classSet: Class<*>? = null) :
|
||||
MemberBaseFinder(tag = "Constructor", classSet) {
|
||||
class ConstructorFinder internal constructor(override val classSet: Class<*>? = null) : MemberBaseFinder(tag = "Constructor", classSet) {
|
||||
|
||||
@PublishedApi
|
||||
internal companion object {
|
||||
|
||||
/**
|
||||
@@ -67,12 +64,10 @@ class ConstructorFinder @PublishedApi internal constructor(@PublishedApi overrid
|
||||
* @param classSet 当前需要查找的 [Class] 实例
|
||||
* @return [ConstructorFinder]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun fromHooker(hookInstance: YukiMemberHookCreator.MemberHookCreator, classSet: Class<*>? = null) =
|
||||
ConstructorFinder(classSet).apply { hookerManager.instance = hookInstance }
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
override var rulesData = ConstructorRulesData()
|
||||
|
||||
/** 当前使用的 [classSet] */
|
||||
@@ -269,7 +264,6 @@ class ConstructorFinder @PublishedApi internal constructor(@PublishedApi overrid
|
||||
}
|
||||
}
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun build() = runCatching {
|
||||
internalBuild()
|
||||
Result()
|
||||
@@ -278,7 +272,6 @@ class ConstructorFinder @PublishedApi internal constructor(@PublishedApi overrid
|
||||
Result(isNoSuch = true, it)
|
||||
}
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun process() = runCatching {
|
||||
hookerManager.isMemberBinded = true
|
||||
internalBuild()
|
||||
@@ -288,10 +281,8 @@ class ConstructorFinder @PublishedApi internal constructor(@PublishedApi overrid
|
||||
Process(isNoSuch = true, it)
|
||||
}
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun failure(throwable: Throwable?) = Result(isNoSuch = true, throwable)
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun denied(throwable: Throwable?) = Process(isNoSuch = true, throwable)
|
||||
|
||||
/**
|
||||
@@ -299,11 +290,10 @@ class ConstructorFinder @PublishedApi internal constructor(@PublishedApi overrid
|
||||
*
|
||||
* 可累计失败次数直到查找成功
|
||||
*/
|
||||
inner class RemedyPlan @PublishedApi internal constructor() {
|
||||
inner class RemedyPlan internal constructor() {
|
||||
|
||||
/** 失败尝试次数数组 */
|
||||
@PublishedApi
|
||||
internal val remedyPlans = HashSet<Pair<ConstructorFinder, Result>>()
|
||||
private val remedyPlans = HashSet<Pair<ConstructorFinder, Result>>()
|
||||
|
||||
/**
|
||||
* 创建需要重新查找的 [Constructor]
|
||||
@@ -320,7 +310,6 @@ class ConstructorFinder @PublishedApi internal constructor(@PublishedApi overrid
|
||||
}
|
||||
|
||||
/** 开始重查找 */
|
||||
@PublishedApi
|
||||
internal fun build() {
|
||||
if (classSet == null) return
|
||||
if (remedyPlans.isNotEmpty()) {
|
||||
@@ -352,7 +341,7 @@ class ConstructorFinder @PublishedApi internal constructor(@PublishedApi overrid
|
||||
*
|
||||
* 可在这里处理是否成功的回调
|
||||
*/
|
||||
inner class Result @PublishedApi internal constructor() {
|
||||
inner class Result internal constructor() {
|
||||
|
||||
/** 找到结果时的回调 */
|
||||
internal var onFindCallback: (HashSet<Constructor<*>>.() -> Unit)? = null
|
||||
@@ -373,8 +362,8 @@ class ConstructorFinder @PublishedApi internal constructor(@PublishedApi overrid
|
||||
* @param throwable 错误信息
|
||||
*/
|
||||
inner class Process internal constructor(
|
||||
@PublishedApi internal val isNoSuch: Boolean = false,
|
||||
@PublishedApi internal val throwable: Throwable? = null
|
||||
internal val isNoSuch: Boolean = false,
|
||||
internal val throwable: Throwable? = null
|
||||
) : BaseResult {
|
||||
|
||||
/**
|
||||
@@ -432,8 +421,8 @@ class ConstructorFinder @PublishedApi internal constructor(@PublishedApi overrid
|
||||
* @param throwable 错误信息
|
||||
*/
|
||||
inner class Result internal constructor(
|
||||
@PublishedApi internal val isNoSuch: Boolean = false,
|
||||
@PublishedApi internal val throwable: Throwable? = null
|
||||
internal val isNoSuch: Boolean = false,
|
||||
internal val throwable: Throwable? = null
|
||||
) : BaseResult {
|
||||
|
||||
/**
|
||||
|
@@ -25,11 +25,10 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/2/4.
|
||||
*/
|
||||
@file:Suppress("unused", "UNCHECKED_CAST", "MemberVisibilityCanBePrivate", "KotlinConstantConditions")
|
||||
@file:Suppress("unused", "UNCHECKED_CAST", "MemberVisibilityCanBePrivate", "KotlinConstantConditions", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.core.finder.members
|
||||
|
||||
import com.highcapable.yukihookapi.annotation.YukiPrivateApi
|
||||
import com.highcapable.yukihookapi.hook.bean.CurrentClass
|
||||
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
||||
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
|
||||
@@ -53,10 +52,8 @@ import java.lang.reflect.Field
|
||||
* 可通过指定类型查找指定 [Field] 或一组 [Field]
|
||||
* @param classSet 当前需要查找的 [Class] 实例
|
||||
*/
|
||||
class FieldFinder @PublishedApi internal constructor(@PublishedApi override val classSet: Class<*>? = null) :
|
||||
MemberBaseFinder(tag = "Field", classSet) {
|
||||
class FieldFinder internal constructor(override val classSet: Class<*>? = null) : MemberBaseFinder(tag = "Field", classSet) {
|
||||
|
||||
@PublishedApi
|
||||
internal companion object {
|
||||
|
||||
/**
|
||||
@@ -65,12 +62,10 @@ class FieldFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
* @param classSet 当前需要查找的 [Class] 实例
|
||||
* @return [FieldFinder]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun fromHooker(hookInstance: YukiMemberHookCreator.MemberHookCreator, classSet: Class<*>? = null) =
|
||||
FieldFinder(classSet).apply { hookerManager.instance = hookInstance }
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
override var rulesData = FieldRulesData()
|
||||
|
||||
/** 当前使用的 [classSet] */
|
||||
@@ -224,7 +219,6 @@ class FieldFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
}
|
||||
}
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun build() = runCatching {
|
||||
internalBuild()
|
||||
Result()
|
||||
@@ -233,13 +227,10 @@ class FieldFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
Result(isNoSuch = true, it)
|
||||
}
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun process() = error("FieldFinder does not contain this usage")
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun failure(throwable: Throwable?) = Result(isNoSuch = true, throwable)
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun denied(throwable: Throwable?) = error("FieldFinder does not contain this usage")
|
||||
|
||||
/**
|
||||
@@ -247,11 +238,10 @@ class FieldFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
*
|
||||
* 可累计失败次数直到查找成功
|
||||
*/
|
||||
inner class RemedyPlan @PublishedApi internal constructor() {
|
||||
inner class RemedyPlan internal constructor() {
|
||||
|
||||
/** 失败尝试次数数组 */
|
||||
@PublishedApi
|
||||
internal val remedyPlans = HashSet<Pair<FieldFinder, Result>>()
|
||||
private val remedyPlans = HashSet<Pair<FieldFinder, Result>>()
|
||||
|
||||
/**
|
||||
* 创建需要重新查找的 [Field]
|
||||
@@ -269,7 +259,6 @@ class FieldFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
}
|
||||
|
||||
/** 开始重查找 */
|
||||
@PublishedApi
|
||||
internal fun build() {
|
||||
if (classSet == null) return
|
||||
if (remedyPlans.isNotEmpty()) {
|
||||
@@ -301,7 +290,7 @@ class FieldFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
*
|
||||
* 可在这里处理是否成功的回调
|
||||
*/
|
||||
inner class Result @PublishedApi internal constructor() {
|
||||
inner class Result internal constructor() {
|
||||
|
||||
/** 找到结果时的回调 */
|
||||
internal var onFindCallback: (HashSet<Field>.() -> Unit)? = null
|
||||
@@ -323,8 +312,8 @@ class FieldFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
* @param throwable 错误信息
|
||||
*/
|
||||
inner class Result internal constructor(
|
||||
@PublishedApi internal val isNoSuch: Boolean = false,
|
||||
private val throwable: Throwable? = null
|
||||
internal val isNoSuch: Boolean = false,
|
||||
internal val throwable: Throwable? = null
|
||||
) : BaseResult {
|
||||
|
||||
/**
|
||||
@@ -485,9 +474,7 @@ class FieldFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
* - 若要直接获取不确定的实例对象 - 请调用 [any] 方法
|
||||
* @return [Any] or null
|
||||
*/
|
||||
@PublishedApi
|
||||
internal val self
|
||||
get() = field?.get(instance)
|
||||
private val self get() = field?.get(instance)
|
||||
|
||||
/**
|
||||
* 获得当前 [Field] 自身 [self] 实例的类操作对象
|
||||
|
@@ -25,11 +25,10 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/2/4.
|
||||
*/
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "KotlinConstantConditions", "UNCHECKED_CAST")
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "KotlinConstantConditions", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.core.finder.members
|
||||
|
||||
import com.highcapable.yukihookapi.annotation.YukiPrivateApi
|
||||
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
||||
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
|
||||
import com.highcapable.yukihookapi.hook.core.api.helper.YukiHookHelper
|
||||
@@ -58,10 +57,8 @@ import java.lang.reflect.Method
|
||||
* 可通过指定类型查找指定 [Method] 或一组 [Method]
|
||||
* @param classSet 当前需要查找的 [Class] 实例
|
||||
*/
|
||||
class MethodFinder @PublishedApi internal constructor(@PublishedApi override val classSet: Class<*>? = null) :
|
||||
MemberBaseFinder(tag = "Method", classSet) {
|
||||
class MethodFinder internal constructor(override val classSet: Class<*>? = null) : MemberBaseFinder(tag = "Method", classSet) {
|
||||
|
||||
@PublishedApi
|
||||
internal companion object {
|
||||
|
||||
/**
|
||||
@@ -70,12 +67,10 @@ class MethodFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
* @param classSet 当前需要查找的 [Class] 实例
|
||||
* @return [MethodFinder]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun fromHooker(hookInstance: YukiMemberHookCreator.MemberHookCreator, classSet: Class<*>? = null) =
|
||||
MethodFinder(classSet).apply { hookerManager.instance = hookInstance }
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
override var rulesData = MethodRulesData()
|
||||
|
||||
/** 当前使用的 [classSet] */
|
||||
@@ -362,7 +357,6 @@ class MethodFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
}
|
||||
}
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun build() = runCatching {
|
||||
internalBuild()
|
||||
Result()
|
||||
@@ -371,7 +365,6 @@ class MethodFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
Result(isNoSuch = true, it)
|
||||
}
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun process() = runCatching {
|
||||
hookerManager.isMemberBinded = true
|
||||
internalBuild()
|
||||
@@ -381,10 +374,8 @@ class MethodFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
Process(isNoSuch = true, it)
|
||||
}
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun failure(throwable: Throwable?) = Result(isNoSuch = true, throwable)
|
||||
|
||||
@YukiPrivateApi
|
||||
override fun denied(throwable: Throwable?) = Process(isNoSuch = true, throwable)
|
||||
|
||||
/**
|
||||
@@ -392,11 +383,10 @@ class MethodFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
*
|
||||
* 可累计失败次数直到查找成功
|
||||
*/
|
||||
inner class RemedyPlan @PublishedApi internal constructor() {
|
||||
inner class RemedyPlan internal constructor() {
|
||||
|
||||
/** 失败尝试次数数组 */
|
||||
@PublishedApi
|
||||
internal val remedyPlans = HashSet<Pair<MethodFinder, Result>>()
|
||||
private val remedyPlans = HashSet<Pair<MethodFinder, Result>>()
|
||||
|
||||
/**
|
||||
* 创建需要重新查找的 [Method]
|
||||
@@ -414,7 +404,6 @@ class MethodFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
}
|
||||
|
||||
/** 开始重查找 */
|
||||
@PublishedApi
|
||||
internal fun build() {
|
||||
if (classSet == null) return
|
||||
if (remedyPlans.isNotEmpty()) {
|
||||
@@ -446,7 +435,7 @@ class MethodFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
*
|
||||
* 可在这里处理是否成功的回调
|
||||
*/
|
||||
inner class Result @PublishedApi internal constructor() {
|
||||
inner class Result internal constructor() {
|
||||
|
||||
/** 找到结果时的回调 */
|
||||
internal var onFindCallback: (HashSet<Method>.() -> Unit)? = null
|
||||
@@ -467,8 +456,8 @@ class MethodFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
* @param throwable 错误信息
|
||||
*/
|
||||
inner class Process internal constructor(
|
||||
@PublishedApi internal val isNoSuch: Boolean = false,
|
||||
@PublishedApi internal val throwable: Throwable? = null
|
||||
internal val isNoSuch: Boolean = false,
|
||||
internal val throwable: Throwable? = null
|
||||
) : BaseResult {
|
||||
|
||||
/**
|
||||
@@ -526,8 +515,8 @@ class MethodFinder @PublishedApi internal constructor(@PublishedApi override val
|
||||
* @param throwable 错误信息
|
||||
*/
|
||||
inner class Result internal constructor(
|
||||
@PublishedApi internal val isNoSuch: Boolean = false,
|
||||
@PublishedApi internal val throwable: Throwable? = null
|
||||
internal val isNoSuch: Boolean = false,
|
||||
internal val throwable: Throwable? = null
|
||||
) : BaseResult {
|
||||
|
||||
/**
|
||||
|
@@ -39,7 +39,6 @@ import java.lang.reflect.Constructor
|
||||
* @param paramCountRange 参数个数范围
|
||||
* @param paramCountConditions 参数个数条件
|
||||
*/
|
||||
@PublishedApi
|
||||
internal class ConstructorRulesData internal constructor(
|
||||
var paramTypes: Array<out Class<*>>? = null,
|
||||
var paramTypesConditions: ObjectsConditions? = null,
|
||||
|
@@ -38,7 +38,6 @@ import java.lang.reflect.Field
|
||||
* @param type 类型
|
||||
* @param typeConditions 类型条件
|
||||
*/
|
||||
@PublishedApi
|
||||
internal class FieldRulesData internal constructor(
|
||||
var name: String = "",
|
||||
var nameConditions: NameConditions? = null,
|
||||
|
@@ -39,7 +39,6 @@ import java.lang.reflect.Member
|
||||
* @param matchCountRange 匹配的字节码个数范围
|
||||
* @param matchCountConditions 匹配的字节码个数条件
|
||||
*/
|
||||
@PublishedApi
|
||||
internal open class MemberRulesData internal constructor(
|
||||
var isFindInSuper: Boolean = false,
|
||||
var matchCount: Int = -1,
|
||||
|
@@ -45,7 +45,6 @@ import java.lang.reflect.Method
|
||||
* @param returnType 返回值类型
|
||||
* @param returnTypeConditions 返回值类型条件
|
||||
*/
|
||||
@PublishedApi
|
||||
internal class MethodRulesData internal constructor(
|
||||
var name: String = "",
|
||||
var nameConditions: NameConditions? = null,
|
||||
|
@@ -58,7 +58,6 @@ import kotlin.math.abs
|
||||
/**
|
||||
* 这是一个对 [Class]、[Member] 查找的工具实现类
|
||||
*/
|
||||
@PublishedApi
|
||||
internal object ReflectionTool {
|
||||
|
||||
/** 当前工具类的标签 */
|
||||
@@ -115,7 +114,6 @@ internal object ReflectionTool {
|
||||
* @return [Class]
|
||||
* @throws NoClassDefFoundError 如果找不到 [Class] 或设置了错误的 [ClassLoader]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun findClassByName(name: String, loader: ClassLoader?, initialize: Boolean = false): Class<*> {
|
||||
val uniqueCode = "[$name][$loader]"
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/2/2.
|
||||
*/
|
||||
@file:Suppress("unused", "UNCHECKED_CAST")
|
||||
@file:Suppress("unused", "UNCHECKED_CAST", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.factory
|
||||
|
||||
@@ -372,7 +372,7 @@ inline fun Class<*>.generic(initiate: GenericClass.() -> Unit) = generic()?.appl
|
||||
* @return [CurrentClass]
|
||||
*/
|
||||
inline fun <reified T : Any> T.current(ignored: Boolean = false) =
|
||||
CurrentClass(javaClass, instance = this).apply { isShutErrorPrinting = ignored }
|
||||
CurrentClass(javaClass, instance = this).apply { isIgnoreErrorLogs = ignored }
|
||||
|
||||
/**
|
||||
* 获得当前实例的类操作对象
|
||||
|
@@ -316,7 +316,6 @@ object YukiHookLogger {
|
||||
}
|
||||
|
||||
/** 结束方法体 */
|
||||
@PublishedApi
|
||||
internal fun build() = Unit
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/2/2.
|
||||
*/
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST")
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.param
|
||||
|
||||
@@ -62,19 +62,7 @@ import com.highcapable.yukihookapi.hook.xposed.prefs.YukiHookPrefsBridge
|
||||
* 装载 Hook 的目标 APP 入口对象实现类
|
||||
* @param wrapper [PackageParam] 的参数包装类实例 - 默认是空的
|
||||
*/
|
||||
open class PackageParam internal constructor(@PublishedApi internal var wrapper: PackageParamWrapper? = null) {
|
||||
|
||||
@PublishedApi
|
||||
internal companion object {
|
||||
|
||||
/** 获取当前 Xposed 模块包名 */
|
||||
@PublishedApi
|
||||
internal val modulePackageName get() = YukiXposedModule.modulePackageName
|
||||
|
||||
/** Android 系统框架名称 */
|
||||
@PublishedApi
|
||||
internal const val SYSTEM_FRAMEWORK_NAME = AppParasitics.SYSTEM_FRAMEWORK_NAME
|
||||
}
|
||||
open class PackageParam internal constructor(internal var wrapper: PackageParamWrapper? = null) {
|
||||
|
||||
/** 当前设置的 [ClassLoader] */
|
||||
private var currentClassLoader: ClassLoader? = null
|
||||
@@ -304,7 +292,7 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
*/
|
||||
inline fun loadApp(isExcludeSelf: Boolean = false, initiate: PackageParam.() -> Unit) {
|
||||
if (wrapper?.type != HookEntryType.ZYGOTE &&
|
||||
(isExcludeSelf.not() || isExcludeSelf && packageName != modulePackageName)
|
||||
(isExcludeSelf.not() || isExcludeSelf && packageName != YukiXposedModule.modulePackageName)
|
||||
) initiate(this)
|
||||
}
|
||||
|
||||
@@ -319,7 +307,7 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
*/
|
||||
fun loadApp(isExcludeSelf: Boolean = false, hooker: YukiBaseHooker) {
|
||||
if (wrapper?.type != HookEntryType.ZYGOTE &&
|
||||
(isExcludeSelf.not() || isExcludeSelf && packageName != modulePackageName)
|
||||
(isExcludeSelf.not() || isExcludeSelf && packageName != YukiXposedModule.modulePackageName)
|
||||
) loadHooker(hooker)
|
||||
}
|
||||
|
||||
@@ -335,7 +323,7 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
fun loadApp(isExcludeSelf: Boolean = false, vararg hooker: YukiBaseHooker) {
|
||||
if (hooker.isEmpty()) error("loadApp method need a \"hooker\" param")
|
||||
if (wrapper?.type != HookEntryType.ZYGOTE &&
|
||||
(isExcludeSelf.not() || isExcludeSelf && packageName != modulePackageName)
|
||||
(isExcludeSelf.not() || isExcludeSelf && packageName != YukiXposedModule.modulePackageName)
|
||||
) hooker.forEach { loadHooker(it) }
|
||||
}
|
||||
|
||||
@@ -343,13 +331,13 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
* 装载并 Hook 系统框架
|
||||
* @param initiate 方法体
|
||||
*/
|
||||
inline fun loadSystem(initiate: PackageParam.() -> Unit) = loadApp(SYSTEM_FRAMEWORK_NAME, initiate)
|
||||
inline fun loadSystem(initiate: PackageParam.() -> Unit) = loadApp(AppParasitics.SYSTEM_FRAMEWORK_NAME, initiate)
|
||||
|
||||
/**
|
||||
* 装载并 Hook 系统框架
|
||||
* @param hooker Hook 子类
|
||||
*/
|
||||
fun loadSystem(hooker: YukiBaseHooker) = loadApp(SYSTEM_FRAMEWORK_NAME, hooker)
|
||||
fun loadSystem(hooker: YukiBaseHooker) = loadApp(AppParasitics.SYSTEM_FRAMEWORK_NAME, hooker)
|
||||
|
||||
/**
|
||||
* 装载并 Hook 系统框架
|
||||
@@ -357,7 +345,7 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
*/
|
||||
fun loadSystem(vararg hooker: YukiBaseHooker) {
|
||||
if (hooker.isEmpty()) error("loadSystem method need a \"hooker\" param")
|
||||
loadApp(SYSTEM_FRAMEWORK_NAME, *hooker)
|
||||
loadApp(AppParasitics.SYSTEM_FRAMEWORK_NAME, *hooker)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -652,7 +640,6 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
* @param loader 当前 [ClassLoader] - 若留空使用默认 [ClassLoader]
|
||||
* @return [HookClass]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun VariousClass.toHookClass(loader: ClassLoader? = null) =
|
||||
runCatching { get(loader).toHookClass() }.getOrElse { HookClass(name = "VariousClass", throwable = Throwable(it.message)) }
|
||||
|
||||
@@ -660,7 +647,6 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
* [Class] 转换为 [HookClass]
|
||||
* @return [HookClass]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun Class<*>.toHookClass() = HookClass(instance = this, name)
|
||||
|
||||
/**
|
||||
@@ -669,7 +655,7 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
* - ❗请使用 [onAppLifecycle] 方法来获取 [AppLifecycle]
|
||||
* @param isOnFailureThrowToApp 是否在发生异常时将异常抛出给宿主
|
||||
*/
|
||||
inner class AppLifecycle @PublishedApi internal constructor(private val isOnFailureThrowToApp: Boolean) {
|
||||
inner class AppLifecycle internal constructor(private val isOnFailureThrowToApp: Boolean) {
|
||||
|
||||
/**
|
||||
* 是否为当前操作 [HookEntryType.PACKAGE] 的调用域
|
||||
@@ -747,7 +733,6 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
}
|
||||
|
||||
/** 设置创建生命周期监听回调 */
|
||||
@PublishedApi
|
||||
internal fun build() {
|
||||
AppParasitics.AppLifecycleCallback.isOnFailureThrowToApp = isOnFailureThrowToApp
|
||||
AppParasitics.AppLifecycleCallback.isCallbackSetUp = true
|
||||
|
@@ -44,7 +44,6 @@ import dalvik.system.PathClassLoader
|
||||
* @param appInfo APP [ApplicationInfo]
|
||||
* @param appResources APP [YukiResources]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal class PackageParamWrapper internal constructor(
|
||||
var type: HookEntryType,
|
||||
var packageName: String,
|
||||
|
@@ -30,7 +30,6 @@
|
||||
package com.highcapable.yukihookapi.hook.xposed.bridge.caller
|
||||
|
||||
import android.content.pm.ApplicationInfo
|
||||
import com.highcapable.yukihookapi.annotation.YukiGenerateApi
|
||||
import com.highcapable.yukihookapi.hook.log.yLoggerE
|
||||
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiXposedModule
|
||||
import com.highcapable.yukihookapi.hook.xposed.bridge.resources.YukiResources
|
||||
@@ -41,8 +40,7 @@ import com.highcapable.yukihookapi.hook.xposed.bridge.type.HookEntryType
|
||||
*
|
||||
* - ❗装载代码将自动生成 - 请勿手动调用
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
object YukiXposedModuleCaller {
|
||||
internal object YukiXposedModuleCaller {
|
||||
|
||||
/**
|
||||
* 模块是否装载了 Xposed 回调方法
|
||||
@@ -50,8 +48,7 @@ object YukiXposedModuleCaller {
|
||||
* - ❗装载代码将自动生成 - 你不应该手动使用此方法装载 Xposed 模块事件
|
||||
* @return [Boolean]
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
val isXposedCallbackSetUp get() = YukiXposedModule.isXposedCallbackSetUp
|
||||
internal val isXposedCallbackSetUp get() = YukiXposedModule.isXposedCallbackSetUp
|
||||
|
||||
/**
|
||||
* 标识 Xposed 模块开始装载
|
||||
@@ -60,16 +57,14 @@ object YukiXposedModuleCaller {
|
||||
* @param packageName 当前 Xposed 模块包名
|
||||
* @param appFilePath 当前 Xposed 模块自身 APK 路径
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
fun callOnStartLoadModule(packageName: String, appFilePath: String) = YukiXposedModule.onStartLoadModule(packageName, appFilePath)
|
||||
internal fun callOnStartLoadModule(packageName: String, appFilePath: String) = YukiXposedModule.onStartLoadModule(packageName, appFilePath)
|
||||
|
||||
/**
|
||||
* 标识 Xposed 模块装载完成
|
||||
*
|
||||
* - ❗装载代码将自动生成 - 你不应该手动使用此方法装载 Xposed 模块事件
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
fun callOnFinishLoadModule() = YukiXposedModule.onFinishLoadModule()
|
||||
internal fun callOnFinishLoadModule() = YukiXposedModule.onFinishLoadModule()
|
||||
|
||||
/**
|
||||
* 标识可用的 Hook APP (宿主) 开始装载
|
||||
@@ -82,8 +77,7 @@ object YukiXposedModuleCaller {
|
||||
* @param appInfo 宿主 [ApplicationInfo]
|
||||
* @param appResources 宿主 [YukiResources]
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
fun callOnPackageLoaded(
|
||||
internal fun callOnPackageLoaded(
|
||||
type: HookEntryType,
|
||||
packageName: String?,
|
||||
processName: String? = "",
|
||||
@@ -99,6 +93,5 @@ object YukiXposedModuleCaller {
|
||||
* @param msg 日志打印的内容
|
||||
* @param e 异常堆栈信息 - 默认空
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
fun internalLoggerE(msg: String, e: Throwable? = null) = yLoggerE(msg = msg, e = e)
|
||||
internal fun internalLoggerE(msg: String, e: Throwable? = null) = yLoggerE(msg = msg, e = e)
|
||||
}
|
@@ -29,7 +29,6 @@
|
||||
|
||||
package com.highcapable.yukihookapi.hook.xposed.bridge.event.caller
|
||||
|
||||
import com.highcapable.yukihookapi.annotation.YukiGenerateApi
|
||||
import com.highcapable.yukihookapi.hook.xposed.bridge.event.YukiXposedEvent
|
||||
import de.robv.android.xposed.IXposedHookZygoteInit
|
||||
import de.robv.android.xposed.callbacks.XC_InitPackageResources
|
||||
@@ -40,8 +39,7 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
*
|
||||
* - ❗装载代码将自动生成 - 请勿手动调用
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
object YukiXposedEventCaller {
|
||||
internal object YukiXposedEventCaller {
|
||||
|
||||
/**
|
||||
* 回调 initZygote 事件监听
|
||||
@@ -49,8 +47,7 @@ object YukiXposedEventCaller {
|
||||
* - ❗装载代码将自动生成 - 你不应该手动使用此方法装载 Xposed 模块事件
|
||||
* @param sparam Xposed API 实例
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
fun callInitZygote(sparam: IXposedHookZygoteInit.StartupParam?) {
|
||||
internal fun callInitZygote(sparam: IXposedHookZygoteInit.StartupParam?) {
|
||||
if (sparam == null) return
|
||||
YukiXposedEvent.initZygoteCallback?.invoke(sparam)
|
||||
}
|
||||
@@ -61,8 +58,7 @@ object YukiXposedEventCaller {
|
||||
* - ❗装载代码将自动生成 - 你不应该手动使用此方法装载 Xposed 模块事件
|
||||
* @param lpparam Xposed API 实例
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
fun callHandleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
|
||||
internal fun callHandleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
|
||||
if (lpparam == null) return
|
||||
YukiXposedEvent.handleLoadPackageCallback?.invoke(lpparam)
|
||||
}
|
||||
@@ -73,8 +69,7 @@ object YukiXposedEventCaller {
|
||||
* - ❗装载代码将自动生成 - 你不应该手动使用此方法装载 Xposed 模块事件
|
||||
* @param resparam Xposed API 实例
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
fun callHandleInitPackageResources(resparam: XC_InitPackageResources.InitPackageResourcesParam?) {
|
||||
internal fun callHandleInitPackageResources(resparam: XC_InitPackageResources.InitPackageResourcesParam?) {
|
||||
if (resparam == null) return
|
||||
YukiXposedEvent.handleInitPackageResourcesCallback?.invoke(resparam)
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/4/29.
|
||||
*/
|
||||
@file:Suppress("unused", "DEPRECATION", "DiscouragedApi")
|
||||
@file:Suppress("unused", "DEPRECATION", "DiscouragedApi", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.xposed.bridge.resources
|
||||
|
||||
@@ -236,7 +236,7 @@ class YukiResources private constructor(private val baseInstance: XResources) :
|
||||
* 装载 Hook APP 的目标布局 Resources 实现类
|
||||
* @param baseParam 对接 [XC_LayoutInflated.LayoutInflatedParam]
|
||||
*/
|
||||
class LayoutInflatedParam(@PublishedApi internal val baseParam: XC_LayoutInflated.LayoutInflatedParam) {
|
||||
class LayoutInflatedParam(private val baseParam: XC_LayoutInflated.LayoutInflatedParam) {
|
||||
|
||||
/**
|
||||
* 获取当前被 Hook 的布局装载目录名称
|
||||
|
@@ -30,7 +30,6 @@
|
||||
package com.highcapable.yukihookapi.hook.xposed.bridge.resources.caller
|
||||
|
||||
import android.content.res.XResources
|
||||
import com.highcapable.yukihookapi.annotation.YukiGenerateApi
|
||||
import com.highcapable.yukihookapi.hook.xposed.bridge.resources.YukiResources
|
||||
|
||||
/**
|
||||
@@ -38,8 +37,7 @@ import com.highcapable.yukihookapi.hook.xposed.bridge.resources.YukiResources
|
||||
*
|
||||
* - ❗装载代码将自动生成 - 请勿手动调用
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
object YukiXposedResourcesCaller {
|
||||
internal object YukiXposedResourcesCaller {
|
||||
|
||||
/**
|
||||
* 从 [XResources] 创建 [YukiResources]
|
||||
@@ -48,6 +46,5 @@ object YukiXposedResourcesCaller {
|
||||
* @param xResources [XResources] 实例
|
||||
* @return [YukiResources] or null
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
fun createYukiResourcesFromXResources(xResources: XResources?) = xResources?.let { YukiResources.wrapper(it) }
|
||||
internal fun createYukiResourcesFromXResources(xResources: XResources?) = xResources?.let { YukiResources.wrapper(it) }
|
||||
}
|
@@ -28,15 +28,12 @@
|
||||
*/
|
||||
package com.highcapable.yukihookapi.hook.xposed.bridge.type
|
||||
|
||||
import com.highcapable.yukihookapi.annotation.YukiGenerateApi
|
||||
|
||||
/**
|
||||
* 当前正在进行的 Hook 类型
|
||||
*
|
||||
* - ❗装载代码将自动生成 - 请勿手动调用
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
enum class HookEntryType {
|
||||
internal enum class HookEntryType {
|
||||
|
||||
/** 装载 Zygote */
|
||||
ZYGOTE,
|
||||
|
@@ -36,7 +36,6 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import com.highcapable.yukihookapi.annotation.YukiGenerateApi
|
||||
import com.highcapable.yukihookapi.hook.factory.current
|
||||
import com.highcapable.yukihookapi.hook.factory.field
|
||||
import com.highcapable.yukihookapi.hook.factory.method
|
||||
@@ -53,8 +52,7 @@ import com.highcapable.yukihookapi.hook.xposed.parasitic.activity.config.Activit
|
||||
*
|
||||
* - ❗装载代码将自动生成 - 请勿手动调用
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
object HandlerDelegateCaller {
|
||||
internal object HandlerDelegateCaller {
|
||||
|
||||
/** 启动 [Activity] */
|
||||
private const val LAUNCH_ACTIVITY = 100
|
||||
@@ -70,8 +68,7 @@ object HandlerDelegateCaller {
|
||||
* @param msg 当前消息实例
|
||||
* @return [Boolean]
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
fun callHandleMessage(baseInstance: Handler.Callback?, msg: Message): Boolean {
|
||||
internal fun callHandleMessage(baseInstance: Handler.Callback?, msg: Message): Boolean {
|
||||
when (msg.what) {
|
||||
LAUNCH_ACTIVITY -> runCatching {
|
||||
msg.obj.current(ignored = true).field { name = "intent" }.apply {
|
||||
|
@@ -33,7 +33,6 @@ package com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.call
|
||||
import android.app.Activity
|
||||
import android.app.ActivityManager
|
||||
import android.content.Intent
|
||||
import com.highcapable.yukihookapi.annotation.YukiGenerateApi
|
||||
import com.highcapable.yukihookapi.hook.factory.buildOf
|
||||
import com.highcapable.yukihookapi.hook.factory.classOf
|
||||
import com.highcapable.yukihookapi.hook.factory.extends
|
||||
@@ -51,8 +50,7 @@ import java.lang.reflect.Method
|
||||
*
|
||||
* - ❗装载代码将自动生成 - 请勿手动调用
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
object IActivityManagerProxyCaller {
|
||||
internal object IActivityManagerProxyCaller {
|
||||
|
||||
/**
|
||||
* 获取当前使用的 [ClassLoader]
|
||||
@@ -60,8 +58,7 @@ object IActivityManagerProxyCaller {
|
||||
* - ❗装载代码将自动生成 - 请勿手动调用
|
||||
* @return [ClassLoader]
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
val currentClassLoader get() = AppParasitics.baseClassLoader
|
||||
internal val currentClassLoader get() = AppParasitics.baseClassLoader
|
||||
|
||||
/**
|
||||
* 调用代理的 [InvocationHandler.invoke] 方法
|
||||
@@ -72,8 +69,7 @@ object IActivityManagerProxyCaller {
|
||||
* @param args 被调用方法参数
|
||||
* @return [Any] or null
|
||||
*/
|
||||
@YukiGenerateApi
|
||||
fun callInvoke(baseInstance: Any, method: Method?, args: Array<Any>?): Any? {
|
||||
internal fun callInvoke(baseInstance: Any, method: Method?, args: Array<Any>?): Any? {
|
||||
if (method?.name == "startActivity") args?.indexOfFirst { it is Intent }?.also { index ->
|
||||
val argsInstance = (args[index] as? Intent) ?: return@also
|
||||
val component = argsInstance.component
|
||||
|
@@ -25,7 +25,10 @@
|
||||
*
|
||||
* This file is created by fankes on 2022/2/8.
|
||||
*/
|
||||
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "StaticFieldLeak", "SetWorldReadable", "CommitPrefEdits", "UNCHECKED_CAST")
|
||||
@file:Suppress(
|
||||
"unused", "MemberVisibilityCanBePrivate", "StaticFieldLeak", "SetWorldReadable",
|
||||
"CommitPrefEdits", "UNCHECKED_CAST", "NON_PUBLIC_CALL_FROM_PUBLIC_INLINE"
|
||||
)
|
||||
|
||||
package com.highcapable.yukihookapi.hook.xposed.prefs
|
||||
|
||||
@@ -356,8 +359,7 @@ class YukiHookPrefsBridge private constructor(private var context: Context? = nu
|
||||
* @param value 默认值
|
||||
* @return [Any]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun getPrefsData(key: String, value: Any?): Any = when (value) {
|
||||
private fun getPrefsData(key: String, value: Any?): Any = when (value) {
|
||||
is String -> getString(key, value)
|
||||
is Set<*> -> getStringSet(key, value as? Set<String> ?: error("Key-Value type ${value.javaClass.name} is not allowed"))
|
||||
is Int -> getInt(key, value)
|
||||
@@ -650,8 +652,7 @@ class YukiHookPrefsBridge private constructor(private var context: Context? = nu
|
||||
* @param value 要存储的值 - 只能是 [String]、[Set]<[String]>、[Int]、[Float]、[Long]、[Boolean]
|
||||
* @return [Editor]
|
||||
*/
|
||||
@PublishedApi
|
||||
internal fun putPrefsData(key: String, value: Any?) = when (value) {
|
||||
private fun putPrefsData(key: String, value: Any?) = when (value) {
|
||||
is String -> putString(key, value)
|
||||
is Set<*> -> putStringSet(key, value as? Set<String> ?: error("Key-Value type ${value.javaClass.name} is not allowed"))
|
||||
is Int -> putInt(key, value)
|
||||
|
@@ -69,10 +69,6 @@ object ClassName {
|
||||
* 外部调用者包名和类名定义类
|
||||
*/
|
||||
object ExternalCallerName {
|
||||
val YukiGenerateApiAnnotation = Pair(
|
||||
"com.highcapable.yukihookapi.annotation.YukiGenerateApi",
|
||||
"YukiGenerateApi"
|
||||
)
|
||||
val HandlerDelegateCaller = Pair(
|
||||
"com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.caller.HandlerDelegateCaller",
|
||||
"HandlerDelegateCaller"
|
||||
@@ -218,15 +214,13 @@ fun GenerateData.sources() = mapOf(
|
||||
}
|
||||
""".trimIndent(),
|
||||
ClassName.HandlerDelegateImpl_Impl to """
|
||||
@file:Suppress("ClassName")
|
||||
@file:Suppress("ClassName", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
package ${PackageName.HandlerDelegateImpl_Impl}
|
||||
|
||||
import android.os.Handler
|
||||
import ${ExternalCallerName.YukiGenerateApiAnnotation.first}
|
||||
import ${PackageName.HandlerDelegateClass}.${tailPackageName(ClassName.HandlerDelegateClass)}
|
||||
""".trimIndent() + "\n\n" + createCommentContent(ClassName.HandlerDelegateImpl_Impl) + "\n" + """
|
||||
@${ExternalCallerName.YukiGenerateApiAnnotation.second}
|
||||
object ${ClassName.HandlerDelegateImpl_Impl} {
|
||||
|
||||
val wrapperClassName get() = "${PackageName.HandlerDelegateClass}.${tailPackageName(ClassName.HandlerDelegateClass)}"
|
||||
@@ -235,70 +229,65 @@ fun GenerateData.sources() = mapOf(
|
||||
}
|
||||
""".trimIndent(),
|
||||
ClassName.HandlerDelegateClass to """
|
||||
@file:Suppress("ClassName")
|
||||
@file:Suppress("ClassName", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
package ${PackageName.HandlerDelegateClass}
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import androidx.annotation.Keep
|
||||
import ${ExternalCallerName.YukiGenerateApiAnnotation.first}
|
||||
import ${ExternalCallerName.HandlerDelegateCaller.first}
|
||||
""".trimIndent() + "\n\n" + createCommentContent(ClassName.HandlerDelegateClass) + "\n" + """
|
||||
@Keep
|
||||
@${ExternalCallerName.YukiGenerateApiAnnotation.second}
|
||||
class ${tailPackageName(ClassName.HandlerDelegateClass)}(private val baseInstance: Handler.Callback?) : Handler.Callback {
|
||||
|
||||
override fun handleMessage(msg: Message) = ${ExternalCallerName.HandlerDelegateCaller.second}.callHandleMessage(baseInstance, msg)
|
||||
}
|
||||
""".trimIndent(),
|
||||
ClassName.IActivityManagerProxyImpl_Impl to """
|
||||
@file:Suppress("ClassName")
|
||||
@file:Suppress("ClassName", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
package ${PackageName.IActivityManagerProxyImpl_Impl}
|
||||
|
||||
import android.os.Handler
|
||||
import ${ExternalCallerName.YukiGenerateApiAnnotation.first}
|
||||
import ${ExternalCallerName.IActivityManagerProxyCaller.first}
|
||||
import ${PackageName.IActivityManagerProxyClass}.${tailPackageName(ClassName.IActivityManagerProxyClass)}
|
||||
import java.lang.reflect.Proxy
|
||||
""".trimIndent() + "\n\n" + createCommentContent(ClassName.IActivityManagerProxyImpl_Impl) + "\n" + """
|
||||
@${ExternalCallerName.YukiGenerateApiAnnotation.second}
|
||||
object ${ClassName.IActivityManagerProxyImpl_Impl} {
|
||||
|
||||
fun createWrapper(clazz: Class<*>?, instance: Any) =
|
||||
Proxy.newProxyInstance(${ExternalCallerName.IActivityManagerProxyCaller.second}.currentClassLoader, arrayOf(clazz), ${tailPackageName(
|
||||
ClassName.IActivityManagerProxyClass
|
||||
)}(instance))
|
||||
Proxy.newProxyInstance(${ExternalCallerName.IActivityManagerProxyCaller.second}.currentClassLoader, arrayOf(clazz), ${
|
||||
tailPackageName(
|
||||
ClassName.IActivityManagerProxyClass
|
||||
)
|
||||
}(instance))
|
||||
}
|
||||
""".trimIndent(),
|
||||
ClassName.IActivityManagerProxyClass to """
|
||||
@file:Suppress("ClassName")
|
||||
@file:Suppress("ClassName", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
package ${PackageName.IActivityManagerProxyClass}
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import ${ExternalCallerName.YukiGenerateApiAnnotation.first}
|
||||
import ${ExternalCallerName.IActivityManagerProxyCaller.first}
|
||||
import java.lang.reflect.InvocationHandler
|
||||
import java.lang.reflect.Method
|
||||
import java.lang.reflect.Proxy
|
||||
""".trimIndent() + "\n\n" + createCommentContent(ClassName.IActivityManagerProxyClass) + "\n" + """
|
||||
@Keep
|
||||
@${ExternalCallerName.YukiGenerateApiAnnotation.second}
|
||||
class ${tailPackageName(ClassName.IActivityManagerProxyClass)}(private val baseInstance: Any) : InvocationHandler {
|
||||
|
||||
override fun invoke(proxy: Any?, method: Method?, args: Array<Any>?) = ${ExternalCallerName.IActivityManagerProxyCaller.second}.callInvoke(baseInstance, method, args)
|
||||
}
|
||||
""".trimIndent(),
|
||||
ClassName.XposedInit to """
|
||||
@file:Suppress("ClassName")
|
||||
@file:Suppress("ClassName", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
package $entryPackageName
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import ${ExternalCallerName.YukiXposedEventCaller.first}
|
||||
import ${ExternalCallerName.YukiGenerateApiAnnotation.first}
|
||||
${if (isUsingResourcesHook) "import de.robv.android.xposed.IXposedHookInitPackageResources" else ""}
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.IXposedHookZygoteInit
|
||||
@@ -306,7 +295,6 @@ fun GenerateData.sources() = mapOf(
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
""".trimIndent() + "\n\n" + createCommentContent("Xposed Init") + "\n" + """
|
||||
@Keep
|
||||
@${ExternalCallerName.YukiGenerateApiAnnotation.second}
|
||||
class $xInitClassName : IXposedHookZygoteInit, IXposedHookLoadPackage${if (isUsingResourcesHook) ", IXposedHookInitPackageResources" else ""} {
|
||||
|
||||
override fun initZygote(sparam: IXposedHookZygoteInit.StartupParam?) {
|
||||
@@ -330,11 +318,10 @@ fun GenerateData.sources() = mapOf(
|
||||
""".trimIndent()
|
||||
else "\n}"),
|
||||
ClassName.XposedInit_Impl to """
|
||||
@file:Suppress("ClassName")
|
||||
@file:Suppress("ClassName", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
package $entryPackageName
|
||||
|
||||
import ${ExternalCallerName.YukiGenerateApiAnnotation.first}
|
||||
import ${ExternalCallerName.YukiXposedModuleCaller.first}
|
||||
import ${ExternalCallerName.YukiXposedResourcesCaller.first}
|
||||
import com.highcapable.yukihookapi.hook.xposed.bridge.type.HookEntryType
|
||||
@@ -344,7 +331,6 @@ fun GenerateData.sources() = mapOf(
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
${if (customMPackageName.isBlank()) "import $modulePackageName.BuildConfig" else ""}
|
||||
""".trimIndent() + "\n\n" + createCommentContent("Xposed Init Impl") + "\n" + """
|
||||
@${ExternalCallerName.YukiGenerateApiAnnotation.second}
|
||||
object ${entryClassName}_Impl {
|
||||
|
||||
private const val modulePackageName = ${if (customMPackageName.isNotBlank()) "\"$customMPackageName\"" else "BuildConfig.APPLICATION_ID"}
|
||||
|
Reference in New Issue
Block a user