Mods folder: optional victory_mod_* exports a mod may be called at #2846

Open
ifBars wants to merge 1 commit from upstream-pr/2846 into main
ifBars commented 2026-11-29 18:02:18 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ifBars on 2026-11-29T18:02:18Z.


[pr-feature]

Related: #1892, #2113

What it changes

#1892 added a mods folder: every DLL in %LOCALAPPDATA%\victory\mods is loaded before the title runs. Nothing calls those DLLs again afterwards. A mod that needs to patch title code, draw over the picture or keep keys from the title still has to rebuild victory.exe or hook the process from outside.

This adds four optional C exports a mod DLL may provide. Each is looked up once with GetProcAddress when the mod loads. A mod that has none of them is only loaded, as before. Without any mod that asks, a present or an input read costs one atomic load.

Export When it is called
victory_mod_title_ready(const VictoryTitle *) The title is mapped, its imports are bound and the write sites are applied, and none of its code has run. This is next to write_sites::apply_asked in run.rs.
victory_mod_title_exited(uint32_t code) The title's main thread has returned.
victory_mod_present(const VictoryPresent *) Once a frame on the presenting thread. The back buffer is in COPY_DEST. The call comes after the F3 panel and under the notices and the F1 menu. The mod gets the device, the present's command list and the back buffer. It also gets the list's keep-alive, a render target view from our ring and upload memory from our pool, which our own panels use.
victory_mod_captured(VictoryCaptured *) Whenever input is read. The mod lists the keys, mouse buttons and XInput buttons it takes for itself, such as for an open mod menu. The title does not see them, in gameinput.rs and in mouse-and-keyboard mode (mnk.rs).

Every struct starts with its size, so fields can be added later. The console names the exports each mod has, for example Mod palmhook_victory loaded (...): called at title_ready, present, captured.

The folder's DLLs now load through a plain LoadLibraryW in victory_gpu::mods, not through streamline::load_mod. That function is MFG Unlocker's loader and marks MFG Unlocker as present. #2113 fixes the same flag inside that loader. The two changes do not depend on each other, but they touch neighbouring lines in play.rs.

What uses it: Palmhook, a mod host for this title. Today Palmhook is installed as a patched victory.exe per release. With these exports it can ship as one DLL in the mods folder that works with stock releases. A prototype of that DLL is on the prototype/victory-mods-folder branch (crates/palmhook-victory). It installs its script hook in title_ready, draws its overlay in present and reports its captured input in captured. The same four points are what Palmhook's patch for v2026.11.28.03 wires into the runtime, and that patch runs in game.

