HLE: GetModuleFileNameA answers in the ANSI code page #633
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!633
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-633"
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?
@JFIREonFIRE on GitHub · 2026-11-24 05:57 UTC · original
JFIREonFIRE:fix/module-file-name-ansi→main· +91 −2 · 2 files · 1 commits · openFor a title image,
GetModuleFileNameA(crates/victory-hle/src/modules/kernel.rs) copied the path's UTF-8 bytes. The Win32Afunctions use the process's ANSI code page, and the rest of this crate already assumes that:GetModuleFileNameA, which returns ANSI;files.rsnarrow()decodes every narrow title path withMultiByteToWideChar(CP_ACP);CreateFileA/ CRT, which decode with CP_ACP too.So when the game is installed under a folder name outside ASCII, the title's own location comes back mangled for anything it builds from it:
C:\Spiele\Grüße\game.exe, code page 1252üßC3 BC C3 9F(UTF-8)Grüße, another folderFC DFGrüßeTruncation also counted UTF-8 bytes, so it could cut a character in half.
Change
GetModuleFileNameAconverts the name withWideCharToMultiByte(CP_ACP), as the host does: characters the code page lacks become?.XLaunchNewGamegets that same path back from the title (the doc comment says Grand Theft Auto VI relaunches itself with its own path fromGetModuleFileNameA). It now decodes the executable withMultiByteToWideChar(CP_ACP)instead of as UTF-8, so a relaunch from such a folder still finds its executable.kernel::to_ansiandkernel::from_ansi.Paths in ASCII are unchanged.
Tests
a_title_image_name_is_in_the_ansi_code_page: it registersC:\Spiele\Grüße\game.exe, checks thatGetModuleFileNameAreturns the CP_ACP bytes and that they decode back to the path, and, under code page 1252, checks forFC DF. It fails onmain(UTF-8 bytes) and passes with the change. Under a UTF-8 code page (65001) the bytes are the same either way and it still passes.cargo test --workspacepasses on Windows 11 (code page 1252, RTX 3090).This doesn't overlap #186 or #373, which change the last error and the null buffer of the same function, or #455, which changes the relaunch argument matching. I searched PRs and issues for
GetModuleFileNameA, ANSI / code page,XLaunchNewGameand non-ASCII paths and found nothing else.AI use: Claude Code (Claude Opus 5.5) found the issue, wrote the change and test, and ran them.
🤖 Generated with Claude Code
@pickles976 on GitHub · 2026-11-24 06:01 UTC · original
Cross-checked against the sibling project (ivall/xcl) while reviewing this: their
write_ansi_outalready routes throughWideCharToMultiByte(CP_ACP, …)for the sameA-function semantics, so this class looks fixed/never-present on that side. Posting here so the cross-project bug ledger stays honest in both directions — sites and semantics transfer whether the news is good or bad.@Marvisak on GitHub · 2026-11-25 00:31 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-hle/src/modules/kernel.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
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.Merge
Merge the changes and update on Forgejo.