PE: tests for delay-import parsing (names, ordinals, IAT bounds) #2731

Open
github-bot wants to merge 1 commit from github-bot/gh-2731 into main AGit
Owner

@⁠Vedoxdev123 on GitHub · 2026-11-25 19:10 UTC · original
Vedoxdev123:pe/delay-import-tests → main · +90 −0 · 1 files · 1 commits · open

parse_delay_imports in victory-pe had no unit test. Delay imports were only reached through the loader's load_probe fixture and the census's synthetic ImageInfo, so a regression in how the parser reads them (or in the IAT bounds check it shares with normal imports) would not fail a victory-pe test.

What is in it

  • crates/victory-pe/src/image.rs: four tests on a synthetic image, built on the existing synthetic_image helper. No change to the parser.
    • delay_imports_list_names_and_ordinals_with_their_iat_slots: the DLL name, a name import (hint 5), an ordinal import, and the IAT slot RVA of each; normal imports stay empty.
    • an_image_without_a_delay_load_directory_has_no_delay_imports.
    • a_delay_iat_ending_at_the_end_of_the_image_is_accepted: the last slot ends exactly at SizeOfImage.
    • a_delay_iat_running_past_the_image_is_rejected: one byte further, and an IAT at 0xFFFF_FFF8, give PeError::Malformed.

Tested

  • Windows 11, Ryzen 5 5600X, on main 13f91ca.
  • cargo test -p victory-pe: 40 passed (36 before).
  • Checked the new tests can fail: with the bound in entries() changed from end <= size_of_image to end <= u32::MAX, a_delay_iat_running_past_the_image_is_rejected fails. Reverted.
  • cargo clippy -p victory-pe --all-targets --locked -- -D warnings: clean. rustfmt --edition 2024 --check: clean. cargo xtask policy: 184 files ok.

Not tested

  • Only victory-pe was run for this change. A full workspace run on this base (GPU and shader crates excluded) passed with no failures.
  • Delay-import descriptors with the old VA-based attribute (attribute bit 0 clear) are not covered; the parser is object's there.

AI use

  • Claude Code (Claude Sonnet 5.5) found the gap, wrote the tests and ran the checks; I reviewed them.

No game data used.

🤖 Generated with Claude Code

**@⁠Vedoxdev123** on GitHub · 2026-11-25 19:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2731) `Vedoxdev123:pe/delay-import-tests` → `main` · +90 −0 · 1 files · 1 commits · open `parse_delay_imports` in `victory-pe` had no unit test. Delay imports were only reached through the loader's `load_probe` fixture and the census's synthetic `ImageInfo`, so a regression in how the parser reads them (or in the IAT bounds check it shares with normal imports) would not fail a `victory-pe` test. **What is in it** - `crates/victory-pe/src/image.rs`: four tests on a synthetic image, built on the existing `synthetic_image` helper. No change to the parser. - `delay_imports_list_names_and_ordinals_with_their_iat_slots`: the DLL name, a name import (hint 5), an ordinal import, and the IAT slot RVA of each; normal imports stay empty. - `an_image_without_a_delay_load_directory_has_no_delay_imports`. - `a_delay_iat_ending_at_the_end_of_the_image_is_accepted`: the last slot ends exactly at `SizeOfImage`. - `a_delay_iat_running_past_the_image_is_rejected`: one byte further, and an IAT at `0xFFFF_FFF8`, give `PeError::Malformed`. **Tested** - Windows 11, Ryzen 5 5600X, on `main` `13f91ca`. - `cargo test -p victory-pe`: 40 passed (36 before). - Checked the new tests can fail: with the bound in `entries()` changed from `end <= size_of_image` to `end <= u32::MAX`, `a_delay_iat_running_past_the_image_is_rejected` fails. Reverted. - `cargo clippy -p victory-pe --all-targets --locked -- -D warnings`: clean. `rustfmt --edition 2024 --check`: clean. `cargo xtask policy`: 184 files ok. **Not tested** - Only `victory-pe` was run for this change. A full workspace run on this base (GPU and shader crates excluded) passed with no failures. - Delay-import descriptors with the old VA-based attribute (attribute bit 0 clear) are not covered; the parser is `object`'s there. **AI use** - Claude Code (Claude Sonnet 5.5) found the gap, wrote the tests and ran the checks; I reviewed them. No game data used. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
parse_delay_imports had no unit test in victory-pe; delay imports were
only reached through the loader's load_probe fixture and the census's
synthetic ImageInfo. Add four tests on a synthetic image:

- a delay-load directory lists its DLL, a name import (with hint) and an
  ordinal import, with the IAT slot RVA of each, and adds nothing to the
  normal imports;
- an image without the directory has no delay imports;
- an IAT whose last slot ends exactly at SizeOfImage is accepted;
- one byte further, and an IAT at the 4 GiB limit, are refused as malformed.

Tests only; no change to the parser.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:12:57 +00:00
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-25 19:20 UTC · original

Independent Windows verification (AI-assisted, Hy4 flash). Rust/cargo 1.100.0, MSVC, no game data, no GPU.

$env:CARGO_BUILD_JOBS=2
cargo test --locked -p victory-pe --lib delay --quiet
# running 4 tests ... test result: ok. 4 passed; 0 failed; 0 measured; 36 filtered out
cargo test --locked -p victory-pe --lib --quiet
# running 40 tests ... test result: ok. 40 passed; 0 failed; 0 measured; 0 filtered out

Negative control: the four new test names are absent from origin/main in crates/victory-pe/src/image.rs (git grep -c returned no matches), so the tests are genuinely introduced by this PR. No blocking findings; synthetic byte buffers only.

**@⁠cloph-dsp** on GitHub · 2026-11-25 19:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2731#issuecomment-7172165629) Independent Windows verification (AI-assisted, Hy4 flash). Rust/cargo 1.100.0, MSVC, no game data, no GPU. ``` $env:CARGO_BUILD_JOBS=2 cargo test --locked -p victory-pe --lib delay --quiet # running 4 tests ... test result: ok. 4 passed; 0 failed; 0 measured; 36 filtered out cargo test --locked -p victory-pe --lib --quiet # running 40 tests ... test result: ok. 40 passed; 0 failed; 0 measured; 0 filtered out ``` Negative control: the four new test names are absent from `origin/main` in `crates/victory-pe/src/image.rs` (`git grep -c` returned no matches), so the tests are genuinely introduced by this PR. No blocking findings; synthetic byte buffers only.
Author
Owner

@⁠XeNS1 on GitHub · 2026-11-25 19:26 UTC · original

Independent native Linux verification of 694baa30780f4634d03d2f831bf11cb5b20ae652 on 13f91ca, plus integration with the section-RVA coverage in #2740 (f0d5342). Rust 1.100.0, x86-64, two build jobs; no game files or GPU execution.

  • Exact PR head: all four delay-import tests pass; the portable victory-pe suite has 36 passed, 0 failed. Four unchanged tests requiring the host executable to be a Windows PE were excluded by name.
  • Applied #2740 without conflicts in a detached validation worktree: 41 passed, 0 failed, with only three Windows-host tests excluded (its fourth is now portable). Strict --all-targets --all-features Clippy passes for both the original head and the combination; combined staged asset policy passes.
  • Three mutations in a separate snapshot of the exact PR head are detected: changing the image bound from <= to < fails the exact-end acceptance test; allowing every non-overflowing u32 end fails the out-of-image rejection test; changing IAT stride from 8 to 4 fails three new tests. The unmodified snapshot passes all four delay tests.

Commands for the original head:

cargo test -p victory-pe --locked --offline -- --skip parses_own_test_binary --skip rva_to_file_offset_maps_entry_point --skip rva_to_file_offset_rejects_offsets_past_4_gib --skip rejects_iat_outside_image
cargo clippy -p victory-pe --all-targets --all-features --locked --offline -- -D warnings

The combination uses the same commands with the overflow-test exclusion removed.

No blocking findings in this scope. Legacy VA-based delay descriptors and actual Windows loading were not exercised. This complements the existing Windows report; no competing implementation. AI-assisted: OpenAI Codex.

**@⁠XeNS1** on GitHub · 2026-11-25 19:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2731#issuecomment-7172304914) Independent native Linux verification of `694baa30780f4634d03d2f831bf11cb5b20ae652` on `13f91ca`, plus integration with the section-RVA coverage in #2740 (`f0d5342`). Rust 1.100.0, x86-64, two build jobs; no game files or GPU execution. - Exact PR head: all four delay-import tests pass; the portable `victory-pe` suite has **36 passed, 0 failed**. Four unchanged tests requiring the host executable to be a Windows PE were excluded by name. - Applied #2740 without conflicts in a detached validation worktree: **41 passed, 0 failed**, with only three Windows-host tests excluded (its fourth is now portable). Strict `--all-targets --all-features` Clippy passes for both the original head and the combination; combined staged asset policy passes. - Three mutations in a separate snapshot of the exact PR head are detected: changing the image bound from `<=` to `<` fails the exact-end acceptance test; allowing every non-overflowing u32 end fails the out-of-image rejection test; changing IAT stride from 8 to 4 fails three new tests. The unmodified snapshot passes all four delay tests. Commands for the original head: ```sh cargo test -p victory-pe --locked --offline -- --skip parses_own_test_binary --skip rva_to_file_offset_maps_entry_point --skip rva_to_file_offset_rejects_offsets_past_4_gib --skip rejects_iat_outside_image cargo clippy -p victory-pe --all-targets --all-features --locked --offline -- -D warnings ``` The combination uses the same commands with the overflow-test exclusion removed. No blocking findings in this scope. Legacy VA-based delay descriptors and actual Windows loading were not exercised. This complements the existing Windows report; no competing implementation. AI-assisted: OpenAI Codex.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 19:46 UTC · original

