The Ocarina of Time (Switch 2) recomps Hookshot, Longshot, Triforce and ReLink load only RomFS mods; changing the game's code means editing and rebuilding the port. HSML is a loader for such code mods: it starts with the game and loads every mod DLL from the mods folder. Each mod hooks the recompiled game functions it needs, found by their Switch address, and HSML redirects them to the mod's code in memory, leaving the port's files untouched.
HOW TO INSTALL
Extract hsml-v.zip into the port's root folder: the one holding bin\, or the exe itself when there is no bin\. That gives mfplat.dll, bin\mfplat.dll and hsml\hsml.dll; the mfplat.dll beside the exe loads, the other stays unused.
Updating from HSML 1.2 or older: first delete its dbghelp.dll and winmm.dll (root and bin\).
Then:
TECHNICALS
Another Hookshot-derived port works if it keeps:
Build with sh build.sh (msys2 ucrt64 g++) into out\. Offline hook test against a port's exe: sh build.sh test all. Release zip: python release/pack.py.
MORE FROM ME
HOW TO INSTALL
Extract hsml-v.zip into the port's root folder: the one holding bin\, or the exe itself when there is no bin\. That gives mfplat.dll, bin\mfplat.dll and hsml\hsml.dll; the mfplat.dll beside the exe loads, the other stays unused.
Updating from HSML 1.2 or older: first delete its dbghelp.dll and winmm.dll (root and bin\).
Then:
- Mods: extract each into the root, giving mods\\hsml\.dll. Turn one off by renaming its folder to start with _.
- Check: after a game start, hsml.log in the root lists each mod as running or why not. No hsml.log means HSML didn't load, so the zip is not in the root.
- Update: extract the newer zip over the old one.
- Uninstall: delete both mfplat.dll, hsml\ and the mods.
TECHNICALS
- Proxy: mfplat.dll in the root and in bin\. Every port imports Media Foundation, so Windows loads the proxy from beside the exe. It forwards all exports to System32\mfplat.dll and loads the core.
- Core: hsml\hsml.dll. Runs once per process. It reads the exe's f_ symbols (COFF symbol table, or .map with a matching timestamp), loads mods\\hsml\*.dll in folder-name order (folders starting with _ or - are skipped) and calls each mod's int HsmlInit(const HsmlApi*, const char* modDir). The API is in hsml.h: HostOf, Hook, HookHost, HostSym, Log, memory base, port name.
- Hooks: the first 5+ bytes of the function become a jmp to a relay near the exe; the moved instructions go to a trampoline, relocated by loader/x64len.hpp. Functions under 5 bytes, loop / jrcxz and branches back into the moved bytes are refused and logged. The last hook installed runs first and chains to the previous one.
- Mods: built with sdk/. A detour is u64 D(Ctx* c, ...) with the guest registers in c. HsmlModStart checks the memory layout and keeps the mod off on a mismatch.
Another Hookshot-derived port works if it keeps:
- the f_ symbols (COFF table or .map)
- the mfplat.dll import (otherwise the spare winmm / dbghelp proxies, built but not shipped)
- the exe in the root or bin\
- guest memory at 0x100000000000, main at 0x80020000
- the register context (x0.. +0, lr +0xf0, sp +0xf8, v0.. +0x110)
Build with sh build.sh (msys2 ucrt64 g++) into out\. Offline hook test against a port's exe: sh build.sh test all. Release zip: python release/pack.py.
MORE FROM ME
- Immersive First Person: play as Link in first person
- Ragdoll Button: make Link stumble, fall and fly