Skip to content
This repository has been archived by the owner on Dec 13, 2017. It is now read-only.

Commit

Permalink
Change the parameters of start
Browse files Browse the repository at this point in the history
On the switch, `start` takes two parameters : an exception pointer,
and a handle to the main thread. For libtransistor, we'll also add
a third one: a context handle. This should allow ace_loader to start
apps expecting the usual switch treatment, while still providing the
context to libtransistor binaries.
  • Loading branch information
roblabla committed Dec 7, 2017
1 parent fb10dd9 commit f6a7aa9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nro.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static char *nro_argoffs;

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 @@ -68,8 +68,14 @@ uint64_t nro_start()
void *tls_backup = *tls_userspace_pointer;
*(void**)(get_tls() + 0x1f8) = NULL;

thread_h main_handle = 0;
if (svcGetThreadId(&main_handle, CURRENT_THREAD) != RESULT_OK) {
printf("- failed to acquire handle to main thread\n");
return -1;
}

// run NRO
ret = entry(&loader_context);
ret = entry(NULL, main_handle, &loader_context);

// Restore TLS
*tls_userspace_pointer = tls_backup;
Expand Down

0 comments on commit f6a7aa9

Please sign in to comment.