Independent Windows 11 verification and review of 694baa3 (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo xtask policy: 184 files ok.
  • cargo clippy --locked -p victory-pe --all-targets -- -D warnings: 0 warnings.
  • cargo test --locked -p victory-pe: 40 passed, 0 failed (all 4 new delay-import tests pass).
  • Merge compatibility with #2741 (e9df3bd): clean zero-conflict 3-way git merge-tree; the two PRs are strictly complementary (#2731 pins delay-import parsing and upper IAT bounds, #2741 rejects iat_rva == 0 in non-empty descriptors).

Review Notes

  • Clean, 100% synthetic tests covering named/ordinal delay imports, missing directory, exact SizeOfImage upper bound, 1-byte overshoot, and u32 overflow (0xFFFF_FFF8). Ready to merge.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 19:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2731#issuecomment-7172744875) Independent Windows 11 verification and review of `694baa3` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo xtask policy`: **184 files ok**. - `cargo clippy --locked -p victory-pe --all-targets -- -D warnings`: **0 warnings**. - `cargo test --locked -p victory-pe`: **40 passed, 0 failed** (all 4 new delay-import tests pass). - **Merge compatibility with #2741 (`e9df3bd`):** clean zero-conflict 3-way `git merge-tree`; the two PRs are strictly complementary (#2731 pins delay-import parsing and upper IAT bounds, #2741 rejects `iat_rva == 0` in non-empty descriptors). ### Review Notes - Clean, 100% synthetic tests covering named/ordinal delay imports, missing directory, exact `SizeOfImage` upper bound, 1-byte overshoot, and `u32` overflow (`0xFFFF_FFF8`). Ready to merge.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 20:07 UTC · original

Good coverage of the delay-import path: name ordinals, ordinal-bit entries, iat_slot_rva mapping, and the bounds case. Synthetic fixture builds the descriptor table correctly (RVA attributes bit, terminator descriptor).

**@⁠kotekompotek** on GitHub · 2026-11-25 20:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/2731#issuecomment-7173213169) Good coverage of the delay-import path: name ordinals, ordinal-bit entries, iat_slot_rva mapping, and the bounds case. Synthetic fixture builds the descriptor table correctly (RVA attributes bit, terminator descriptor).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:21 UTC · original

Automated triage for the maintainers. Adds four unit tests for parse_delay_imports in crates/victory-pe/src/image.rs on a synthetic image built from the existing synthetic_image helper: names and ordinals with their IAT slot RVAs, no delay directory, an IAT ending exactly at SizeOfImage, and IATs running past the image or past 4 GiB. I checked that the fixture's descriptor layout (RVA attribute, name table, terminator) is valid and that the expected bounds are the correct PE behaviour rather than just what the code does; no parser change and no game data. CI passes. This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2731#issuecomment-7177441219) <!-- victory-triage v1 head=694baa30780f4634d03d2f831bf11cb5b20ae652 verdict=merge-candidate at=2026-11-25T23:20:56Z --> Automated triage for the maintainers. Adds four unit tests for `parse_delay_imports` in crates/victory-pe/src/image.rs on a synthetic image built from the existing `synthetic_image` helper: names and ordinals with their IAT slot RVAs, no delay directory, an IAT ending exactly at `SizeOfImage`, and IATs running past the image or past 4 GiB. I checked that the fixture's descriptor layout (RVA attribute, name table, terminator) is valid and that the expected bounds are the correct PE behaviour rather than just what the code does; no parser change and no game data. CI passes. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 12:28 UTC · original

NVIDIA full-suite run, to go with the reports above by XeNS1, cloph-dsp, fuzeofficlal, since none of them names a GPU run. Tested exact head 694baa3 (on its base 13f91ca).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 777 passed, 0 failed, 9 ignored.
  • The new tests ran and passed: delay_imports_list_names_and_ordinals_with_their_iat_slots, an_image_without_a_delay_load_directory_has_no_delay_imports, a_delay_iat_ending_at_the_end_of_the_image_is_accepted, a_delay_iat_running_past_the_image_is_rejected.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 12:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2731#issuecomment-7192038383) NVIDIA full-suite run, to go with the reports above by XeNS1, cloph-dsp, fuzeofficlal, since none of them names a GPU run. Tested exact head `694baa3` (on its base `13f91ca`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **777 passed, 0 failed, 9 ignored**. - The new tests ran and passed: `delay_imports_list_names_and_ordinals_with_their_iat_slots`, `an_image_without_a_delay_load_directory_has_no_delay_imports`, `a_delay_iat_ending_at_the_end_of_the_image_is_accepted`, `a_delay_iat_running_past_the_image_is_rejected`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2731/head:github-bot/gh-2731'
git switch 'github-bot/gh-2731'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2731'
git switch 'github-bot/gh-2731'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2731'
git switch 'github-bot/gh-2731'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2731'
git switch 'main'
git merge --squash 'github-bot/gh-2731'
git switch 'main'
git merge --ff-only 'github-bot/gh-2731'
git switch 'main'
git merge 'github-bot/gh-2731'
git push origin 'main'
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!2731
No description provided.