From 6e552d6ff2bcf6cdc7041050b4295d1163f4879a Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Sun, 21 Aug 2022 22:51:15 +0800 Subject: [PATCH] Modify ignored CurrentClass error in AppParasitics and HandlerDelegate --- .../hook/xposed/parasitic/AppParasitics.kt | 4 +-- .../activity/delegate/HandlerDelegate.kt | 35 ++++++++++--------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/parasitic/AppParasitics.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/parasitic/AppParasitics.kt index 0f589032..8c2568af 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/parasitic/AppParasitics.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/parasitic/AppParasitics.kt @@ -258,7 +258,7 @@ internal object AppParasitics { internal fun injectModuleAppResources(hostResources: Resources) { if (injectedHostResourcesHashCodes.contains(hostResources.hashCode())) return if (YukiHookBridge.hasXposedBridge) runCatching { - hostResources.assets.current().method { name = "addAssetPath"; param(StringType) }.call(moduleAppFilePath) + hostResources.assets.current(ignored = true).method { name = "addAssetPath"; param(StringType) }.call(moduleAppFilePath) injectedHostResourcesHashCodes.add(hostResources.hashCode()) }.onFailure { yLoggerE(msg = "Failed to inject module resources into [$hostResources]", e = it) @@ -297,7 +297,7 @@ internal object AppParasitics { else error("Could not found \"$proxyClassName\" or Class is not a type of Activity")) } /** Patched [Instrumentation] */ - ActivityThreadClass.field { name = "sCurrentActivityThread" }.ignored().get().any()?.current { + ActivityThreadClass.field { name = "sCurrentActivityThread" }.ignored().get().any()?.current(ignored = true) { method { name = "getInstrumentation" } .invoke() ?.also { field { name = "mInstrumentation" }.set(InstrumentationDelegate.wrapper(it)) } diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/HandlerDelegate.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/HandlerDelegate.kt index 6bede6c5..53238b36 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/HandlerDelegate.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/HandlerDelegate.kt @@ -70,7 +70,7 @@ internal class HandlerDelegate private constructor(private val baseInstance: Han override fun handleMessage(msg: Message): Boolean { when (msg.what) { LAUNCH_ACTIVITY -> runCatching { - msg.obj.current().field { name = "intent" }.apply { + msg.obj.current(ignored = true).field { name = "intent" }.apply { cast()?.also { intent -> IntentClass.field { name = "mExtras" }.ignored().get(intent).cast() ?.classLoader = YukiHookAppHelper.currentApplication()?.classLoader @@ -82,23 +82,24 @@ internal class HandlerDelegate private constructor(private val baseInstance: Han EXECUTE_TRANSACTION -> msg.obj?.runCatching client@{ ClientTransactionClass.method { name = "getCallbacks" }.ignored().get(this).list().takeIf { it.isNotEmpty() } ?.forEach { item -> - item?.current()?.takeIf { it.name.contains(other = "LaunchActivityItem") }?.field { name = "mIntent" }?.apply { - cast()?.also { intent -> - IntentClass.field { name = "mExtras" }.ignored().get(intent).cast() - ?.classLoader = YukiHookAppHelper.currentApplication()?.classLoader - if (intent.hasExtra(ActivityProxyConfig.proxyIntentName)) - intent.getParcelableExtra(ActivityProxyConfig.proxyIntentName).also { subIntent -> - if (Build.VERSION.SDK_INT >= 31) - ActivityThreadClass.method { - name = "getLaunchingActivity" - param(IBinderClass) - }.ignored().get(ActivityThreadClass.method { name = "currentActivityThread" }.ignored().get().call()) - .call(this@client.current().method { name = "getActivityToken" }.call()) - ?.current()?.field { name = "intent" }?.set(subIntent) - set(subIntent) - } + item?.current(ignored = true)?.takeIf { it.name.contains(other = "LaunchActivityItem") }?.field { name = "mIntent" } + ?.apply { + cast()?.also { intent -> + IntentClass.field { name = "mExtras" }.ignored().get(intent).cast() + ?.classLoader = YukiHookAppHelper.currentApplication()?.classLoader + if (intent.hasExtra(ActivityProxyConfig.proxyIntentName)) + intent.getParcelableExtra(ActivityProxyConfig.proxyIntentName).also { subIntent -> + if (Build.VERSION.SDK_INT >= 31) + ActivityThreadClass.method { name = "currentActivityThread" }.ignored().get().call() + ?.current(ignored = true)?.method { + name = "getLaunchingActivity" + param(IBinderClass) + }?.call(this@client.current(ignored = true).method { name = "getActivityToken" }.call()) + ?.current(ignored = true)?.field { name = "intent" }?.set(subIntent) + set(subIntent) + } + } } - } } }?.onFailure { yLoggerE(msg = "Activity Proxy got an Exception in msg.what [$EXECUTE_TRANSACTION]", e = it) } }