Commit Graph
10 Commits
Author SHA1 Message Date
Valiantsin DzerakhandClaude Opus 5.5 3fe8d7a1d9 Mod plugins that hook the middle of game functions, swap pointers in the game's data, use the SD card or switch their hooks during play build in, and may call what the game itself calls; Zonai Fieldworks starts (#1388)
Zonai Fieldworks was refused at several steps; each is now handled:
1. The start-up asked GetInfo 6, 7, 16 and 17 and SetHeapSize; runtime/plugin_init.c serves them.
2. Its start-up calls main where the lift has no function start. The tool names those addresses (--entries-out) and
   the installer lifts again with them as `entry` lines, up to four rounds (installer/steps.py PLUGIN_ENTRY_ROUNDS).
3. Branch hooks into the middle of game functions (far-jump veneers) and pointer swaps in main's data are accepted
   hook kinds; the veneer targets seed the plugin's lift, and an Orig trampoline counts as a seed.
4. Code the start-up writes into the plugin's own .text (hook pads it switches to during play) is found by comparing
   the image before and after the init, and seeds the lift (init_code). Without it the game stopped with "no function
   at guest pc" when a feature switched on.
5. recomp/gen.py: a branch-out alternative on a flag-writing site leaves with the flags from before the site; an inline
   hook may sit on a blr.
6. nn::fs::MountSdCard mounts <profile>/sdcard (runtime/fs_host.c), and nn::settings language codes are answered
   (runtime/ov_system.c).

The import check now also allows what the game's main imports (--exefs, game_imports): the game runs on those paths,
so the runtime serves them. Left out: nn::ro, the C runtime start, the thread-local allocator hook and the shader
compiler. Break in code the hooks reach is allowed (an abort ends the game with the reason, as on the Switch), and
RenameFile, DeleteDirectoryRecursively, Commit and Unmount join the SD card calls. Checked: Zonai Fieldworks, The Second
Quest, Challenge Mode and Material Columns on 1.4.3, Full Inventory Expansion, Quick Weapon Durability and Magic of the
Kingdom on 1.2.1 accepted; UltraCam's init still crashes its service run. Plain lift unchanged; probes 4/4 on both
versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 10:35:59 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c603112fca The plugin check accepts exlaunch's exl_inline_hook_with_fp_impl, the inline-hook entry that saves d0..d15 next to x0..x29. Magic of the Kingdom's hook stub calls it and was refused for it (#1388)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 08:40:59 +03:00
Valiantsin Dzerakh 0e810f429a Merge branch 'dev' into task/tramp 2026-11-22 16:42:36 +03:00
Valiantsin DzerakhandClaude Opus 5.5 b61b2b0922 The plugin check accepts the .quad exlaunch writes for a backward b.cond, cbz or tbz: its relocation drops the offset's sign. Challenge Mode's two backward b.eq hooks were refused for it (#578)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:03:48 +03:00
Valiantsin DzerakhandClaude Opus 5.5 1c2a0e5a33 The plugin check accepts exlaunch's long trampolines: a hooked tbz, cbz, b.cond, adr, adrp, load literal or far b/bl whose relocation takes several words, and the jump back by ldr x17/br x17. Challenge Mode's plugin was refused at its tbnz site (#578)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:31:30 +03:00
ICUMADETHIS d4497da8c7 Preserve plugin image paths in generated patch tables 2026-11-22 08:50:14 +00:00
Valiantsin DzerakhandClaude Opus 5.5 a7f24442b6 The cheat, ExeFS patch and plugin tools read and write their patch files as UTF-8, the encoding recomp/patches.py load now reads them in
Without Python's UTF-8 mode these tools used the locale code page, so a plugin image path with non-ASCII characters
(tools/exefs_plugins.py plugin_lines) would reach the generator in a code page it no longer reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:07:01 +03:00
Valiantsin DzerakhandClaude Opus 5.5 b9b8f3dce1 Each mod plugin is built or refused on its own: one that is refused, crashes or hangs costs only itself (#845)
tools/exefs_plugins.py ran every plugin's init in one service run and refused them all when one was refused. Now a run
without inits lists the plugin modules, then each plugin runs in service runs of its own (TOTK_PLUGIN_ONLY, the others
stay loaded): a refused svc, a crash (the FATAL line is the reason), a timeout or a failed check refuses that plugin
alone, with its reason in plugins.status; the rest are built in. 4 plugins take 2.3 s.

At start, plugins_start compares each plugin right after its own init and takes its branches out of main's .text before
the next one, so each init sees the game's bytes, as in its service run. Only that init's aliases are flushed: the
start stays at 113 ms for Full Inventory Expansion + Quick Weapon Durability (107 ms before).

The installer's second lift keeps every plugin of the service runs in the layout when one is built: the records hold
that layout's addresses. A refused plugin stays loaded and never starts. A mod with a built plugin and a refused one,
used without its code, runs the built one (mods.c; --probe-mods case T).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:25:24 +03:00
Valiantsin DzerakhandClaude Opus 5.5 8cee1afe5d The rebuild builds mod plugins in: service run, checks, patch sets and status lines (#845)
After the design in #845 by itaskaev2. tools/exefs_plugins.py writes an accepted plugin's patch set
(recomp/patches.py plugin lines and hook sites, one ordered set mod_<hash> per plugin, several plugins
in one record told apart by their hooks) and a line per plugin of build-cache/plugins.status: built, or
refused with the first reason. It also checks the code the hooks reach (direct branches and calls from
the stubs, impls, callbacks and targets): no svc but OutputDebugString, imports only from a reviewed
list. The init's imports may now include malloc, free, memcpy, memmove and memset, because the init runs
again at every start and its heap blocks exist while the game runs.

The setup's lift step runs the plugin stage when a mod has exefs/subsdk*: a lift with the plugins, a
totk.exe of it in the compile step's folder, the service run, then the lift with the hook sites; a failed
stage warns (warn.plugins_skipped) and installs without the plugins. docs/mods.md describes what works,
what is refused and why, and the rebuild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 08:48:31 +03:00
Valiantsin DzerakhandClaude Opus 5.5 b2b85c05fa tools/exefs_plugins.py runs a plugin's init twice and checks the record (#845)
Two service runs with other GetSystemTick values, the words that differ between them listed with what they point
into, and a check that refuses a plugin with a reason per broken rule: a refused run, svcs, GetInfo ids or imports
outside the reviewed lists, writes outside main's .text, and writes that are none of exlaunch's inline hooks
(b to a stur/bl impl/ldur/b/.quad stub whose trampoline is the original relocated plus b site+4), call-site rewrites
(bl to a function start of the plugin's lift) or replace hooks (b from a main function start, Orig trampoline found).
tests/exefs_plugins_test.py covers the layout with and without plugins and one bad record per rule.

After the design in #845 by itaskaev2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 08:05:19 +03:00