VFS: hook FindFirstFileExA, which Windows does not send to the W hooks #1264

Open
github-bot wants to merge 1 commit from github-bot/gh-1264 into main AGit
Owner

@⁠emirduran707 on GitHub · 2026-11-24 13:59 UTC · original
emirduran707:vfs-find-first-ex-a → main · +90 −0 · 2 files · 1 commits · open

FindFirstFileExA was not hooked, and on Windows it does not go through the hooks that are: kernel32!FindFirstFileExA jumps to its own kernelbase export, and that reaches neither FindFirstFileExW nor FindFirstFileA. Measured on Windows 11 26300 by replacing each of those with a stub that fails: FindFirstFileExA("C:\Windows\*") still listed the folder, while a stub on kernelbase!FindFirstFileExA itself stopped it. #59 noted that FindFirstFileExA works through the W hooks; that was measured under Wine, where it holds.

So a title's FindFirstFileExA("G:\data\*", …) went straight to Windows. With no G: on the PC it failed with ERROR_PATH_NOT_FOUND; with a PC drive of that letter it listed the PC's folder; and a real path into the game folder listed the original files, without the overlay's files and with deleted ones still there.

hk_find_first_ex_a handles it like hk_find_first_a: the same info levels and search ops as the W hook go to the merged listing (find_first_vfs, then converted to WIN32_FIND_DATAA), and the rest pass through. FindNextFileA and FindClose already handle the merged handle.

What is in it

  • crates/xcl/src/vfs_hooks.rs: the hook and its entry in the kernelbase list.
  • crates/xcl/tests/vfs_find_ansi.rs (new; an integration test, since the hooks act through the global VFS): a game folder with two files, an overlay with a third and a deletion of one original. Listing G:\data\* with FindFirstFileExA/FindNextFileA/FindClose at info levels 0 and 1 must give exactly the merged names.

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on 3755c18: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests
  • the new test without the hook's entry: FindFirstFileExA("G:\\data\\*", 0) failed: error 3; with it it passes
  • a first smoke run of this commit showed 924 frames, with a slow load while other builds were using the CPU; the run below was made again with nothing else running

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1541 (PresentX 1541)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19650 MB

this PR:

xcl-smoke v1
commit: 3755c18e492f3f1e4bf473a6e1cfcddf3480d46d
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1545 (PresentX 1545)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19501 MB

Not tested

  • Wine: the hook expects kernelbase to export FindFirstFileExA.
  • A title that calls FindFirstFileExA directly; the smoke title's run is a regression check only.
  • NVIDIA and Intel GPUs.

AI use

  • Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above.

🤖 Generated with Claude Code

**@⁠emirduran707** on GitHub · 2026-11-24 13:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1264) `emirduran707:vfs-find-first-ex-a` → `main` · +90 −0 · 2 files · 1 commits · open `FindFirstFileExA` was not hooked, and on Windows it does not go through the hooks that are: `kernel32!FindFirstFileExA` jumps to its own `kernelbase` export, and that reaches neither `FindFirstFileExW` nor `FindFirstFileA`. Measured on Windows 11 26300 by replacing each of those with a stub that fails: `FindFirstFileExA("C:\Windows\*")` still listed the folder, while a stub on `kernelbase!FindFirstFileExA` itself stopped it. #59 noted that `FindFirstFileExA` works through the W hooks; that was measured under Wine, where it holds. So a title's `FindFirstFileExA("G:\data\*", …)` went straight to Windows. With no `G:` on the PC it failed with `ERROR_PATH_NOT_FOUND`; with a PC drive of that letter it listed the PC's folder; and a real path into the game folder listed the original files, without the overlay's files and with deleted ones still there. `hk_find_first_ex_a` handles it like `hk_find_first_a`: the same info levels and search ops as the W hook go to the merged listing (`find_first_vfs`, then converted to `WIN32_FIND_DATAA`), and the rest pass through. `FindNextFileA` and `FindClose` already handle the merged handle. **What is in it** - `crates/xcl/src/vfs_hooks.rs`: the hook and its entry in the kernelbase list. - `crates/xcl/tests/vfs_find_ansi.rs` (new; an integration test, since the hooks act through the global VFS): a game folder with two files, an overlay with a third and a deletion of one original. Listing `G:\data\*` with `FindFirstFileExA`/`FindNextFileA`/`FindClose` at info levels 0 and 1 must give exactly the merged names. **Tested** - AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release - `cargo test --workspace -- --test-threads=4` on 3755c18: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests - the new test without the hook's entry: `FindFirstFileExA("G:\\data\\*", 0) failed: error 3`; with it it passes - a first smoke run of this commit showed 924 frames, with a slow load while other builds were using the CPU; the run below was made again with nothing else running **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1541 (PresentX 1541) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19650 MB ``` this PR: ``` xcl-smoke v1 commit: 3755c18e492f3f1e4bf473a6e1cfcddf3480d46d gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1545 (PresentX 1545) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19501 MB ``` **Not tested** - Wine: the hook expects `kernelbase` to export `FindFirstFileExA`. - A title that calls `FindFirstFileExA` directly; the smoke title's run is a regression check only. - NVIDIA and Intel GPUs. **AI use** - Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 #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]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:48:50 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 14:05 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --test vfs_find_ansi: 1 passed, 0 failed.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 14:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1264#issuecomment-7133826451) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl --test vfs_find_ansi: 1 passed, 0 failed. Thanks!
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 14:09 UTC · original

Independent native Windows check on 3755c18, Windows 11 build 26300, Rust 1.99.1 MSVC, debug.

I extended the synthetic fixture to enumerate the same wildcard through the game folder’s absolute Windows path as well as G:. With both FindExInfoStandard and FindExInfoBasic, the PR returned added.txt and original.txt for the absolute path. Restoring the parent hooks returned deleted.txt and original.txt instead. A separate unmapped host directory listed correctly in both builds and at both info levels. The stock G: assertions passed on the PR.

Synthetic files only. AI-assisted. Codex (GPT-6, exact variant unavailable) extended and ran the scratch fixture and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-24 14:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/1264#issuecomment-7133918328) Independent native Windows check on [`3755c18`](https://github.com/ivall/xcl/commit/3755c18e492f3f1e4bf473a6e1cfcddf3480d46d), Windows 11 build 26300, Rust 1.99.1 MSVC, debug. I extended the synthetic fixture to enumerate the same wildcard through the game folder’s absolute Windows path as well as `G:`. With both `FindExInfoStandard` and `FindExInfoBasic`, the PR returned `added.txt` and `original.txt` for the absolute path. Restoring the parent hooks returned `deleted.txt` and `original.txt` instead. A separate unmapped host directory listed correctly in both builds and at both info levels. The stock `G:` assertions passed on the PR. Synthetic files only. AI-assisted. Codex (GPT-6, exact variant unavailable) extended and ran the scratch fixture and drafted this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 04:40 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 04:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/1264#issuecomment-7182807761) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1264/head:github-bot/gh-1264'
git switch 'github-bot/gh-1264'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1264'
git switch 'github-bot/gh-1264'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1264'
git switch 'github-bot/gh-1264'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1264'
git switch 'main'
git merge --squash 'github-bot/gh-1264'
git switch 'main'
git merge --ff-only 'github-bot/gh-1264'
git switch 'main'
git merge 'github-bot/gh-1264'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.