Native mod DLLs (experimental): load them and call victory_on_title_mapped #2970
Closed
github-bot
wants to merge 2 commits from
github-bot/gh-2970 into main
AGit
pull from: github-bot/gh-2970
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!2970
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2970"
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-01 22:02 UTC · original
Korothi:native-mod-dlls→main· +279 −3 · 5 files · 2 commits · closed without mergingWhat 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).@andrew-ai on GitHub · 2026-12-01 22:12 UTC · original
The switch-reference check fails because LEONIDA_NATIVE_MODS is missing from d3d12/docs/switches.md. On main
c4ca57615, all 20 tests in tests/test_d3d12_switches.py pass. After merging this head (1cfd799b7) locally, 19 pass and test_the_tracked_switches_page_matches_the_sources reports the missing name.Running
python -I tools/d3d12_switches.py --out d3d12/docs/switches.mdon the merged tree and repeatingpython -I tests/test_d3d12_switches.pygives 20/20. Only the generated switch reference changed. Documentation check only; no title or native mod was loaded. Codex-assisted for #2570.@KelboLive on GitHub · 2026-12-01 22:22 UTC · original · requested changes
The shape is right: per-user opt-in folder (
%LOCALAPPDATA%\leonida\native-modsorLEONIDA_NATIVE_MODS),Mods: nonewhen it is absent, the callback after the exe and title imports are bound but beforespawn_main(so DLL attach/TLS callbacks have not run, matchingdocs/native-mods.md:23-25), and load/missing-export/nonzero-return failures are logged and skipped.TitleInfois#[repr(C)]and matches the documented fields.check_no_game_datapasses andcargo test -p leonidais 47/47.Three things before merge:
LEONIDA_NATIVE_MODSis read atrun.rs:316but has no row ind3d12/docs/switches.md, sotests/test_d3d12_switches.pyfails (19/20) ontest_the_tracked_switches_page_matches_the_sources. Regenerating with--outfixes it.exe.parent()(DLLs beside the title exe load by default) and all 47leonidatests still pass. Please extract the directory/extension choice into a pure helper and test default / env override / absent dir — and explicitly that the title's directory is never the default.LoadLibraryW(:345) resolves a mod's dependencies through the standard search order (app/game dir, system dirs, CWD, PATH), not the mod's own folder. Document that, or useLoadLibraryExWwithLOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32if dependencies should stay beside the mod.Minor wording: "A DLL without the export is left alone" actually means it is loaded (its
DllMainruns) but not called; the body's "skipped" has the same ambiguity.Also, per CONTRIBUTING, new code needs a listed model: this was written/reviewed on Sonnet 5.5, so it needs a re-review on one of the listed models before merge.
Merge is clean against current main.
@Korothi on GitHub · 2026-12-02 00:28 UTC · original
Pushed
debb73caeaddressing all three points:d3d12/docs/switches.mdregenerated;tests/test_d3d12_switches.pypasses 20/20.native_mods_dir,is_native_mod_dll,native_mod_paths) with unit tests: default, env override, absent dir, extension filter, ordering.native_mods_dirtakes no exe path, so the title's directory cannot be a default.docs/native-mods.mdand at theLoadLibraryWcall, rather than switching toLoadLibraryExW, to keep the behaviour I tested. Happy to switch if you'd rather keep dependencies beside the mod.Wording fixed: a DLL without the export stays loaded (its
DllMainruns) but is not called.@andrew-ai on GitHub · 2026-12-02 00:30 UTC · original
Confirmed the switch-reference fix at
debb73cae. The tracked table contains LEONIDA_NATIVE_MODS, the generator check exits 0, and all 20 tests in tests/test_d3d12_switches.py pass on Windows. My documentation finding is resolved. Codex-assisted.@Korothi on GitHub · 2026-12-02 00:41 UTC · original
Pushed
debb73caddressing all three points:d3d12/docs/switches.mdregenerated;tests/test_d3d12_switches.pypasses 20/20.native_mods_dir,is_native_mod_dll,native_mod_paths) with unit tests: default, env override, absent dir, extension filter, ordering.native_mods_dirtakes no exe path, so the title's directory cannot be a default.docs/native-mods.mdand at theLoadLibraryWcall, rather than switching toLoadLibraryExW, to keep the behaviour I tested. Happy to switch if you'd rather keep dependencies beside the mod.Wording fixed: a DLL without the export stays loaded (its
DllMainruns) but is not called.Re-review done on Astra: no blocking findings; optional nits (empty/relative override semantics, case-sensitive sort, dependency-order wording) not applied. Details are in the PR body.
@MoonEyes on GitHub · 2026-12-02 12:19 UTC · original
Closing: this pull request no longer applies to current
main(merge conflict ind3d12/docs/switches.md), and open pull requests that have fallen out of step withmainare being closed so the list stays workable. If you still want this change, rebase it on currentmainand reopen it (or open a new pull request); it will be looked at again.AI-assisted (Claude Code).
@Korothi on GitHub · 2026-12-02 13:54 UTC · original
Rebased on current main (the conflict was only in the generated switches.md, regenerated). GitHub refused to reopen this PR, so it continues in #3144
Pull request closed