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

Commit

Permalink
Clean TLS userspace pointer before starting NRO
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Dec 2, 2017
1 parent 80c275d commit 7fd7240
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nro.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,17 @@ uint64_t nro_start()

loader_context.return_flags = 0; // out

// Backup and clean main thread TLS pointer
void **tls_userspace_pointer = (void**)(get_tls() + 0x1F8);
void *tls_backup = *tls_userspace_pointer;
*(void**)(get_tls() + 0x1f8) = NULL;

// run NRO
ret = entry(&loader_context);

// Restore TLS
*tls_userspace_pointer = tls_backup;

// show log buffer if requested
if(loader_context.log_buffer != NULL && *loader_context.log_length > 0)
{
Expand Down

0 comments on commit 7fd7240

Please sign in to comment.