Repository navigation
host/mods: load emulator mod folders (1/2): RomFS, cheats, exefs patches - #2149
Closed
roandegraaf wants to merge 1 commit into
Closed
roandegraaf wants to merge 1 commit into
roandegraaf wants to merge 1 commit into
Conversation
This was referenced Nov 10, 2026
Mods made for Switch emulators load from a mods folder: RomFS files switched while the game runs, cheat files of every mod as one list, .pchtxt / .ips patches as a module loads (DM_MODS, the Mac window's Mods menu).
dm/host/hle_mods.c reads DM_MODS (default <DM_ROOT>/mods), one folder per mod in
the layouts mods ship in (romfs/, exefs/, cheats/ directly, or under
atmosphere/contents/<title ID>/), ordered and switched by order.txt. A folder of
mods is a pack; two of a pack that replace the same RomFS file are alternatives.
- romfs/ folders join the RomFS overlay, and the Mods menu (or DM_CTL "mod-on" /
"mod-off") changes the list while the game runs (dm_fs_overlay_set). A
<name>.dm-delete marker hides a game file or directory, and those of the mods
after it. A name that differs from the game's only in case is taken, with a
warning in the log, where it silently did nothing before.
- Every cheats/<build ID>.txt of the running build is loaded, the cheats
folder's own first, then each mod's by priority: a cheat an earlier file has
with the same name and code is left out, the same name with other code is a
second entry ("Name seedds#2"), a mod's cheats are listed under its name, and
<build>.enabled / <build>.values stay one file each, in the cheats folder.
CHEAT_MAX is 512, for all files together.
- exefs/*.pchtxt and <build ID>.ips are written into the module whose build ID
they name while it is still writable (loader.c map_image), a file whole or
not at all. A file is refused with a [RED] line when a patch replaces a word
the rewriter moved (<name>.changed.tsv) or writes an instruction the rewriter
would have had to replace; applying those before the rewriter runs is the
next change.
Mac-tested on 0400486024DEC000 only: two RomFS mods from the
menu, synthetic patches and cheat files. Code modules of a mod (ExLaunch,
Skyline) are not loaded, and no exefs patch is applied on iOS.
Rebased on main at 034e91a: only the game note's Found on this game list conflicted (both kept); symptom index regenerated. Main's rewriter now also rounds odd-sized sub/add sp, #imm frames (c081686), so the host refuses a patch that writes sub / add sp, sp, #imm by an amount that is not a multiple of 16 too (t_mods: five new cases). Checked again: host build, make -C dm/host/tests run (t_mods, t_cheats, t_fs, t_hid), test_docs, test_env_switches, test_architecture, lint tests.
Front-ends: new: mods are folders in DM_MODS (default <DM_ROOT>/mods), ordered and turned off by order.txt there; the host reads it at the start
Front-ends: interface: every <build ID>.txt of the running build is loaded, from the cheats folder and each enabled mod's cheats/, as one list; a cheat's section may be a mod's name
roandegraaf
force-pushed
the
mods-loader
branch
from
November 12, 2026 14:13
16ca835 to
83bc59c
Compare
Owner
|
Thanks @roandegraaf for putting together this mod-folder loader and documenting the emulator folder conventions and safety checks! Closing this combined PR as superseded by the smaller, actively maintained split PRs #3146 (per-game Mac mods folder and Still open: reviewing and landing those focused mod PRs, keeping this PR's rewrite-safety checks and mod layout notes in mind. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebased on main at 034e91a (2026-11-12). Only the game note's "Found on this game" list conflicted. One addition from main: its rewriter now also rounds odd-sized
sub/add sp, #immframes (c081686), so the host also refuses a patch that writessub/add sp, sp, #immby an amount that is not a multiple of 16 (five newt_modscases).Part of a set of three. This one stands alone on
main. #2150 is stacked on it (merge this first). #2151 is independent of both, but touches neighbouring lines indm.h,front_mac.m,hle_hid.c,t_hid.cand the docs, so whichever lands second needs a small rebase, which I will do.Overlaps #883, which also adds a
dm/host/hle_mods.cand RomFS mods through the overlay, but builds mods into the app at pack time (build_ipa_from_nsp.py --mods) and runs code patches throughpatch_nso.pythen. This PR reads a mods folder at run time, switches RomFS mods while the game runs, merges cheat files, and applies code patches as a module loads (#2150 rewrites the rest at launch). #2305 adds a LayeredFSromfs/folder and game updates, with launcher buttons; #519 writes a profile's own<module>.runtime.tsvat load time, not mod files. The maintainer may want one mods design; I can fold the pack-time path of #883 in or rebase onto it.What and why
A mod folder as Ryujinx, the yuzu family or Atmosphère take it had no place to go: only
DM_ROMFS_OVERLAYreplaced RomFS files, by hand, and one cheat file per build was read.dm/host/hle_mods.creads a mods folder (DM_MODS, default<DM_ROOT>/mods), one folder per mod in the layouts mods ship in, ordered and switched byorder.txt. A folder of mods is a pack; two of a pack that replace the same RomFS file are alternatives.romfs/folders join the overlay, and the Mac window's Mods menu (orDM_CTLmod-on/mod-off) changes the list while the game runs.<name>.dm-deletehides a game file or directory, and those of the mods after it. This is a new convention of this host: LayeredFS and the emulators have none, so the name is yours to change.cheats/<build ID>.txtof the running build is loaded as one list, the cheats folder's own first, then each mod's by priority.Name #2).<build>.enabledand<build>.valuesstay one file each, in the cheats folder.CHEAT_MAXis 512, for all files together.exefs/*.pchtxtand<build ID>.ipsare written into the module whose build ID they name while it is still writable (loader.cmap_image), a file whole or not at all. A file is refused with a[RED]line when a patch replaces a word the rewriter moved (<name>.changed.tsv) or writes an instruction the rewriter would have had to replace (ansvc, a thread or timer system register, an exclusive access,sub sp, sp, xN,sub/add sp, sp, #immnot a multiple of 16, x18). tools/mods: rewrite refused mod code patches at launch (2/2) #2150 takes those.Not loaded: a mod's code modules (ExLaunch, Skyline). No exefs patch on iOS (signed code).
Reference entry: Mods made for emulators do nothing, or only half of them does. User docs:
docs/development.md"Mods".Checked
mainat 034e91a): the host builds;make -C dm/host/tests GAME=0400486024DEC000 runexits 0 (t_modsok with the newspcases,t_cheats156 / 156,t_fswith the new overlay cases,t_hid);test_docs,test_env_switches,test_lint_python,test_lint_c,test_architecturepass.0400486024DEC000(v131072) on the Mac, with two RomFS mods switched from the Mods menu while playing, and headless to the frame loop with synthetic patch files. Those runs were on an older base (my shader libraries are of chaine82ac5d18f5e), so on this branch the game itself was not run..app, iOS, a downloaded mod with a code patch. The delete marker and the case fallback are unit-tested only, not exercised in a running game.scripts/regress.py check --games: not run. Only one game is built on this Mac, and the report wants five;hle_fs.c,hle_cheats.candloader.care on every game's path, so a run on your games would be welcome.Front ends
Front-ends: new: mods are folders in DM_MODS (default <DM_ROOT>/mods), ordered and turned off by order.txt there; the host reads it at the start
Front-ends: interface: every .txt of the running build is loaded, from the cheats folder and each enabled mod's cheats/, as one list; a cheat's section may be a mod's name
Docs
docs/reference/<subsystem>.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index)