Commit c5b4c704 authored by swift_gan's avatar swift_gan

fix offset

parent 3cace0f8
...@@ -58,10 +58,10 @@ namespace SandHook { ...@@ -58,10 +58,10 @@ namespace SandHook {
class CastEntryPointQuickCompiled : public IMember<art::mirror::ArtMethod, void*> { class CastEntryPointQuickCompiled : public IMember<art::mirror::ArtMethod, void*> {
protected: protected:
Size calOffset(JNIEnv *jniEnv, art::mirror::ArtMethod* p) override { Size calOffset(JNIEnv *jniEnv, art::mirror::ArtMethod* p) override {
if (SDK_INT >= ANDROID_L2) { if (SDK_INT >= ANDROID_M) {
return getParentSize() - BYTE_POINT; return getParentSize() - BYTE_POINT;
} else { } else {
return getParentSize() - 8 * 2 - 4 * 4; return getParentSize() - 4 - 2 * BYTE_POINT;
} }
} }
}; };
...@@ -86,10 +86,17 @@ namespace SandHook { ...@@ -86,10 +86,17 @@ namespace SandHook {
accessFlag = 524313; accessFlag = 524313;
} }
int offset = findOffset(p, getParentSize(), 2, accessFlag); int offset = findOffset(p, getParentSize(), 2, accessFlag);
if (offset < 0) if (offset < 0) {
return getParentSize() + 1; if (SDK_INT == ANDROID_L2) {
else return 20;
} else if (SDK_INT == ANDROID_L) {
return 56;
} else {
return getParentSize() + 1;
}
} else {
return static_cast<size_t>(offset); return static_cast<size_t>(offset);
}
} }
}; };
...@@ -132,13 +139,7 @@ namespace SandHook { ...@@ -132,13 +139,7 @@ namespace SandHook {
Size artMethod1 = (Size) env->GetStaticMethodID(sizeTestClass, "method1", "()V"); Size artMethod1 = (Size) env->GetStaticMethodID(sizeTestClass, "method1", "()V");
Size artMethod2 = (Size) env->GetStaticMethodID(sizeTestClass, "method2", "()V"); Size artMethod2 = (Size) env->GetStaticMethodID(sizeTestClass, "method2", "()V");
if (sdk == ANDROID_L2) { size = artMethod2 - artMethod1;
size = 64;
} else if (sdk == ANDROID_L) {
size = 72;
} else {
size = artMethod2 - artMethod1;
}
art::mirror::ArtMethod* m1 = reinterpret_cast<art::mirror::ArtMethod *>(artMethod1); art::mirror::ArtMethod* m1 = reinterpret_cast<art::mirror::ArtMethod *>(artMethod1);
art::mirror::ArtMethod* m2 = reinterpret_cast<art::mirror::ArtMethod *>(artMethod2); art::mirror::ArtMethod* m2 = reinterpret_cast<art::mirror::ArtMethod *>(artMethod2);
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include <jni.h> #include <jni.h>
#include "arch.h" #include "arch.h"
#include "utils.h" #include "utils.h"
#include "../casts/art/art.h"
#define ANDROID_K 19
#define ANDROID_L 21 #define ANDROID_L 21
#define ANDROID_L2 22 #define ANDROID_L2 22
#define ANDROID_M 23 #define ANDROID_M 23
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment