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

Closed
CharlyRien wants to merge 1 commit from upstream-pr/1054 into main
CharlyRien commented 2026-11-24 10:57:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-24T10:57:29Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:5470826826 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1054). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-11-24T10:57:29Z. --- 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)
dcastell1 commented 2026-11-24 12:05:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T11:07:16Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7129682272 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1054#issuecomment-7129682272). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T11:07:16Z. --- 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.
pvfreis commented 2026-11-24 13:02:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T13:02:28Z.

Review: COMMENTED


Review of 7ecc08f against its merge base 02bfd1d, by reading the code; nothing was built or run here (no script of my own either; the only commands were read-only gh and git, including two git merge-tree trial merges, which run no code). I found no defect in this PR on its own. The hook is narrow: only the two disposition classes are looked at, the name is taken from the handle at the time of the call, the whiteout is written only after the real call returns success, and the last error is kept on both paths. One thing has to be settled with #1038 before both are in, and one smaller note follows.

  1. CONFIRMED in the code of the two heads read together (Windows' part is from its documentation and from the run #1038's author reports, not from a run here): with #1038 merged, a FALSE disposition brings the game file back. This was found by the author of #1038 (gloger2003, in that PR's description); I traced it and agree. #1038 at 7f93905 records the whiteout when a game file is opened with FILE_FLAG_DELETE_ON_CLOSE (open_file in vfs_hooks.rs). Here, a successful FileDispositionInfo { DeleteFile: FALSE } (or FileDispositionInfoEx without the delete flag) on a handle to an overlay copy calls commit_write, which removes the whiteout (crates/xcl/src/vfs_hooks.rs:612-614, crates/xcl/src/vfs.rs:497-500). Windows documents that FALSE has no effect on a handle opened with FILE_FLAG_DELETE_ON_CLOSE: the call succeeds and the copy is still deleted at close. Scenario: open G:\data\x with delete-on-close, call SetFileInformationByHandle(FileDispositionInfo, FALSE), close: the copy is gone, the whiteout is gone, the original is visible again. On this PR alone nothing is lost (there is no whiteout to remove, and delete-on-close is listed under Not tested). Otherwise the two PRs agree: both go through commit_overlay_removal, add_whiteout is a set insert (vfs.rs:390-395), so a file that gets both a delete-on-close open and an explicit delete is recorded once; and the two heads merge as text without conflicts (git merge-tree).

  2. CONFIRMED (minor, test coverage): the "only after success" branch is not tested for a handle that is inside the overlay. The failed call in the test uses INVALID_HANDLE_VALUE (vfs_hooks.rs:1888-1890), for which overlay_file_rel is already None, so the test would pass even if the whiteout were written before the call. A read-only game file gives the real case: its overlay copy is read-only, the disposition fails with access denied, and no whiteout may appear. Also untested: FileDispositionInfoEx with no delete flag, and FILE_DISPOSITION_FLAG_ON_CLOSE being passed through (vfs_hooks.rs:595-598). The FileDispositionInfoEx case accepts either result (vfs_hooks.rs:1849-1856), which is honest for file systems without the class.

Checked without a finding: the class numbers and flag values (4, 21, 0x1, 0x8); a handle outside the overlay, a directory, and a path that only shares the overlay's prefix all return None (vfs_hooks.rs:566, :582-586); a path-based rename before the delete is handled because the name is read from the handle at delete time (:604); XCL's own std::fs::remove_file inside delete_file runs under the hook guard and is passed through (:624), so DeleteFileW is not handled twice; an overlay file with no game file behind it gets no whiteout (vfs.rs:504). Merged 47efa2e (non-empty directory removal) does not overlap: it changes remove_dir only, this PR passes directories through, and the head merges into main at 47efa2e without conflicts (git merge-tree). A directory deleted through a handle still reports success and stays visible, as the description says, which now differs from RemoveDirectoryW on main returning "not empty".

