mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-05 18:25:28 +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.PackageParam
|
||||||
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
||||||
import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiResources
|
import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiResources
|
||||||
|
import dalvik.system.PathClassLoader
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于包装 [PackageParam]
|
* 用于包装 [PackageParam]
|
||||||
@@ -56,6 +57,16 @@ class PackageParamWrapper internal constructor(
|
|||||||
var appResources: YukiResources? = null
|
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() =
|
override fun toString() =
|
||||||
"PackageParamWrapper [type] $type [packageName] $packageName [processName] $processName [appInfo] $appInfo [appResources] $appResources"
|
"PackageParamWrapper [type] $type [packageName] $packageName [processName] $processName [appInfo] $appInfo [appResources] $appResources"
|
||||||
}
|
}
|
@@ -190,13 +190,13 @@ object YukiHookBridge {
|
|||||||
appResources = appResources
|
appResources = appResources
|
||||||
).also { packageParamWrappers[packageName ?: SYSTEM_FRAMEWORK_NAME] = it }
|
).also { packageParamWrappers[packageName ?: SYSTEM_FRAMEWORK_NAME] = it }
|
||||||
else null
|
else null
|
||||||
else packageParamWrappers[packageName]?.also {
|
else packageParamWrappers[packageName]?.also { wrapper ->
|
||||||
it.type = type
|
wrapper.type = type
|
||||||
if (packageName?.isNotBlank() == true) it.packageName = packageName
|
packageName?.takeIf { it.isNotBlank() }?.also { wrapper.packageName = it }
|
||||||
if (processName?.isNotBlank() == true) it.processName = processName
|
processName?.takeIf { it.isNotBlank() }?.also { wrapper.processName = it }
|
||||||
if (appClassLoader != null && (type == HookEntryType.ZYGOTE || appClassLoader is PathClassLoader)) it.appClassLoader = appClassLoader
|
appClassLoader?.takeIf { type == HookEntryType.ZYGOTE || it is PathClassLoader }?.also { wrapper.appClassLoader = it }
|
||||||
if (appInfo != null) it.appInfo = appInfo
|
appInfo?.also { wrapper.appInfo = it }
|
||||||
if (appResources != null) it.appResources = appResources
|
appResources?.also { wrapper.appResources = it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ object YukiHookBridge {
|
|||||||
else null
|
else null
|
||||||
else -> null
|
else -> null
|
||||||
}?.also {
|
}?.also {
|
||||||
YukiHookAPI.onXposedLoaded(it)
|
if (it.isCorrectProcess) YukiHookAPI.onXposedLoaded(it)
|
||||||
if (it.type != HookEntryType.ZYGOTE && it.packageName == modulePackageName)
|
if (it.type != HookEntryType.ZYGOTE && it.packageName == modulePackageName)
|
||||||
AppParasitics.hookModuleAppRelated(it.appClassLoader, it.type)
|
AppParasitics.hookModuleAppRelated(it.appClassLoader, it.type)
|
||||||
if (it.type == HookEntryType.PACKAGE) AppParasitics.registerToAppLifecycle(it.packageName)
|
if (it.type == HookEntryType.PACKAGE) AppParasitics.registerToAppLifecycle(it.packageName)
|
||||||
|
Reference in New Issue
Block a user