mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-05 18:25:28 +08:00
Modify remove checkingInternal function in ReflectionFactory, YukiMemberHookCreator
This commit is contained in:
@@ -158,7 +158,7 @@ class YukiMemberHookCreator @PublishedApi internal constructor(
|
|||||||
else -> Result().await {
|
else -> Result().await {
|
||||||
when {
|
when {
|
||||||
isDisableCreatorRunHook.not() && hookClass.instance != null -> runCatching {
|
isDisableCreatorRunHook.not() && hookClass.instance != null -> runCatching {
|
||||||
hookClass.instance?.apply { checkingInternal(); checkingDangerous() }
|
hookClass.instance?.checkingDangerous()
|
||||||
it.onPrepareHook?.invoke()
|
it.onPrepareHook?.invoke()
|
||||||
preHookMembers.forEach { (_, m) -> m.hook() }
|
preHookMembers.forEach { (_, m) -> m.hook() }
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
package com.highcapable.yukihookapi.hook.factory
|
package com.highcapable.yukihookapi.hook.factory
|
||||||
|
|
||||||
import com.highcapable.yukihookapi.YukiHookAPI
|
|
||||||
import com.highcapable.yukihookapi.hook.bean.CurrentClass
|
import com.highcapable.yukihookapi.hook.bean.CurrentClass
|
||||||
import com.highcapable.yukihookapi.hook.bean.GenericClass
|
import com.highcapable.yukihookapi.hook.bean.GenericClass
|
||||||
import com.highcapable.yukihookapi.hook.core.finder.base.rules.ModifierRules
|
import com.highcapable.yukihookapi.hook.core.finder.base.rules.ModifierRules
|
||||||
@@ -40,7 +39,6 @@ import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder
|
|||||||
import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool
|
import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool
|
||||||
import com.highcapable.yukihookapi.hook.core.finder.type.factory.*
|
import com.highcapable.yukihookapi.hook.core.finder.type.factory.*
|
||||||
import com.highcapable.yukihookapi.hook.type.java.*
|
import com.highcapable.yukihookapi.hook.type.java.*
|
||||||
import com.highcapable.yukihookapi.hook.xposed.bridge.status.YukiXposedModuleStatus
|
|
||||||
import com.highcapable.yukihookapi.hook.xposed.parasitic.AppParasitics
|
import com.highcapable.yukihookapi.hook.xposed.parasitic.AppParasitics
|
||||||
import dalvik.system.BaseDexClassLoader
|
import dalvik.system.BaseDexClassLoader
|
||||||
import java.lang.reflect.*
|
import java.lang.reflect.*
|
||||||
@@ -326,10 +324,7 @@ inline fun Class<*>.constructor(initiate: ConstructorConditions = { emptyParam()
|
|||||||
* 如果当前实例不存在泛型将返回 null
|
* 如果当前实例不存在泛型将返回 null
|
||||||
* @return [GenericClass] or null
|
* @return [GenericClass] or null
|
||||||
*/
|
*/
|
||||||
fun Class<*>.generic(): GenericClass? {
|
fun Class<*>.generic() = genericSuperclass?.let { (it as? ParameterizedType?)?.let { e -> GenericClass(e) } }
|
||||||
checkingInternal()
|
|
||||||
return genericSuperclass?.let { (it as? ParameterizedType?)?.let { e -> GenericClass(e) } }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得当前 [Class] 的泛型父类
|
* 获得当前 [Class] 的泛型父类
|
||||||
@@ -345,10 +340,8 @@ inline fun Class<*>.generic(initiate: GenericClass.() -> Unit) = generic()?.appl
|
|||||||
* @param ignored 是否开启忽略错误警告功能 - 默认否
|
* @param ignored 是否开启忽略错误警告功能 - 默认否
|
||||||
* @return [CurrentClass]
|
* @return [CurrentClass]
|
||||||
*/
|
*/
|
||||||
inline fun <reified T : Any> T.current(ignored: Boolean = false): CurrentClass {
|
inline fun <reified T : Any> T.current(ignored: Boolean = false) =
|
||||||
javaClass.checkingInternal()
|
CurrentClass(javaClass, instance = this).apply { isShutErrorPrinting = ignored }
|
||||||
return CurrentClass(javaClass, instance = this).apply { isShutErrorPrinting = ignored }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得当前实例的类操作对象
|
* 获得当前实例的类操作对象
|
||||||
@@ -413,17 +406,4 @@ inline fun Class<*>.allConstructors(isAccessible: Boolean = true, result: (index
|
|||||||
* @param result 回调 - ([Int] 下标,[Field] 实例)
|
* @param result 回调 - ([Int] 下标,[Field] 实例)
|
||||||
*/
|
*/
|
||||||
inline fun Class<*>.allFields(isAccessible: Boolean = true, result: (index: Int, field: Field) -> Unit) =
|
inline fun Class<*>.allFields(isAccessible: Boolean = true, result: (index: Int, field: Field) -> Unit) =
|
||||||
declaredFields.forEachIndexed { p, it -> result(p, it.also { e -> e.isAccessible = isAccessible }) }
|
declaredFields.forEachIndexed { p, it -> result(p, it.also { e -> e.isAccessible = isAccessible }) }
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查内部类调用
|
|
||||||
* @throws RuntimeException 如果遇到非法调用
|
|
||||||
*/
|
|
||||||
@PublishedApi
|
|
||||||
internal fun Class<*>.checkingInternal() {
|
|
||||||
if (name == YukiXposedModuleStatus.IMPL_CLASS_NAME) return
|
|
||||||
if (name == classOf<YukiHookAPI>().name || name.startsWith("com.highcapable.yukihookapi.hook")) throw RuntimeException(
|
|
||||||
"!!!DO NOT ALLOWED!!! You cannot hook or reflection to call the internal class of the YukiHookAPI itself, " +
|
|
||||||
"The called class is [$this]"
|
|
||||||
)
|
|
||||||
}
|
|
Reference in New Issue
Block a user