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

Open
github-bot wants to merge 1 commit from github-bot/gh-2846 into main AGit
Owner

@⁠ifBars on GitHub · 2026-11-29 18:02 UTC · original
ifBars:mods-folder-hooks → main · +341 −6 · 9 files · 1 commits · draft

[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

**@⁠ifBars** on GitHub · 2026-11-29 18:02 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2846) `ifBars:mods-folder-hooks` → `main` · +341 −6 · 9 files · 1 commits · draft [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)
A DLL in %LOCALAPPDATA%\victory\mods (#1892) is loaded before the title runs and
is not called again, so a mod that works on the title, the picture or the input
still has to patch victory.exe or hook it from outside. Each mod may now export:

- victory_mod_title_ready: the title is mapped, bound and write-site patched,
  and none of its code has run (run.rs, beside write_sites::apply_asked)
- victory_mod_title_exited: the title's main thread returned
- victory_mod_present: once a frame, with our device, the present's command
  list and the back buffer in COPY_DEST, after the F3 panel and under the
  notices and the F1 menu; with keep, rtv and upload from our own panels
- victory_mod_captured: the keys, mouse buttons and XInput buttons the mod
  takes for itself (an open mod menu), kept from the title in gameinput.rs
  and in mouse-and-keyboard mode

Each export is looked up once at load; a missing one is not called, and with
none a present or an input read costs one atomic load. The console names the
exports a mod has. The folder's DLLs load with a plain LoadLibraryW, not
through MFG Unlocker's loader (which #2113 also fixes).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 18:06:53 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-hle/src/modules/mnk.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2846/head:github-bot/gh-2846'
git switch 'github-bot/gh-2846'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2846'
git switch 'github-bot/gh-2846'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2846'
git switch 'github-bot/gh-2846'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2846'
git switch 'main'
git merge --squash 'github-bot/gh-2846'
git switch 'main'
git merge --ff-only 'github-bot/gh-2846'
git switch 'main'
git merge 'github-bot/gh-2846'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

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