pe_map cannot resolve a forwarded export #206
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#206
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@raulmoracode on GitHub · 2026-11-21 18:23 UTC · original
Problem
pe_map_exportreturns null for a forwarded export. The export address table entry points back into the export directory, where the stringModule.Symbollives, and the lookup treats that as "not code here".Windows returns the target module's address from
GetProcAddressin the same situation: it parses the forwarder string, loads the module and looks the symbol up. Forwarded exports are common in system DLLs (kernel32forwards tokernelbase, for example), so a mapped image that only forwards an export is currently unusable through the mapper's own lookup.The Python inventory already follows forwarders (
tools/pe_inventory.py,bundled_export_forwarders). The C++ mapper does not.Proposed change
Add
pe_map_export_resolved(mapped, name, resolve), which behaves likepe_map_exportexcept that a forwarder is resolved through the same host resolver thatpe_map_imagealready takes:Module.Symbol→resolve("Module", "Symbol", 0);Module.#ordinal→resolve("Module", nullptr, ordinal).pe_map_exportkeeps its current contract and still returns null for a forwarder, so existing callers see no change.Verification path
A source-built DLL (
cpu_forwarder) exportslocal_valueand forwardsmix_argstocpu_import_provider.mix_args. The test compares both loaders:GetProcAddresson aLoadLibraryExWcopy;local_valuemust resolve to the same RVA underpe_mapand Windows;pe_map_exportmust still return null for the forwarder.The
Module.#ordinalform is implemented but has no fixture yet.Required environment
x64 Windows, MSVC with MASM, CMake/Ninja, Python 3.11 or newer with
pefile. No game files.AI-assisted.
@R0Y00 on GitHub · 2026-11-21 19:05 UTC · original
The per-call host resolver is approved. #208 carries the implementation; the remaining Windows checks cover ordinal callback arguments, a null resolver and malformed or out-of-directory forwarders. This issue tracks the fix through merge. Contract and review feedback