Repository navigation
Community ExeFS patches (IPS, IPS32, .pchtxt) go into the rewrite: --exefs-patches - #2297
chayan-bit wants to merge 1 commit into
Conversation
… of the NSP script (EXEFS_PATCHES, or DM_EXEFS_PATCHES for patch_nso.py) names a folder of the player's own IPS, IPS32 and .pchtxt files, in Atmosphère's exefs_patches/<name>/<build ID>.ips layout or any other, and each module (main, the subsdks, the NROs) takes those that name its build ID. Players use these patches for 60 fps, resolution and quality mods on a Switch, Ryujinx and the yuzu family, and until now had no way to apply them here: a patched NSO written by hand would lose the rewriter's checks, and Atmosphère cheats (hle_cheats.c) refuse to write over words the rewriter changed. dm/tools/exefs_patches.py reads the three formats, its parsers ported from Ryujinx's IPSPatcher.cs, IPSwitchPatcher.cs and MemPatch.cs (MIT): RLE records, @Flag offset_shift, @enabled / @disabled sections, quoted strings with C escapes, @Stop. An NSO's offsets count its 0x100-byte header and an NRO's count from its start, as Atmosphère's ro patcher and Ryujinx's ApplyNroPatches apply them. Where Ryujinx warns and goes on, this stops: a malformed file, a record in the NSO header or past the data segment, and two records that write different bytes to the same byte. patch_nso.py writes the records after every cut (registered, function-matched and the engine finders') and before its scan, so a patched word is rewritten like the game's own: an x18 use or an svc goes through its site, and an exclusive load or store gets the ordering of e3ad825. A record over a cut, an observation gate (registered, or the address region, StandardAllocator and Unreal ones found later), a frame step or stub site (checked before the stub asserts its original bytes, so the line names the patch), or the engine region's size mov stops the rewrite with a [RED] line, and so does a word the scan rewrites (x18, svc, a system register, sub sp) written into a data block of the text, which the scan leaves alone. Patched words land in changed.tsv like any other changed word, so a cheat does not write over them. <module>.exefs_patches.tsv lists the files and records, the NSP script names on the console what each module took, and its rewrite key covers the patch files by name and content. Without the option nothing changes: the same image, cuts and sites (build_src.sha256 lists exefs_patches.py). Checked: test_exefs_patches (19 tests: the parsers, matching and conflicts, and patch_nso.py on a synthetic NSO and NRO built in the test: a patched mov x1, x18 and svc become sites and give the same output as the same words in the file, a patched ldxr becomes ldaxr, an NRO's records land at their own offsets, an x18 word in a data block of the text stops the rewrite while the same word in ro is written, a record in the header or over a registered cut or a frame step site stops it with a [RED] line, an empty folder changes nothing), and every dm/tools/tests file before and after: the same 9 files fail on this Mac either way, from its toolchain (.NET 8 against the projects' .NET 10, no swiftc, GNU stat, a global commit hook), and test_docs and test_env_switches pass. No game was patched: no patch or game file is in this change, and the tests use none.
|
Overlaps #2150 (open since 2026-11-10, stacked on #2149). Both send a mod's
If both land, there are two env names for the same rewriter step ( |
|
Thanks @chayan-bit for porting the IPS, IPS32, and Closing this PR as superseded by #3158, which is actively kept up to date on current Still open: reviewing and landing #3158, and keeping the synthetic parser edge cases from this PR in mind if any coverage gaps come up. |
What and why
Players use community ExeFS patches (60 fps, resolution, quality) on a Switch, Ryujinx and the yuzu family, and had no way to apply them here: a hand-patched NSO loses the rewriter's checks, and cheats refuse words the rewriter changed.
--exefs-patches <folder>(EXEFS_PATCHES;DM_EXEFS_PATCHESforpatch_nso.py) names a folder of the player's own IPS, IPS32 and.pchtxtfiles (Atmosphère'sexefs_patches/<name>/<build ID>.ipslayout or any other); each module (main, subsdks, NROs) takes those naming its build ID.dm/tools/exefs_patches.py: the parsers, ported from Ryujinx's IPSPatcher.cs, IPSwitchPatcher.cs and MemPatch.cs (MIT). An NSO's offsets count its 0x100-byte header, an NRO's its start (as Atmosphère's ro patcher and Ryujinx's ApplyNroPatches). Where Ryujinx warns and goes on, this stops: a malformed file, a record in the NSO header or past the data segment, two records writing different bytes to one byte.patch_nso.py: the records go in after every cut and before the scan, so patched words are rewritten like the game's own (x18 uses and svcs become sites, exclusive accesses get the ordering of e3ad825). A record over a cut, an observation gate, a frame step or stub site, or a site word written into a data block of the text, stops the rewrite with a[RED]line naming the patch. Patched words are inchanged.tsv;<module>.exefs_patches.tsvlists files and records.Checked
dm/tools/tests/test_exefs_patches.py(19, synthetic NSO, NRO and patches built in the test: parsers, matching, conflicts, NRO offsets, a patch over a frame step site, patch_nso.py end to end incl. ldxr → ldaxr and a byte-identical output with an empty folder); everydm/tools/testsfile on main and on this branch (the same 9 files fail on this Mac either way, from the local toolchain: .NET 8 vs 10, no swiftc, GNU stat, a global commit hook); ruff and pyright 1.1.414 add no findings.regress.py check --games: not run. Without the option the rewriter's output is byte-identical (tested), so no game changes unless the option is given.Docs
docs/development.md: an "ExeFS patches" section and an example under "The packing script in detail";docs/env_switches.tsvrow forDM_EXEFS_PATCHESScope discussion: #2294
Demo