CLI: resolve same-directory title DLL exports in census #2037

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/2039 into main
fuzeofficlal commented 2026-11-25 03:52:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T03:52:00Z.


Summary

  • Scan PE images in two passes during victory census, indexing exports of scanned DLLs by canonical parent directory and ASCII-lowercased filename.
  • Resolve named, ordinal, and forwarded imports satisfied by same-directory title DLLs under a dedicated title column instead of reporting them as unresolved missing host/HLE gaps, while preserving cross-directory scan-order independence and existing FunctionKey / canonical-path deduplication.
  • Add synthetic PE/DLL unit tests covering named, ordinal, forwarded, strict-mode, duplicate-path, and multi-directory exports.

Fixes #838

Testing

  • cargo test -p victory --locked
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo xtask policy
<!-- greyfinch-sync:Marvisak/VIctory:issue:6596810529 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2039). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T03:52:00Z. --- ## Summary - Scan PE images in two passes during `victory census`, indexing exports of scanned DLLs by canonical parent directory and ASCII-lowercased filename. - Resolve named, ordinal, and forwarded imports satisfied by same-directory title DLLs under a dedicated `title` column instead of reporting them as unresolved `missing` host/HLE gaps, while preserving cross-directory scan-order independence and existing `FunctionKey` / canonical-path deduplication. - Add synthetic PE/DLL unit tests covering named, ordinal, forwarded, strict-mode, duplicate-path, and multi-directory exports. Fixes #838 ## Testing - `cargo test -p victory --locked` - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` - `cargo xtask policy`
catminou4 commented 2026-11-25 04:06:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:57:01Z.

Review: COMMENTED


Static review only: apps/CLI are Windows-only paths — nothing compiles or runs on macOS; source review of the diff.

CLI census resolves same-directory title DLL exports — path-resolution fix for the offline census tool.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051646766 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2039#pullrequestreview-6051646766). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T03:57:01Z. **Review:** COMMENTED --- Static review only: apps/CLI are Windows-only paths — nothing compiles or runs on macOS; source review of the diff. CLI census resolves same-directory title DLL exports — path-resolution fix for the offline census tool.
DenRakEiw commented 2026-11-25 04:06:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T03:57:06Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory — 16 passed, 0 failed
  • cargo clippy -p victory --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean resolution of same-directory title DLL exports in census with thorough test coverage. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051647309 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2039#pullrequestreview-6051647309). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T03:57:06Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory` — 16 passed, 0 failed - `cargo clippy -p victory --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean resolution of same-directory title DLL exports in `census` with thorough test coverage. Looks good. AI-assisted (Gemini 4 Neon).
jeremygold02 commented 2026-11-25 05:06:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:08:00Z.


Triage verdict — Keep for #838, distinguish forwarder declarations from resolved imports (0c8615f)

Evidence

  • @fuzeofficlal’s two-pass census addresses the missing title category for same-directory named and ordinal exports. The forwarder case currently indexes an export’s name and ordinal without checking its target. The fixture declares FooFwd -> other.Target, supplies no target DLL, and expects three title resolutions and zero missing. Export index · Forwarder fixture
  • The runtime title resolver uses GetProcAddress and only reports a title import when it obtains an address. A forwarder declaration alone does not establish that its target is reachable. Runtime resolver · Export lookup · PE forwarder format

Checks and limits

  • The focused synthetic census test passed on this head and confirmed the classification above. I checked the runtime call path statically. I did not execute a loader fixture for the missing target.

Next step

  • Add reachable and missing-target forwarder fixtures. If full offline resolution is outside this change, report a forwarder with an unverified target separately or conservatively as unresolved, while retaining the direct name and ordinal coverage.

This verification was AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152558842 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2039#issuecomment-7152558842). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:08:00Z. --- **Triage verdict — Keep for #838, distinguish forwarder declarations from resolved imports** (`0c8615f`) **Evidence** - @fuzeofficlal’s two-pass census addresses the missing title category for same-directory named and ordinal exports. The forwarder case currently indexes an export’s name and ordinal without checking its target. The fixture declares `FooFwd -> other.Target`, supplies no target DLL, and expects three title resolutions and zero missing. [Export index](https://github.com/Marvisak/VIctory/blob/0c8615fa4452ddfe6e5f5f090cb009d74a9049fd/apps/victory/src/census.rs#L45-L61) · [Forwarder fixture](https://github.com/Marvisak/VIctory/blob/0c8615fa4452ddfe6e5f5f090cb009d74a9049fd/apps/victory/src/census.rs#L686-L734) - The runtime title resolver uses `GetProcAddress` and only reports a title import when it obtains an address. A forwarder declaration alone does not establish that its target is reachable. [Runtime resolver](https://github.com/Marvisak/VIctory/blob/940d32f69b22265690a0b5a15d6ded572ba33baf/crates/victory-loader/src/windows.rs#L168-L181) · [Export lookup](https://github.com/Marvisak/VIctory/blob/940d32f69b22265690a0b5a15d6ded572ba33baf/crates/victory-loader/src/windows.rs#L200-L215) · [PE forwarder format](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#export-address-table) **Checks and limits** - The focused synthetic census test passed on this head and confirmed the classification above. I checked the runtime call path statically. I did not execute a loader fixture for the missing target. **Next step** - Add reachable and missing-target forwarder fixtures. If full offline resolution is outside this change, report a forwarder with an unverified target separately or conservatively as unresolved, while retaining the direct name and ordinal coverage. This verification was AI-assisted.
fuzeofficlal commented 2026-11-25 05:06:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:44:21Z.


Updated in 6f8735f9 — good catch @jeremygold02. TitleExports now distinguishes direct RVA exports from forwarder strings and verifies each forwarder target against HleResolver (HLE / HostPolicy) or same-directory title DLL exports, guarded by a visited set and MAX_FORWARD_HOPS = 16 bound for cycles. Updated the forwarder fixture to chain through real same-directory and HLE targets, and added dangling_and_cyclic_forwarders_stay_missing covering missing target DLLs, missing target symbols/ordinals, mutual cycles, and self-loops.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153119049 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2039#issuecomment-7153119049). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T04:44:21Z. --- Updated in `6f8735f9` — good catch @jeremygold02. `TitleExports` now distinguishes direct RVA exports from forwarder strings and verifies each forwarder target against `HleResolver` (HLE / `HostPolicy`) or same-directory title DLL exports, guarded by a visited set and `MAX_FORWARD_HOPS = 16` bound for cycles. Updated the forwarder fixture to chain through real same-directory and HLE targets, and added `dangling_and_cyclic_forwarders_stay_missing` covering missing target DLLs, missing target symbols/ordinals, mutual cycles, and self-loops.
Marvisak commented 2026-11-25 10:07:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:20:02Z.


Automated triage for the maintainers.

Merge candidate.

apps/victory/src/census.rs: collect parses every image first and indexes the direct exports of scanned DLLs by canonical directory and lowercase file name; tally_image then counts an import that neither HLE nor the host policy covers as title when a same-directory DLL that title_dll allows exports it, replacing the old unreachable!("census maps no title DLLs") arm. As asked in the second look, the forwarder chain is gone: TitleExports::insert_all skips exports with no RVA, so forwarded exports stay missing, and ExportTarget, parse_forwarder, MAX_FORWARD_HOPS and the forwarder tests are removed. The branch is one commit on f3578e3, after #1863, and keeps its scan-loop changes; tests use synthetic PE data written to a temp directory only.

CI: passing (check).

On your reply: checked, the simplification matches what was asked.

Recommending a look, not approving.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158189638 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2039#issuecomment-7158189638). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T09:20:02Z. --- <!-- victory-triage v1 head=f12f2177a772d249b6b738d581431a3678137219 verdict=merge-candidate at=2026-11-26T00:26:02Z --> Automated triage for the maintainers. **Merge candidate.** `apps/victory/src/census.rs`: `collect` parses every image first and indexes the direct exports of scanned DLLs by canonical directory and lowercase file name; `tally_image` then counts an import that neither HLE nor the host policy covers as `title` when a same-directory DLL that `title_dll` allows exports it, replacing the old `unreachable!("census maps no title DLLs")` arm. As asked in the second look, the forwarder chain is gone: `TitleExports::insert_all` skips exports with no RVA, so forwarded exports stay missing, and `ExportTarget`, `parse_forwarder`, `MAX_FORWARD_HOPS` and the forwarder tests are removed. The branch is one commit on `f3578e3`, after #1863, and keeps its scan-loop changes; tests use synthetic PE data written to a temp directory only. CI: passing (`check`). On your reply: checked, the simplification matches what was asked. Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
Marvisak commented 2026-11-25 22:04:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:02:46Z.


