HLE: the narrow module path and argv are in the ANSI code page #4539
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4539
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4538"
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?
@breachato on GitHub · 2026-11-30 22:07 UTC · original
breachato:hle-narrow-paths-ansi→main· +36 −4 · 1 files · 1 commits · open[pr-fix]
What it changes
GetModuleFileNameAgave a title image's path as UTF-8 bytes (path.as_bytes()), and the C runtime's narrowargv(__p___argv, built bytitle_argvwithCString::new) was UTF-8 too. Windows gives both in the ANSI code page, and so does our ownGetCommandLineA(throughhost::ansi). With a non-ASCII folder, for exampleC:\Téléchargements\jeu\game.exeor a user folder with an accent:éforéfromGetModuleFileNameA, and when it passes the path on to other narrow calls (CreateFileA,fopen, ...) they read it in the code page and do not find the file;GetCommandLineAandargv[0]disagree on the program.Both now go through
host::ansi, asGetCommandLineAdoes (a character the code page lacks becomes its default character, as on Windows).GetCommandLineA's notes already said a NUL inside an argument ends it there "as intitle_argv";title_argvactually dropped such an argument, and now ends it there.How it was tested
narrow_paths_and_arguments_are_in_the_ansi_code_page: a title image atC:\Téléchargements\jeu\game.exe, thenGetModuleFileNameAandtitle_argv.main, code page 1252):GetModuleFileNameAwroteC:\TC3 A9lC3 A9chargements...(UTF-8). After:C:\TE9lE9chargements..., the bytesGetCommandLineAgives for the same text.cargo test -p victory-hle --lib --locked modules::kernel: 19 passed, including the existingthe_command_line_reads_back_as_the_title_arguments(argv still equals the split command line).cargo test -p victory-hle --lib --locked: 469 passed;modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_itfailed in the full parallel run and passes alone, the known flake (#2420, #2439).cargo clippy -p victory-hle --no-deps --all-targets: nothing inkernel.rs.cargo testpassed for the crates it touches: yesHow to try it
cargo test -p victory-hle --lib --locked narrow_paths_and_arguments. Onmainit fails with the UTF-8 bytes above (on any code page but UTF-8).Checked for overlap
GetModuleFileNameAor__p___argv.Assisted by Claude.
github-bot referenced this pull request2026-12-01 02:08:57 +00:00
380affaf0dto77ae93ba77View 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.