From 2ca382367d979fee24327ae67741685164948759 Mon Sep 17 00:00:00 2001 From: rovo89 Date: Wed, 11 Sep 2013 22:27:50 +0200 Subject: [PATCH] v39: Copy more bytes for the backup of the original method Xposed caused strange effects on the Genymotion emulator. I tracked this down to an additional attribute they had added to the Method structure. As the size of the structure is determined at compile time, this attribute wasn't stored in the list of original methods. Therefore its value was undefined during the invokation. Now 16 additional bytes are copied for each method that is hooked. That should be enough, such modifications are very rare. --- xposed.cpp | 4 ++-- xposed.h | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/xposed.cpp b/xposed.cpp index 4a040f89e..15bb0a882 100644 --- a/xposed.cpp +++ b/xposed.cpp @@ -36,7 +36,7 @@ jmethodID xposedHandleHookedMethod = NULL; jclass xresourcesClass = NULL; jmethodID xresourcesTranslateResId = NULL; jmethodID xresourcesTranslateAttrId = NULL; -std::list xposedOriginalMethods; +std::list xposedOriginalMethods; const char* startClassName = NULL; void* PTR_gDvmJit = NULL; @@ -424,7 +424,7 @@ static void de_robv_android_xposed_XposedBridge_hookMethodNative(JNIEnv* env, jc } // Save a copy of the original method - xposedOriginalMethods.push_front(*method); + xposedOriginalMethods.push_front(*((MethodXposedExt*)method)); // Replace method with our own code SET_METHOD_FLAG(method, ACC_NATIVE); diff --git a/xposed.h b/xposed.h index 3edb3716c..39f37e115 100644 --- a/xposed.h +++ b/xposed.h @@ -5,6 +5,12 @@ #include "Dalvik.h" #include +// copy a few bytes more than defined for Method in AOSP +// to accomodate for (rare) extensions by the target ROM +struct MethodXposedExt : Method { + int dummyForRomExtensions[4]; +}; + namespace android { #define XPOSED_DIR "/data/xposed/" @@ -14,7 +20,7 @@ namespace android { #define XPOSED_CLASS "de/robv/android/xposed/XposedBridge" #define XPOSED_CLASS_DOTS "de.robv.android.xposed.XposedBridge" #define XRESOURCES_CLASS "android/content/res/XResources" -#define XPOSED_VERSION "38" +#define XPOSED_VERSION "39" #ifndef ALOGD #define ALOGD LOGD @@ -24,7 +30,7 @@ namespace android { #endif extern bool keepLoadingXposed; -typedef std::list::iterator XposedOriginalMethodsIt; +typedef std::list::iterator XposedOriginalMethodsIt; // called directoy by app_process void xposedInfo();