hle: translate \??\ object-manager paths onto virtual drives #2089

Open
github-bot wants to merge 2 commits from github-bot/gh-2089 into main AGit
Owner

@⁠Pradhyumna51 on GitHub · 2026-11-25 04:34 UTC · original
Pradhyumna51:fix/hle-object-prefix-virtual-drives → main · +89 −11 · 2 files · 2 commits · open

Commit 11ca3ce taught media::local to accept the \??\ object-manager prefix so shares under \??\UNC\... stay blocked, while returning \??\X:... paths directly before files::translate could rewrite them. Meanwhile, files::translate and files::narrow only checked for \\?\, leaving \??\X:\... paths unmapped in both the file APIs and Media Foundation path resolution.

files::translate and files::narrow now recognize \??\ alongside \\?\, stripping a verbatim \\?\ prefix from the mounted host root or rewriting a \\server\share root to UNC\server\share when \??\ is used. media::local now passes local \??\X:... paths through files::translate.

Verified locally with cargo +stable-x86_64-pc-windows-gnu test -p victory-hle --locked --lib -- --test-threads=1 (144 passed, 0 failed) and cargo +stable-x86_64-pc-windows-gnu xtask policy (182 files ok).

**@⁠Pradhyumna51** on GitHub · 2026-11-25 04:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2089) `Pradhyumna51:fix/hle-object-prefix-virtual-drives` → `main` · +89 −11 · 2 files · 2 commits · open Commit 11ca3ce taught `media::local` to accept the `\??\` object-manager prefix so shares under `\??\UNC\...` stay blocked, while returning `\??\X:...` paths directly before `files::translate` could rewrite them. Meanwhile, `files::translate` and `files::narrow` only checked for `\\?\`, leaving `\??\X:\...` paths unmapped in both the file APIs and Media Foundation path resolution. `files::translate` and `files::narrow` now recognize `\??\` alongside `\\?\`, stripping a verbatim `\\?\` prefix from the mounted host root or rewriting a `\\server\share` root to `UNC\server\share` when `\??\` is used. `media::local` now passes local `\??\X:...` paths through `files::translate`. Verified locally with `cargo +stable-x86_64-pc-windows-gnu test -p victory-hle --locked --lib -- --test-threads=1` (144 passed, 0 failed) and `cargo +stable-x86_64-pc-windows-gnu xtask policy` (182 files ok).
Recognize the Windows object-manager \??\ prefix alongside \\?\ in files::translate and files::narrow, and let media::local pass \??\X:... paths through files::translate instead of returning the raw guest path.
Borrow the caller UTF-16 slice directly for drive, verbatim, and object-manager paths instead of re-encoding from the lossy classification string, and test unpaired-surrogate preservation.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:54:31 +00:00
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 04:42 UTC · original

I ran CreateFileA and CreateFileW through the synthetic conformance title from #2057 (637ba6f), before and after applying the runtime diff from 84ed850. Each check opened the same mounted ASCII file with GENERIC_READ and OPEN_EXISTING and compared the bytes read against the fixture.

Path Before (A/W) After (A/W)
G:\conformance.txt Both pass Both pass
\\?\G:\conformance.txt Both pass Both pass
\??\G:\conformance.txt Both return INVALID_HANDLE_VALUE, last error 3 Both pass

The other 152 checks gave identical results in both runs (147 passed, 5 failed). This exercises guest file reads on a local virtual drive. Media paths and native Windows behavior were outside this test.

AI-assisted testing and review.

**@⁠Dathinel** on GitHub · 2026-11-25 04:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2089#issuecomment-7153096599) I ran CreateFileA and CreateFileW through the synthetic conformance title from #2057 (`637ba6f`), before and after applying the runtime diff from `84ed850`. Each check opened the same mounted ASCII file with `GENERIC_READ` and `OPEN_EXISTING` and compared the bytes read against the fixture. | Path | Before (A/W) | After (A/W) | | --- | --- | --- | | `G:\conformance.txt` | Both pass | Both pass | | `\\?\G:\conformance.txt` | Both pass | Both pass | | `\??\G:\conformance.txt` | Both return `INVALID_HANDLE_VALUE`, last error 3 | Both pass | The other 152 checks gave identical results in both runs (147 passed, 5 failed). This exercises guest file reads on a local virtual drive. Media paths and native Windows behavior were outside this test. AI-assisted testing and review.
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:46 UTC · original

Triage verdict — Keep the virtual-drive fix, preserve original wide paths (84ed850)

Evidence

  • @⁠Pradhyumna51’s patch fills the mapping gap for object-manager-prefixed local drive paths after 11ca3ce. The old Media Foundation branch handed the original UTF-16 units through unchanged. This version classifies a lossy string and reconstructs the host path from it, so an unmapped native path can lose original code units. Media classification and fallback

Checks and limits

  • Two focused exact-head native Windows tests passed with synthetic local files. They cover object-prefix mapping through the narrow and wide file wrappers and the existing mounted-drive case. The Media Foundation preservation edge is from source review. File fixture

Next step

  • Keep the local-drive classification, then pass the original wide path to translation and preserve it for the unmapped fallback. Add a small path-resolution assertion for code-unit preservation alongside the existing file-open checks.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2089#issuecomment-7153145870) **Triage verdict — Keep the virtual-drive fix, preserve original wide paths** (`84ed850`) **Evidence** - @⁠Pradhyumna51’s patch fills the mapping gap for object-manager-prefixed local drive paths after `11ca3ce`. The old Media Foundation branch handed the original UTF-16 units through unchanged. This version classifies a lossy string and reconstructs the host path from it, so an unmapped native path can lose original code units. [Media classification and fallback](https://github.com/Marvisak/VIctory/blob/84ed8501cab75a2b9283009156a756e9b382b57e/crates/victory-hle/src/modules/media.rs#L44-L109) **Checks and limits** - Two focused exact-head native Windows tests passed with synthetic local files. They cover object-prefix mapping through the narrow and wide file wrappers and the existing mounted-drive case. The Media Foundation preservation edge is from source review. [File fixture](https://github.com/Marvisak/VIctory/blob/84ed8501cab75a2b9283009156a756e9b382b57e/crates/victory-hle/src/modules/files.rs#L983-L1017) **Next step** - Keep the local-drive classification, then pass the original wide path to translation and preserve it for the unmapped fallback. Add a small path-resolution assertion for code-unit preservation alongside the existing file-open checks. This verification was AI-assisted.
Author
Owner

@⁠Pradhyumna51 on GitHub · 2026-11-25 04:50 UTC · original

Updated media::local in 6df6d10 to pass Cow::Borrowed(url) directly for drive, \\?\, and \??\ paths rather than re-encoding wide units from the lossy classification string, while keeping file: URL percent-decoding owned. Both virtual-drive translation and unmapped fallbacks now preserve arbitrary UTF-16 code units unchanged.

Added unit assertions in only_local_files_reach_the_host for an unpaired surrogate on both an unmapped \??\C:\ path and a mounted \??\ drive, and verified with cargo +stable-x86_64-pc-windows-gnu test -p victory-hle --locked --lib -- --test-threads=1 (144 passed, 0 failed) and cargo +stable-x86_64-pc-windows-gnu xtask policy (182 files ok).

**@⁠Pradhyumna51** on GitHub · 2026-11-25 04:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2089#issuecomment-7153215095) Updated `media::local` in `6df6d10` to pass `Cow::Borrowed(url)` directly for drive, `\\?\`, and `\??\` paths rather than re-encoding wide units from the lossy classification string, while keeping `file:` URL percent-decoding owned. Both virtual-drive translation and unmapped fallbacks now preserve arbitrary UTF-16 code units unchanged. Added unit assertions in `only_local_files_reach_the_host` for an unpaired surrogate on both an unmapped `\??\C:\` path and a mounted `\??\` drive, and verified with `cargo +stable-x86_64-pc-windows-gnu test -p victory-hle --locked --lib -- --test-threads=1` (144 passed, 0 failed) and `cargo +stable-x86_64-pc-windows-gnu xtask policy` (182 files ok).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:34 UTC · original

Automated triage for the maintainers.

files::translate and files::narrow (modules/files.rs) now accept the \??\ prefix as well as \\?\, so \??\X:\... reaches a virtual drive. A \\?\ or \\server\share root is rewritten correctly under a prefix, which also fixes the \\?\ prefix with a verbatim root. media::local (modules/media.rs) sends local \??\X: paths through translate and passes the original UTF-16 units through instead of a lossy re-encoding. I checked that the share and UNC rejections in local are unchanged. Unmapped \??\C: paths reach the host exactly as before, so the media guards are not loosened. Tests cover the mapping, a verbatim-root mount and unpaired surrogates. A contributor's conformance run shows \??\G: opens failing before and passing after. CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2089#issuecomment-7159872919) <!-- victory-triage v1 head=6df6d100d1e3b5d547df7cc4af94fae7eaebe938 verdict=merge-candidate at=2026-11-25T10:33:56Z --> Automated triage for the maintainers. `files::translate` and `files::narrow` (`modules/files.rs`) now accept the `\??\` prefix as well as `\\?\`, so `\??\X:\...` reaches a virtual drive. A `\\?\` or `\\server\share` root is rewritten correctly under a prefix, which also fixes the `\\?\` prefix with a verbatim root. `media::local` (`modules/media.rs`) sends local `\??\X:` paths through `translate` and passes the original UTF-16 units through instead of a lossy re-encoding. I checked that the share and UNC rejections in `local` are unchanged. Unmapped `\??\C:` paths reach the host exactly as before, so the media guards are not loosened. Tests cover the mapping, a verbatim-root mount and unpaired surrogates. A contributor's conformance run shows `\??\G:` opens failing before and passing after. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 01:41 UTC · original

Code review and Windows 11 verification at head 6df6d100d1e3 merged onto main (63bcca43c6a0):

The \??\ prefix support and Cow::Borrowed(url) surrogate preservation in media.rs look useful (xtask policy 191 ok, clippy 0 warnings, victory-hle 155/155 passed), though three path edge cases and a merge conflict with #1772 are worth addressing:

  1. . / .. skipped for \??\ and \\?\ paths (crates/victory-hle/src/modules/files.rs:167):
    • verbatim() is only invoked when prefix.is_empty() && root.len() + tail.len() >= LONG, so any \??\ (or \\?\) path skips verbatim() entirely. While / is converted to \, . and .. in \??\X:\a\..\b remain unnormalized (and Windows object-manager / verbatim paths do not normalize ..).
  2. Drive-root double backslash (files.rs:186):
    • Without stripping trailing separators on root (as #1772 does), a mount at C:\ with input \??\X: produces \??\C:\\.
  3. Minor notes: media.rs:66 trim_start_matches("UNC\\") is case-sensitive, and GetDiskFreeSpaceW (files.rs:431) does not yet extract a volume root for \??\ paths.
  4. Conflict with #1772: Both PRs modify translate() in files.rs (git merge conflicts). Rebasing onto #1772 would resolve the conflict and inherit verbatim() normalization and volume_root cleanly.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 01:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2089#issuecomment-7180031874) Code review and Windows 11 verification at head `6df6d100d1e3` merged onto `main` (`63bcca43c6a0`): The `\??\` prefix support and `Cow::Borrowed(url)` surrogate preservation in `media.rs` look useful (`xtask policy` 191 ok, `clippy` 0 warnings, `victory-hle` 155/155 passed), though three path edge cases and a merge conflict with `#1772` are worth addressing: 1. **`.` / `..` skipped for `\??\` and `\\?\` paths (`crates/victory-hle/src/modules/files.rs:167`)**: - `verbatim()` is only invoked when `prefix.is_empty() && root.len() + tail.len() >= LONG`, so any `\??\` (or `\\?\`) path skips `verbatim()` entirely. While `/` is converted to `\`, `.` and `..` in `\??\X:\a\..\b` remain unnormalized (and Windows object-manager / verbatim paths do not normalize `..`). 2. **Drive-root double backslash (`files.rs:186`)**: - Without stripping trailing separators on `root` (as `#1772` does), a mount at `C:\` with input `\??\X:` produces `\??\C:\\`. 3. **Minor notes**: `media.rs:66` `trim_start_matches("UNC\\")` is case-sensitive, and `GetDiskFreeSpaceW` (`files.rs:431`) does not yet extract a volume root for `\??\` paths. 4. **Conflict with `#1772`**: Both PRs modify `translate()` in `files.rs` (`git merge` conflicts). Rebasing onto `#1772` would resolve the conflict and inherit `verbatim()` normalization and `volume_root` cleanly.
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/2089/head:github-bot/gh-2089'
git switch 'github-bot/gh-2089'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2089'
git switch 'github-bot/gh-2089'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2089'
git switch 'github-bot/gh-2089'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2089'
git switch 'main'
git merge --squash 'github-bot/gh-2089'
git switch 'main'
git merge --ff-only 'github-bot/gh-2089'
git switch 'main'
git merge 'github-bot/gh-2089'
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/Marvisak--VIctory!2089
No description provided.