Skip to content

Commit

Permalink
Update dexkit
Browse files Browse the repository at this point in the history
  • Loading branch information
YifePlayte committed Nov 2, 2023
1 parent b4636a2 commit 3a61c5e
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 53 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
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

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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 工具
Expand Down

0 comments on commit 3a61c5e

Please sign in to comment.