Commit da81d7bd authored by swift_gan's avatar swift_gan

fix 5.1 thumb

parent c5b4c704
...@@ -99,10 +99,10 @@ bool doHookWithInline(JNIEnv* env, ...@@ -99,10 +99,10 @@ bool doHookWithInline(JNIEnv* env,
SandHook::HookTrampoline* hookTrampoline = trampolineManager.installInlineTrampoline(originMethod, hookMethod, backupMethod); SandHook::HookTrampoline* hookTrampoline = trampolineManager.installInlineTrampoline(originMethod, hookMethod, backupMethod);
if (hookTrampoline == nullptr) if (hookTrampoline == nullptr)
return false; return false;
void* entryPointFormInterpreter = SandHook::CastArtMethod::entryPointFormInterpreter->get(hookMethod); // void* entryPointFormInterpreter = SandHook::CastArtMethod::entryPointFormInterpreter->get(hookMethod);
if (entryPointFormInterpreter != NULL) { // if (entryPointFormInterpreter != NULL) {
SandHook::CastArtMethod::entryPointFormInterpreter->set(originMethod, entryPointFormInterpreter); // SandHook::CastArtMethod::entryPointFormInterpreter->set(originMethod, entryPointFormInterpreter);
} // }
hookTrampoline->inlineSecondory->flushCache(reinterpret_cast<Size>(hookMethod), SandHook::CastArtMethod::size); hookTrampoline->inlineSecondory->flushCache(reinterpret_cast<Size>(hookMethod), SandHook::CastArtMethod::size);
if (hookTrampoline->callOrigin != nullptr) { if (hookTrampoline->callOrigin != nullptr) {
//backup //backup
......
...@@ -64,7 +64,7 @@ namespace SandHook { ...@@ -64,7 +64,7 @@ namespace SandHook {
} }
bool isThumbCode(Size codeAddr) { bool isThumbCode(Size codeAddr) {
return (codeAddr & (Size)1) == (Size)1; return (codeAddr & 0x1) == 0x1;
} }
void checkThumbCode(Trampoline* trampoline, Code code) { void checkThumbCode(Trampoline* trampoline, Code code) {
......
...@@ -76,6 +76,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -76,6 +76,7 @@ public class MainActivity extends AppCompatActivity {
public static int methodBeHooked(int a, int b) { public static int methodBeHooked(int a, int b) {
a = a + 1 + 2; a = a + 1 + 2;
b = b + a + 3; b = b + a + 3;
Log.e("MainActivity", "methodBeHooked called");
return a + b; return a + b;
} }
......
...@@ -5,6 +5,7 @@ import android.util.Log; ...@@ -5,6 +5,7 @@ import android.util.Log;
import com.swift.sandhook.MainActivity; import com.swift.sandhook.MainActivity;
import com.swift.sandhook.wrapper.HookClass; import com.swift.sandhook.wrapper.HookClass;
import com.swift.sandhook.wrapper.HookMethod; import com.swift.sandhook.wrapper.HookMethod;
import com.swift.sandhook.wrapper.HookMethodBackup;
import com.swift.sandhook.wrapper.MethodParams; import com.swift.sandhook.wrapper.MethodParams;
@HookClass(MainActivity.class) @HookClass(MainActivity.class)
...@@ -14,6 +15,12 @@ public class CustmizeHooker { ...@@ -14,6 +15,12 @@ public class CustmizeHooker {
@MethodParams({int.class, int.class}) @MethodParams({int.class, int.class})
public static int staticMethodHooked(int a, int b) { public static int staticMethodHooked(int a, int b) {
Log.e("CustmizeHooker", "methodBeHooked be hooked"); Log.e("CustmizeHooker", "methodBeHooked be hooked");
return staticMethodHookedBackup(a, b);
}
@HookMethodBackup("methodBeHooked")
@MethodParams({int.class, int.class})
public static int staticMethodHookedBackup(int a, int b) {
return 0; return 0;
} }
......
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