Skip to content

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

Open
fuzeofficlal wants to merge 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/cli-census-title-dll-exports-838
Open

fuzeofficlal wants to merge 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/cli-census-title-dll-exports-838

Conversation

@fuzeofficlal

Copy link
Copy Markdown
Contributor

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

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.

@fuzeofficlal

Copy link
Copy Markdown
Contributor Author

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
fuzeofficlal force-pushed the fix/cli-census-title-dll-exports-838 branch from 0c8615f to 6f8735f Compare November 25, 2026 04:44

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

Copy link
Copy Markdown
Owner

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
fuzeofficlal force-pushed the fix/cli-census-title-dll-exports-838 branch from 6f8735f to 224e876 Compare November 25, 2026 22:07
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 Marvisak#838
@fuzeofficlal

Copy link
Copy Markdown
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contribution access: PR creation rejected (follow-up to #811 ready: census counts title-DLL imports as missing)

5 participants