mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 01:35:17 +08:00
Fix a bug when ClassLoader during non-zygote process was still not PathClassLoader in PackageParamWrapper, YukiHookBridge
This commit is contained in:
@@ -34,6 +34,7 @@ import com.highcapable.yukihookapi.annotation.YukiPrivateApi
|
||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
||||
import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiResources
|
||||
import dalvik.system.PathClassLoader
|
||||
|
||||
/**
|
||||
* 用于包装 [PackageParam]
|
||||
@@ -56,6 +57,16 @@ class PackageParamWrapper internal constructor(
|
||||
var appResources: YukiResources? = null
|
||||
) {
|
||||
|
||||
/**
|
||||
* 获取当前正在进行的 Hook 进程是否正确
|
||||
*
|
||||
* 此功能为修复在 Hook 系统框架、系统 APP 等情况时会出现 [ClassLoader] 不匹配的问题
|
||||
*
|
||||
* 如果 [type] 不是 [HookEntryType.ZYGOTE] 那么 [appClassLoader] 就应该得到 [PathClassLoader]
|
||||
* @return [Boolean] 是否正确
|
||||
*/
|
||||
internal val isCorrectProcess get() = type == HookEntryType.ZYGOTE || (type != HookEntryType.ZYGOTE && appClassLoader is PathClassLoader)
|
||||
|
||||
override fun toString() =
|
||||
"PackageParamWrapper [type] $type [packageName] $packageName [processName] $processName [appInfo] $appInfo [appResources] $appResources"
|
||||
}
|
@@ -190,13 +190,13 @@ object YukiHookBridge {
|
||||
appResources = appResources
|
||||
).also { packageParamWrappers[packageName ?: SYSTEM_FRAMEWORK_NAME] = it }
|
||||
else null
|
||||
else packageParamWrappers[packageName]?.also {
|
||||
it.type = type
|
||||
if (packageName?.isNotBlank() == true) it.packageName = packageName
|
||||
if (processName?.isNotBlank() == true) it.processName = processName
|
||||
if (appClassLoader != null && (type == HookEntryType.ZYGOTE || appClassLoader is PathClassLoader)) it.appClassLoader = appClassLoader
|
||||
if (appInfo != null) it.appInfo = appInfo
|
||||
if (appResources != null) it.appResources = appResources
|
||||
else packageParamWrappers[packageName]?.also { wrapper ->
|
||||
wrapper.type = type
|
||||
packageName?.takeIf { it.isNotBlank() }?.also { wrapper.packageName = it }
|
||||
processName?.takeIf { it.isNotBlank() }?.also { wrapper.processName = it }
|
||||
appClassLoader?.takeIf { type == HookEntryType.ZYGOTE || it is PathClassLoader }?.also { wrapper.appClassLoader = it }
|
||||
appInfo?.also { wrapper.appInfo = it }
|
||||
appResources?.also { wrapper.appResources = it }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ object YukiHookBridge {
|
||||
else null
|
||||
else -> null
|
||||
}?.also {
|
||||
YukiHookAPI.onXposedLoaded(it)
|
||||
if (it.isCorrectProcess) YukiHookAPI.onXposedLoaded(it)
|
||||
if (it.type != HookEntryType.ZYGOTE && it.packageName == modulePackageName)
|
||||
AppParasitics.hookModuleAppRelated(it.appClassLoader, it.type)
|
||||
if (it.type == HookEntryType.PACKAGE) AppParasitics.registerToAppLifecycle(it.packageName)
|
||||
|
Reference in New Issue
Block a user