Repository navigation
vfs: fix TRUNCATE_EXISTING on un-overlaid game files - #88
Merged
Merged
Conversation
Collaborator
|
Merged. Tested on Windows 11 with an RX 9070 (RDNA4): |
Michael-Glaser
added a commit
to Michael-Glaser/xcl
that referenced
this pull request
Nov 24, 2026
…cl-dev#104) On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (xcl-dev#59, xcl-dev#60, xcl-dev#68, xcl-dev#69, xcl-dev#78, xcl-dev#81, xcl-dev#84, xcl-dev#88, xcl-dev#89, xcl-dev#93, xcl-dev#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method. Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at xcl-dev#59 and the original base-table stub for slots >= scanned). Slot xcl-dev#10 (Reset) stays Reset on both layouts and is not orphaned. Assisted-by: Antigravity (Gemini 4 Neon)
Michael-Glaser
added a commit
to Michael-Glaser/xcl
that referenced
this pull request
Nov 24, 2026
…vall#104) On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (ivall#59, ivall#60, ivall#68, ivall#69, ivall#78, ivall#81, ivall#84, ivall#88, ivall#89, ivall#93, ivall#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method. Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at ivall#59 and the original base-table stub for slots >= scanned). Slot ivall#10 (Reset) stays Reset on both layouts and is not orphaned. Assisted-by: Antigravity (Gemini 4 Neon)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
TRUNCATE_EXISTINGopens of un-overlaid read-only game files invfsandvfs_hooks:in_orig == true,in_ov == false) withTRUNCATE_EXISTING(5),Vfs::open_decision_forcalledprepare_write(&rel, false)(which creates only the parent directory in the overlay, not the file) and returnedDecision::Use(ov). TheCreateFileW/CreateFileA/CreateFile2hooks then forwardedovto Windows withTRUNCATE_EXISTING, which failed withERROR_FILE_NOT_FOUNDbecauseovdoes not yet exist on disk.Decision::UseWithDisposition(String, u32)and wired it throughhk_create_file_w,hk_create_file_a, andhk_create_file_2.TRUNCATE_EXISTING(and no existing overlay entry / dangling symlink),open_decision_forrewrites the disposition toCREATE_ALWAYSin the overlay instead of publishing a 0-byte placeholder file ahead of the native call. That way Windows atomically creates the truncated overlay copy only if the nativeCreateFile*succeeds, leaving the original file untouched and avoiding empty placeholder files on failed opens.TRUNCATE_EXISTING:GENERIC_WRITE(0x4000_0000) before checking existence, returningERROR_INVALID_PARAMETERotherwise (matching Win32CreateFileW, which also rejectsGENERIC_READ,FILE_WRITE_DATA, andGENERIC_ALLwithoutGENERIC_WRITE).FILE_FLAG_OPEN_REPARSE_POINT) without creating overlay entries, returningERROR_INVALID_PARAMETERwhenFILE_FLAG_BACKUP_SEMANTICSis set andERROR_ACCESS_DENIEDotherwise (matching native Win32CreateFileW).Decision::Use(ov)with the originalTRUNCATE_EXISTINGdisposition.Verification
cargo test -p xcl --lib vfs -- --test-threads=2: 7 passed; 0 failedtruncate_existing_rewrites_unoverlaid_disposition_and_opens_with_win32(verifies zero placeholder file prior to native open, real Win32CreateFileWcreation/truncation for both un-overlaid and already-overlaid files, and untouched original game file).truncate_existing_validation_errors(verifiesGENERIC_WRITEenforcement, missing/whited-out files, and native Win32 parity for directory errors with and withoutFILE_FLAG_BACKUP_SEMANTICS).