Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Change the parameters of start #45

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/crt0.nro.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/crt0.nso.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion lib/crt0_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions projects/ace_loader/nro.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down