From 3a61c5ecf0b7787dc556d6b7c9d88ec67dbd6f13 Mon Sep 17 00:00:00 2001 From: YifePlayte Date: Thu, 2 Nov 2023 16:53:56 +0800 Subject: [PATCH] Update dexkit --- app/build.gradle.kts | 2 +- .../hooks/multipackage/ForceSupportSendApp.kt | 29 ++++++--------- ...nofficialSystemApplicationsInstallation.kt | 20 +++++----- .../ModifyScreenRecorderConfig.kt | 37 ++++++++++++------- .../RemoveAdbInstallIntercept.kt | 8 ++-- .../RemoveReportInApplicationInfo.kt | 8 ++-- .../voiceassist/ChangeBrowserForMiAi.kt | 8 ++-- .../com/yifeplayte/wommo/hook/utils/DexKit.kt | 2 +- 8 files changed, 61 insertions(+), 53 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 70b0fec..5d51649 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -80,6 +80,6 @@ android { dependencies { compileOnly("de.robv.android.xposed:api:82") implementation("com.github.kyuubiran:EzXHelper:2.0.8") - implementation("org.luckypray:DexKit:1.1.8") + implementation("org.luckypray:dexkit:2.0.0-rc7") implementation(project(":blockmiui")) } diff --git a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/multipackage/ForceSupportSendApp.kt b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/multipackage/ForceSupportSendApp.kt index cdfc38a..0bf4ec5 100644 --- a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/multipackage/ForceSupportSendApp.kt +++ b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/multipackage/ForceSupportSendApp.kt @@ -13,10 +13,8 @@ import com.yifeplayte.wommo.hook.utils.DexKit.dexKitBridge object ForceSupportSendApp : BaseMultiHook() { override val key = "force_support_send_app" - override val hooks = mapOf( - "com.milink.service" to { milink() }, - "com.xiaomi.mirror" to { if (!mirror()) mirrorNew() } - ) + override val hooks = mapOf("com.milink.service" to { milink() }, + "com.xiaomi.mirror" to { if (!mirror()) mirrorNew() }) private fun milink() { val clazzMiuiSynergySdk = loadClass("com.xiaomi.mirror.synergy.MiuiSynergySdk") @@ -54,24 +52,19 @@ object ForceSupportSendApp : BaseMultiHook() { .createHook { returnConstant(true) } - dexKitBridge.findMethodUsingString { - usingString = "support_all_app_sub_screen" - methodReturnType = "boolean" + dexKitBridge.findMethod { + matcher { + usingStrings = listOf("support_all_app_sub_screen") + returnType = "boolean" + } }.first().getMethodInstance(safeClassLoader).createHook { returnConstant(true) } - var clazzRelayAppMessage: Class<*>? = null - dexKitBridge.batchFindClassesUsingStrings { - addQuery( - "clazzRelayAppMessage", listOf("RelayAppMessage{type=", ", isRelay=") - ) - }.forEach { (key, classes) -> - when (key) { - "clazzRelayAppMessage" -> { - clazzRelayAppMessage = classes.first().getClassInstance(safeClassLoader) - } + val clazzRelayAppMessage = dexKitBridge.findClass { + matcher { + usingStrings = listOf("RelayAppMessage{type=", ", isRelay=") } - } + }.first().getInstance(safeClassLoader) clazzRelayAppMessage?.let { clazz -> val fieldNameIsHideIcon = clazz.fieldFinder().filterByType(Boolean::class.javaPrimitiveType!!).toList() diff --git a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/packageinstaller/AllowUnofficialSystemApplicationsInstallation.kt b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/packageinstaller/AllowUnofficialSystemApplicationsInstallation.kt index d88fce2..64ee712 100644 --- a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/packageinstaller/AllowUnofficialSystemApplicationsInstallation.kt +++ b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/packageinstaller/AllowUnofficialSystemApplicationsInstallation.kt @@ -1,8 +1,8 @@ package com.yifeplayte.wommo.hook.hooks.singlepackage.packageinstaller import android.content.pm.ApplicationInfo -import com.github.kyuubiran.ezxhelper.EzXHelper -import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook +import com.github.kyuubiran.ezxhelper.EzXHelper.safeClassLoader +import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks import com.yifeplayte.wommo.hook.hooks.BaseHook import com.yifeplayte.wommo.hook.utils.DexKit.dexKitBridge @@ -10,14 +10,14 @@ object AllowUnofficialSystemApplicationsInstallation : BaseHook() { override val key = "allow_unofficial_system_applications_installation" override fun hook() { dexKitBridge.findMethod { - methodParamTypes = arrayOf("Landroid/content/pm/ApplicationInfo;") - methodReturnType = "boolean" - }.forEach { - it.getMethodInstance(EzXHelper.safeClassLoader).createHook { - before { param -> - (param.args[0] as ApplicationInfo).flags = - (param.args[0] as ApplicationInfo).flags.or(ApplicationInfo.FLAG_SYSTEM) - } + matcher { + paramTypes = listOf("Landroid/content/pm/ApplicationInfo;") + returnType = "boolean" + } + }.map { it.getMethodInstance(safeClassLoader) }.createHooks { + before { param -> + (param.args[0] as ApplicationInfo).flags = + (param.args[0] as ApplicationInfo).flags.or(ApplicationInfo.FLAG_SYSTEM) } } } diff --git a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/screenrecorder/ModifyScreenRecorderConfig.kt b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/screenrecorder/ModifyScreenRecorderConfig.kt index b58ff46..e796257 100644 --- a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/screenrecorder/ModifyScreenRecorderConfig.kt +++ b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/screenrecorder/ModifyScreenRecorderConfig.kt @@ -1,6 +1,6 @@ package com.yifeplayte.wommo.hook.hooks.singlepackage.screenrecorder -import com.github.kyuubiran.ezxhelper.EzXHelper +import com.github.kyuubiran.ezxhelper.EzXHelper.safeClassLoader import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook import com.github.kyuubiran.ezxhelper.MemberExtensions.isFinal import com.yifeplayte.wommo.hook.hooks.BaseHook @@ -9,10 +9,12 @@ import com.yifeplayte.wommo.hook.utils.DexKit.dexKitBridge object ModifyScreenRecorderConfig : BaseHook() { override val key = "modify_screen_recorder_config" override fun hook() { - dexKitBridge.findMethodUsingString { - usingString = "Error when set frame value, maxValue = " - methodParamTypes = arrayOf("I", "I") - }.firstOrNull()?.getMethodInstance(EzXHelper.safeClassLoader)?.createHook { + dexKitBridge.findMethod { + matcher { + usingStrings = listOf("Error when set frame value, maxValue = ") + paramTypes = listOf("I", "I") + } + }.firstOrNull()?.getMethodInstance(safeClassLoader)?.createHook { before { param -> param.args[0] = 3600 param.args[1] = 1 @@ -29,13 +31,13 @@ object ModifyScreenRecorderConfig : BaseHook() { }?.set(null, intArrayOf(15, 24, 30, 48, 60, 90, 120, 144)) } } - dexKitBridge.findMethodUsingString { - usingString = "defaultBitRate = " - }.map { - it.getMethodInstance(EzXHelper.safeClassLoader) - }.firstOrNull { - it.parameterCount == 2 && it.parameterTypes[0] == Int::class.java && it.parameterTypes[1] == Int::class.java - }?.createHook { + dexKitBridge.findMethod { + matcher { + usingStrings = listOf("defaultBitRate = ") + paramCount = 2 + paramTypes = listOf("int", "int") + } + }.firstOrNull()?.getMethodInstance(safeClassLoader)?.createHook { before { param -> param.args[0] = 3600 param.args[1] = 1 @@ -45,11 +47,18 @@ object ModifyScreenRecorderConfig : BaseHook() { }.let { fieldAccessible -> fieldAccessible.isFinal && fieldAccessible.get(null).let { kotlin.runCatching { - (it as IntArray).contentEquals(intArrayOf(200, 100, 50, 32, 24, 16, 8, 6, 4, 1)) + (it as IntArray).contentEquals( + intArrayOf( + 200, 100, 50, 32, 24, 16, 8, 6, 4, 1 + ) + ) }.getOrDefault(false) } } - }?.set(null, intArrayOf(3600, 2400, 1200, 800, 400, 200, 100, 50, 32, 24, 16, 8, 6, 4, 1)) + }?.set( + null, + intArrayOf(3600, 2400, 1200, 800, 400, 200, 100, 50, 32, 24, 16, 8, 6, 4, 1) + ) } } } diff --git a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/securitycenter/RemoveAdbInstallIntercept.kt b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/securitycenter/RemoveAdbInstallIntercept.kt index ee55019..cc1f8c9 100644 --- a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/securitycenter/RemoveAdbInstallIntercept.kt +++ b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/securitycenter/RemoveAdbInstallIntercept.kt @@ -8,9 +8,11 @@ import com.yifeplayte.wommo.hook.utils.DexKit.dexKitBridge object RemoveAdbInstallIntercept : BaseHook() { override val key = "remove_adb_install_intercept" override fun hook() { - dexKitBridge.findMethodUsingString { - usingString = "permcenter_install_intercept_enabled" - methodReturnType = "boolean" + dexKitBridge.findMethod { + matcher { + usingStrings = listOf("permcenter_install_intercept_enabled") + returnType = "boolean" + } }.first().getMethodInstance(safeClassLoader).createHook { returnConstant(false) } diff --git a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/securitycenter/RemoveReportInApplicationInfo.kt b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/securitycenter/RemoveReportInApplicationInfo.kt index 1396a64..c99e47f 100644 --- a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/securitycenter/RemoveReportInApplicationInfo.kt +++ b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/securitycenter/RemoveReportInApplicationInfo.kt @@ -8,9 +8,11 @@ import com.yifeplayte.wommo.hook.utils.DexKit.dexKitBridge object RemoveReportInApplicationInfo : BaseHook() { override val key = "remove_report_in_application_info" override fun hook() { - dexKitBridge.findMethodUsingString { - usingString = "com.xiaomi.market" - methodDeclareClass = "com.miui.appmanager.ApplicationsDetailsActivity" + dexKitBridge.findMethod { + matcher { + usingStrings = listOf("com.xiaomi.market") + declaredClass = "com.miui.appmanager.ApplicationsDetailsActivity" + } }.firstOrNull()?.getMethodInstance(safeClassLoader)?.createHook { returnConstant(false) } diff --git a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/voiceassist/ChangeBrowserForMiAi.kt b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/voiceassist/ChangeBrowserForMiAi.kt index 5a12c7f..d21b9eb 100644 --- a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/voiceassist/ChangeBrowserForMiAi.kt +++ b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/singlepackage/voiceassist/ChangeBrowserForMiAi.kt @@ -9,9 +9,11 @@ import com.yifeplayte.wommo.hook.utils.DexKit.dexKitBridge object ChangeBrowserForMiAi : BaseHook() { override val key = "change_browser_for_mi_ai" override fun hook() { - dexKitBridge.findMethodUsingString { - usingString = "addBackForUri intent is null" - methodReturnType = "Landroid/content/Intent;" + dexKitBridge.findMethod { + matcher{ + usingStrings = listOf("addBackForUri intent is null") + returnType = "Landroid/content/Intent;" + } }.map { it.getMethodInstance(safeClassLoader) }.createHooks { after { val intent = it.result as Intent diff --git a/app/src/main/java/com/yifeplayte/wommo/hook/utils/DexKit.kt b/app/src/main/java/com/yifeplayte/wommo/hook/utils/DexKit.kt index f1efb37..fd6955a 100644 --- a/app/src/main/java/com/yifeplayte/wommo/hook/utils/DexKit.kt +++ b/app/src/main/java/com/yifeplayte/wommo/hook/utils/DexKit.kt @@ -1,7 +1,7 @@ package com.yifeplayte.wommo.hook.utils import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam -import io.luckypray.dexkit.DexKitBridge +import org.luckypray.dexkit.DexKitBridge /** * DexKit 工具