Native mod DLLs (experimental): load them and call victory_on_title_mapped #3144
Open
github-bot
wants to merge 2 commits from
github-bot/gh-3144 into main
AGit
pull from: github-bot/gh-3144
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!3144
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3144"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Korothi on GitHub · 2026-12-02 13:54 UTC · original
Korothi:native-mod-dlls→main· +277 −1 · 5 files · 2 commits · openWhat and why
Adds experimental support for native mod DLLs, which the runtime had no way to load (Lua mods are the only mods today).
Before the title starts, every
.dllin%LOCALAPPDATA%\leonida\native-mods\(or the folderLEONIDA_NATIVE_MODSnames) is loaded, in name order. Each one that exportsvictory_on_title_mapped(const TitleInfo *)is called once, after the title is mapped and before any title code runs, with the image base, size and the absolute exe path.DllMainhas run) and is not called.Start-up output starts with
Mods: noneor the list of loaded DLLs (a DLL without the export counts as loaded).A mod's own dependencies are found by
LoadLibraryW's standard search order (the runtime's folder, the system folders, the current folder,PATH), not in the mod's folder;docs/native-mods.mdsays so.The contract (when it is called, return value, how the struct may grow under a new
version) is in the newdocs/native-mods.md, which marks the callback as experimental and says a fault seen with a native mod has to be reproduced without it before it is reported. The change is ind3d12/apps/leonida/src/run.rs: the folder choice, the file filter and the loader, and one call. The folder choice and the file filter are small pure functions with unit tests; the title's own folder is never a default.d3d12/docs/switches.mdis regenerated forLEONIDA_NATIVE_MODS. Lua mods and the trainer menu are untouched.It lets a script-hook style DLL start (I used ScriptHook VI's
shvi_core.dll).Open question for maintainers: whether the runtime should support native DLL mods at all. The code only notifies DLLs it loaded itself.
Tested
On Windows, built with
build-nvidia.ps1, with ScriptHook VI's core DLL in the native-mods folder and its plugin files next to the title's exe: theMods:line names the DLL, the callback returns 0 and the mod's menu opens in game. With the folder empty or absent the output saysMods: noneand nothing else changes. Repeated after the review follow-up with the same result. Not tested: other mods, other builds, Linux/Proton.cargo test -p leonidapasses, including the new unit tests for the folder choice and the file filter.python -I tests/test_d3d12_switches.pypasses (20/20) andscripts/check_no_game_data.pypasses.GPUs tested: NVIDIA GeForce RTX 5090, driver 621.40, Windows 11
AI-assisted: yes
The first version was written with Claude Sonnet 5.5, which is below the model list CONTRIBUTING.md gives for new code. It was reviewed by a separate read-only agent that also ran on Claude Sonnet 5.5; its findings were fixed. The follow-up that answers the maintainer's review (helpers and tests, wording, dependency note, regenerated switches page) was also written with Claude Sonnet 5.5.
The whole change was then re-reviewed in a separate read-only session on Astra: no blocking findings and no memory-safety defect found. Optional nits (empty and relative override semantics, case-sensitive sort order, wording of the dependency search order) were not applied.
Checklist
mainand merges cleanly.scripts/check_no_game_data.pypasses).@Kal0s-design on GitHub · 2026-12-02 15:16 UTC · original
Ran natively on Windows 11, head
776a6c0d3merged into currentmain(43fc605ed, merges cleanly), toolchain 1.98.1 fromrust-toolchain.toml,--locked.cargo test -p leonida --lockednative_mod_testsincluded)cargo clippy -p leonida --tests --lockedleonida; the oneunused_mutinleonida-gpu/src/host.rsis already on mainpython -I tests/test_d3d12_switches.py/tools/d3d12_switches.py --check/scripts/check_no_game_data.pyNo title was run. To exercise
load_native_modsitself I added a throwaway#[ignore]test (not pushed) that calls it with a dummy base/size and a fake exe path, one process per case, withLOCALAPPDATAandLEONIDA_NATIVE_MODSpointed at scratch folders. The mod DLLs are tinycdylibs built for this. So "the exe's folder" below is the test binary's folder, not the runtime's.Mods: nonereturned 0. Nothing else enables it: the folder existing is the switchLEONIDA_NATIVE_MODS=(empty)Mods: none(does not fall back to the default folder)DllMainran, listed inMods:, "not called" line, as documented.dllvoidreturned 1(whatever is left inrax), i.e. reported as declinedexe_pathcorrectstruct_size/versionseen by the modThings that look worth a change:
A relative
LEONIDA_NATIVE_MODScan load a different file than the one listed.read_dirresolves the relative folder against the current folder, butLoadLibraryWgets the relative path (relmods\x.dll) and, for a relative path, uses the standard search, which starts in the executable's folder. Withrelmods\x.dllin both places (two different DLLs), the one listed came from the current folder but the one loaded and run was the one beside the exe. With the copy beside the exe removed, the current-folder one loaded.LEONIDA_NATIVE_MODS=.loads every DLL in the current folder, andLEONIDA_NATIVE_MODS=0(the usual "off" value inswitches.md) names a folder0in the current folder instead of turning it off. Making the folder absolute (std::path::absolute) before listing would make the listed and the loaded file the same.A mod's dependencies come from the current folder and
PATH. A mod importingmoddep.dll:moddep.dllplacedmoddep.dllis then loaded as a mod of its own (listed inMods:, "no export")PATHPATHcopyPATHPATHcopy is used, and the mods-folder copy is loaded a second time as a "mod"This matches what
docs/native-mods.mdsays, so it is a design choice rather than a bug, but the repo already loads a third-party DLL differently:leonida-gpu/src/fsr.rsusesLoadLibraryExW(path, NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32), which takes dependencies from the DLL's own folder and System32 and never from the current folder orPATH. The same flags here would remove the current-folder/PATHlookup and make "put the dependency next to the mod" work. Dependencies would still be listed as mods unless they go in a sub-folder.A mod that faults leaves no
Mods:line. TheMods:line and the per-mod lines are collected and printed only after the loop. Witha_good.dll,b_crash.dll(writes to address 8 in the callback) andc_good.dll, the process ends with0xc0000005. With the runtime'sreport_crashes()installed first, asrun()does, the report namesb_crash.dll+0x14b4, but nothing in the output says thata_good.dllwas loaded and called, andc_good.dllis never loaded. A fault in a mod'sDllMainwould look the same. Printing each line as it happens (or theMods:line before the callbacks) would keep "this run was modded" in the log the docs ask reporters to include.Calling convention: x64 only, where
extern "C"andextern "system"are the same, so a__stdcallexport behaves the same. Not a separate test. DLLs are never unloaded (FreeLibraryis not called), as the docs say.Not checked: a real title run, any real mod, the non-diagnostics/diagnostics feature split, Linux/Proton builds, a mod that starts threads or hooks before returning.
GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).
@fiestorra on GitHub · 2026-12-02 16:04 UTC · original
Verified on the surface this pull request has, which is code plus documentation and no end-to-end test: it builds, its own test passes, and the repository's documentation checks pass on it.
And the three things I would look at in review, all of which are right:
native_mods_dirprefersLEONIDA_NATIVE_MODSand falls back to%LOCALAPPDATA%\leonida\native-mods, and the title's own folder is never a default - the comment says why ("its DLLs are the title's, not mods"), and that is the decision that keeps a mod folder from becoming an arbitrary DLL load;docs/README.mdlinksnative-mods.mdandswitches.mdnamesLEONIDA_NATIVE_MODS, so the switch is documented where the repository's own check looks for it;load_native_modsis called before any title code runs, with the mapped base andSizeOfImage, which is the only moment a mod can hook something.What I could not test, and it is the whole of the experimental feature: loading a DLL and calling
victory_on_title_map- that needs a real mod DLL and a title mapped, and this machine cannot run the title. The code pathload_native_modsitself is not exercised by the test above, only the folder decision is.AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.
@MoonEyes on GitHub · 2026-12-02 18:02 UTC · original
Code review only, not built (Windows-only
leonidabinary). The code is sound, but whether to ship it is a maintainer decision.776a6c0d3, merge base72d143c45, 46 behind currentmain45dc41f95. A trial merge is clean.action_required).Review of
d3d12/apps/leonida/src/run.rs:native_mods_dir,is_native_mod_dll,native_mod_paths) are tested, including that the title's folder is never a default and that sub-folders are ignored.load_native_modsruns after imports are bound and beforespawn_main, as documented.exe_wis leaked deliberately so the pointer outlives the call, andTitleInfocarriesstruct_sizeandversionfor growth.extern "C", which is the same assystemon x64.Points for the maintainer decision:
.dllin%LOCALAPPDATA%\leonida\native-modsis loaded with no opt-in. Any process running as the user can drop a DLL there and have it injected into every run. An opt-in, such as requiringLEONIDA_NATIVE_MODSor a launcher toggle, would close that. Folder trust is the reason I would gate it.DllMainor callback takes the runtime down before theMods:line prints, because the line is printed after the loop. Printing each mod's name before calling it would make crash reports attributable.Verdict: ready on code. Whether native DLL mods are supported, and whether loading is opt-in, is for a maintainer to decide.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@MoonEyes on GitHub · 2026-12-02 22:00 UTC · original
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
@fiestorra on GitHub · 2026-12-03 00:25 UTC · original
VERIFY-3144 — Windows nativo:
red then greenen las pruebas de los mods nativos776a6c0d3—apps/leonida/src/run.rs(+177),docs/switches.md(5)Ran at the head (the binary's own tests:
-p leonida, not--lib, which finds nothing for a binary crate)Negative control (synthetic): I made
native_mods_dirignore the environment (from_env.filter(|_| false)), rebuilt and ran:It bites.
What the change is, and the review points it answers are the right ones:
native_mods_dir(from_env, local_app_data)takes its two inputs as arguments — so the default folder, the override and "neither" are all testable without setting a variable;the_titles_folder_is_never_the_default— the one that matters: a mod folder inside the title's own directory would be deleted or overwritten by a game update, and the test pins that it is not chosen;is_native_mod_dll—.dllin any case, because a mod authored on a case-insensitive filesystem says.DLL.And a detail worth crediting: the tests are
#[cfg(any(windows, test))], so the helpers exist on non-Windows too for the tests' sake — the same seam#3164was missing tonight.What I could not test
Written with an AI assistant.
@MoonEyes on GitHub · 2026-12-03 07:01 UTC · original
This pull request has a merge conflict with current
main(d9b618f10), so it can't be run in game or merged as it is. Could you merge the latestmaininto it (or rebase onto it) and resolve the conflict? Once the head is updated, the in-game gate run can be done on the new head.AI-assisted (Claude Code).
@fiestorra on GitHub · 2026-12-03 09:29 UTC · original
Tres más, estas de dos commits cada una, rebasadas contra
d9b618f10y empujadasEl resolvedor funcionó igual, porque el conflicto de cada commit es la misma línea del recuento (el
whileresuelve y sigue hasta que el rebase termina, en vez de asumir un solo bloque):Las tres: 0 marcadores,
pytest tests/test_d3d12_switches.py20 passed, ycargo test -p leonida-gpu --libcon el fallo de la iGPU de siempre.Y el desglose de tests, que es lo que separa estas tres de
#3009y#3126:leonida-gpu#3144#3171#3248O sea que de las cinco rebasadas hoy, tres no añaden tests (
#3009,#3126,#3144) y dos sí (#3171,#3248) — y todas tocan código de runtime. Quien fusione tiene ahora el dato delante en vez de descubrirlo después.Ramas
pr-3144-rebased,pr-3171-rebasedypr-3248-rebaseden el fork.Lo que esto ya permite decir: de los 22 conflictos, seis están resueltos y empujados (
#3009,#3126,#3140,#3144,#3171,#3248) más los cuatro de antes (#3233,#3253,#3269,#3289) más#3225y#3308— doce en total, y todos con el mismo patrón: una línea del recuento que se recalcula contando el fichero.Lo que no he resuelto: los que chocan en un
.rs(#2567,#2856,#3115,#3197) y los de varios commits con código (#2580,#3124,#3130,#3209,#3214) — esos no son una línea y no los toco sin leer el cambio.776a6c0d3btoc40c78673a@Korothi on GitHub · 2026-12-03 11:34 UTC · original
Rebased onto current main (
b053a1813); head is nowc40c78673. Only the generated switches.md conflicted, regenerated. cargo test -p leonida and the switches tests pass.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.