Skip to content

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

Merged
Marvisak merged 1 commit into
Marvisak:mainfrom
Dufftwt:fix/name-title-dll-that-fails-to-prepare
Nov 24, 2026
Merged

Marvisak merged 1 commit into
Marvisak:mainfrom
Dufftwt:fix/name-title-dll-that-fails-to-prepare

Conversation

@Dufftwt

@Dufftwt Dufftwt commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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:

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.
muhammed-aksoy pushed a commit to muhammed-aksoy/VIctory that referenced this pull request Nov 24, 2026
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…the error

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremygold02

Copy link
Copy Markdown
Contributor

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

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
…pare is named in the error

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Marvisak
Marvisak merged commit 93c0852 into Marvisak:main Nov 24, 2026
suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
…-prepare

Loader: a title DLL that fails to prepare is named in the error
itsonlysimbo pushed a commit to itsonlysimbo/VIctory that referenced this pull request Nov 24, 2026
…fails-to-prepare

Loader: a title DLL that fails to prepare is named in the error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants