VFS: moves through MoveFileWithProgressW are redirected too #58

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

@⁠gefydev on GitHub · 2026-11-22 23:03 UTC · original
gefydev:vfs-move-file-with-progress → main · +15 −0 · 1 files · 1 commits · merged 2026-11-23 09:44 UTC

vfs_hooks.rs hooks MoveFileExW, but not MoveFileWithProgressW. MoveFileA and MoveFileExA reach MoveFileWithProgressW without going through MoveFileExW, so a move between console paths (T:\a.txt → T:\b.txt) goes to the PC's own T: and fails. MoveFileWithProgressW is now hooked too, with the same handling (the body of the MoveFileExW hook moved into a shared move_file). When MoveFileExW itself calls MoveFileWithProgressW, the existing hook guard lets the inner call through, so a move is never handled twice.

Validation

The hooks are process-wide and need an initialized VFS (a global OnceLock), so I did not add them to the unit tests. I checked with two probe tests, run alone, on the branch gefydev/probe-movefile (not part of this PR):

  • Which kernelbase entry each API reaches, under Wine:
    MoveFileW: reaches MoveFileExW=1 MoveFileWithProgressW=1
    MoveFileA: reaches MoveFileExW=0 MoveFileWithProgressW=1
    MoveFileExW: reaches MoveFileExW=1 MoveFileWithProgressW=1
    MoveFileExA: reaches MoveFileExW=0 MoveFileWithProgressW=1
    
  • T:\a.txt → T:\b.txt with the real hooks and a VFS mounting T:: on main, MoveFileA and MoveFileExA fail and the file stays; with this change all four APIs move it.

I have not yet run the probes on Windows itself, so I can't say for sure that its kernelbase takes the same paths. If MoveFileA doesn't reach MoveFileWithProgressW there, the extra hook does nothing. cargo test -p xcl --lib: 343 passed, 0 failed, on Windows GNU under Wine.

**@⁠gefydev** on GitHub · 2026-11-22 23:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/58) `gefydev:vfs-move-file-with-progress` → `main` · +15 −0 · 1 files · 1 commits · merged 2026-11-23 09:44 UTC `vfs_hooks.rs` hooks `MoveFileExW`, but not `MoveFileWithProgressW`. `MoveFileA` and `MoveFileExA` reach `MoveFileWithProgressW` without going through `MoveFileExW`, so a move between console paths (`T:\a.txt` → `T:\b.txt`) goes to the PC's own `T:` and fails. `MoveFileWithProgressW` is now hooked too, with the same handling (the body of the `MoveFileExW` hook moved into a shared `move_file`). When `MoveFileExW` itself calls `MoveFileWithProgressW`, the existing hook guard lets the inner call through, so a move is never handled twice. ## Validation The hooks are process-wide and need an initialized VFS (a global `OnceLock`), so I did not add them to the unit tests. I checked with two probe tests, run alone, on the branch `gefydev/probe-movefile` (not part of this PR): - Which `kernelbase` entry each API reaches, under Wine: ``` MoveFileW: reaches MoveFileExW=1 MoveFileWithProgressW=1 MoveFileA: reaches MoveFileExW=0 MoveFileWithProgressW=1 MoveFileExW: reaches MoveFileExW=1 MoveFileWithProgressW=1 MoveFileExA: reaches MoveFileExW=0 MoveFileWithProgressW=1 ``` - `T:\a.txt` → `T:\b.txt` with the real hooks and a VFS mounting `T:`: on `main`, `MoveFileA` and `MoveFileExA` fail and the file stays; with this change all four APIs move it. I have not yet run the probes on Windows itself, so I can't say for sure that its `kernelbase` takes the same paths. If `MoveFileA` doesn't reach `MoveFileWithProgressW` there, the extra hook does nothing. `cargo test -p xcl --lib`: 343 passed, 0 failed, on Windows GNU under Wine.
Only MoveFileExW was hooked, but MoveFileA, MoveFileExA (and, depending
on the build, MoveFileW) reach MoveFileWithProgressW without going
through it, so a move between console paths (T:\a → T:\b) went to the
PC's own drive and failed. MoveFileWithProgressW is hooked as well, with
the same handling; when MoveFileExW calls it, the hook guard lets the
inner call through.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:07:01 +00:00
github manually merged commit f2d5b6f538 into gh-pr/58/base 2026-11-26 04:07:03 +00:00
Author
Owner

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

Merged (6ca99f2). I ran your probe on Windows 11 – the paths differ from Wine:

MoveFileW:             reaches MoveFileExW=0 MoveFileWithProgressW=1
MoveFileA:             reaches MoveFileExW=0 MoveFileWithProgressW=0
MoveFileExW:           reaches MoveFileExW=1 MoveFileWithProgressW=0
MoveFileExA:           reaches MoveFileExW=0 MoveFileWithProgressW=0
MoveFileWithProgressA: (neither, nor kernel32!MoveFileTransactedW)

So on Windows this PR is what makes MoveFileW work at all (it was not redirected before), but the ANSI moves reach no kernelbase entry – kernel32 does them with an internal helper. 8064fe3 hooks MoveFileA / MoveFileExA / MoveFileWithProgressA in kernel32 (paths to wide, then the MoveFileWithProgressW path). With the real hooks and a VFS mounting T: (no such drive on the PC) all six entries move T:\a.txt → T:\b.txt; a game file moved through MoveFileExA lands in the overlay and the game folder stays intact.

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/58#issuecomment-7097053412) Merged (6ca99f2). I ran your probe on **Windows 11** – the paths differ from Wine: ``` MoveFileW: reaches MoveFileExW=0 MoveFileWithProgressW=1 MoveFileA: reaches MoveFileExW=0 MoveFileWithProgressW=0 MoveFileExW: reaches MoveFileExW=1 MoveFileWithProgressW=0 MoveFileExA: reaches MoveFileExW=0 MoveFileWithProgressW=0 MoveFileWithProgressA: (neither, nor kernel32!MoveFileTransactedW) ``` So on Windows this PR is what makes `MoveFileW` work at all (it was not redirected before), but the ANSI moves reach no kernelbase entry – kernel32 does them with an internal helper. 8064fe3 hooks `MoveFileA` / `MoveFileExA` / `MoveFileWithProgressA` in kernel32 (paths to wide, then the `MoveFileWithProgressW` path). With the real hooks and a VFS mounting `T:` (no such drive on the PC) all six entries move `T:\a.txt` → `T:\b.txt`; a game file moved through `MoveFileExA` lands in the overlay and the game folder stays intact. 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.