HLE: virtual drives mishandle verbatim/drive-root mounts and GetDiskFreeSpaceW volume roots (fix on a fork) #1742
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#1742
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@AndyLatimer on GitHub · 2026-11-24 21:45 UTC · original
Summary
In
crates/victory-hle/src/modules/files.rs, virtual-drive path translation andGetDiskFreeSpaceWmishandle three host-root forms on Windows:Verbatim (
\\?\) mounted host roots (for example, any path returned bystd::fs::canonicalizeon Windows):translate()only enteredverbatim()whenprefix.is_empty() && root.len() + tail.len() >= LONG.X:/a/b.txt) or dot segments (X:/sub/../b.txt),translate()kept/and./..verbatim inside the\\?\host path, which Windows rejects (CreateFileWreturnsINVALID_HANDLE_VALUE).\\?\X:\a.txt),translate()prepended a second\\?\, producing\\?\\\?\C:\...\a.txt(ERROR_INVALID_NAME, code 123).root_wide()stripped the trailing\from verbatim drive roots (\\?\C:\->\\?\C:, length 6) because the minimum kept length was hardcoded to 3.Drive-root mounts (
C:\) and UNC mounts under\\?\:root_wide()keeps the trailing\onC:\(length 3), sotranslate()doubled the separator onX:\foo(C:\\foo),X:(C:\\), and\\?\X:\foo(\\?\C:\\foo).verbatim()stripped the trailing\from\\?\C:\whentailhad no remaining components, leaving\\?\C:.\\server\share\dirwith an extended title path\\?\X:\foo,translate()produced\\?\\\server\share\dir\fooinstead of\\?\UNC\server\share\dir\foo.GetDiskFreeSpaceWvolume-root extraction:GetDiskFreeSpaceWonly matched[letter, b':', sep, ..]at the start of the translated host path.translate()emitted a\\?\path (e.g. a verbatim query\\?\X:\, a canonicalized\\?\mount, or a long host root>= 248chars) or a UNC path (\\server\share\.../\\?\UNC\server\share\...), it failed to reduce the path to its volume root (C:\or\\server\share\), causing Win32GetDiskFreeSpaceWto fail (ERROR_INVALID_NAME/ERROR_PATH_NOT_FOUND).(Note: this is distinct from open PRs #182 and #421, which clean
../.segments in short and\\?\title paths over plain host roots without addressing\\?\mounted roots, drive-root separator doubling, orGetDiskFreeSpaceW.)Fix on fork
github.com/AndyLatimer/VIctory@462a64e62d(based onorigin/mainffe310e)Changes
root_wide: keep trailing separator on verbatim drive roots (min = 7for\\?\,3otherwise).verbatim: restore trailing\when the result ends at a drive colon (\\?\C:).translate: routeroot.starts_with(&VERBATIM)throughverbatim(), convert UNC roots under\\?\to\\?\UNC\..., and avoid doubling separators whenrootitself ends with a separator.GetDiskFreeSpaceW: extract volume roots viavolume_root()for plain drive,\\?\verbatim drive, UNC (\\server\share\...), and\\?\UNC\server\share\...paths.crates/victory-hle/src/modules/files.rs:verbatim_host_roots_translate_and_open_on_the_hostdrive_root_mount_does_not_double_separatorsdisk_free_space_handles_verbatim_and_long_virtual_rootsVerification
Tested on Windows 11 x64 MSVC (Rust 1.98.1), synthetic unit tests only (no game files or console SDK data):
cargo test -p victory-hle --lib files::): all 3 new tests fail:verbatim_host_roots_translate_and_open_on_the_host:CreateFileWreturns-1for\\?\C:\Users\...\from_slash.bin(forward slash in verbatim path).drive_root_mount_does_not_double_separators:Some("C:\\\\foo") != Some("C:\\foo").disk_free_space_handles_verbatim_and_long_virtual_roots:GetDiskFreeSpaceWreturns0(ERROR_INVALID_NAME, code 123 on\\?\<letter>:\).rustfmt --edition 2024 --check crates/victory-hle/src/modules/files.rs: 0 diffs on touched lines (1 pre-existing untouched line atkernel_reads_reach_the_buffer).cargo test -p victory-hle: 97 unit tests + 1 integration test passed, 0 failed.cargo clippy -p victory-hle --all-targets -- -D warnings: clean.cargo check -p victory --features diagnostics: clean.cargo xtask policy:asset policy: 154 files ok.AI disclosure: found, verified, and drafted with assistance from Google Antigravity.
@Marvisak on GitHub · 2026-11-25 12:49 UTC · original
Automated triage for the maintainers. Confirmed by reading
main(940d32f),crates/victory-hle/src/modules/files.rs:translatetakes theverbatim()route only when the title path has no\\?\prefix and the result is at leastLONGcharacters. A short path over a\\?\host root keeps its/and./..segments, and a\\?\X:\...title path over a\\?\(or UNC) root gets a second prefix.root_widekeeps at most 3 characters of trailing separator, so\\?\C:\becomes\\?\C:. A plainC:\root keeps its\, andtranslatethen adds another one before the tail (C:\\foo, andC:\\forX:).GetDiskFreeSpaceWreduces only a host path that starts withletter:plus a separator to its volume root, so\\?\and UNC host paths are passed through whole.Open PR #1772 carries the fork fix with the three tests.
Generated by Claude Code