vfs: fix TRUNCATE_EXISTING on un-overlaid game files #88
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!88
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/88/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@certified-retart on GitHub · 2026-11-23 02:45 UTC · original
certified-retart:fix/vfs-truncate-existing→main· +150 −1 · 2 files · 1 commits · merged 2026-11-23 10:47 UTCSummary
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).github-bot referenced this pull request2026-11-26 04:19:41 +00:00
@ivall on GitHub · 2026-11-23 10:48 UTC · original
Merged. Tested on Windows 11 with an RX 9070 (RDNA4):
cargo test --workspacegreen with the retail samples (shader pack, console DLLs, texture archive), lib tests also withXCL_SPLIT_WAVE64=1; Unicorn Overlord and XDefiant run with this round merged. Thanks!