diff options
author | comex | 2015-02-22 22:03:10 -0500 |
---|---|---|
committer | comex | 2015-02-23 00:54:02 -0500 |
commit | b258239d9674ebae73868eeaeb4b674ca14270f0 (patch) | |
tree | 94bb0fec594cd851c8d3d592ee2a4e8f4f84b4e1 /lib/darwin/inject-asm-raw.c | |
parent | various fixes (diff) | |
download | substitute-b258239d9674ebae73868eeaeb4b674ca14270f0.tar.gz |
Redo manual syscalls, and use them for hooking.. And fix mmap, which now makes the whole thing slightly broken, because vm_remap into the middle of the shared region apparently silently does nothing.
Diffstat (limited to 'lib/darwin/inject-asm-raw.c')
-rw-r--r-- | lib/darwin/inject-asm-raw.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/darwin/inject-asm-raw.c b/lib/darwin/inject-asm-raw.c index ca316f1..55dab5f 100644 --- a/lib/darwin/inject-asm-raw.c +++ b/lib/darwin/inject-asm-raw.c @@ -1,3 +1,5 @@ +#define WANT_BSDTHREAD_TERMINATE +#define WANT_SEMAPHORE_WAIT_TRAP #include "darwin/manual-syscall.h" #ifdef __arm64__ @@ -6,6 +8,11 @@ #define _PAGE_SIZE 0x1000 #endif +int manual_bsdthread_terminate(void *, unsigned long, unsigned, unsigned); +GEN_SYSCALL(bsdthread_terminate, 361); +int manual_semaphore_wait_trap(int); +GEN_SYSCALL(semaphore_wait_trap, -36); + /* This is somewhat more complicated than it has to be because it does not use * pthread_join, which depends on pthread_self, which would need to be * initialized manually; the format of this has changed in the past, and could @@ -31,7 +38,7 @@ void entry(struct baton *baton) { int pt = 0; baton->pthread_create(&pt, 0, (void *) bsd_thread_func, baton); baton->pthread_detach(pt); - manual_syscall(361 /* bsdthread_terminate */, 0, 0, 0, baton->sem_port); + manual_bsdthread_terminate(0, 0, 0, baton->sem_port); ((void (*)()) 0xbad)(); } static int bsd_thread_func(void *arg) { @@ -45,7 +52,7 @@ static int bsd_thread_func(void *arg) { init(baton->shuttle, baton->nshuttle); } - manual_syscall(-36 /* semaphore_wait_trap */, baton->sem_port, 0, 0, 0); + manual_semaphore_wait_trap(baton->sem_port); #ifndef __i386__ /* since we're munmapping our own code, this must be optimized into a jump * (taill call elimination) */ @@ -61,8 +68,7 @@ static int bsd_thread_func(void *arg) { } #ifdef __i386__ /* yuck */ -asm("jmp _entry;" - ".globl _jump_to_munmap;" +asm(".globl _jump_to_munmap;" "_jump_to_munmap:" "push %ebp;" "mov %esp, %ebp;" |