diff --git a/lib/crt0.nro.S b/lib/crt0.nro.S index 191ce08f..cfe5004b 100644 --- a/lib/crt0.nro.S +++ b/lib/crt0.nro.S @@ -41,7 +41,7 @@ _mod_header: start: sub sp, sp, 0x10 stp x29, x30, [sp] - adrp x1, _start // aslr base + adrp x3, _start // aslr base bl _libtransistor_start ldp x29, x30, [sp], 0x10 ret diff --git a/lib/crt0.nso.S b/lib/crt0.nso.S index 8bfef284..044379c1 100644 --- a/lib/crt0.nso.S +++ b/lib/crt0.nso.S @@ -37,7 +37,7 @@ _mod_header: .section .text, "e" start: - adrp x1, _start // aslr base + adrp x3, _start // aslr base bl _libtransistor_start loop: b loop diff --git a/lib/crt0_common.c b/lib/crt0_common.c index c40d04ef..1cfa574a 100644 --- a/lib/crt0_common.c +++ b/lib/crt0_common.c @@ -158,12 +158,17 @@ static int bsslog_write(struct _reent *reent, void *v, const char *ptr, int len) static jmp_buf exit_jmpbuf; static int exit_value; +static thread_h MAIN_HANDLE; -int _libtransistor_start(libtransistor_context_t *ctx, void *aslr_base) { +int _libtransistor_start(void *exception_info_ptr, thread_h main_handle, libtransistor_context_t *ctx, void *aslr_base) { if(relocate(aslr_base)) { return -4; } + MAIN_HANDLE = main_handle; + + dbg_printf("exception_ptr: %x", exception_info_ptr); + dbg_printf("main handle: %x", main_handle); dbg_printf("aslr base: %p", aslr_base); dbg_printf("ctx: %p", ctx); diff --git a/projects/ace_loader/nro.c b/projects/ace_loader/nro.c index e9188c3f..c2fb184c 100644 --- a/projects/ace_loader/nro.c +++ b/projects/ace_loader/nro.c @@ -28,7 +28,7 @@ extern thread_h aceloader_main_thread_handle; uint64_t nro_start() { - uint64_t (*entry)(libtransistor_context_t*) = nro_base + 0x80; + uint64_t (*entry)(void *, thread_h, libtransistor_context_t*) = nro_base + 0x80; uint64_t ret; // generate memory block @@ -73,7 +73,7 @@ uint64_t nro_start() *(void**)(get_tls() + 0x1f8) = NULL; // run NRO - ret = entry(&loader_context); + ret = entry(NULL, aceloader_main_thread_handle, &loader_context); // Restore TLS *tls_userspace_pointer = tls_backup;