Skip to content

VFS: deleting a game file through a handle only deletes an overlay copy, and the original comes back #998

Backlog

Description

@Conrage

Deleting a game file by handle doesn't go through the DeleteFileW hook, so no whiteout is added. Two common ways to do that:

  • std::filesystem::remove in the MSVC STL: CreateFile2(DELETE | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT) then SetFileInformationByHandle(FileDispositionInfoEx)
  • CreateFileW(..., FILE_FLAG_DELETE_ON_CLOSE) for temp or lock files

What happens under XCL:

  1. DELETE is in WRITE_ACCESS and FILE_FLAG_DELETE_ON_CLOSE counts as a write, so open_decision_for treats the open as a write. With OPEN_EXISTING it calls prepare_write(rel, keep = true), which copies the whole original into the overlay:
    https://github.com/ivall/xcl/blob/9aec53d/crates/xcl/src/vfs.rs#L530-L534
    https://github.com/ivall/xcl/blob/9aec53d/crates/xcl/src/vfs.rs#L584-L592
  2. The handle points at that overlay copy. The disposition (or close) deletes the copy.
  3. Nothing hooks SetFileInformationByHandle / NtSetInformationFile, and nothing adds a whiteout on close, so the original is visible again.

Result: the delete reports success, but the next GetFileAttributesW / CreateFileW / FindFirstFileW still sees the original. The title can also wait on a full copy of a large file it only wanted to delete. Folders behave the same way: BACKUP_SEMANTICS creates an empty overlay folder, which is then deleted, and the game folder stays visible.

Related: a rename by handle (SetFileInformationByHandle(FileRenameInfo)) also bypasses the MoveFileExW hook. It renames the overlay copy and leaves the original at its old name, so the file ends up at both names.

Expected: a delete by handle of a game path leaves the file hidden, like DeleteFileW does (whiteout plus removal of any overlay copy), without copying the original first.

Suggested fix: hook SetFileInformationByHandle (FileDispositionInfo/Ex, FileRenameInfo/Ex) for handles that came from a game path, and add the whiteout on delete-on-close. Opens whose only "write" access is DELETE could also skip the content copy.

Not tested: found by reading the code and the MSVC STL filesystem.cpp; not run (no Windows machine).

AI use: found, checked and written up by Claude Code (Claude Opus 5.5) at my request.

Activity

  1. CharlyRien commented on Nov 24, 2026

    @CharlyRien

    I'm taking the delete-by-handle part: a hook on SetFileInformationByHandle that, for FileDispositionInfo / FileDispositionInfoEx on a handle to the overlay copy of a game file, adds the whiteout once the delete succeeds (through the existing commit_overlay_removal). With a unit test that fails on main.

    Not in this PR: FILE_FLAG_DELETE_ON_CLOSE, rename by handle, and skipping the content copy for a DELETE-only open. Each can be its own PR.

    AI use: Claude Code with Claude Fable 5.2.

  2. vladbondarenko97 commented on Nov 24, 2026

    @vladbondarenko97
    Contributor

    I'm taking the rename-by-handle part: SetFileInformationByHandle(FileRenameInfo / FileRenameInfoEx) on a handle to a game path is routed through the same overlay move as the MoveFileExW hook, so the original is whited out and the file ends up only at the new name. It will be stacked on #1054 (it reuses that hook), with a unit test that fails on main. Retail regression runs on an RTX 3080 Ti.

    Not in it: delete-on-close (#1038) and the copy-skip for DELETE-only opens.

    AI use: Claude Code (Claude Opus 5.5 plans and reviews, Claude Sonnet 5.5 implements).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions