diff --git a/xposed.cpp b/xposed.cpp index 5ecb7d816..a044a763a 100644 --- a/xposed.cpp +++ b/xposed.cpp @@ -118,6 +118,17 @@ bool xposedDisableSafemode() { return false; } +static int xposedReadIntConfig(const char* fileName, int defaultValue) { + FILE *fp = fopen(fileName, "r"); + if (fp == NULL) + return defaultValue; + + int result; + int success = fscanf(fp, "%i", &result); + fclose(fp); + + return (success >= 1) ? result : defaultValue; +} // ignore the broadcasts by various Superuser implementations to avoid spamming the Xposed log bool xposedShouldIgnoreCommand(const char* className, int argc, const char* const argv[]) { @@ -246,6 +257,12 @@ static bool xposedInitMemberOffsets(JNIEnv* env) { MEMBER_OFFSET_COPY(DvmJitGlobals, codeCacheFull); + int overrideCodeCacheFull = xposedReadIntConfig(XPOSED_OVERRIDE_JIT_RESET_OFFSET, -1); + if (overrideCodeCacheFull > 0 && overrideCodeCacheFull < 0x400) { + ALOGI("Offset for DvmJitGlobals.codeCacheFull is overridden, new value is 0x%x", overrideCodeCacheFull); + MEMBER_OFFSET_VAR(DvmJitGlobals, codeCacheFull) = overrideCodeCacheFull; + } + // detect offset of ArrayObject->contents jintArray dummyArray = env->NewIntArray(1); if (dummyArray == NULL) { @@ -489,7 +506,12 @@ static void de_robv_android_xposed_XposedBridge_hookMethodNative(JNIEnv* env, jc if (PTR_gDvmJit != NULL) { // reset JIT cache - MEMBER_VAL(PTR_gDvmJit, DvmJitGlobals, codeCacheFull) = true; + char currentValue = *((char*)PTR_gDvmJit + MEMBER_OFFSET_VAR(DvmJitGlobals,codeCacheFull)); + if (currentValue == 0 || currentValue == 1) { + MEMBER_VAL(PTR_gDvmJit, DvmJitGlobals, codeCacheFull) = true; + } else { + ALOGE("Unexpected current value for codeCacheFull: %d", currentValue); + } } } diff --git a/xposed.h b/xposed.h index c9ccd43ad..cba249dd6 100644 --- a/xposed.h +++ b/xposed.h @@ -14,6 +14,7 @@ namespace android { #define XPOSED_ENABLE_FOR_TOOLS XPOSED_DIR "conf/enable_for_tools" #define XPOSED_SAFEMODE_NODELAY XPOSED_DIR "conf/safemode_nodelay" #define XPOSED_SAFEMODE_DISABLE XPOSED_DIR "conf/safemode_disable" +#define XPOSED_OVERRIDE_JIT_RESET_OFFSET XPOSED_DIR "conf/jit_reset_offset" #define XPOSED_CLASS "de/robv/android/xposed/XposedBridge" #define XPOSED_CLASS_DOTS "de.robv.android.xposed.XposedBridge" @@ -21,7 +22,7 @@ namespace android { #define MIUI_RESOURCES_CLASS "android/content/res/MiuiResources" #define XTYPEDARRAY_CLASS "android/content/res/XResources$XTypedArray" -#define XPOSED_VERSION "56" +#define XPOSED_VERSION "57" #ifndef ALOGD #define ALOGD LOGD @@ -51,6 +52,7 @@ void disableXposed(); bool isXposedDisabled(); bool xposedSkipSafemodeDelay(); bool xposedDisableSafemode(); +static int xposedReadIntConfig(const char* fileName, int defaultValue); bool xposedShouldIgnoreCommand(const char* className, int argc, const char* const argv[]); bool addXposedToClasspath(bool zygote); static void xposedPrepareSubclassReplacement(jclass clazz);