The structs a handler reads in guest memory are declared beside the hooks, each version's layout apart:
struct nn::os::MutexType @version(< 9.0.0) {
u8 state @0x0
u32 owner @0x4
} size 0x10
struct nn::os::MutexType @version(>= 9.0.0) { u8 state @0x0; u32 owner @0x8 } size 0x20
void; bool is a byte and addr 8 bytes), a name and its
offset. Fields are separated by line ends or semicolons, and the struct's size follows its closing brace. A field
that runs past the size is refused.@version holds for every version and is its name's only declaration.HookLayout_nn_os_MutexType (:: becomes _): its size, and each
field as a HookField_<type> holding its offset. The variants are a table of these, by version.= handler uses nn::os::MutexType (several are
separated by commas). The handler takes a pointer to the layout after the CPU,
u32 os_lock(CPU* c, const HookLayout_nn_os_MutexType* nn_os_MutexType, u64 m), the variant for the module the
hook was installed in.hook_get_<type>(c, L->field, addr) and
hook_put_<type>(c, L->field, addr, value) (hook.h), little-endian whatever the host's order. The field types
differ per type, so hook_get_u32 doesn't take a u8 field. An atomic access takes
c->mem + addr + L->field.offset itself.tests/hook_versions.c checks the entries hookgen makes of tests/hook/versions.hook, the labels, the entry and
layout picked for a module's version (none, below and between ranges, the bounds of each comparison), and the
accessors.
Made from docs/platforms/nx/hooks.md at 69237645142c. GPL-3.0-or-later.