diff options
author | comex | 2015-01-24 22:45:15 -0500 |
---|---|---|
committer | comex | 2015-01-24 22:45:40 -0500 |
commit | 6237f5fdcb39aa8b692ec8c7623aecddf0c2fd30 (patch) | |
tree | cd59362c292b42fac04ae676eca48e5296ca0de1 | |
parent | it compiles... (diff) | |
download | substitute-6237f5fdcb39aa8b692ec8c7623aecddf0c2fd30.tar.gz |
fixes
Diffstat (limited to '')
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | lib/hook-functions.c | 11 |
2 files changed, 8 insertions, 4 deletions
@@ -102,6 +102,7 @@ $(eval $(call define_test,interpose,interpose,$(CC) -std=c11 -lsubstitute)) $(eval $(call define_test,inject,inject,$(CC) -std=c11 -lsubstitute out/darwin/inject.o out/darwin/read.o)) $(eval $(call define_test,stop-threads,stop-threads,$(CC) -std=c11 out/darwin/stop-other-threads.o -framework CoreFoundation)) $(eval $(call define_test,execmem,execmem,$(CC) -std=c11 out/darwin/execmem.o -segprot __TEST rwx rx)) +$(eval $(call define_test,hook-functions,hook-functions,$(CC) -std=c11 -lsubstitute)) out/insns-arm.o: test/insns-arm.S Makefile clang -arch armv7 -c -o $@ $< diff --git a/lib/hook-functions.c b/lib/hook-functions.c index 5a502c8..38d2a80 100644 --- a/lib/hook-functions.c +++ b/lib/hook-functions.c @@ -163,9 +163,9 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks, uintptr_t initial_target; if (need_intro_trampoline) { + initial_target = (uintptr_t) trampoline_ptr; make_jump_patch(&trampoline_ptr, (uintptr_t) trampoline_ptr, (uintptr_t) hook->replacement, arch); - initial_target = (uintptr_t) trampoline_ptr; } else { initial_target = (uintptr_t) hook->replacement; } @@ -196,6 +196,7 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks, if ((ret = execmem_alloc_unsealed(0, &trampoline_ptr, &trampoline_size_left))) goto end; + hi->trampoline_page = trampoline_ptr; jumpback_size = jump_patch_size((uintptr_t) trampoline_ptr + rewritten_size, pc_patch_end, arch, /* force */ true); @@ -203,14 +204,16 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks, } hi->outro_trampoline = trampoline_ptr; + uintptr_t dpc = pc_patch_end; #ifdef __arm__ - if (arch.pc_low_bit) + if (arch.pc_low_bit) { hi->outro_trampoline++; + dpc++; + } #endif memcpy(trampoline_ptr, rewritten_temp, rewritten_size); trampoline_ptr += rewritten_size; - make_jump_patch(&trampoline_ptr, (uintptr_t) trampoline_ptr, pc_patch_end, - arch); + make_jump_patch(&trampoline_ptr, (uintptr_t) trampoline_ptr, dpc, arch); trampoline_size_left -= outro_size; } |