Loader: a title DLL that fails to prepare is named in the error #285

Merged
Dufftwt merged 1 commit from upstream-pr/285 into main 2026-11-24 07:59:50 +00:00
Dufftwt commented 2026-11-24 02:02:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dufftwt on 2026-11-24T02:02:57Z.


What's wrong

map_dll in windows.rs brings each of the title's DLLs in three steps:

let original = std::fs::read(&path).with_context(|| format!("reading {}", path.display()))?;
let image = load(&prepare(&original)?, dirs.1)
    .with_context(|| format!("loading {}", path.display()))?;

Reading and loading add the DLL's path to their errors. Preparing doesn't. When the PE parser or the patcher refuses a DLL, the run ends with an error that doesn't say which file it was, for example:

Error: malformed image: Invalid PE import descriptor name

A title has several DLLs besides the exe (Grand Theft Auto VI has four), and through LateDlls the failure is reported under whichever DLL the title asked for, which may not be the dependency that actually failed. A reporter can't tell which file is the problem.

What the fix does

The prepare step gets the same context as its neighbours: preparing <path>.

How it behaves after the fix

Error: preparing D:\Games\…\broken.dll: malformed image: …

Nothing changes for DLLs that load.

Tests

The new integration test tests/title_dlls.rs writes a file named broken.dll that isn't a PE (MZ not a PE) into a temporary title folder. It then checks that load_title_dll fails with an error naming broken.dll.

I ran cargo test --workspace on GitHub's windows-latest with Rust 1.98.1 from rust-toolchain.toml:

  • This PR: everything passes, including the new test. The other crates have 0 failed.
  • The new test alone on main: it fails because the error is only malformed image: Could not read file magic, with no file name.
  • I ran with --test-threads=1. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (#181, #244).

Not tested: a real title DLL that fails to prepare.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6572921094 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/285). Originally posted by [Dufftwt](https://github.com/Dufftwt) on 2026-11-24T02:02:57Z. --- ## What's wrong `map_dll` in `windows.rs` brings each of the title's DLLs in three steps: ```rust let original = std::fs::read(&path).with_context(|| format!("reading {}", path.display()))?; let image = load(&prepare(&original)?, dirs.1) .with_context(|| format!("loading {}", path.display()))?; ``` Reading and loading add the DLL's path to their errors. **Preparing doesn't.** When the PE parser or the patcher refuses a DLL, the run ends with an error that doesn't say which file it was, for example: ``` Error: malformed image: Invalid PE import descriptor name ``` A title has several DLLs besides the exe (Grand Theft Auto VI has four), and through `LateDlls` the failure is reported under whichever DLL the title asked for, which may not be the dependency that actually failed. A reporter can't tell which file is the problem. ## What the fix does The prepare step gets the same context as its neighbours: `preparing <path>`. ## How it behaves after the fix ``` Error: preparing D:\Games\…\broken.dll: malformed image: … ``` Nothing changes for DLLs that load. ## Tests The new integration test `tests/title_dlls.rs` writes a file named `broken.dll` that isn't a PE (`MZ not a PE`) into a temporary title folder. It then checks that `load_title_dll` fails with an error naming `broken.dll`. I ran `cargo test --workspace` on GitHub's `windows-latest` with Rust 1.98.1 from `rust-toolchain.toml`: - **This PR:** everything passes, including the new test. The other crates have 0 failed. - **The new test alone on `main`:** it fails because the error is only `malformed image: Could not read file magic`, with no file name. - I ran with `--test-threads=1`. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (#181, #244). **Not tested:** a real title DLL that fails to prepare.
jeremygold02 commented 2026-11-24 06:55:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:16:37Z.


Tested PR #285 at head 5f29f3ae5a92eef900c77cfa0dc824cc4b812e09 (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at 5f29f3ae5a92eef900c77cfa0dc824cc4b812e09.

  • cargo test --locked -p victory-loader --test title_dlls a_title_dll_that_does_not_prepare_is_named — passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s ); cases: a_title_dll_that_does_not_prepare_is_named.

Behavior covered: Checks a title DLL preparation failure reports the offending DLL name through the loader integration test.
Code: crates/victory-loader/src/windows.rs, crates/victory-loader/tests/title_dlls.rs

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121870197 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/285#issuecomment-7121870197). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:16:37Z. --- Tested PR #285 at head `5f29f3ae5a92eef900c77cfa0dc824cc4b812e09` (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at `5f29f3ae5a92eef900c77cfa0dc824cc4b812e09`. - `cargo test --locked -p victory-loader --test title_dlls a_title_dll_that_does_not_prepare_is_named` — passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s ); cases: a_title_dll_that_does_not_prepare_is_named. Behavior covered: Checks a title DLL preparation failure reports the offending DLL name through the loader integration test. Code: [crates/victory-loader/src/windows.rs](https://github.com/Marvisak/VIctory/blob/5f29f3ae5a92eef900c77cfa0dc824cc4b812e09/crates/victory-loader/src/windows.rs), [crates/victory-loader/tests/title_dlls.rs](https://github.com/Marvisak/VIctory/blob/5f29f3ae5a92eef900c77cfa0dc824cc4b812e09/crates/victory-loader/tests/title_dlls.rs)
mercuryVM commented 2026-11-24 07:32:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T07:32:35Z.

Review: APPROVED


Tested 5f29f3a on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed), including the new tests/title_dlls.rs.

The three steps of map_dll (read, prepare, load) now all name the DLL, so a PE parse or patch failure says which file. The integration test feeds a non-PE broken.dll through the public load_title_dll and checks the file name in the {:#} chain.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6035308605 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/285#pullrequestreview-6035308605). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T07:32:35Z. **Review:** APPROVED --- Tested 5f29f3a on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (265 passed, 0 failed), including the new `tests/title_dlls.rs`. The three steps of `map_dll` (read, prepare, load) now all name the DLL, so a PE parse or patch failure says which file. The integration test feeds a non-PE `broken.dll` through the public `load_title_dll` and checks the file name in the `{:#}` chain. No issues found. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 08:02:02 +00:00
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!285
No description provided.