Census: deduplicate PE imports without hint #476

Merged
nathanbzrr merged 1 commit from upstream-pr/476 into main 2026-11-25 00:08:38 +00:00
nathanbzrr commented 2026-11-24 03:50:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by nathanbzrr on 2026-11-24T03:50:23Z.


Problem

victory census in apps/victory/src/census.rs tracked per-DLL unique functions in BTreeSet<ImportSymbol>. Because ImportSymbol derives Eq and Ord over all fields including the advisory PE hint: u16, identical dll!function imports appearing across different binaries (or in both regular and delay-load import tables) with different hint values were counted multiple times in funcs, hle, host, and missing totals, disagreeing with missing entries (which key by e.symbol.to_string()).

What changed

  • Added a private FunctionKey { Name(String), Ordinal(u16) } enum implementing From<&ImportSymbol> in apps/victory/src/census.rs so PE import hint values are ignored when deduplicating per-DLL functions.
  • Switched DllStats.functions from BTreeSet<ImportSymbol> to BTreeSet<FunctionKey>.
  • Extracted tally_image() from run() and inserted FunctionKey::from(&e.symbol) into stats.functions.
  • Added synthetic in-memory unit tests covering cross-image and imports + delay_imports deduplication across differing hint values, ordinal imports, and missing total consistency.

Tests (isolated branch a3f89ed)

  • rustfmt --edition 2024 --check apps/victory/src/census.rs: passed (exit 0).
  • cargo test -p victory --bin victory census: 2 passed, 0 failed, 1 filtered out (census::tests::deduplicates_imports_ignoring_hint_across_images_and_delay_imports, census::tests::counts_distinct_symbols_and_dlls_separately).
  • cargo clippy -p victory --all-targets: passed (exit 0; 0 errors/warnings in apps/victory/src/census.rs).
  • cargo xtask policy: asset policy: 151 files ok.

No game files. AI-assisted; reviewed and verified with the tests above.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6574191845 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/476). Originally posted by [nathanbzrr](https://github.com/nathanbzrr) on 2026-11-24T03:50:23Z. --- ## Problem `victory census` in `apps/victory/src/census.rs` tracked per-DLL unique functions in `BTreeSet<ImportSymbol>`. Because `ImportSymbol` derives `Eq` and `Ord` over all fields including the advisory PE `hint: u16`, identical `dll!function` imports appearing across different binaries (or in both regular and delay-load import tables) with different `hint` values were counted multiple times in `funcs`, `hle`, `host`, and `missing` totals, disagreeing with `missing` entries (which key by `e.symbol.to_string()`). ## What changed - Added a private `FunctionKey { Name(String), Ordinal(u16) }` enum implementing `From<&ImportSymbol>` in `apps/victory/src/census.rs` so PE import `hint` values are ignored when deduplicating per-DLL functions. - Switched `DllStats.functions` from `BTreeSet<ImportSymbol>` to `BTreeSet<FunctionKey>`. - Extracted `tally_image()` from `run()` and inserted `FunctionKey::from(&e.symbol)` into `stats.functions`. - Added synthetic in-memory unit tests covering cross-image and `imports` + `delay_imports` deduplication across differing `hint` values, ordinal imports, and `missing` total consistency. ## Tests (isolated branch `a3f89ed`) - `rustfmt --edition 2024 --check apps/victory/src/census.rs`: passed (exit 0). - `cargo test -p victory --bin victory census`: 2 passed, 0 failed, 1 filtered out (`census::tests::deduplicates_imports_ignoring_hint_across_images_and_delay_imports`, `census::tests::counts_distinct_symbols_and_dlls_separately`). - `cargo clippy -p victory --all-targets`: passed (exit 0; 0 errors/warnings in `apps/victory/src/census.rs`). - `cargo xtask policy`: `asset policy: 151 files ok`. No game files. AI-assisted; reviewed and verified with the tests above.
mercuryVM commented 2026-11-24 06:53:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T06:14:45Z.

Review: APPROVED


Tested a3f89ed on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (266 passed, 0 failed).

  • The PE hint is advisory, so keying functions on name or ordinal alone is the right identity. The per-DLL totals now agree with missing, which already keyed on symbol.to_string().
  • tally_image is a pure move of the loop body. The new tests build ImageInfo in memory with no title data.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6034547114 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/476#pullrequestreview-6034547114). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T06:14:45Z. **Review:** APPROVED --- Tested a3f89ed on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (266 passed, 0 failed). - The PE hint is advisory, so keying `functions` on name or ordinal alone is the right identity. The per-DLL totals now agree with `missing`, which already keyed on `symbol.to_string()`. - `tally_image` is a pure move of the loop body. The new tests build `ImageInfo` in memory with no title data. No issues found. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 01:03:54 +00:00
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!476
No description provided.