A function's code, and the layout of the structs it works on, change between versions of the SDK that built the module exporting it. A hook can say which versions it holds for:
@version(>= 5.0.0, < 12.0.0)
hook lock(addr m) -> u32 = os_lock_old uses nn::os::MutexType
@version(>= 12.0.0) hook lock(addr m) -> u32 = os_lock uses nn::os::MutexType
@version(...) goes on the line before the hook, or at the start of its line. It holds comparisons (>=, >,
<=, <, ==) joined by commas, all of which must hold, and a key before them: sdk when none is given. A
declaration takes one, but one for a 32-bit game, which takes a group for each range apart (above).sdk is the module's SDK version. An SDK-built module carries middleware labels in its read-only data, of the
form SDK MW+<vendor>+<vendor>SDK_nnSdk-<x>_<y>_<z> (and ..._NVN-... for the NVN library). hook_install
reads each module's when the game starts (hook_label_version, packed x << 16 | y << 8 | z, each part at most
hooks: module sdk, SDK 20.5.22). In the games looked at so far only the sdk
module carries one: main, rtld and the subsdk modules have none, so their version is unknown.nvn is the NVN API version (major.minor, packed major << 16 | minor), for the NVN functions the runtime
implements (gpu/nvn/nvn.hook). It is the game's own driver's: at the game's first
nvnBootstrapLoader call, before it has any NVN function, the driver's lookup finds nvnDeviceGetInteger by name
and its switch's answers for the API's major and minor version are read from its code (gpu/nvn/nvn_driver.c).
Each NVN function the game then resolves takes the declaration that holds for that version, and one declared only
for other versions stops the game with its name and the version when it is called
(tests/nvn_versions.c). The log says whether the version is one nvn_api_described holds
(gpu/nvn/nvn_driver.c: 53.5, 53.13, 53.105, 53.209, 53.311 to 53.314 and 55.8 to 55.15). The runtime takes the
game's NVN calls for every version.movie is the version of the movie library, from the label its subsdk module carries
(SDK MW+<vendor>+<vendor>SDK_movie-x_y_z), packed as sdk's. That module has no nnSdk label, so its
functions (NVIDIA's multimedia stack, whose JPEG decoder and encoder nn/tvmr_jpeg.hook runs natively) are
versioned by it. hooks: module subsdk0, SDK unknown, movie 4.4.1 is its line in the log.hook_select picks the entry whose
range holds the module's version. When a symbol has entries but none holds, the hook isn't installed and the log
names the symbol and the version once. A versioned hook says the range it was installed for, once
(hook: lock at ... runs os_lock, the hook for sdk >= 12.0.0, with the layouts nn::os::MutexType of line 12).sm stops the game when it opens it, and the stop ends with what
was left: how many symbols have declarations of which none holds for their module's version, and the first one's
name, module, version and declared versions (hook_missed_text: 41 of the SDK functions the runtime has a hook
for run their own code in this 32-bit game, ...: the first is ... in sdk, of version 3.0.1, declared for sdk <
1.0.0). In a 32-bit game whose SDK no declaration for a 32-bit game was read in, that reason takes the place of the
advice for a homebrew program (hook_unread_text): its SDK and the module it is in, the SDKs the declarations were
read in (HOOK_A32_READ_SDKS, 0.12.16, 4.4.0 and 10.6.0), how many of its functions run their own code by family,
and what to do (This 32-bit game's SDK is 9.3.0 (module sdk) ...).Made from docs/platforms/nx/hooks.md at 69237645142c. GPL-3.0-or-later.