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

Manually merged
github merged 1 commit from gh-pr/75/head into gh-pr/75/base 2026-11-26 03:49:19 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 00:15 UTC · original
tedin7:vic-pe-export-holes → main · +74 −0 · 1 files · 1 commits · merged 2026-11-24 00:33 UTC

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.

**@⁠tedin7** on GitHub · 2026-11-24 00:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/75) `tedin7:vic-pe-export-holes` → `main` · +74 −0 · 1 files · 1 commits · merged 2026-11-24 00:33 UTC ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:49:18 +00:00
github manually merged commit 9a5cbbeb64 into gh-pr/75/base 2026-11-26 03:49:19 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:24 UTC · original

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

**@⁠DaviTostes** on GitHub · 2026-11-24 00:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/75#issuecomment-7118037384) 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).
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!75
No description provided.