PE: read long-format import descriptors #963

Closed
github-bot wants to merge 1 commit from gh-pr/963/head into gh-pr/963/base
Owner

@⁠enzoduarte1 on GitHub · 2026-11-24 14:33 UTC · original
enzoduarte1:pe/import-lib-long-format → main · +311 −21 · 1 files · 1 commits · closed without merging

What

ImportLibrary::parse only understood short-format import objects. Long-format import libraries (the ones whose archive members start with a 20-byte descriptor and no inline strings) were counted in other_members but yielded no imports at all.

This patch recognizes that descriptor form, walks the following COFF members, and recovers the DLL from __IMPORT_DESCRIPTOR_<dll> plus exports from __imp_<name> symbols. Type, ordinal/hint and name-decoration bits are read from the descriptor header, matching the short-format rules already used by the object crate. Short imports and unrecognized members keep their previous behaviour.

Tested

  • Windows 11, Rust 1.98.1, x86_64-pc-windows-gnu (no MSVC linker on this machine).
  • cargo test -p victory-pe --lib -- --test-threads=1: 11 passed, 0 failed.
  • New tests cover a short import, a long import with named exports, a long import by ordinal, and accounting for an unknown member.
  • cargo check --workspace: clean, no new warnings.
  • rustfmt --edition 2024 --check crates/victory-pe/src/implib.rs and git diff --check: clean.
  • cargo xtask policy: 154 files ok. No game files or data taken from them were added.

Checklist

  • cargo fmt --all --check and cargo test --workspace pass — the workspace has pre-existing formatting diffs and the loader fixture needs MSVC /DELAYLOAD, which MinGW rejects here; the changed crate and a full cargo check --workspace are clean.
  • cargo xtask policy passes. The change adds no game files or data taken from them (docs/asset-policy.md).
  • If an AI tool wrote part of this change, the description says so: an AI tool assisted with the parser and tests; I reviewed and ran them.
**@⁠enzoduarte1** on GitHub · 2026-11-24 14:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/963) `enzoduarte1:pe/import-lib-long-format` → `main` · +311 −21 · 1 files · 1 commits · closed without merging ## What `ImportLibrary::parse` only understood short-format import objects. Long-format import libraries (the ones whose archive members start with a 20-byte descriptor and no inline strings) were counted in `other_members` but yielded no imports at all. This patch recognizes that descriptor form, walks the following COFF members, and recovers the DLL from `__IMPORT_DESCRIPTOR_<dll>` plus exports from `__imp_<name>` symbols. Type, ordinal/hint and name-decoration bits are read from the descriptor header, matching the short-format rules already used by the `object` crate. Short imports and unrecognized members keep their previous behaviour. ## Tested - Windows 11, Rust 1.98.1, `x86_64-pc-windows-gnu` (no MSVC linker on this machine). - `cargo test -p victory-pe --lib -- --test-threads=1`: 11 passed, 0 failed. - New tests cover a short import, a long import with named exports, a long import by ordinal, and accounting for an unknown member. - `cargo check --workspace`: clean, no new warnings. - `rustfmt --edition 2024 --check crates/victory-pe/src/implib.rs` and `git diff --check`: clean. - `cargo xtask policy`: 154 files ok. No game files or data taken from them were added. ## Checklist - [ ] `cargo fmt --all --check` and `cargo test --workspace` pass — the workspace has pre-existing formatting diffs and the loader fixture needs MSVC `/DELAYLOAD`, which MinGW rejects here; the changed crate and a full `cargo check --workspace` are clean. - [x] `cargo xtask policy` passes. The change adds no game files or data taken from them (`docs/asset-policy.md`). - [x] If an AI tool wrote part of this change, the description says so: an AI tool assisted with the parser and tests; I reviewed and ran them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:15:09 +00:00
github-bot closed this pull request 2026-11-26 04:15:09 +00:00
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 15:13 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at adeb9ff: cargo test -p victory-pe passes, 11 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 15:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/963#issuecomment-7135655851) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at adeb9ff: `cargo test -p victory-pe` passes, 11 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:28 UTC · original

Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/963#issuecomment-7148552286) Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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!963
No description provided.