Loader: a title DLL in a case-sensitive folder is skipped without an error (fix on a fork) #762

Open
opened 2026-11-26 04:13:56 +00:00 by github-bot · 4 comments
Owner

@⁠Peppacodes on GitHub · 2026-11-24 09:47 UTC · original

What's wrong

map_dll (crates/victory-loader/src/windows.rs:149-151) lowercases a title DLL's name and joins that to the title folder:

let name = name.to_ascii_lowercase();
let path = dirs.0.join(&name);
if !seen.insert(name.clone()) || !wanted(&name) || !path.is_file() {
    return Ok(());
}

In an ordinary NTFS folder that works, because lookups ignore case. In a case-sensitive folder, GameLib.dll and gamelib.dll are different names, so is_file() is false and the DLL is skipped with Ok(()). Both callers go through it:

  • load_title_dlls, for the exe's imports at start-up.
  • load_title_dll, for a title's own LoadLibrary, which then reports "not a title image".

WSL creates folders on Windows drives as case-sensitive, and new subfolders inherit the flag. So a dump extracted with Linux tools under WSL gets it.

What a user sees: the DLL is never mapped and its imports go to stubs. With the default --unimplemented trap, the run stops at the first call into it, and nothing says the DLL wasn't found.

Repro

Late.dll (a copy of version.dll) is in a case-sensitive temp folder.

  • load_title_dll returns no DLLs for Late.dll, LATE.DLL and late.dll, including the exact spelling.
  • In an ordinary folder it maps all three.

Fix

What changed:

  • The lowercased name is still the key for seen, wanted and the returned list, so callers get the same names as before.
  • A new file_in looks the file up by the name as written. If that fails, it takes the folder's entry that matches ignoring ASCII case, the way the Windows loader ignores case.
  • Error messages now show the file's real name.

Test

a_title_dll_in_a_case_sensitive_folder_is_found_by_any_spelling, in crates/victory-loader/tests/title_dlls.rs:

  • It makes a case-sensitive temp folder with fsutil file setCaseSensitiveInfo (no admin needed). It then loads Late.dll as Late.dll, LATE.DLL and late.dll.
  • It fails on main (left: []) and passes with the fix.
  • It skips where Windows can't make such a folder.

Results on Windows 11 with Rust 1.98.1, using the CI's own commands:

  • cargo test --workspace --locked: 343 passed, 0 failed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean.
  • rustfmt --edition 2024 --check on the two changed files: clean.
  • cargo xtask policy: 154 files ok.

Not checked: a folder WSL created itself, since the test sets the same flag directly; and case-sensitive network shares.

PR creation is limited to collaborators right now, so this is an issue with the branch. I can open a PR when it reopens.

No game files used. AI use: Claude Code (Claude Opus 5.5) found this in an audit of the loader, wrote the fix and the test, and ran everything above.

