diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt index 9e85b9bf..1c8cb719 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt @@ -37,8 +37,8 @@ import com.highcapable.yukihookapi.hook.core.finder.MethodFinder import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules import com.highcapable.yukihookapi.hook.store.MemberCacheStore import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge +import com.highcapable.yukihookapi.hook.xposed.bridge.factory.YukiHookHelper import com.highcapable.yukihookapi.hook.xposed.bridge.status.YukiHookModuleStatus -import de.robv.android.xposed.XposedHelpers import java.lang.reflect.Constructor import java.lang.reflect.Field import java.lang.reflect.Member @@ -85,7 +85,7 @@ fun classOf(name: String, loader: ClassLoader? = null): Class<*> { return MemberCacheStore.findClass(hashCode) ?: run { when { YukiHookBridge.hasXposedBridge -> - runCatching { XposedHelpers.findClassIfExists(name, loader) }.getOrNull() + runCatching { YukiHookHelper.findClass(name, loader) }.getOrNull() ?: when (loader) { null -> Class.forName(name) else -> loader.loadClass(name) diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/bridge/factory/YukiBridgeFactory.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/bridge/factory/YukiBridgeFactory.kt index 282b90f9..792c3750 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/bridge/factory/YukiBridgeFactory.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/bridge/factory/YukiBridgeFactory.kt @@ -37,6 +37,7 @@ import com.highcapable.yukihookapi.hook.param.wrapper.HookParamWrapper import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge import de.robv.android.xposed.XC_MethodHook import de.robv.android.xposed.XposedBridge +import de.robv.android.xposed.XposedHelpers import java.lang.reflect.Member /** @@ -70,6 +71,16 @@ internal object YukiHookedMembers { */ internal object YukiHookHelper { + /** + * 使用 [XposedHelpers.findClass] 来查找 [Class] + * @param name [Class] 的完整包名+名称 + * @param loader [Class] 所在的 [ClassLoader] - 默认空 - 可不填 + * @return [Class] or null + * @throws ClassNotFoundException 如果找不到 [Class] + */ + internal fun findClass(name: String, loader: ClassLoader? = null) = + if (YukiHookBridge.hasXposedBridge) XposedHelpers.findClass(name, loader) else null + /** * Hook [BaseFinder.BaseResult] * @param traction 直接调用 [BaseFinder.BaseResult]