Commit 790083c1 authored by swift_gan's avatar swift_gan

done arm32 compat

parent c2bf39ef
...@@ -100,7 +100,7 @@ origin_code_t: ...@@ -100,7 +100,7 @@ origin_code_t:
//4 byte //4 byte
ldr RegT, [RegT] ldr RegT, [RegT]
//4 byte //4 byte
add RegT, RegT, #8 add RegT, RegT, SIZE_JUMP
//2 byte //2 byte
mov pc, RegT mov pc, RegT
nop nop
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#define SIZE_INLINE_HOOK_TRAMPOLINE 4 * 17 #define SIZE_INLINE_HOOK_TRAMPOLINE 4 * 17
#define OFFSET_INLINE_ORIGIN_CODE 4 * 7 #define OFFSET_INLINE_ORIGIN_CODE 4 * 7
#define OFFSET_INLINE_OP_OFFSET_CODE 4 * 10 #define OFFSET_INLINE_OP_OFFSET_CODE 4 * 10
#define OFFSET_INLINE_OP_ORIGIN_OFFSET_CODE 4 * 12
#define OFFSET_INLINE_ADDR_ORIGIN_METHOD 4 * 14 #define OFFSET_INLINE_ADDR_ORIGIN_METHOD 4 * 14
#define OFFSET_INLINE_OFFSET_ENTRY_CODE 4 * 15 #define OFFSET_INLINE_OFFSET_ENTRY_CODE 4 * 15
#define OFFSET_INLINE_ADDR_HOOK_METHOD 4 * 16 #define OFFSET_INLINE_ADDR_HOOK_METHOD 4 * 16
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Created by swift on 2019/1/20. // Created by swift on 2019/1/20.
// //
#include "trampoline_manager.h" #include "trampoline_manager.h"
#include "trampoline.h"
namespace SandHook { namespace SandHook {
...@@ -103,7 +104,8 @@ namespace SandHook { ...@@ -103,7 +104,8 @@ namespace SandHook {
} }
if (directJumpTrampoline->isThumCode()) { if (directJumpTrampoline->isThumCode()) {
directJumpTrampoline->setExecuteSpace(directJumpTrampoline->getThumbCodeAddress(originEntry)); originEntry = directJumpTrampoline->getThumbCodeAddress(originEntry);
directJumpTrampoline->setExecuteSpace(originEntry);
directJumpTrampoline->setJumpTarget(directJumpTrampoline->getThumbCodePcAddress(inlineHookTrampoline->getCode())); directJumpTrampoline->setJumpTarget(directJumpTrampoline->getThumbCodePcAddress(inlineHookTrampoline->getCode()));
} else { } else {
directJumpTrampoline->setExecuteSpace(originEntry); directJumpTrampoline->setExecuteSpace(originEntry);
...@@ -124,6 +126,16 @@ namespace SandHook { ...@@ -124,6 +126,16 @@ namespace SandHook {
Code originCode = nullptr; Code originCode = nullptr;
if (callOriginTrampoline->isThumCode()) { if (callOriginTrampoline->isThumCode()) {
originCode = callOriginTrampoline->getThumbCodePcAddress(inlineHookTrampoline->getCallOriginCode()); originCode = callOriginTrampoline->getThumbCodePcAddress(inlineHookTrampoline->getCallOriginCode());
#if defined(__arm__)
Code originRemCode = callOriginTrampoline->getThumbCodePcAddress(originEntry + directJumpTrampoline->getCodeLen());
Size offset = originRemCode - getEntryCode(originMethod);
if (offset != directJumpTrampoline->getCodeLen()) {
Code32Bit offset32;
offset32.code = offset;
unsigned char offsetOP = callOriginTrampoline->isBigEnd() ? offset32.op.op2 : offset32.op.op1;
callOriginTrampoline->tweakOpImm(OFFSET_INLINE_OP_ORIGIN_OFFSET_CODE, offsetOP);
}
#endif
} else { } else {
originCode = inlineHookTrampoline->getCallOriginCode(); originCode = inlineHookTrampoline->getCallOriginCode();
} }
......
...@@ -9,7 +9,7 @@ public class MyApp extends Application { ...@@ -9,7 +9,7 @@ public class MyApp extends Application {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
try { try {
SandHook.addHookClass(LogHooker.class, ActivityHooker.class, ObjectHooker.class); SandHook.addHookClass(ActivityHooker.class, ObjectHooker.class);
} catch (HookErrorException e) { } catch (HookErrorException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
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