victory: add VICTORY_LOAD_DLLS / VICTORY_HOST_EXE_DIR host DLL hook #464
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!464
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-464"
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?
@Rockstar-1998 on GitHub · 2026-12-04 13:14 UTC · original
Rockstar-1998:main→main· +75 −0 · 1 files · 2 commits · openAdd an opt-in Windows host DLL loader hook (
VICTORY_LOAD_DLLS) before spawning the title's main thread so external tools (e.g. ScriptHook / trainer loaders) can attach cleanly after imports are bound.VICTORY_LOAD_DLLS=<path>;<path>: loads each host DLL viaLoadLibraryWand callsvictory_on_title_mapped(&TitleInfo)if exported (missing files/exports or non-zero returns are logged and skipped).VICTORY_HOST_EXE_DIR=<dir>: optional directory override forTitleInfo::exe_path(keeping the original executable name), allowing host DLLs to write state outside a read-only game dump directory.VICTORY_LOAD_DLLSis unset; gated on#[cfg(windows)].@chatgpt-codex-connector[bot] on GitHub · 2026-12-04 13:14 UTC · original · edited 2026-12-04 13:16 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
826dcf8ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-12-04 13:16 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
826dcf8ae7ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@ -499,0 +542,4 @@for path in list.split(';').map(str::trim).filter(|p| !p.is_empty()) {let path_w = wide(std::ffi::OsStr::new(path));// SAFETY: a NUL-terminated path; the module stays loaded for the run.let module = unsafe { LoadLibraryW(path_w.as_ptr()) };@chatgpt-codex-connector[bot] on GitHub · 2026-12-04 13:16 UTC · original
When a requested DLL has a private dependency beside it, this
LoadLibraryWcall resolves that dependency using the host process's normal search order, which does not include the requested DLL's directory. The load then fails and the hook never runs; use a DLL-directory-aware search policy so plugin bundles can load.Useful? React with 👍 / 👎.
@Kal0s-design on GitHub · 2026-12-04 14:17 UTC · original
Tested
826dcf8natively on Windows (MSVC toolchain from rust-toolchain.toml, not Wine). I didn't launch a game. I droveload_host_dllsdirectly from a throwaway unit test (not pushed) with small test DLLs built locally as cdylibs. Each one counts its DllMain attach and writes what it receives fromvictory_on_title_mapped.With
VICTORY_LOAD_DLLSunset the function returns at run.rs:526-528 before doing anything, so the default path is the same as main apart from the call site at run.rs:459-460.cargo test -p victory --bins -- --test-threads=2gives 27 passed, 0 failed. Clippy has no warnings pointing at run.rs.What worked
C:/.../x.dll) all load. DllMain runs once and the export gets struct_size 32, version 1, and the base, size and exe path passed in.a.dll ;; b.dll ;) load both and skip the blank (run.rs:542).not loaded (... os error 126)and the loop moves on. A DLL with no export (version.dll) logs and moves on. A nonzero return is only logged (run.rs:569-570). The doc comment says those DLLs are "skipped", but nothing runs after the call anyway, so this is just wording.VICTORY_HOST_EXE_DIRonly changes the string handed to the DLL (run.rs:530-541). The original file name is kept, and a whitespace-only value falls back to the real exe path. It doesn't touch SetDllDirectory, the current directory or the process search path, so other DLL loads aren't affected.spawn_main(run.rs:459-462), and the title DLL attaches, TLS callbacks and entry point all run inside the thread thatspawn_mainstarts (victory-loader/src/windows.rs:402, 405, 412). So host DLLs are notified before any title code runs.Things I'd change
not loaded (os error 126), and the message names the host DLL, not the missing dependency, which is confusing to debug. Swapping inLoadLibraryExW(path, NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS)loaded the same DLL fine in my test. Per the docs those flags also take PATH and the current directory out of the search for the DLL's own dependencies. I didn't test that part.rel\x.dllresolved against the current directory, and a barex.dllwas picked up from the current directory too. Since the env var is set by the user this isn't a security hole, but a bare name can silently load a different copy depending on where you launched from. With the flags above a relative path is rejected (os error 87, which I saw), so that would also force absolute paths. Logging the resolved module path (GetModuleFileNameW) next to the given name would help either way."C:\Program Files\x.dll"with the quotes) fail with 126 because quotes aren't stripped. Probably fine, but worth a line in the doc since paths copied from Explorer come with quotes.a.dll;a.dll) getsvictory_on_title_mappedcalled twice while DllMain runs once, because LoadLibraryW just hands back the loaded module. The init has to be idempotent, or the list could be deduplicated.Smaller notes
victory_on_title_mappedfor real work would help. I didn't see a hang in testing.TitleInfoand the export signature only exist inside the function (run.rs:513-519, 567). A short doc block with the struct layout would make this easier for DLL authors to use.Overall the opt-in design is sound and does nothing when unset. Point 1 is the one I'd fix before merging.
AI-assisted: yes
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.