HLE media: translate \??\<drive> paths through the virtual drives #3271

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3273 into main
andrewpozdnakov7-jpg commented 2026-11-26 15:23:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T15:23:34Z.


media::local handles \\?\<drive> by letting the path reach files::translate, but the \??\<drive> spelling returned early with the title's URL unchanged. A title that opens a media file as \??\G:\video.mp4 handed Media Foundation the virtual drive letter instead of the host folder behind it.

The \??\ branch now translates the drive path like the other spellings, and keeps the title's own spelling when the drive is not virtual, so \??\C:\Windows\a.wav still comes back exactly as given.

  • New case in media tests: \??\<letter>:\movies\intro.mp4 reads the file from the mounted folder, next to the existing \\?\ and file: cases.
  • cargo test -p victory-hle: all suites pass (147 lib tests plus the probes).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean. cargo xtask policy: 192 files ok.

Fixes #2410.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5512722620 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3273). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T15:23:34Z. --- `media::local` handles `\\?\<drive>` by letting the path reach `files::translate`, but the `\??\<drive>` spelling returned early with the title's URL unchanged. A title that opens a media file as `\??\G:\video.mp4` handed Media Foundation the virtual drive letter instead of the host folder behind it. The `\??\` branch now translates the drive path like the other spellings, and keeps the title's own spelling when the drive is not virtual, so `\??\C:\Windows\a.wav` still comes back exactly as given. - New case in `media` tests: `\??\<letter>:\movies\intro.mp4` reads the file from the mounted folder, next to the existing `\\?\` and `file:` cases. - `cargo test -p victory-hle`: all suites pass (147 lib tests plus the probes). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. `cargo xtask policy`: 192 files ok. Fixes #2410.
Dukestar69 commented 2026-11-26 15:27:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T15:27:02Z.

Review: APPROVED


Reviewed the diff and verified locally on Windows 11 x64:

  • Translating \??\<drive> paths via files::translate(&wide) while preserving untranslated host-drive paths via unwrap_or_else(|| with_nul(url)) cleanly aligns \??\ with \\?\ for virtual drives.
  • cargo test -p victory-hle --lib modules::media:: -- --test-threads=1: 5 passed, 0 failed (including only_local_files_reach_the_host covering \??\<drive>).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6076743201 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3273#pullrequestreview-6076743201). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T15:27:02Z. **Review:** APPROVED --- Reviewed the diff and verified locally on Windows 11 x64: - Translating `\??\<drive>` paths via `files::translate(&wide)` while preserving untranslated host-drive paths via `unwrap_or_else(|| with_nul(url))` cleanly aligns `\??\` with `\\?\` for virtual drives. - `cargo test -p victory-hle --lib modules::media:: -- --test-threads=1`: 5 passed, 0 failed (including `only_local_files_reach_the_host` covering `\??\<drive>`). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
AurumCarlos commented 2026-11-26 15:27:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-26T15:27:49Z.

Review: COMMENTED


The change is correct: rest takes the same files::translate path as plain drive paths, and a host drive keeps the title's \??\ spelling.

But #2089 (still open) already fixes \??\ virtual-drive translation, in both media.rs and files.rs. #3030 was closed in favour of it, and #2416 (same issue, #2410) was closed too. Worth linking it and agreeing with its author which one goes forward, since this one covers only the media half.

<!-- greyfinch-sync:Marvisak/VIctory:review:6076753355 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3273#pullrequestreview-6076753355). Originally posted by [AurumCarlos](https://github.com/AurumCarlos) on 2026-11-26T15:27:49Z. **Review:** COMMENTED --- The change is correct: `rest` takes the same `files::translate` path as plain drive paths, and a host drive keeps the title's `\??\` spelling. But #2089 (still open) already fixes `\??\` virtual-drive translation, in both `media.rs` and `files.rs`. #3030 was closed in favour of it, and #2416 (same issue, #2410) was closed too. Worth linking it and agreeing with its author which one goes forward, since this one covers only the media half.
fuzeofficlal commented 2026-11-26 21:16:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T21:16:17Z.

Review: APPROVED


LGTM — verified against origin/main (63bcca43) on Windows x64.

  • \??\<drive> paths now translate through files::translate just like other virtual drive paths, while unmounted host drives fall back to with_nul(url) with the \??\ prefix intact and \??\UNC\... stays rejected.
  • Minor non-blocking note (P3): Going through String::from_utf16_lossy (crates/victory-hle/src/modules/media.rs:45, 69) replaces any unpaired UTF-16 surrogate in a mounted \??\ path with U+FFFD (matching the plain drive-letter path at line 111); passing &url[4..] directly to files::translate would preserve raw UTF-16 code units if ever needed.
  • Checks:
    • cargo test --locked -p victory-hle --lib -- --test-threads=1 modules::media::: 5 passed, 0 failed (including the new \??\{letter}: assertion).
    • cargo clippy -p victory-hle --all-targets --locked -- -D warnings (default and --all-features): clean.
    • cargo xtask policy: 191 files ok; rustfmt --edition 2024: clean.

Synthetic tests only; no game data used.

<!-- greyfinch-sync:Marvisak/VIctory:review:6080549138 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3273#pullrequestreview-6080549138). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T21:16:17Z. **Review:** APPROVED --- LGTM — verified against `origin/main` (`63bcca43`) on Windows x64. - `\??\<drive>` paths now translate through `files::translate` just like other virtual drive paths, while unmounted host drives fall back to `with_nul(url)` with the `\??\` prefix intact and `\??\UNC\...` stays rejected. - **Minor non-blocking note (P3)**: Going through `String::from_utf16_lossy` (`crates/victory-hle/src/modules/media.rs:45, 69`) replaces any unpaired UTF-16 surrogate in a mounted `\??\` path with `U+FFFD` (matching the plain drive-letter path at line 111); passing `&url[4..]` directly to `files::translate` would preserve raw UTF-16 code units if ever needed. - **Checks**: - `cargo test --locked -p victory-hle --lib -- --test-threads=1 modules::media::`: 5 passed, 0 failed (including the new `\??\{letter}:` assertion). - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` (default and `--all-features`): clean. - `cargo xtask policy`: 191 files ok; `rustfmt --edition 2024`: clean. Synthetic tests only; no game data used.
Jackster commented 2026-11-26 22:34:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:34:09Z.


Windows 11, 63bcca4 + this PR:

  • cargo test -p victory-hle media::: 5 passed / 0 failed.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.

The modified test now also asks for \??\<drive>:\movies\intro.mp4 and gets the same file as the plain drive path, so the object-manager spelling of a virtual drive is translated; a host drive under \??\ still comes back as the title spelled it (the files::translate fallback). Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204794595 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3273#issuecomment-7204794595). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T22:34:09Z. --- Windows 11, `63bcca4` + this PR: - `cargo test -p victory-hle media::`: 5 passed / 0 failed. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. The modified test now also asks for `\??\<drive>:\movies\intro.mp4` and gets the same file as the plain drive path, so the object-manager spelling of a virtual drive is translated; a host drive under `\??\` still comes back as the title spelled it (the `files::translate` fallback). Synthetic only. AI-assisted.
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/3273:upstream-pr/3273'
git switch 'upstream-pr/3273'

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/3273'
git switch 'upstream-pr/3273'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3273'
git switch 'upstream-pr/3273'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3273'
git switch 'main'
git merge --squash 'upstream-pr/3273'
git switch 'main'
git merge --ff-only 'upstream-pr/3273'
git switch 'main'
git merge 'upstream-pr/3273'
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!3271
No description provided.