**@⁠Peppacodes** on GitHub · 2026-11-24 09:47 UTC · [original](https://github.com/Marvisak/VIctory/issues/762) ## What's wrong `map_dll` (`crates/victory-loader/src/windows.rs:149-151`) lowercases a title DLL's name and joins that to the title folder: ```rust let name = name.to_ascii_lowercase(); let path = dirs.0.join(&name); if !seen.insert(name.clone()) || !wanted(&name) || !path.is_file() { return Ok(()); } ``` In an ordinary NTFS folder that works, because lookups ignore case. In a case-sensitive folder, `GameLib.dll` and `gamelib.dll` are different names, so `is_file()` is false and the DLL is skipped with `Ok(())`. Both callers go through it: - `load_title_dlls`, for the exe's imports at start-up. - `load_title_dll`, for a title's own `LoadLibrary`, which then reports "not a title image". WSL creates folders on Windows drives as case-sensitive, and new subfolders inherit the flag. So a dump extracted with Linux tools under WSL gets it. What a user sees: the DLL is never mapped and its imports go to stubs. With the default `--unimplemented trap`, the run stops at the first call into it, and nothing says the DLL wasn't found. ## Repro `Late.dll` (a copy of `version.dll`) is in a case-sensitive temp folder. - `load_title_dll` returns no DLLs for `Late.dll`, `LATE.DLL` and `late.dll`, including the exact spelling. - In an ordinary folder it maps all three. ## Fix - **Branch:** https://github.com/Peppacodes/VIctory/tree/fix/title-dll-name-case - **Compare:** https://github.com/Marvisak/VIctory/compare/main...Peppacodes:VIctory:fix/title-dll-name-case - **Commit:** `1e24f34`, rebased on `main` (`ffe310e`), 0 commits behind it. It changes `windows.rs` and its test. What changed: - The lowercased name is still the key for `seen`, `wanted` and the returned list, so callers get the same names as before. - A new `file_in` looks the file up by the name as written. If that fails, it takes the folder's entry that matches ignoring ASCII case, the way the Windows loader ignores case. - Error messages now show the file's real name. ## Test `a_title_dll_in_a_case_sensitive_folder_is_found_by_any_spelling`, in `crates/victory-loader/tests/title_dlls.rs`: - It makes a case-sensitive temp folder with `fsutil file setCaseSensitiveInfo` (no admin needed). It then loads `Late.dll` as `Late.dll`, `LATE.DLL` and `late.dll`. - It fails on `main` (`left: []`) and passes with the fix. - It skips where Windows can't make such a folder. Results on Windows 11 with Rust 1.98.1, using the CI's own commands: - `cargo test --workspace --locked`: 343 passed, 0 failed. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. - `rustfmt --edition 2024 --check` on the two changed files: clean. - `cargo xtask policy`: 154 files ok. Not checked: a folder WSL created itself, since the test sets the same flag directly; and case-sensitive network shares. PR creation is limited to collaborators right now, so this is an issue with the branch. I can open a PR when it reopens. No game files used. AI use: Claude Code (Claude Opus 5.5) found this in an audit of the loader, wrote the fix and the test, and ran everything above.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:56 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 10:27 UTC · original

I tested the lookup from 1e24f34 in Wine 11.22 on an ext4 directory using a source-built DLL. The directory contained a folder named LATE.DLL and a file named late.dll. A request for LATE.dll fell back to directory enumeration, which returned the folder first. Both load_title_dll and load_title_dlls returned an empty list.

The fallback can skip the folder by changing the first .find(|e| …) to .filter(|e| …) and the trailing .filter(|p| p.is_file()) to .find(|p| p.is_file()). With just those two changes, both entry points returned ["late.dll"] in the same fixture. The exact-name lookup and lowercase key stay as in your patch.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 10:27 UTC · [original](https://github.com/Marvisak/VIctory/issues/762#issuecomment-7128802051) I tested the lookup from `1e24f34` in Wine 11.22 on an ext4 directory using a source-built DLL. The directory contained a folder named `LATE.DLL` and a file named `late.dll`. A request for `LATE.dll` fell back to directory enumeration, which returned the folder first. Both `load_title_dll` and `load_title_dlls` returned an empty list. The fallback can skip the folder by changing the first `.find(|e| …)` to `.filter(|e| …)` and the trailing `.filter(|p| p.is_file())` to `.find(|p| p.is_file())`. With just those two changes, both entry points returned `["late.dll"]` in the same fixture. The exact-name lookup and lowercase key stay as in your patch.
Author
Owner

@⁠Peppacodes on GitHub · 2026-11-24 10:38 UTC · original

Thanks, confirmed on Windows too. In a case-sensitive NTFS folder, the LATE.DLL folder is listed before late.dll, and load_title_dll("LATE.dll") returned [] on 1e24f34.

Your filter/find change is now on the branch as 22c3d00. A new test, a_folder_spelled_like_a_title_dll_does_not_hide_it, fails on 1e24f34 and passes with it. Workspace tests (344), both clippy runs, rustfmt and cargo xtask policy all pass.

**@⁠Peppacodes** on GitHub · 2026-11-24 10:38 UTC · [original](https://github.com/Marvisak/VIctory/issues/762#issuecomment-7129048262) Thanks, confirmed on Windows too. In a case-sensitive NTFS folder, the `LATE.DLL` folder is listed before `late.dll`, and `load_title_dll("LATE.dll")` returned `[]` on `1e24f34`. Your `filter`/`find` change is now on the branch as `22c3d00`. A new test, `a_folder_spelled_like_a_title_dll_does_not_hide_it`, fails on `1e24f34` and passes with it. Workspace tests (344), both clippy runs, rustfmt and `cargo xtask policy` all pass.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-24 19:42 UTC · original

@⁠Peppacodes your fix for this issue is now in a pull request, #1603, together with the three others of yours (#762, #764, #765, #832): the branches are merged as they are, with your commits and your name unchanged, onto main ffe310e. Clippy (both runs) and cargo test --workspace pass on the result. If you would rather open your own pull request for this one, say so and I will take it out of #1603. AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-24 19:42 UTC · [original](https://github.com/Marvisak/VIctory/issues/762#issuecomment-7142472528) @⁠Peppacodes your fix for this issue is now in a pull request, #1603, together with the three others of yours (#762, #764, #765, #832): the branches are merged as they are, with your commits and your name unchanged, onto `main` `ffe310e`. Clippy (both runs) and `cargo test --workspace` pass on the result. If you would rather open your own pull request for this one, say so and I will take it out of #1603. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:50 UTC · original

Automated triage for the maintainers.

Confirmed on main: map_dll in crates/victory-loader/src/windows.rs lowercases the DLL name and joins it to the title folder, then returns Ok(()) when path.is_file() is false. In a case-sensitive folder a DLL whose real name has capitals is skipped without an error, both at start-up (load_title_dlls) and for a title's LoadLibrary (load_title_dll).

Open pull request #1434 already matches title DLL names ignoring ASCII case; please compare your branch (including the folder-before-file fix from the comments, 22c3d00) with it and comment there, or open your own pull request if yours handles more. The bundle #1603 mentioned above is not open.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:50 UTC · [original](https://github.com/Marvisak/VIctory/issues/762#issuecomment-7152297396) <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-24T19:42:19Z at=2026-11-25T03:50:58Z --> Automated triage for the maintainers. Confirmed on `main`: `map_dll` in `crates/victory-loader/src/windows.rs` lowercases the DLL name and joins it to the title folder, then returns `Ok(())` when `path.is_file()` is false. In a case-sensitive folder a DLL whose real name has capitals is skipped without an error, both at start-up (`load_title_dlls`) and for a title's `LoadLibrary` (`load_title_dll`). Open pull request #1434 already matches title DLL names ignoring ASCII case; please compare your branch (including the folder-before-file fix from the comments, `22c3d00`) with it and comment there, or open your own pull request if yours handles more. The bundle #1603 mentioned above is not open. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#762
No description provided.