Skip to content

Commit

Permalink
v39: Copy more bytes for the backup of the original method
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rovo89 committed Sep 11, 2013
1 parent 24692c7 commit 2ca3823
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions xposed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jmethodID xposedHandleHookedMethod = NULL;
jclass xresourcesClass = NULL;
jmethodID xresourcesTranslateResId = NULL;
jmethodID xresourcesTranslateAttrId = NULL;
std::list<Method> xposedOriginalMethods;
std::list<MethodXposedExt> xposedOriginalMethods;
const char* startClassName = NULL;
void* PTR_gDvmJit = NULL;

Expand Down Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions xposed.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#include "Dalvik.h"
#include <list>

// 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/"
Expand All @@ -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
Expand All @@ -24,7 +30,7 @@ namespace android {
#endif

extern bool keepLoadingXposed;
typedef std::list<Method>::iterator XposedOriginalMethodsIt;
typedef std::list<MethodXposedExt>::iterator XposedOriginalMethodsIt;

// called directoy by app_process
void xposedInfo();
Expand Down

0 comments on commit 2ca3823

Please sign in to comment.