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

Open
Pradhyumna51 wants to merge 2 commits from upstream-pr/2089 into main
Pradhyumna51 commented 2026-11-25 04:34:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Pradhyumna51 on 2026-11-25T04:34:48Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6597287848 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2089). Originally posted by [Pradhyumna51](https://github.com/Pradhyumna51) on 2026-11-25T04:34:48Z. --- 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).
DenRakEiw commented 2026-11-25 05:06:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:41:38Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-hle --lib files:: — 7 passed, 0 failed (including object_prefix_paths_reach_the_host_folder)
  • cargo clippy -p victory-hle --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean translation of \??\ object-manager paths onto virtual drives with unit test coverage. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051958437 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2089#pullrequestreview-6051958437). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:41:38Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-hle --lib files::` — 7 passed, 0 failed (including `object_prefix_paths_reach_the_host_folder`) - `cargo clippy -p victory-hle --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean translation of `\??\` object-manager paths onto virtual drives with unit test coverage. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 05:06:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:02:19Z.

Review: COMMENTED


Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.

??\ object-manager paths translated onto virtual drives — path canonicalization for drive-letter-less NT paths; matches how titles open files via object manager.

<!-- greyfinch-sync:Marvisak/VIctory:review:6052104896 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2089#pullrequestreview-6052104896). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T05:02:19Z. **Review:** COMMENTED --- Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff. \??\ object-manager paths translated onto virtual drives — path canonicalization for drive-letter-less NT paths; matches how titles open files via object manager.
Dathinel commented 2026-11-25 05:06:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T04:42:51Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153096599 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2089#issuecomment-7153096599). Originally posted by [Dathinel](https://github.com/Dathinel) on 2026-11-25T04:42:51Z. --- 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.
jeremygold02 commented 2026-11-25 05:06:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:46:05Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153145870 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2089#issuecomment-7153145870). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:46:05Z. --- **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.
Pradhyumna51 commented 2026-11-25 05:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Pradhyumna51 on 2026-11-25T04:50:39Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153215095 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2089#issuecomment-7153215095). Originally posted by [Pradhyumna51](https://github.com/Pradhyumna51) on 2026-11-25T04:50:39Z. --- 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).
Marvisak commented 2026-11-25 11:05:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:34:05Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159872919 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2089#issuecomment-7159872919). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:34:05Z. --- <!-- 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)_
fuzeofficlal commented 2026-11-26 02:07:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:41:42Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7180031874 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2089#issuecomment-7180031874). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T01:41:42Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2089:upstream-pr/2089'
git switch 'upstream-pr/2089'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2089'
git switch 'upstream-pr/2089'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2089'
git switch 'upstream-pr/2089'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2089'
git switch 'main'
git merge --squash 'upstream-pr/2089'
git switch 'main'
git merge --ff-only 'upstream-pr/2089'
git switch 'main'
git merge 'upstream-pr/2089'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2087
No description provided.