Skip to content

Instantly share code, notes, and snippets.

@roblabla
Last active February 18, 2019 18:11
Show Gist options
  • Save roblabla/c4d656212e1069423d7d04b31db25858 to your computer and use it in GitHub Desktop.
Save roblabla/c4d656212e1069423d7d04b31db25858 to your computer and use it in GitHub Desktop.
// Call with x0 = hbabi, x1 = 0xFFFFFFFFFFFFFFFF, x2 = NRO address
// Starts running the NRO. Returns the exit code of the homebrew.
nroEntrypointTrampoline:
// TODO: Ideally, set up a new stack so NRO has a full stack to work with.
// Save r19-r29
stp x19, x20, [sp,-0x10]!
stp x21, x22, [sp,-0x10]!
stp x23, x24, [sp,-0x10]!
stp x25, x26, [sp,-0x10]!
stp x27, x28, [sp,-0x10]!
stp x29, x30, [sp,-0x10]!
// Call NRO.
blr x2
// Restore r19-r29
ldp x29, x30, [sp], 0x10
ldp x27, x28, [sp], 0x10
ldp x25, x26, [sp], 0x10
ldp x23, x24, [sp], 0x10
ldp x21, x22, [sp], 0x10
ldp x19, x20, [sp], 0x10
// TODO: Ideally, reset old stack pointer
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment