VFS: moves through MoveFileWithProgressW are redirected too #57

Merged
gefydev merged 1 commit from upstream-pr/58 into main 2026-11-23 09:44:41 +00:00
gefydev commented 2026-11-22 23:03:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gefydev on 2026-11-22T23:03:12Z.


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.

<!-- greyfinch-sync:ivall/xcl:issue:6548967141 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/58). Originally posted by [gefydev](https://github.com/gefydev) on 2026-11-22T23:03:12Z. --- `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.
upstream-sync closed this pull request 2026-11-24 06:56:57 +00:00
ivall commented 2026-11-24 07:00:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T09:45:17Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7097053412 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/58#issuecomment-7097053412). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T09:45:17Z. --- 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!
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!57
No description provided.