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

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

@⁠fuzeofficlal on GitHub · 2026-11-25 03:52 UTC · original
fuzeofficlal:fix/cli-census-title-dll-exports-838 → main · +601 −41 · 1 files · 1 commits · open

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
**@⁠fuzeofficlal** on GitHub · 2026-11-25 03:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2039) `fuzeofficlal:fix/cli-census-title-dll-exports-838` → `main` · +601 −41 · 1 files · 1 commits · open ## 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`
Scan PE inputs once, index direct exports (rva.is_some()) of title DLLs
by directory and lowercase name, and classify imports served by a
same-directory title DLL as title instead of missing while keeping host-
and HLE-served DLLs out of title resolution.

Closes #838
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:52:32 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:08 UTC · original

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.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2039#issuecomment-7152558842) **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.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 04:44 UTC · original

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 04:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2039#issuecomment-7153119049) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 09:20 UTC · original · edited 2026-11-26 00:26 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 09:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2039#issuecomment-7158189638) · edited 2026-11-26 00:26 UTC <!-- 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)_
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:02 UTC · original

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.

**@⁠Marvisak** on GitHub · 2026-11-25 22:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2039#issuecomment-7175866004) 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.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 22:30 UTC · original

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).
**@⁠fuzeofficlal** on GitHub · 2026-11-25 22:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2039#issuecomment-7176444408) 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 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/2039/head:github-bot/gh-2039'
git switch 'github-bot/gh-2039'

Merge

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