Loader: a bare title file name left the package drive empty; the package mount is now read-only #1104

Open
FordMustang0288 wants to merge 1 commit from upstream-pr/1107 into main
FordMustang0288 commented 2026-11-25 19:37:35 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by FordMustang0288 on 2026-11-25T19:37:35Z.


What

Two host-side fixes for running the title from a package directory, and a guard that stops a title write from reaching the user's own game files.

1. A title started by bare file name lost its package root.

run.rs took the package root as

let title_dir = exe.parent().unwrap_or(Path::new("."));

A caller that starts the title by file name with the working directory set to the package root — the natural invocation, and what a launcher does after cd — gets Some("") from parent(), never None. The fallback never ran, the root was an empty path, and the log showed it plainly:

INFO victory_hle::modules::files: virtual drive drive=G root= hides_host_drive=false

The G: mount then had nothing behind it.

2. A path with no drive of its own did not mean the package.

The title asks for a container at the package root by a path with no drive and no directory of its own (its name appears in the linked upstream reports). With an empty package drive that resolved against the host's current drive (Z: under Wine, i.e. the Linux root):
path="\\<container>" result=0xffffffff succeeded=false last_error=2 (ERROR_FILE_NOT_FOUND).
The mount result stayed zero and the title asserted at its own +0x2237178.

An empty parent now means the working directory, and the package is mounted through mount_package, which marks the drive read-only and makes it the title's current drive — after the T: mount, so it is the one left in force.

3. The read-only flag is enforced, not just recorded.

DRIVES carries a read-only bool; resolve_drive returns it with the resolved path; translate keeps its old behaviour for read-only callers, so reads of the package are unaffected. Mutating bindings refuse a write that lands on the mount with ERROR_ACCESS_DENIED: DeleteFileW/A, RemoveDirectoryW, SetFileAttributesW, CreateDirectoryW, and either side of MoveFileExW. The CreateFile family refuses only on write intent (GENERIC_WRITE, GENERIC_ALL, FILE_WRITE_DATA, FILE_APPEND_DATA, FILE_WRITE_EA, FILE_WRITE_ATTRIBUTES, DELETE, WRITE_DAC, WRITE_OWNER), so a read or query mask still succeeds.

This matters because on hosts that hand the title the user's own files — hardlinks, or the extracted package itself — a write through the package drive silently corrupts input the user owns. Refusing is better than rewriting: the console's package is read-only too, and a title that writes has its T: drive.

The doc comments on mount_package, translate, resolve_drive and has_write_intent describe what the code now does, including that reads are unaffected.

Why this is worth reviewing separately from existing reports

The same assert at +0x2237178 is documented in Marvisak/VIctory#8, xcl-dev/xcl#301 and #945, and all three attribute it to the archive set: an archive absent, held open by another process, or right-sized with wrong contents. That advice is sound but was not the cause here — all 22 archives were present, the set matched the canonical public inventory exactly, and every archive began with valid RPF9 magic. The cause was the empty package root above, which also explains a second symptom nobody had connected to it: the title probing a host path for one of its own DLLs, because with no package drive there was nowhere for a root-relative path to land.

Verified here

Windows GNU cross-build, run under Wine with Proton's vkd3d-proton and Microsoft's dxil.dll. Before/after on the same machine and the same staged package:

before after
probe of the package's own container result=0xffffffff succeeded=false last_error=2 succeeded=true last_error=0
DirectStorage open never reached file opened path="G:\\<container>"
probe activity in a run 6 lines 189 lines
title outcome 0x80000003 about 3 s in no exception; runs to timeout
frames none presented at 30 fps, 21 draws/frame
victory-hle crate tests (Windows target under Wine) — 97 of 98

The one crate-test failure is modules::net::tests::only_loopback_is_reachable, which asserts that the host's ws2_32.dll exports every function this layer overrides; Wine's does not export WSAConnectByList, real Windows does. The patched files do not touch net.rs.

Not claimed: this does not make the title playable. It renders menus and reaches the world at 0.1 fps on the first run with four compute programs refused at pipeline creation — separate issues, filed separately.

Limits of the guard worth stating

