Commit cef1dcc7 authored by swift_gan's avatar swift_gan

start impl arm32

parent 7a8cde98
...@@ -2,27 +2,40 @@ ...@@ -2,27 +2,40 @@
#if defined(__arm__) #if defined(__arm__)
#define Reg0 r12
//need restore
#define Reg1 x11
#define RegMethod r0
FUNCTION_START(REPLACEMENT_HOOK_TRAMPOLINE) FUNCTION_START(REPLACEMENT_HOOK_TRAMPOLINE)
ldr r0, addr_art_method ldr RegMethod, addr_art_method
ldr r12, offset_entry_code ldr Reg0, offset_entry_code
add r12, r0, r12 add Reg0, RegMethod, Reg0
ldr pc, [r12] ldr pc, [Reg0]
addr_art_method: addr_art_method:
.long 0 .long 0
offset_entry_code: offset_entry_code:
.long 0 .long 0
FUNCTION_END(REPLACEMENT_HOOK_TRAMPOLINE) FUNCTION_END(REPLACEMENT_HOOK_TRAMPOLINE)
#define SIZE_JUMP 0x8
FUNCTION_START(DIRECT_JUMP_TRAMPOLINE) FUNCTION_START(DIRECT_JUMP_TRAMPOLINE)
ldr pc, addr_target ldr pc, addr_target
addr_target: addr_target:
.long 0 .long 0
FUNCTION_END(DIRECT_JUMP_TRAMPOLINE) FUNCTION_END(DIRECT_JUMP_TRAMPOLINE)
FUNCTION_START(INLINE_HOOK_TRAMPOLINE) FUNCTION_START(INLINE_HOOK_TRAMPOLINE)
FUNCTION_END(INLINE_HOOK_TRAMPOLINE) FUNCTION_END(INLINE_HOOK_TRAMPOLINE)
FUNCTION_START(CALL_ORIGIN_TRAMPOLINE) FUNCTION_START(CALL_ORIGIN_TRAMPOLINE)
FUNCTION_END(CALL_ORIGIN_TRAMPOLINE) FUNCTION_END(CALL_ORIGIN_TRAMPOLINE)
#endif #endif
\ No newline at end of file
package com.swift.sandhook.wrapper; package com.swift.sandhook;
import android.util.Log; import android.util.Log;
import com.swift.sandhook.wrapper.HookClass;
import com.swift.sandhook.wrapper.HookMethod;
import com.swift.sandhook.wrapper.HookMethodBackup;
import com.swift.sandhook.wrapper.MethodParams;
@HookClass(Log.class) @HookClass(Log.class)
public class LogHooker { public class LogHooker {
......
...@@ -3,14 +3,13 @@ package com.swift.sandhook; ...@@ -3,14 +3,13 @@ package com.swift.sandhook;
import android.app.Application; import android.app.Application;
import com.swift.sandhook.wrapper.HookErrorException; import com.swift.sandhook.wrapper.HookErrorException;
import com.swift.sandhook.wrapper.LogHooker;
public class MyApp extends Application { public class MyApp extends Application {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
try { try {
SandHook.addHookClass(LogHooker.class, ActivityHooker.class); SandHook.addHookClass(LogHooker.class, ActivityHooker.class, ObjectHooker.class);
} catch (HookErrorException e) { } catch (HookErrorException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
package com.swift.sandhook;
import android.util.Log;
import com.swift.sandhook.wrapper.HookClass;
import com.swift.sandhook.wrapper.HookMethod;
import com.swift.sandhook.wrapper.HookMethodBackup;
@HookClass(Object.class)
public class ObjectHooker {
@HookMethod("toString")
public static String toStr(Object thiz) {
Log.e("ObjectHooker", "hooked success ");
return toStrBackup(thiz);
}
@HookMethodBackup("toString")
public static String toStrBackup(Object thiz) {
return null;
}
}
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