Against CONTRIBUTING: Tested, Regression run (both blocks, the PR's names this head), Not tested and AI use are all there. From the two blocks, by arithmetic and not measured here: frames 1625 / 1629 = 99.8 %, peak commit 14607 / 14484 = 100.8 %. The PR adds two unit tests and no e2e case.

Verdict: fine to merge on its own from reading; decide with #1038 which of the two changes the FALSE branch (finding 1) before the second one goes in, and a test of a failing delete on an overlay handle (finding 2) would be a cheap addition.

Review by Claude Code (written by Claude Fable 5.2, checked with Claude Opus 5.5); each point checked by a person before posting.

<!-- greyfinch-sync:ivall/xcl:review:6039655761 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1054#pullrequestreview-6039655761). Originally posted by [pvfreis](https://github.com/pvfreis) on 2026-11-24T13:02:28Z. **Review:** COMMENTED --- Review of `7ecc08f` against its merge base `02bfd1d`, by reading the code; nothing was built or run here (no script of my own either; the only commands were read-only `gh` and `git`, including two `git merge-tree` trial merges, which run no code). I found no defect in this PR on its own. The hook is narrow: only the two disposition classes are looked at, the name is taken from the handle at the time of the call, the whiteout is written only after the real call returns success, and the last error is kept on both paths. One thing has to be settled with #1038 before both are in, and one smaller note follows. 1. **CONFIRMED in the code of the two heads read together (Windows' part is from its documentation and from the run #1038's author reports, not from a run here): with #1038 merged, a `FALSE` disposition brings the game file back.** This was found by the author of #1038 (gloger2003, in that PR's description); I traced it and agree. #1038 at `7f93905` records the whiteout when a game file is opened with `FILE_FLAG_DELETE_ON_CLOSE` (`open_file` in `vfs_hooks.rs`). Here, a successful `FileDispositionInfo { DeleteFile: FALSE }` (or `FileDispositionInfoEx` without the delete flag) on a handle to an overlay copy calls `commit_write`, which removes the whiteout (`crates/xcl/src/vfs_hooks.rs:612-614`, `crates/xcl/src/vfs.rs:497-500`). Windows documents that `FALSE` has no effect on a handle opened with `FILE_FLAG_DELETE_ON_CLOSE`: the call succeeds and the copy is still deleted at close. Scenario: open `G:\data\x` with delete-on-close, call `SetFileInformationByHandle(FileDispositionInfo, FALSE)`, close: the copy is gone, the whiteout is gone, the original is visible again. On this PR alone nothing is lost (there is no whiteout to remove, and delete-on-close is listed under Not tested). Otherwise the two PRs agree: both go through `commit_overlay_removal`, `add_whiteout` is a set insert (`vfs.rs:390-395`), so a file that gets both a delete-on-close open and an explicit delete is recorded once; and the two heads merge as text without conflicts (`git merge-tree`). 2. **CONFIRMED (minor, test coverage):** the "only after success" branch is not tested for a handle that is inside the overlay. The failed call in the test uses `INVALID_HANDLE_VALUE` (`vfs_hooks.rs:1888-1890`), for which `overlay_file_rel` is already `None`, so the test would pass even if the whiteout were written before the call. A read-only game file gives the real case: its overlay copy is read-only, the disposition fails with access denied, and no whiteout may appear. Also untested: `FileDispositionInfoEx` with no delete flag, and `FILE_DISPOSITION_FLAG_ON_CLOSE` being passed through (`vfs_hooks.rs:595-598`). The `FileDispositionInfoEx` case accepts either result (`vfs_hooks.rs:1849-1856`), which is honest for file systems without the class. Checked without a finding: the class numbers and flag values (4, 21, 0x1, 0x8); a handle outside the overlay, a directory, and a path that only shares the overlay's prefix all return `None` (`vfs_hooks.rs:566`, `:582-586`); a path-based rename before the delete is handled because the name is read from the handle at delete time (`:604`); XCL's own `std::fs::remove_file` inside `delete_file` runs under the hook guard and is passed through (`:624`), so `DeleteFileW` is not handled twice; an overlay file with no game file behind it gets no whiteout (`vfs.rs:504`). Merged `47efa2e` (non-empty directory removal) does not overlap: it changes `remove_dir` only, this PR passes directories through, and the head merges into `main` at `47efa2e` without conflicts (`git merge-tree`). A directory deleted through a handle still reports success and stays visible, as the description says, which now differs from `RemoveDirectoryW` on `main` returning "not empty". Against CONTRIBUTING: Tested, Regression run (both blocks, the PR's names this head), Not tested and AI use are all there. From the two blocks, by arithmetic and not measured here: frames 1625 / 1629 = 99.8 %, peak commit 14607 / 14484 = 100.8 %. The PR adds two unit tests and no e2e case. Verdict: fine to merge on its own from reading; decide with #1038 which of the two changes the `FALSE` branch (finding 1) before the second one goes in, and a test of a failing delete on an overlay handle (finding 2) would be a cheap addition. Review by Claude Code (written by Claude Fable 5.2, checked with Claude Opus 5.5); each point checked by a person before posting.
DavidM1911 commented 2026-11-25 09:08:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T09:04:47Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7157846289 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1054#issuecomment-7157846289). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T09:04:47Z. --- 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!
github-actions[bot] commented 2026-11-29 07:41:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:41:07Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7252626158 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1054#issuecomment-7252626158). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T07:41:07Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1047
No description provided.