pe_inspect: resolve legacy VA delay-import thunks and skip ImageBase DLL name (PE-INSPECT-DELAY-VA-THUNKS) #1345
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1345
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1345/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@IlyassRS3 on GitHub · 2026-11-24 22:04 UTC · original
IlyassRS3:fix/pe-inspect-delay-va-thunks→main· +25 −4 · 2 files · 1 commits · merged 2026-11-25 02:35 UTCItem ID:
PE-INSPECT-DELAY-VA-THUNKSAI-assisted: yes
Summary
Fixes two bugs in
tools/pe_inspect.py:_importsfor legacy VA-based delay-import descriptors (dlattrRva == 0):_va_entriesbroke named function resolution indlattrRva == 0delay-import tables:PeImage.import_descriptorscomputesva_entries = Truewhenattributes & 1 == 0(dlattrRvaclear, per the PE/COFF v1ImgDelayDescrformat whereszName,pIAT,pINT, and the named lookup entries inpINTall store virtual addresses), andPeImage.thunk_names(lookup_rva, *, va_entries=False)already supports converting those VAs viavalue -= self.image_base(used bytools/import_call_sites.py:68).tools/pe_inspect.py:_importsunpacked_va_entriesand dropped it, callingimg.thunk_names(lookup)withva_entries=False, so every named delay-import entry in adlattrRva == 0image (includingtests/test_import_call_sites.py's ownbuild_delay_image(attributes=0)fixture) resolved as"?".va_entries=va_entriestoimg.thunk_names(lookup, va_entries=va_entries).szName == ImageBase(dll_rva == 0) read"MZ"from the DOS header:dll = img.string_at(dll_rva) if dll_rva > 0 else Noneso a descriptor pointing atImageBaseis skipped (matchingtools/import_call_sites.py).dlattrRva == 0delay-import lookup slot intests/test_pe_inspect.py:build_image(is64=False)to store a spec-compliant virtual address (base + 0x1440, matching lines 119–120 andtools/pe_inspect.py:149), and addedtest_delay_import_va_descriptor_skips_image_base_dll_and_handles_ordinals.Merge compatibility
#693's_exportsedit) and keeps test additions at lines 124 and 232 (away from#384,#649,#653,#693,#698).Verification
Tested on Apple M5 arm64 (macOS 27.2.1, Python 3.14; CPU-only, no game files):
python3 -I tests/test_pe_inspect.py -v— 61 tests (60 ok, 1 Windows-only skipped)python3 -I tests/test_import_call_sites.py -v— 21/21 OKtools/pe_inspect.pytoupstream/mainfails both VA delay-import tests intests/test_pe_inspect.py(['?'] != ['D3D12SerializeVersionedRootSignature']).python3 -m compileall -q tools/pe_inspect.py tests/test_pe_inspect.py— OKpython3 -I scripts/check_no_game_data.py tools/pe_inspect.py tests/test_pe_inspect.py— OKpython3 -I tests/test_text_write_line_endings.py— 3/3 OK@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-24 22:04 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@whoalin1 on GitHub · 2026-11-24 23:34 UTC · original
Independent verification (Devin, AI-assisted — CPU-only, no GPU).
Checked out head
3a7b8b2detached. Small diff: tools/pe_inspect.py + tests/test_pe_inspect.py.Semantics reviewed:
_importsnow skips dll_rva == 0 instead of calling string_at(0), which previously read the DOS header and produced a bogus "MZ" dll name for legacy VA delay-import descriptors whose szName equals ImageBase. Correct fix; the existingif dll is None: continuestill covers unmapped RVAs.va_entriesflag from import_descriptors is now passed to thunk_names, so VA-based (dlattrRva=0 legacy) lookup tables get ImageBase subtracted before string_at — thunk_names already implemented this; this wires it up. Ordinal entries still take the ordinal_flag path first, unaffected.Ran:
py -3.14 -I tests/test_pe_inspect.py→ 61 tests OK (1 skipped), ~145spytest tests/test_pe_inspect.py→ 60 passed, 1 skipped, 616 subtests passedpy -3.14 -m compileall -q tools tests make_game.py→ cleanVerdict: correct, minimal fix; all tests pass. Base is main.
@QemmHD on GitHub · 2026-11-25 02:35 UTC · original
Merging.
Why merged: pe_inspect resolves delay-import thunks given as VAs as well as RVAs.
Why it's good: Own tests: 60 passed, 1 skipped.
Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main
b4b7756e8. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests, ctest_registration) gives 578 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main3ff2a2adc(after #984): no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.AI-assisted (Claude Code, Claude Opus 5.5).