pe_inspect: resolve legacy VA delay-import thunks and skip ImageBase DLL name (PE-INSPECT-DELAY-VA-THUNKS) #1345
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1345"
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?
Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-24T22:04:09Z.
Item 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 OKImported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-24T22:04:18Z.
Review: COMMENTED
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.
Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-24T23:34:13Z.
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.
Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-25T02:35:48Z.
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).