VFS: a delete through a handle hides the game file (#998) #1054

Open
github-bot wants to merge 1 commit from github-bot/gh-1054 into main AGit
Owner

@⁠CharlyRien on GitHub · 2026-11-24 10:57 UTC · original
CharlyRien:vfs/delete-by-handle → main · +155 −0 · 1 files · 1 commits · open

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 #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 #997 / #1016.
  • Not in this PR, as said on #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

**@⁠CharlyRien** on GitHub · 2026-11-24 10:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/1054) `CharlyRien:vfs/delete-by-handle` → `main` · +155 −0 · 1 files · 1 commits · open 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 #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 #997 / #1016. - Not in this PR, as said on #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](https://claude.com/claude-code)
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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:42:03 +00:00
Author
Owner

@⁠dcastell1 on GitHub · 2026-11-24 11:07 UTC · original

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@384f7f7 (baseline 737 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
739 passed; 0 failed; 41 ignored   (exit 0)

Two more passing tests than the baseline, and the e2e that #1038 leaves red on this base passes here — the whiteout the title's delete-through-a-handle writes is in the list. Worth cross-checking with #1038's author, since both are after the same behaviour.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

**@⁠dcastell1** on GitHub · 2026-11-24 11:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/1054#issuecomment-7129682272) Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on `main@384f7f7` (baseline **737 passed, 0 failed, 41 ignored** on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 739 passed; 0 failed; 41 ignored (exit 0) ``` Two more passing tests than the baseline, and the e2e that #1038 leaves red on this base passes here — the whiteout the title's delete-through-a-handle writes is in the list. Worth cross-checking with #1038's author, since both are after the same behaviour. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 09:04 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 09:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/1054#issuecomment-7157846289) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1054/head:github-bot/gh-1054'
git switch 'github-bot/gh-1054'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1054'
git switch 'github-bot/gh-1054'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1054'
git switch 'github-bot/gh-1054'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1054'
git switch 'main'
git merge --squash 'github-bot/gh-1054'
git switch 'main'
git merge --ff-only 'github-bot/gh-1054'
git switch 'main'
git merge 'github-bot/gh-1054'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.