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

Manually merged
github merged 1 commit from gh-pr/285/head into gh-pr/285/base 2026-11-26 03:57:56 +00:00
Owner

@⁠Dufftwt on GitHub · 2026-11-24 02:02 UTC · original
Dufftwt:fix/name-title-dll-that-fails-to-prepare → main · +18 −2 · 2 files · 1 commits · merged 2026-11-24 07:59 UTC

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.

**@⁠Dufftwt** on GitHub · 2026-11-24 02:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/285) `Dufftwt:fix/name-title-dll-that-fails-to-prepare` → `main` · +18 −2 · 2 files · 1 commits · merged 2026-11-24 07:59 UTC ## 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.
Reading and loading a title DLL report its path when they fail;
preparing it, in between, did not. A DLL the PE parser refuses ended
the run with just "malformed image: ..." (or the like), without saying
which of the title's DLLs it was.

The prepare step now adds "preparing <path>" like its neighbours.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:57:54 +00:00
github manually merged commit 5f29f3ae5a into gh-pr/285/base 2026-11-26 03:57:56 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 04:16 UTC · original

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

**@⁠jeremygold02** on GitHub · 2026-11-24 04:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/285#issuecomment-7121870197) 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)
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!285
No description provided.