Add resources hooking support for MIUI

This commit is contained in:
solohsu 2019-04-30 00:24:44 +08:00
parent 7d5a72b683
commit aba57dc40f
4 changed files with 28 additions and 2 deletions

View File

@ -26,7 +26,22 @@ public class InlinedMethodCallers {
*/
private static final String[][] BOOT_IMAGE = {
// callers of Application#attach(Context)
{"android.app.Instrumentation", "newApplication", "(Ljava/lang/ClassLoader;Ljava/lang/String;Landroid/content/Context;)Landroid/app/Application;"}
{"android.app.Instrumentation", "newApplication", "(Ljava/lang/ClassLoader;Ljava/lang/String;Landroid/content/Context;)Landroid/app/Application;"},
// for MIUI resources hooking
{"android.content.res.MiuiResources", "init", "(Ljava/lang/String;)V"},
{"android.content.res.MiuiResources", "updateMiuiImpl", "()V"},
{"android.content.res.MiuiResources", "setImpl", "(Landroid/content/res/ResourcesImpl;)V"},
{"android.content.res.MiuiResources", "loadOverlayValue", "(Landroid/util/TypedValue;I)V"},
{"android.content.res.MiuiResources", "getThemeString", "(I)Ljava/lang/CharSequence;"},
{"android.content.res.MiuiResources", "<init>", "(Ljava/lang/ClassLoader;)V"},
{"android.content.res.MiuiResources", "<init>", "()V"},
{"android.content.res.MiuiResources", "<init>", "(Landroid/content/res/AssetManager;Landroid/util/DisplayMetrics;Landroid/content/res/Configuration;)V"},
{"android.miui.ResourcesManager", "initMiuiResource", "(Landroid/content/res/Resources;Ljava/lang/String;)V"},
{"android.app.LoadedApk", "getResources", "()Landroid/content/res/Resources;"},
{"android.content.res.Resources", "getSystem", "()Landroid/content/res/Resources;"},
{"android.app.ApplicationPackageManager", "getResourcesForApplication", "(Landroid/content/pm/ApplicationInfo;)Landroid/content/res/Resources;"},
{"android.app.ContextImpl", "setResources", "(Landroid/content/res/Resources;)V"},
};
private static final String[][] SYSTEM_SERVER = {};

View File

@ -19,8 +19,12 @@ public class PrebuiltMethodsDeopter {
}
for (String[] caller : callers) {
try {
Class clazz = XposedHelpers.findClassIfExists(caller[0], cl);
if (clazz == null) {
continue;
}
Object method = EdXpConfigGlobal.getHookProvider().findMethodNative(
XposedHelpers.findClass(caller[0], cl), caller[1], caller[2]);
clazz, caller[1], caller[2]);
if (method != null) {
EdXpConfigGlobal.getHookProvider().deoptMethodNative(method);
}

View File

@ -59,6 +59,13 @@ static bool onIsInSamePackageCalled(void *thiz, void *that) {
|| strstr(thatDesc, "com/elderdrivers/riru/") != nullptr) {
return true;
}
// for MIUI resources hooking
if (strstr(thisDesc, "android/content/res/MiuiTypedArray") != nullptr
|| strstr(thatDesc, "android/content/res/MiuiTypedArray") != nullptr
|| strstr(thisDesc, "android/content/res/XResources$XTypedArray") != nullptr
|| strstr(thatDesc, "android/content/res/XResources$XTypedArray") != nullptr) {
return true;
}
return (*isInSamePackageBackup)(thiz, that);
}