Automated triage for the maintainers, second look (a review against main, with the PR built and tested).

The title column is right, and this can be merged once it is simplified and rebased. Please drop the forwarder chain: no title DLL forwards an export, and the chain counts HLE targets that the Windows loader would not use. In apps/victory/src/census.rs TitleExports::insert_all, index only exports with e.rva.is_some(), so that a forwarded export stays missing, and delete ExportTarget, parse_forwarder, MAX_FORWARD_HOPS and resolves_title_export_inner (a plain title_dll(..) check plus an export lookup is enough), the dangling_and_cyclic_forwarders_stay_missing test, the Forward cases of resolves_same_dir_title_dll_exports_by_name_ordinal_and_forward, and ExportSpec::Forward in the PE builder. Then rebase onto main: #1863, merged today, changed the same scan loop.

Push the change and it will be reviewed again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175866004 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2039#issuecomment-7175866004). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:02:46Z. --- Automated triage for the maintainers, second look (a review against `main`, with the PR built and tested). The title column is right, and this can be merged once it is simplified and rebased. Please drop the forwarder chain: no title DLL forwards an export, and the chain counts HLE targets that the Windows loader would not use. In `apps/victory/src/census.rs` `TitleExports::insert_all`, index only exports with `e.rva.is_some()`, so that a forwarded export stays missing, and delete `ExportTarget`, `parse_forwarder`, `MAX_FORWARD_HOPS` and `resolves_title_export_inner` (a plain `title_dll(..)` check plus an export lookup is enough), the `dangling_and_cyclic_forwarders_stay_missing` test, the Forward cases of `resolves_same_dir_title_dll_exports_by_name_ordinal_and_forward`, and `ExportSpec::Forward` in the PE builder. Then rebase onto `main`: #1863, merged today, changed the same scan loop. Push the change and it will be reviewed again. Thank you for the contribution.
fuzeofficlal commented 2026-11-25 23:06:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T22:30:20Z.


Simplified and rebased onto main (f3578e3) in f12f217 per second-look feedback:

  • Dropped forwarder-chain resolution (ExportTarget, parse_forwarder, MAX_FORWARD_HOPS, resolves_title_export_inner).
  • TitleExports::insert_all now indexes only direct exports (e.rva.is_some()), so forwarded exports remain missing, and resolves_title_export is a plain title_dll(&resolver.host, dll_key) check plus set lookup.
  • Removed dangling_and_cyclic_forwarders_stay_missing, the Forward cases in the resolution test, and ExportSpec::Forward from the synthetic PE builder.
  • Re-verified cargo test -p victory census (9/9 passed), cargo clippy -p victory --all-targets -- -D warnings, and cargo xtask policy (190 files ok).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7176444408 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2039#issuecomment-7176444408). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T22:30:20Z. --- Simplified and rebased onto `main` (`f3578e3`) in `f12f217` per second-look feedback: - Dropped forwarder-chain resolution (`ExportTarget`, `parse_forwarder`, `MAX_FORWARD_HOPS`, `resolves_title_export_inner`). - `TitleExports::insert_all` now indexes only direct exports (`e.rva.is_some()`), so forwarded exports remain missing, and `resolves_title_export` is a plain `title_dll(&resolver.host, dll_key)` check plus set lookup. - Removed `dangling_and_cyclic_forwarders_stay_missing`, the `Forward` cases in the resolution test, and `ExportSpec::Forward` from the synthetic PE builder. - Re-verified `cargo test -p victory census` (9/9 passed), `cargo clippy -p victory --all-targets -- -D warnings`, and `cargo xtask policy` (190 files ok).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2039:upstream-pr/2039'
git switch 'upstream-pr/2039'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2039'
git switch 'upstream-pr/2039'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2039'
git switch 'upstream-pr/2039'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2039'
git switch 'main'
git merge --squash 'upstream-pr/2039'
git switch 'main'
git merge --ff-only 'upstream-pr/2039'
git switch 'main'
git merge 'upstream-pr/2039'
git push origin 'main'
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!2037
No description provided.