The CRT and C++ mutators (_wfopen, _wfsopen, fopen, _open, fiopen, remove, _wchmod, _wutime64) are not covered, so a title writing through one of those to a package path would still reach the host file. This is an improvement, not a sandbox.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6612233122 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1107). Originally posted by [FordMustang0288](https://github.com/FordMustang0288) on 2026-11-25T19:37:35Z. --- ## What Two host-side fixes for running the title from a package directory, and a guard that stops a title write from reaching the user's own game files. **1. A title started by bare file name lost its package root.** `run.rs` took the package root as ```rust let title_dir = exe.parent().unwrap_or(Path::new(".")); ``` A caller that starts the title by file name with the working directory set to the package root — the natural invocation, and what a launcher does after `cd` — gets `Some("")` from `parent()`, never `None`. The fallback never ran, the root was an empty path, and the log showed it plainly: ``` INFO victory_hle::modules::files: virtual drive drive=G root= hides_host_drive=false ``` The `G:` mount then had nothing behind it. **2. A path with no drive of its own did not mean the package.** The title asks for a container at the package root by a path with no drive and no directory of its own (its name appears in the linked upstream reports). With an empty package drive that resolved against the host's current drive (`Z:` under Wine, i.e. the Linux root): `path="\\<container>" result=0xffffffff succeeded=false last_error=2` (ERROR_FILE_NOT_FOUND). The mount result stayed zero and the title asserted at its own `+0x2237178`. An empty parent now means the working directory, and the package is mounted through `mount_package`, which marks the drive read-only and makes it the title's current drive — after the `T:` mount, so it is the one left in force. **3. The read-only flag is enforced, not just recorded.** `DRIVES` carries a read-only bool; `resolve_drive` returns it with the resolved path; `translate` keeps its old behaviour for read-only callers, so **reads of the package are unaffected**. Mutating bindings refuse a write that lands on the mount with `ERROR_ACCESS_DENIED`: `DeleteFileW/A`, `RemoveDirectoryW`, `SetFileAttributesW`, `CreateDirectoryW`, and either side of `MoveFileExW`. The `CreateFile` family refuses only on write intent (`GENERIC_WRITE`, `GENERIC_ALL`, `FILE_WRITE_DATA`, `FILE_APPEND_DATA`, `FILE_WRITE_EA`, `FILE_WRITE_ATTRIBUTES`, `DELETE`, `WRITE_DAC`, `WRITE_OWNER`), so a read or query mask still succeeds. This matters because on hosts that hand the title the user's own files — hardlinks, or the extracted package itself — a write through the package drive silently corrupts input the user owns. Refusing is better than rewriting: the console's package is read-only too, and a title that writes has its `T:` drive. The doc comments on `mount_package`, `translate`, `resolve_drive` and `has_write_intent` describe what the code now does, including that reads are unaffected. ## Why this is worth reviewing separately from existing reports The same assert at `+0x2237178` is documented in Marvisak/VIctory#8, xcl-dev/xcl#301 and #945, and all three attribute it to the archive set: an archive absent, held open by another process, or right-sized with wrong contents. That advice is sound but was not the cause here — all 22 archives were present, the set matched the canonical public inventory exactly, and every archive began with valid `RPF9` magic. The cause was the empty package root above, which also explains a second symptom nobody had connected to it: the title probing a host path for one of its own DLLs, because with no package drive there was nowhere for a root-relative path to land. ## Verified here Windows GNU cross-build, run under Wine with Proton's vkd3d-proton and Microsoft's `dxil.dll`. Before/after on the same machine and the same staged package: | | before | after | | --- | --- | --- | | probe of the package's own container | `result=0xffffffff succeeded=false last_error=2` | `succeeded=true last_error=0` | | DirectStorage open | never reached | `file opened path="G:\\<container>"` | | probe activity in a run | 6 lines | 189 lines | | title outcome | `0x80000003` about 3 s in | no exception; runs to timeout | | frames | none | presented at 30 fps, 21 draws/frame | | `victory-hle` crate tests (Windows target under Wine) | — | 97 of 98 | The one crate-test failure is `modules::net::tests::only_loopback_is_reachable`, which asserts that the **host's** `ws2_32.dll` exports every function this layer overrides; Wine's does not export `WSAConnectByList`, real Windows does. The patched files do not touch `net.rs`. Not claimed: this does not make the title playable. It renders menus and reaches the world at 0.1 fps on the first run with four compute programs refused at pipeline creation — separate issues, filed separately. ## Limits of the guard worth stating The CRT and C++ mutators (`_wfopen`, `_wfsopen`, `fopen`, `_open`, `fiopen`, `remove`, `_wchmod`, `_wutime64`) are **not** covered, so a title writing through one of those to a package path would still reach the host file. This is an improvement, not a sandbox.
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/1107:upstream-pr/1107'
git switch 'upstream-pr/1107'

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/1107'
git switch 'upstream-pr/1107'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1107'
git switch 'upstream-pr/1107'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1107'
git switch 'main'
git merge --squash 'upstream-pr/1107'
git switch 'main'
git merge --ff-only 'upstream-pr/1107'
git switch 'main'
git merge 'upstream-pr/1107'
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
fxceless/victory-fork!1104
No description provided.