Skip to content

VFS: CopyFileW is redirected too - #59

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:vfs-copy-file
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:vfs-copy-file

Conversation

@gefydev

@gefydev gefydev commented Nov 22, 2026

Copy link
Copy Markdown
Member

vfs_hooks.rs hooks CopyFileExW and CopyFile2, but not CopyFileW, which doesn't have to go through CopyFileExW (under Wine it doesn't). CopyFileA calls CopyFileW, so a copy between console paths with either one (T:\f.txt → T:\g.txt) went to the PC's own drive and failed.

CopyFileW is now hooked with the same handling as CopyFileExW (source through source_of, destination through dest_of). Where Windows' CopyFileW does call CopyFileExW, the existing hook guard lets the inner call through.

Same kind of gap as #58 (MoveFileWithProgressW); the two 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 test alone: a VFS that mounts T: on a temp folder, the real hooks installed, then each file API on T: paths. Under Wine:

main this branch
CopyFileW(T:\f.txt, T:\g.txt) fails, nothing copied copied
CopyFileA(T:\f.txt, T:\g.txt) fails, nothing copied copied
CopyFileExA(...) copied copied

The same probe shows DeleteFileA, CreateDirectoryA, RemoveDirectoryA, SetFileAttributesA, FindFirstFileExA and GetFileAttributesExA already work through their W hooks. I haven't run it on Windows itself yet. cargo test -p xcl --lib: 343 passed, 0 failed, on Windows GNU under Wine.

Only CopyFileExW and CopyFile2 were hooked. CopyFileW, and CopyFileA
through it, need not go through CopyFileExW, so a copy between console
paths (T:\f.txt → T:\g.txt) went to the PC's own drive and failed.
CopyFileW is hooked with the same handling as CopyFileExW; when it calls
CopyFileExW, the hook guard lets the inner call through.
@ivall
ivall merged commit 8603bcd into xcl-dev:main Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
On Windows 11 kernel32's ANSI moves reach none of kernelbase's W move entries (measured with
counting hooks: MoveFileW reaches MoveFileWithProgressW, the ANSI ones neither it nor
MoveFileExW), so they are hooked in kernel32: paths become wide and go the
MoveFileWithProgressW way. Checked with the real hooks and a VFS mounting T: / G: (T: does
not exist on the PC): all six move entries move T:\a.txt to T:\b.txt, a move of a game
file through MoveFileExA lands in the overlay and leaves the game folder intact; CopyFileW
/ A, CopyFileEx W / A, CopyFile2 and ReplaceFile W / A (also onto a game file, backup in the
overlay) as in #59 / #60.
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged (8603bcd). For the record, on Windows 11 CopyFileW calls CopyFileExW (both hooks fire, the guard handles it) and CopyFileA / CopyFileExA reach CopyFileExW, so there this was already covered; the extra hook is harmless and helps under Wine. All five copy entries verified on T: with the real hooks.

Tested on Windows 11 (RX 9070): cargo test --workspace green (lib 351, e2e), and a 45 s Unicorn Overlord run on the release build (VFS hooks active, ~60 fps, clean exit). Thanks!

ivall added a commit that referenced this pull request Nov 23, 2026
…ommandListsX, big pipelines in the background

The frame clock fired one event type per deadline; a title scheduling the origin and
type 2 at the same offset waited on type 2 for ever after two frames. Now every type
due fires. Newer console layout: queue #35 is ExecuteCommandListsX, list #61 is
ExecuteIndirect (the shift by two from #59 on). Bottom-of-pipe writes into memory the
GPU does not see are done by the CPU after the queue's work, waits there read it on the
CPU. Compute pipelines of 256 KB of DXIL or more are built in the background (2 at a
time), a bind of one not started builds it itself. DXC -O1 from 1 MB of HLSL.
`xcl shaders --precompile --pipelines` warms the driver's cache.
Michael-Glaser added a commit to Michael-Glaser/xcl that referenced this pull request Nov 24, 2026
…cl-dev#104)

On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (xcl-dev#59, xcl-dev#60, xcl-dev#68, xcl-dev#69, xcl-dev#78, xcl-dev#81, xcl-dev#84, xcl-dev#88, xcl-dev#89, xcl-dev#93, xcl-dev#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method.

Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at xcl-dev#59 and the original base-table stub for slots >= scanned). Slot xcl-dev#10 (Reset) stays Reset on both layouts and is not orphaned.

Assisted-by: Antigravity (Gemini 4 Neon)
Michael-Glaser added a commit to Michael-Glaser/xcl that referenced this pull request Nov 24, 2026
…vall#104)

On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (ivall#59, ivall#60, ivall#68, ivall#69, ivall#78, ivall#81, ivall#84, ivall#88, ivall#89, ivall#93, ivall#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method.

Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at ivall#59 and the original base-table stub for slots >= scanned). Slot ivall#10 (Reset) stays Reset on both layouts and is not orphaned.

Assisted-by: Antigravity (Gemini 4 Neon)
kacper-serewis pushed a commit to kacper-serewis/xcl that referenced this pull request Nov 24, 2026
On Windows, kernel32!FindFirstFileExA jumps to kernelbase!FindFirstFileExA,
which reaches neither FindFirstFileExW nor FindFirstFileA (measured on
Windows 11 26300 by patching each of them with a failing stub: ExA still
listed C:\Windows; patching kernelbase!FindFirstFileExA itself did stop it).
Only Wine's implementation goes through the W function, which is where xcl-dev#59
measured it. So FindFirstFileExA("G:\data\*") failed with
ERROR_PATH_NOT_FOUND, or listed a PC drive or the unmerged game folder,
instead of the merged VFS listing.

Hook kernelbase!FindFirstFileExA like FindFirstFileA: the info levels and
search ops hk_find_first_ex_w virtualises go through find_first_vfs and are
converted with w_to_a; the others pass through. FindNextFileA and FindClose
already handle the merged handle.

The new integration test lists a game folder with an overlay file and a
whiteout through FindFirstFileExA/FindNextFileA; without the hook it fails
with error 3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 3755c18)
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
On Windows, kernel32!FindFirstFileExA jumps to kernelbase!FindFirstFileExA,
which reaches neither FindFirstFileExW nor FindFirstFileA (measured on
Windows 11 26300 by patching each of them with a failing stub: ExA still
listed C:\Windows; patching kernelbase!FindFirstFileExA itself did stop it).
Only Wine's implementation goes through the W function, which is where xcl-dev#59
measured it. So FindFirstFileExA("G:\data\*") failed with
ERROR_PATH_NOT_FOUND, or listed a PC drive or the unmerged game folder,
instead of the merged VFS listing.

Hook kernelbase!FindFirstFileExA like FindFirstFileA: the info levels and
search ops hk_find_first_ex_w virtualises go through find_first_vfs and are
converted with w_to_a; the others pass through. FindNextFileA and FindClose
already handle the merged handle.

The new integration test lists a game folder with an overlay file and a
whiteout through FindFirstFileExA/FindNextFileA; without the hook it fails
with error 3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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