src/nx/nn/ext_skyline.hooks holds native hooks for the detours loaders are known to make (skyline's and
Cobalt's on nn::fs::MountRom, one game's optimizer mod's on nn::fs::MountRom by name alone,
nn::fs::MountSdCard and nn::fs::OpenFile, skyline's on nn::ro::Initialize), each with the handler and
arguments of the function's native hook (tests/ext_skyline_hooks.py checks them against it), in a table of its own
(prefix skyline, ext_skyline.c). They are not installed at the start: once a function's native hook is
invalidated, a dispatch miss at a pc (rt_miss, hook_trampoline) checks whether the code there is the mod's
trampoline of that function, its first instructions as hook_install saw them
(1, or 4 or 5 when the hook was too far for a b) followed by a jump back to the one after them (a b, or
ldr x17, #8 and br x17 of the address, after a nop that aligns it), as skyline's and exlaunch's
And64InlineHook writes it. The first time it runs, the hook takes the trampoline's slot, and the mod's call of the
original runs the handler. A handler that hands a case back to the function's own code (hook_run_original) runs the
trampoline's code, entered at the trampoline: the SDK's, past the instructions the mod moved. A first instruction that
reads the pc (adr, adrp, a literal load, a branch) is rewritten in the trampoline, so it is never recognized, and
that function's original stays the SDK's code. A hook of a detour no loader makes is never reached, so the file lists
the known ones only, and its hooks change no route list.
Made from docs/platforms/nx/hooks.md at 69237645142c. GPL-3.0-or-later.