VFS: FindFirstFileExW with FindExSearchLimitToDirectories is listed too #64

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

@⁠gefydev on GitHub · 2026-11-22 23:15 UTC · original
gefydev:vfs-find-limit-to-directories → main · +4 −2 · 1 files · 1 commits · merged 2026-11-23 10:20 UTC

hk_find_first_ex_w virtualises only fSearchOp == FindExSearchNameMatch and passes anything else to Windows unchanged. With FindExSearchLimitToDirectories, a search on a console path (G:\data\*) therefore reaches the PC as G:\data\* and finds nothing.

That op is only a hint: the FindFirstFileExW documentation says that when the file system doesn't support directory filtering, the flag is ignored and files are returned too, and callers have to check FILE_ATTRIBUTE_DIRECTORY themselves. So the VFS can list it like a name match. Ops above 1 (FindExSearchLimitToDevices) still pass through.

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 alone, with a VFS that mounts G: on a temp game folder holding data\f.txt and data\sub\, and the real hooks installed. Under Wine:

FindFirstFileExW(G:\data\*, FindExInfoBasic, …) main this branch
FindExSearchNameMatch . .. f.txt sub . .. f.txt sub
FindExSearchLimitToDirectories nothing (fails) . .. f.txt sub

cargo test -p xcl --lib: 343 passed, 0 failed, on Windows GNU under Wine.

**@⁠gefydev** on GitHub · 2026-11-22 23:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/64) `gefydev:vfs-find-limit-to-directories` → `main` · +4 −2 · 1 files · 1 commits · merged 2026-11-23 10:20 UTC `hk_find_first_ex_w` virtualises only `fSearchOp == FindExSearchNameMatch` and passes anything else to Windows unchanged. With `FindExSearchLimitToDirectories`, a search on a console path (`G:\data\*`) therefore reaches the PC as `G:\data\*` and finds nothing. That op is only a hint: the `FindFirstFileExW` documentation says that when the file system doesn't support directory filtering, the flag is ignored and files are returned too, and callers have to check `FILE_ATTRIBUTE_DIRECTORY` themselves. So the VFS can list it like a name match. Ops above 1 (`FindExSearchLimitToDevices`) still pass through. ## 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 alone, with a VFS that mounts `G:` on a temp game folder holding `data\f.txt` and `data\sub\`, and the real hooks installed. Under Wine: | `FindFirstFileExW(G:\data\*, FindExInfoBasic, …)` | `main` | this branch | |---|---|---| | `FindExSearchNameMatch` | `. .. f.txt sub` | `. .. f.txt sub` | | `FindExSearchLimitToDirectories` | nothing (fails) | `. .. f.txt sub` | `cargo test -p xcl --lib`: 343 passed, 0 failed, on Windows GNU under Wine.
The hook passed every search op but FindExSearchNameMatch to Windows
unchanged, so FindExSearchLimitToDirectories on a console path (G:\data\*)
found nothing. The op is advisory – a file system without directory
filtering ignores it and returns every match – so it is now listed like
a name match.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:07:27 +00:00
github manually merged commit 80489d08e8 into gh-pr/64/base 2026-11-26 04:07:29 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 10:20 UTC · original

Merged (3fa4203). Checked on Windows itself with the real hooks and a VFS mounting G:: FindFirstFileExW(G:\data\*) gives . .. f.txt sub with both FindExSearchNameMatch and FindExSearchLimitToDirectories. Tested on Windows 11 with an RX 9070: cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), and Unicorn Overlord reaches its title screen with everything from this round merged. Thanks!

**@⁠ivall** on GitHub · 2026-11-23 10:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/64#issuecomment-7097812492) Merged (3fa4203). Checked on Windows itself with the real hooks and a VFS mounting `G:`: `FindFirstFileExW(G:\data\*)` gives `. .. f.txt sub` with both `FindExSearchNameMatch` and `FindExSearchLimitToDirectories`. Tested on Windows 11 with an RX 9070: `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), and Unicorn Overlord reaches its title screen with everything from this round merged. Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.