Skip to content

VFS: report existing game files on CREATE_ALWAYS - #158

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
ebarr24:fix/vfs-create-always-last-error
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
ebarr24:fix/vfs-create-always-last-error

Conversation

@ebarr24

@ebarr24 ebarr24 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

When CREATE_ALWAYS overwrites an existing file, Win32 returns a valid handle and sets GetLastError() to ERROR_ALREADY_EXISTS (183). XCL's first overwrite of a game file creates a new physical overlay file. That open succeeds with last error 0, so the title sees the file as newly created. Win32 CreateFileW contract

The CreateFileW, CreateFileA, and CreateFile2 hooks share the same open decision. When a visible original file has no overlay entry, report ERROR_ALREADY_EXISTS after the redirected overwrite succeeds. The test covers the first overwrite, an existing overlay file, a new path, and a previously deleted path. It checks the original bytes and verifies that a native open failure preserves its error.

Verification

On Windows 11 25H2 (26200.9711), Rust 1.100.0 x86_64-pc-windows-gnu, RTX 3080 (driver 616.92), and DXC 1.9.2609.5:

cargo build --locked --workspace
cargo test --locked -p xcl create_always_reports_existing_game_file -- --test-threads=4
  • With the regression harness on base db5dc26, overwriting a game file for the first time succeeds with 0 instead of 183.
  • On 323767f the regression passes.
  • The full workspace suite on 9f1a048 with the independent fixture test fix reported 569 passes, zero failures and 39 ignored. Two native-wave64 tests and the unconfigured retail-sample tests returned early. Fixture test fix #157

AI-assisted patch preparation and verification.

The first overwrite of a visible game file creates a new overlay file, so the native open reports success with a zero last error. Preserve ERROR_ALREADY_EXISTS for the title after a successful redirected open.
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants