Loader: match title DLL filenames ignoring ASCII case #1433

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/1434 into main
fuzeofficlal commented 2026-11-24 17:58:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:58:12Z.


Fixes #762.

Summary

  • Match title DLL files in dirs.0 case-insensitively (eq_ignore_ascii_case + path.is_file(), skipping colliding subdirectories) when the exact path is not a file so mixed-case title DLLs load properly on case-sensitive folders and broken images report their real on-disk filename in error context.

Verification

  • Added directory_scan_matches_files_ignoring_ascii_case_and_skips_folders and maps_mixed_case_title_dlls_in_case_sensitive_folders (using per-directory NTFS case sensitivity with colliding uppercase directory names and malformed DLL error checks).
  • cargo test -p victory-loader, cargo clippy --workspace --all-targets --all-features, and cargo xtask policy: passed.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5477547907 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1434). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-24T17:58:12Z. --- Fixes #762. ### Summary - Match title DLL files in `dirs.0` case-insensitively (`eq_ignore_ascii_case` + `path.is_file()`, skipping colliding subdirectories) when the exact path is not a file so mixed-case title DLLs load properly on case-sensitive folders and broken images report their real on-disk filename in error context. ### Verification - Added `directory_scan_matches_files_ignoring_ascii_case_and_skips_folders` and `maps_mixed_case_title_dlls_in_case_sensitive_folders` (using per-directory NTFS case sensitivity with colliding uppercase directory names and malformed DLL error checks). - `cargo test -p victory-loader`, `cargo clippy --workspace --all-targets --all-features`, and `cargo xtask policy`: passed.
catminou4 commented 2026-11-24 19:25:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T19:25:07Z.

Review: COMMENTED


Static review only: crates/victory-loader/src/windows.rs is #[cfg(windows)], so neither the unit test nor the load_probe.rs integration test can run on macOS. The logic is sound: exact-case match first, then a directory scan with eq_ignore_ascii_case that skips directories, dedup still keyed on the lowercase name, and the wanted-check happens before any file I/O. The integration test is thorough (case-sensitive folders via fsutil, four spellings, startup imports, and the invalid-PE error path keeping the real filename). Please make sure it runs in the Windows CI leg before merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6045877881 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1434#pullrequestreview-6045877881). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T19:25:07Z. **Review:** COMMENTED --- Static review only: `crates/victory-loader/src/windows.rs` is `#[cfg(windows)]`, so neither the unit test nor the `load_probe.rs` integration test can run on macOS. The logic is sound: exact-case match first, then a directory scan with `eq_ignore_ascii_case` that skips directories, dedup still keyed on the lowercase name, and the wanted-check happens before any file I/O. The integration test is thorough (case-sensitive folders via `fsutil`, four spellings, startup imports, and the invalid-PE error path keeping the real filename). Please make sure it runs in the Windows CI leg before merge.
acetonahard-code commented 2026-11-24 21:28:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T21:15:11Z.


Tested on Windows 11 with the repo toolchain, merged into current main (ffe310e):

cargo test -p victory-loader passed failed ignored
main 25 0 0
main + this PR 27 0 0
main, --all-features 26 0 -
main + this PR, --all-features 28 0 -
  • The 2 new tests pass.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7144682139 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1434#issuecomment-7144682139). Originally posted by [acetonahard-code](https://github.com/acetonahard-code) on 2026-11-24T21:15:11Z. --- Tested on Windows 11 with the repo toolchain, merged into current `main` (ffe310e): | `cargo test -p victory-loader` | passed | failed | ignored | |---|---|---|---| | `main` | 25 | 0 | 0 | | `main` + this PR | 27 | 0 | 0 | | `main`, `--all-features` | 26 | 0 | - | | `main` + this PR, `--all-features` | 28 | 0 | - | - The 2 new tests pass. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
Marvisak commented 2026-11-25 04:06:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:27:36Z.


Automated triage for the maintainers.

Merge candidate (update after your reply). map_dll in crates/victory-loader/src/windows.rs now tries the import name as written first. If that misses, it falls back to a case-insensitive directory scan (find_dll_file → scan_dll_file → select_dll_entry) and keeps the lowercased name as the seen/loaded key. Thanks for removing the fsutil call. The new tests are a pure unit test on select_dll_entry, a tempfile scan test, and a load test that copies version.dll the way existing load_probe.rs tests do. None of them spawn a process or change filesystem attributes, so the maintainer-decision point no longer applies.

Your reply points to a real defect in main. map_dll lowercases the name before dirs.0.join, so in a case-sensitive directory even an exact-case match is skipped silently. Folders created from WSL on NTFS are a real way to get such a directory. The Wine/Proton case is weaker, since Wine already does its own case-insensitive lookup.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151933635 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1434#issuecomment-7151933635). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T03:27:36Z. --- <!-- victory-triage v1 head=4339556a4f9f4d0f143176980c1247f4a7747539 verdict=merge-candidate at=2026-11-25T07:21:17Z --> Automated triage for the maintainers. **Merge candidate (update after your reply).** `map_dll` in `crates/victory-loader/src/windows.rs` now tries the import name as written first. If that misses, it falls back to a case-insensitive directory scan (`find_dll_file` → `scan_dll_file` → `select_dll_entry`) and keeps the lowercased name as the `seen`/`loaded` key. Thanks for removing the `fsutil` call. The new tests are a pure unit test on `select_dll_entry`, a `tempfile` scan test, and a load test that copies `version.dll` the way existing `load_probe.rs` tests do. None of them spawn a process or change filesystem attributes, so the maintainer-decision point no longer applies. Your reply points to a real defect in `main`. `map_dll` lowercases the name before `dirs.0.join`, so in a case-sensitive directory even an exact-case match is skipped silently. Folders created from WSL on NTFS are a real way to get such a directory. The Wine/Proton case is weaker, since Wine already does its own case-insensitive lookup. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-25 05:06:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:39:32Z.


Rebased onto 940d32f (4339556a) and removed the fsutil process call and filesystem-attribute mutation, replacing it with an in-memory unit test on select_dll_entry.

On where this is reached in practice: map_dll previously lowercased name before joining the path (let name = name.to_ascii_lowercase(); let path = dirs.0.join(&name);), so in any case-sensitive directory even an exact-case match between the PE import descriptor and a mixed-case DLL filename on disk (FooBar.dll -> dirs.0.join("foobar.dll").is_file()) silently returned Ok(()) without loading the DLL, leaving its imports on missing stubs. That hits Linux + Wine/Proton runs backed by ext4/btrfs/xfs mounts without kernel casefold (as reported in #762) as well as directories created from WSL on NTFS (which inherit FILE_CS_FLAG_CASE_SENSITIVE_DIR) or accessed over \\wsl.localhost\....

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153045655 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1434#issuecomment-7153045655). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T04:39:32Z. --- Rebased onto `940d32f` (`4339556a`) and removed the `fsutil` process call and filesystem-attribute mutation, replacing it with an in-memory unit test on `select_dll_entry`. On where this is reached in practice: `map_dll` previously lowercased `name` *before* joining the path (`let name = name.to_ascii_lowercase(); let path = dirs.0.join(&name);`), so in any case-sensitive directory even an exact-case match between the PE import descriptor and a mixed-case DLL filename on disk (`FooBar.dll` -> `dirs.0.join("foobar.dll").is_file()`) silently returned `Ok(())` without loading the DLL, leaving its imports on `missing` stubs. That hits Linux + Wine/Proton runs backed by `ext4`/`btrfs`/`xfs` mounts without kernel `casefold` (as reported in #762) as well as directories created from WSL on NTFS (which inherit `FILE_CS_FLAG_CASE_SENSITIVE_DIR`) or accessed over `\\wsl.localhost\...`.
cloph-dsp commented 2026-11-27 03:49:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T03:49:33Z.


Independent CPU-only verification on Windows (Rust 1.100.0/MSVC, per-worktree CARGO_TARGET_DIR=target-1434-watch, CARGO_BUILD_JOBS=2, no game data).

  • PR head 4339556a, base/merge base 940d32f; 2 files, +135/-4.
  • cargo test --locked -p victory-loader --lib -- windows::tests::select_dll_entry_matches_ignoring_ascii_case_and_skips_colliding_folders --exact --test-threads=1 --quiet -> 1 passed, 35 filtered.
  • cargo test --locked -p victory-loader --lib -- windows::tests::directory_scan_matches_files_ignoring_ascii_case_and_skips_folders --exact --test-threads=1 --quiet -> 1 passed, 35 filtered.
  • cargo test --locked -p victory-loader --test load_probe -- maps_mixed_case_title_dlls_and_reports_matched_filename --exact --test-threads=1 --quiet -> 1 passed, 2 filtered.
  • git diff --check 940d32f HEAD -> clean.
  • Negative control: all three new test names are absent from 940d32f (git grep -c -F ... 940d32f -- crates/victory-loader -> no output / exit 1).

Note: only the three named synthetic tests were replayed; the full crate suite and real title DLL loading were not exercised. GPU/driver: N/A (CPU-only loader tests). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM involved.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7209301259 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1434#issuecomment-7209301259). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-27T03:49:33Z. --- Independent CPU-only verification on Windows (Rust 1.100.0/MSVC, per-worktree `CARGO_TARGET_DIR=target-1434-watch`, `CARGO_BUILD_JOBS=2`, no game data). - PR head `4339556a`, base/merge base `940d32f`; 2 files, +135/-4. - `cargo test --locked -p victory-loader --lib -- windows::tests::select_dll_entry_matches_ignoring_ascii_case_and_skips_colliding_folders --exact --test-threads=1 --quiet` -> 1 passed, 35 filtered. - `cargo test --locked -p victory-loader --lib -- windows::tests::directory_scan_matches_files_ignoring_ascii_case_and_skips_folders --exact --test-threads=1 --quiet` -> 1 passed, 35 filtered. - `cargo test --locked -p victory-loader --test load_probe -- maps_mixed_case_title_dlls_and_reports_matched_filename --exact --test-threads=1 --quiet` -> 1 passed, 2 filtered. - `git diff --check 940d32f HEAD` -> clean. - Negative control: all three new test names are absent from `940d32f` (`git grep -c -F ... 940d32f -- crates/victory-loader` -> no output / exit 1). Note: only the three named synthetic tests were replayed; the full crate suite and real title DLL loading were not exercised. GPU/driver: N/A (CPU-only loader tests). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM involved.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1434:upstream-pr/1434'
git switch 'upstream-pr/1434'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1434'
git switch 'upstream-pr/1434'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1434'
git switch 'upstream-pr/1434'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1434'
git switch 'main'
git merge --squash 'upstream-pr/1434'
git switch 'main'
git merge --ff-only 'upstream-pr/1434'
git switch 'main'
git merge 'upstream-pr/1434'
git push origin 'main'
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
Marvisak/VIctory!1433
No description provided.