Files: send rewritten narrow paths to the host, not to our wide wrappers #111
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!111
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/111/head"
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?
@Dufftwt on GitHub · 2026-11-24 00:36 UTC · original
Dufftwt:fix/narrow-paths-translated-twice→main· +88 −16 · 1 files · 1 commits · merged 2026-11-24 07:50 UTCWhat's wrong
The title sees its console drives because VIctory mounts host folders as drive letters. The game folder is always
G:and the temp folder is alwaysT:. Every file call the title makes goes through a wrapper infiles.rsthat turnsG:\...into the real host path.Five of the narrow (
char*) wrappers rewrite the path correctly, but then hand the result to our own wide wrapper instead of to Windows:CreateFileA→ ourCreateFileWGetFileAttributesA→ ourGetFileAttributesWfopen→ our_wfopenfopen_s→ our_wfopen_sstd::_Fiopen(whatstd::ifstream/std::ofstreamuse) → our wide_FiopenThe wide wrapper rewrites the path a second time. Usually that does nothing, because the host path starts with a letter that isn't mounted. But
G:andT:are fixed letters. So if the game is installed on a hostG:drive, the host path starts withG:as well and is rewritten again:On that setup, every narrow open of a game file fails, or creates a file in the wrong folder. The wide calls are fine, so the failures look random. The same happens with
T:if the data folder is on a hostT:drive.The other narrow wrappers in the same file already do this correctly:
DeleteFileA,SetCurrentDirectoryA,_open,_stat64i32andremovepass the rewritten path straight to the host's wide function.What the fix does
The five wrappers now call the host's wide function directly, using the existing
host!macro, just like their siblings. A narrow path is now rewritten exactly once, the same as a wide path. The module comment now explains why they must not go through our wide wrappers.How it behaves after the fix
G:orT:, a narrow call and its wide twin open the same file.Tests
The new test
narrow_paths_are_rewritten_onceinfiles.rs:G:drive mounted asG:;I ran
cargo test --workspace --no-fail-faston GitHub'swindows-latestwith Rust 1.98.1 fromrust-toolchain.toml:victory-hlehas 82 passed and 0 failed.main: it fails.GetFileAttributesAfinds the file through the doubled path (left: 32, right: 4294967295).victory-gpu'sroot::tests::host_serialized_blobs_create_root_signatures. It fails the same way on unmodifiedmainon that runner, and #36 changes that test.Not tested: a real run of the game installed on a
G:drive...in a title path stops at the virtual drive's root #182@DaviTostes on GitHub · 2026-11-24 01:12 UTC · original
Tested
27b530e: pass (no regression).cargo xwin ... --target x86_64-pc-windows-msvc -p victory-hle: 81 passed, 1 failed, including the 1 test this PR adds.modules::net::tests::only_loopback_is_reachable(Wine lacksWSAConnectByList, as in #118), not this PR.No game data used.