How it was tested

  • GPU and profile: RTX 3060 Ti 8 GB, i5-11600K, Series S, 1080p, DLSS performance. The integration points match the Palmhook adapter patch, which ran in game on v2026.11.28.03 on this PC (2026-11-29). The script hook ticked, and the menu opened and was drawn over the game. This exact branch has not run in game: on this PC, v2026.11.29.01 builds stall during world load, the same way several open reports describe.
  • Before: a DLL in the mods folder is loaded and never called.
  • After: victory_gpu::mods::tests::captured_input_is_every_mods_together covers combining the input that several mods take. cargo clippy reports nothing new in the touched code (-p victory-gpu -p victory-hle -p victory --all-targets; the warnings it does print are in lines this change does not touch).
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test passed for the crates it touches: yes for cargo test -p victory-gpu --lib mods::, cargo test -p victory-hle --lib gameinput (84 passed, 2 ignored) and cargo test -p victory (78 + 1 + 2 passed). These ran before rebasing onto 55d06914. After the rebase, the mods:: test passes again and clippy reports nothing in the touched files. cargo xtask policy reports one violation, in crates/victory-loader/src/heap_sites/frame_users.rs, which this change does not touch; the same check fails on main too.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1892 (the folder), #2113 (the MFG flag in load_mod).

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5553527838 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2846). Originally posted by [ifBars](https://github.com/ifBars) on 2026-11-29T18:02:18Z. --- [pr-feature] Related: #1892, #2113 ## What it changes #1892 added a mods folder: every DLL in `%LOCALAPPDATA%\victory\mods` is loaded before the title runs. Nothing calls those DLLs again afterwards. A mod that needs to patch title code, draw over the picture or keep keys from the title still has to rebuild `victory.exe` or hook the process from outside. This adds four optional C exports a mod DLL may provide. Each is looked up once with `GetProcAddress` when the mod loads. A mod that has none of them is only loaded, as before. Without any mod that asks, a present or an input read costs one atomic load. | Export | When it is called | | --- | --- | | `victory_mod_title_ready(const VictoryTitle *)` | The title is mapped, its imports are bound and the write sites are applied, and none of its code has run. This is next to `write_sites::apply_asked` in `run.rs`. | | `victory_mod_title_exited(uint32_t code)` | The title's main thread has returned. | | `victory_mod_present(const VictoryPresent *)` | Once a frame on the presenting thread. The back buffer is in COPY_DEST. The call comes after the F3 panel and under the notices and the F1 menu. The mod gets the device, the present's command list and the back buffer. It also gets the list's keep-alive, a render target view from our ring and upload memory from our pool, which our own panels use. | | `victory_mod_captured(VictoryCaptured *)` | Whenever input is read. The mod lists the keys, mouse buttons and XInput buttons it takes for itself, such as for an open mod menu. The title does not see them, in `gameinput.rs` and in mouse-and-keyboard mode (`mnk.rs`). | Every struct starts with its `size`, so fields can be added later. The console names the exports each mod has, for example `Mod palmhook_victory loaded (...): called at title_ready, present, captured.` The folder's DLLs now load through a plain `LoadLibraryW` in `victory_gpu::mods`, not through `streamline::load_mod`. That function is MFG Unlocker's loader and marks MFG Unlocker as present. #2113 fixes the same flag inside that loader. The two changes do not depend on each other, but they touch neighbouring lines in `play.rs`. What uses it: [Palmhook](https://github.com/ifBars/palmhook), a mod host for this title. Today Palmhook is installed as a patched `victory.exe` per release. With these exports it can ship as one DLL in the mods folder that works with stock releases. A prototype of that DLL is on the `prototype/victory-mods-folder` branch ([`crates/palmhook-victory`](https://github.com/ifBars/palmhook/blob/prototype/victory-mods-folder/crates/palmhook-victory/src/lib.rs)). It installs its script hook in `title_ready`, draws its overlay in `present` and reports its captured input in `captured`. The same four points are what Palmhook's patch for v2026.11.28.03 wires into the runtime, and that patch runs in game. ## How it was tested - GPU and profile: RTX 3060 Ti 8 GB, i5-11600K, Series S, 1080p, DLSS performance. The integration points match the Palmhook adapter patch, which ran in game on v2026.11.28.03 on this PC (2026-11-29). The script hook ticked, and the menu opened and was drawn over the game. This exact branch has not run in game: on this PC, v2026.11.29.01 builds stall during world load, the same way several open reports describe. - Before: a DLL in the mods folder is loaded and never called. - After: `victory_gpu::mods::tests::captured_input_is_every_mods_together` covers combining the input that several mods take. `cargo clippy` reports nothing new in the touched code (`-p victory-gpu -p victory-hle -p victory --all-targets`; the warnings it does print are in lines this change does not touch). - For shader changes, the wave sizes tested: not a shader change. - `cargo test` passed for the crates it touches: yes for `cargo test -p victory-gpu --lib mods::`, `cargo test -p victory-hle --lib gameinput` (84 passed, 2 ignored) and `cargo test -p victory` (78 + 1 + 2 passed). These ran before rebasing onto 55d06914. After the rebase, the `mods::` test passes again and clippy reports nothing in the touched files. `cargo xtask policy` reports one violation, in `crates/victory-loader/src/heap_sites/frame_users.rs`, which this change does not touch; the same check fails on `main` too. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1892 (the folder), #2113 (the MFG flag in `load_mod`). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2846:upstream-pr/2846'
git switch 'upstream-pr/2846'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2846'
git switch 'upstream-pr/2846'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2846'
git switch 'upstream-pr/2846'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2846'
git switch 'main'
git merge --squash 'upstream-pr/2846'
git switch 'main'
git merge --ff-only 'upstream-pr/2846'
git switch 'main'
git merge 'upstream-pr/2846'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
trustno1-coder/VIctory-NVIDIA!2846
No description provided.