HLE: a volume root in the \\?\ form is the host volume's root #4479

Open
github-bot wants to merge 1 commit from github-bot/gh-4478 into main AGit
Owner

@⁠breachato on GitHub · 2026-11-30 20:54 UTC · original
breachato:hle-volume-root-verbatim → main · +81 −8 · 1 files · 1 commits · open

[pr-fix]

What it changes

GetDriveType, GetDiskFreeSpace and GetVolumeInformation (W and A) want a volume root, so for a virtual drive files.rs cuts the host path down to the host volume's root (G:\ → C:\, host_volume_root). That only matched a host path that starts with its drive letter.

translate itself gives the \\?\ form in two cases: when the title writes \\?\X:\.. (supported, per the module docs), and for every path on a drive whose host folder is 248 characters or longer (LONG). In both cases the root reached the host as a folder:

  • GetVolumeInformationW/A failed (returned 0) for all of them;
  • GetDriveTypeW/A returned DRIVE_NO_ROOT_DIR (1) for a long drive's plain X:\.

This adds volume_root, generic over u8/u16: it strips the \\?\ prefix before taking C:\, and turns \\?\UNC\server\share\.. into \\server\share\ (the form verbatim builds for a drive on a share). host_volume_root and GetVolumeInformationA (which had its own copy of the drive-letter case) both use it.

How it was tested

  • No GPU or game needed: the calls go to the host's kernel32 with temp folders mounted as virtual drives.
  • Before (main), per call GetDriveTypeW|GetDriveTypeA|GetDiskFreeSpaceW|GetDiskFreeSpaceA|GetVolumeInformationW|GetVolumeInformationA:
    • short drive, title's \\?\X:\: 3|3|1|1|0|0
    • drive with a 256-character folder, X:\: 1|1|1|1|0|0
    • same drive, \\?\X:\: 3|3|1|1|0|0
  • After: 3|3|1|1|1|1 in all three.
  • New tests: a_volume_root_is_found_in_every_host_form (drive letter, /, \\?\C:\, \\?\UNC\server\share, narrow bytes, and the forms that are not roots) and a_verbatim_or_long_virtual_root_is_the_host_volume_root (the six calls above end to end; fails on main).
  • cargo test -p victory-hle --lib --locked: 471 passed. modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_it failed once in the full parallel run and passes alone; it is the known parallel-run flake (#2420, #2439).
  • cargo clippy -p victory-hle --no-deps --all-targets: nothing in files.rs (the one warning left, in xmem.rs:1933, is on main too).
  • cargo test passed for the crates it touches: yes

How to try it

cargo test -p victory-hle --lib --locked modules::files. To see the bug on main, keep only the new end-to-end test: it stops at the first \\?\X:\ root.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #4468 also edits files.rs (translate, a host path on the drive's own letter), a different function.

Assisted by Claude.

**@⁠breachato** on GitHub · 2026-11-30 20:54 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4478) `breachato:hle-volume-root-verbatim` → `main` · +81 −8 · 1 files · 1 commits · open [pr-fix] ## What it changes `GetDriveType`, `GetDiskFreeSpace` and `GetVolumeInformation` (W and A) want a volume root, so for a virtual drive `files.rs` cuts the host path down to the host volume's root (`G:\` → `C:\`, `host_volume_root`). That only matched a host path that starts with its drive letter. `translate` itself gives the `\\?\` form in two cases: when the title writes `\\?\X:\..` (supported, per the module docs), and for every path on a drive whose host folder is 248 characters or longer (`LONG`). In both cases the root reached the host as a folder: - `GetVolumeInformationW/A` failed (returned 0) for all of them; - `GetDriveTypeW/A` returned `DRIVE_NO_ROOT_DIR` (1) for a long drive's plain `X:\`. This adds `volume_root`, generic over `u8`/`u16`: it strips the `\\?\` prefix before taking `C:\`, and turns `\\?\UNC\server\share\..` into `\\server\share\` (the form `verbatim` builds for a drive on a share). `host_volume_root` and `GetVolumeInformationA` (which had its own copy of the drive-letter case) both use it. ## How it was tested - No GPU or game needed: the calls go to the host's kernel32 with temp folders mounted as virtual drives. - Before (`main`), per call `GetDriveTypeW|GetDriveTypeA|GetDiskFreeSpaceW|GetDiskFreeSpaceA|GetVolumeInformationW|GetVolumeInformationA`: - short drive, title's `\\?\X:\`: `3|3|1|1|0|0` - drive with a 256-character folder, `X:\`: `1|1|1|1|0|0` - same drive, `\\?\X:\`: `3|3|1|1|0|0` - After: `3|3|1|1|1|1` in all three. - New tests: `a_volume_root_is_found_in_every_host_form` (drive letter, `/`, `\\?\C:\`, `\\?\UNC\server\share`, narrow bytes, and the forms that are not roots) and `a_verbatim_or_long_virtual_root_is_the_host_volume_root` (the six calls above end to end; fails on `main`). - `cargo test -p victory-hle --lib --locked`: 471 passed. `modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_it` failed once in the full parallel run and passes alone; it is the known parallel-run flake (#2420, #2439). - `cargo clippy -p victory-hle --no-deps --all-targets`: nothing in `files.rs` (the one warning left, in `xmem.rs:1933`, is on `main` too). - `cargo test` passed for the crates it touches: yes ## How to try it `cargo test -p victory-hle --lib --locked modules::files`. To see the bug on `main`, keep only the new end-to-end test: it stops at the first `\\?\X:\` root. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #4468 also edits `files.rs` (`translate`, a host path on the drive's own letter), a different function. Assisted by Claude.
GetDriveType, GetDiskFreeSpace and GetVolumeInformation (W and A) want a
volume root, so a virtual drive's root is cut down to the host volume's
(C:\). That only matched a host path starting with its drive letter.
translate gives the \\?\ form for a title path in that form and for every
path on a drive whose folder is 248 characters or longer, so those roots
reached the host as folders: GetVolumeInformation failed for all of them
and GetDriveType said DRIVE_NO_ROOT_DIR for a long drive's X:\.

volume_root now strips the \\?\ prefix (and turns \\?\UNC\server\share
into \\server\share\), and GetVolumeInformationA uses it too instead of
its own copy of the drive-letter case.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 20:59:23 +00:00
github-bot force-pushed github-bot/gh-4478 from 37ac74c8f8 to 5e16277e2f 2026-12-01 14:00:20 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/4479/head:github-bot/gh-4478'
git switch 'github-bot/gh-4478'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4478'
git switch 'github-bot/gh-4478'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4478'
git switch 'github-bot/gh-4478'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4478'
git switch 'main'
git merge --squash 'github-bot/gh-4478'
git switch 'main'
git merge --ff-only 'github-bot/gh-4478'
git switch 'main'
git merge 'github-bot/gh-4478'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4479
No description provided.