VFS: CopyFileW is redirected too #59

Manually merged
github merged 1 commit from gh-pr/59/head into gh-pr/59/base 2026-11-26 04:07:07 +00:00
Owner

@⁠gefydev on GitHub · 2026-11-22 23:05 UTC · original
gefydev:vfs-copy-file → main · +20 −0 · 1 files · 1 commits · merged 2026-11-23 09:44 UTC

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.

**@⁠gefydev** on GitHub · 2026-11-22 23:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/59) `gefydev:vfs-copy-file` → `main` · +20 −0 · 1 files · 1 commits · merged 2026-11-23 09:44 UTC `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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:07:06 +00:00
github manually merged commit 935155ca99 into gh-pr/59/base 2026-11-26 04:07:07 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 09:45 UTC · original

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** on GitHub · 2026-11-23 09:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/59#issuecomment-7097053655) 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!
This discussion has been locked. Commenting is limited to contributors.
No description provided.