Keep import names that pefile rejects in the PE inventory #81
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!81
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/81/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?
@Vonsek on GitHub · 2026-11-21 15:41 UTC · original
Vonsek:pe-inventory-imports→main· +80 −16 · 3 files · 2 commits · merged 2026-11-21 16:42 UTCChange
pefile 2024.8.26 skips import lookup entries whose names contain characters outside letters, digits and
._?@$()<>, skips ordinal 0, and drops any descriptor those skips leave empty, without a parse warning.pe_inventorytherefore lost such edges silently: a provider could appear unlinked independency_paths, and an image whose only delay descriptor was affected failed with "Could not parse delay imports". pefile also substitutes names from its built-in table for some ordinal imports (ws2_32,oleaut32,wsock32), so those edges andby_ordinaldid not reflect the image.pe_inventorynow reads normal and delay import descriptors and lookup tables itself, with the same descriptor rules aspe_map.cpp(stop at Name 0, OriginalFirstThunk or else FirstThunk; delay descriptors as RVAs, or as virtual addresses when attributes bit 0 is clear). It reports every entry as stored (#Nfor ordinals) and raisesValueErrorfor data outside the file's sections or an unterminated name. pefile still parses exports.Behavior change: ordinal imports from
ws2_32/oleaut32/wsock32now appear as#N, which shows up as changed edges against an older baseline. Desktop resolution is unaffected because System32 export tables are keyed by#ordinalas well.Verification
Windows result at
5f912f5on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100, Python 3.12, RTX 5080 (driver 32.0.16.1692): both tests passed (conditional_import_paths0.13 s,static_exe_intake2.98 s). The Windows CI job also passed: https://github.com/R0Y00/Xbox2Windows/actions/runs/44920493329.Pre-Windows evidence: on Linux, with lld-link builds of the intake fixtures from the repository's
.deffiles and a stub for the Windows host queries,tests/intake/check.pypasses with this change and exits with "Could not parse delay imports" without it.parse_imageoutput is unchanged on 27 third-party PE32/PE32+ images (4,900 edges).conditional_import_pathspasses.Evidence and follow-up
static_exe_intakepatches the source-built candidate (as the existingbad-tlscase does), renamingnamed_valueanddelayed_valueto same-lengthnamed-value/delayed-value, and checks that both edges reach the inventory andentry_import_gaps, and thatdependency_pathsreportsbundled_export_missingagainstintake_provider.dll. No new binary fixtures.Follow-ups not in this PR:
call_evidence.py,cpu_call_aot.pyandcpu_chained_aot.pystill take imports from pefile; pefile's export parsing has a similar (warned) name filter.@R0Y00 on GitHub · 2026-11-21 15:46 UTC · original
Thanks for the inventory work. When the draft is ready, please request review. I'll focus on descriptor and file bounds for normal and delay imports.