PE: skip unused export slots instead of reporting them at RVA 0 #75

Merged
tedin7 merged 1 commit from upstream-pr/75 into main 2026-11-24 00:33:39 +00:00
tedin7 commented 2026-11-24 00:15:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tedin7 on 2026-11-24T00:15:13Z.


What

parse_exports now skips export address-table slots whose address is 0.

Why

An address of 0 marks an unused slot (a gap in the ordinals, as in DLLs built with holes or NONAME ranges). The Windows loader does not treat these as exports. object's ExportTable::exports() still lists them, so ImageInfo::exports reported phantom entries with rva: Some(0) (the image base) and no name. Anything that resolves or lists exports from ImageInfo (e.g. victory inspect) would see them. Forwarded exports are unaffected (a forwarder address is always inside the export directory, never 0).

Tested

New unit test unused_export_slots_are_not_exports builds a synthetic in-memory PE32+ (no game or retail data) with ordinal base 1 and three slots: "alpha", a hole, "gamma".

Linux x86_64, cargo test -j4 -p victory-pe:

  • before the fix, the new test FAILS: left has 3 entries including (None, 2, Some(0))
  • after the fix, the new test passes
  • cargo clippy -p victory-pe --tests: clean
  • rustfmt --check on image.rs: clean

The 4 existing tests that parse the host executable (parses_own_test_binary, rva_to_file_offset_maps_entry_point, rejects_iat_outside_image, dump_tls) fail on Linux because the host is an ELF binary. This is pre-existing and unrelated to this change.

Not run: Windows runtime and GPU.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6571619649 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/75). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T00:15:13Z. --- ## What `parse_exports` now skips export address-table slots whose address is 0. ## Why An address of 0 marks an unused slot (a gap in the ordinals, as in DLLs built with holes or `NONAME` ranges). The Windows loader does not treat these as exports. `object`'s `ExportTable::exports()` still lists them, so `ImageInfo::exports` reported phantom entries with `rva: Some(0)` (the image base) and no name. Anything that resolves or lists exports from `ImageInfo` (e.g. `victory inspect`) would see them. Forwarded exports are unaffected (a forwarder address is always inside the export directory, never 0). ## Tested New unit test `unused_export_slots_are_not_exports` builds a synthetic in-memory PE32+ (no game or retail data) with ordinal base 1 and three slots: "alpha", a hole, "gamma". Linux x86_64, `cargo test -j4 -p victory-pe`: - before the fix, the new test FAILS: left has 3 entries including `(None, 2, Some(0))` - after the fix, the new test passes - `cargo clippy -p victory-pe --tests`: clean - `rustfmt --check` on image.rs: clean The 4 existing tests that parse the host executable (`parses_own_test_binary`, `rva_to_file_offset_maps_entry_point`, `rejects_iat_outside_image`, `dump_tls`) fail on Linux because the host is an ELF binary. This is pre-existing and unrelated to this change. Not run: Windows runtime and GPU.
upstream-sync closed this pull request 2026-11-24 06:51:11 +00:00
DaviTostes commented 2026-11-24 06:54:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T00:24:33Z.


Tested 9a5cbbe stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass.

  • cargo test --workspace: 156 passed, 0 failed, 3 ignored; merge with #39 clean.
  • The PR adds 4 #[test]s for the export-address slots, included in that run.
  • No game data used.

AI-assisted (DeepSeek V4.1 Flash coding agent).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7118037384 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/75#issuecomment-7118037384). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T00:24:33Z. --- Tested `9a5cbbe` stacked on **#39** on **Arch Linux x86_64, rustc 1.98.1**: **pass**. - `cargo test --workspace`: **156 passed, 0 failed, 3 ignored**; merge with #39 clean. - The PR adds 4 `#[test]`s for the export-address slots, included in that run. - No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
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!75
No description provided.