Skip to content

[upstream #1054] VFS: a delete through a handle hides the game file (#998) - #96

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1054
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1054

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

A game file deleted through a handle came back: SetFileInformationByHandle was not hooked, so the delete removed only the overlay copy the handle points at and no whiteout was recorded. MSVC's std::filesystem::remove deletes this way. Part of xcl-dev#998 (the delete-by-handle case for files).

What is in it

  • crates/xcl/src/vfs_hooks.rs: a hook on SetFileInformationByHandle. After a successful FileDispositionInfo / FileDispositionInfoEx delete on a file inside the overlay, the whiteout is recorded through the existing commit_overlay_removal; a disposition that takes the delete back removes it. Everything else is passed through unchanged: other information classes, handles outside the overlay, failed calls.
  • Two unit tests in the same file: delete_by_handle_hides_the_game_file and set_file_info_by_handle_passes_everything_else_through.

Tested

  • NVIDIA GeForce RTX 3090, driver 616.56 (32.0.16.1656); AMD Ryzen 9 5950X, 32 GB; Windows 11 Pro 23H2 build 22631.6199; Rust 1.100.0 stable-x86_64-pc-windows-msvc; release; DXC 1.9.2602.17
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4 on this PR's head: 729 passed, 0 failed, 41 ignored (main at 02bfd1d: 727 passed, 0 failed, 41 ignored)
  • SKIPPED GPU tests printed: 2, both no wave64 (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware). With --nocapture, main shows 3 more on this machine (no reserved cube with mips on this adapter; no D3D12 debug layer installed, twice); that run was not repeated on the PR.
  • delete_by_handle_hides_the_game_file fails without the new logic (with set_file_info_vfs returning the original call's result at once: 11 passed, 1 failed in cargo test -p xcl --release --lib vfs_hooks, at the whiteout assertion).

Regression run

main:

xcl-smoke v1
commit: 02bfd1d6c0659a5102abde6d73babba8afd9fce9
gpu: NVIDIA GeForce RTX 3090
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1629 (PresentX 1629)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14484 MB

PR:

xcl-smoke v1
commit: 7ecc08f8a9434315b6ebc1214433eaac9cfa6767
gpu: NVIDIA GeForce RTX 3090
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1625 (PresentX 1626)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14607 MB

Not tested

  • The retail run does not reach the changed code path as far as I can tell: it stays on the title's first screens for 60 s with no input, and I saw no delete through a handle of a game file. It is a regression check only.
  • No title is known to use this path. The retail title of the regression run cannot reach it through its imports: dumpbin -imports shows no SetFileInformationByHandle in its exe, msvcp140.dll, XCurl.dll or libHttpClient.GDK.dll, and its msvcp140.dll exports no __std_fs_* function. For files the exe imports DeleteFileW, RemoveDirectoryW, MoveFileExW, CreateFileW, CreateDirectoryW, FindFirstFileW and the CRT's remove. A call through GetProcAddress is not ruled out. The run's report.json has an empty vfs section (no redirected writes, no whiteouts). So this fixes a case found by reading the code, not one seen in a game; other titles were not checked.
  • Whether a real title's std::filesystem::remove reaches the kernelbase SetFileInformationByHandle export (only the unit tests and pls_quota, which installs the hooks, cover it).
  • Directories: a directory deleted through a handle is passed through as before (the game directory stays visible). Left out because it overlaps VFS: RemoveDirectoryW on a non-empty game folder succeeds and hides the folder in every later run xcl-dev/xcl#997 / VFS: reject removal of non-empty virtual directories xcl-dev/xcl#1016.
  • Not in this PR, as said on VFS: deleting a game file through a handle only deletes an overlay copy, and the original comes back xcl-dev/xcl#998: FILE_FLAG_DELETE_ON_CLOSE (and FILE_DISPOSITION_FLAG_ON_CLOSE, passed through), rename by handle, skipping the content copy for a DELETE-only open.
  • A write-open of the same path between the disposition and the last close removes the whiteout again (existing prepare_write behaviour); not tested.
  • vfs::tests::truncate_existing_validation_errors fails when only the vfs tests are run (cargo test -p xcl --release --lib vfs: 21 passed, 1 failed, 3 runs of 3, last error 127 where 5 is expected) and passes in the whole suite. Seen with this PR; reported by the tool as the same without it, which I did not rerun myself. Not touched here.
  • AMD and Intel GPUs, Windows 10, Wine, debug build.

AI use

  • Claude Code with Claude Fable 5.2 wrote the code, the tests and this description, and ran the tests and the smoke runs on my machine.

🤖 Generated with Claude Code


Mirror of xcl-dev#1054 (auto-synced, do not edit).

A title that deletes a game file through a handle (MSVC's
std::filesystem::remove: CreateFile2 with DELETE, then
SetFileInformationByHandle with FileDispositionInfoEx or
FileDispositionInfo) holds a handle to the overlay copy. The delete
removed only that copy and no whiteout was recorded, so the original
was visible again.

SetFileInformationByHandle is hooked now. After a successful delete
disposition on a file inside the overlay the whiteout is recorded
through commit_overlay_removal; a disposition that takes the delete
back removes it again. Directories, FILE_DISPOSITION_FLAG_ON_CLOSE,
other information classes and handles outside the overlay are passed
through unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1054 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1054 branch November 25, 2026 00:11
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