VFS: ReplaceFileW is redirected #60
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!60
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/60/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?
@gefydev on GitHub · 2026-11-22 23:07 UTC · original
gefydev:vfs-replace-file→main· +39 −0 · 1 files · 1 commits · merged 2026-11-23 09:44 UTCReplaceFileWis the usual way to save safely: writesave.tmp, then replacesave.datwith it, optionally keepingsave.bak.vfs_hooks.rsdoesn't hook it, so:T:\, the PLS driveS:\), the call goes to the PC's own drive and fails, leaving the old save and the temporary file.The new hook:
source_offor the two existing files,dest_offor the backup) and calls the original.CopyFileWand the replacement withMoveFileExW. Both go through their own hooks (the guard is dropped first), so the write lands in the overlay the same way a move does today.CopyFileWis only hooked in #59; without it the backup copy is still the right call, it just isn't redirected yet. The two PRs don't conflict.Validation
The hooks are process-wide and need an initialized VFS (a global
OnceLock), so this isn't a unit test. I ran a probe alone, with a VFS that mountsG:(the game) andT:on temp folders and the real hooks installed. Under Wine:mainReplaceFileW(T:\save.dat, T:\save.tmp, T:\save.bak)save.datstill old, no backup,save.tmpleftsave.datnew,save.bakold,save.tmpgoneReplaceFileW(G:\save.dat, T:\save.tmp, null)G:\save.datstill the originalG:\save.datreads the new data fromoverlay\save.dat; the file in the game folder is still the original (checked outside Wine)cargo test -p xcl --lib: 343 passed, 0 failed, on Windows GNU under Wine.github-bot referenced this pull request2026-11-26 04:19:41 +00:00
@ivall on GitHub · 2026-11-23 09:45 UTC · original
Merged (
533187c). Verified on Windows 11 with the real hooks:ReplaceFileWandReplaceFileA(which reachesReplaceFileW) onT:– new data, backup with the old, temp gone;ReplaceFileW(G:\save.dat, T:\save.tmp, G:\save.bak)–G:\save.datreads the new data from the overlay, the backup is in the overlay, the game folder's file is unchanged (checked from outside the process).Tested on Windows 11 (RX 9070):
cargo test --workspacegreen (lib 351, e2e), and a 45 s Unicorn Overlord run on the release build (VFS hooks active, ~60 fps, clean exit). Thanks!