pe: check live page protection in pe_map_export #166
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/167"
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 R0Y00/Xbox2Windows. Originally posted by raulmoracode on 2026-11-21T17:51:02Z.
Change
pe_map_exportread the export directory, the address table, the name table and the ordinal table after a bounds check againstSizeOfImageonly. A mapped section can lack read access, by its characteristics or after a run-time reprotect, so the lookup could dereference an unreadable page.This applies the live protection check that
readable()already performs for the TLS directory and callback list:docs/experiments.mdno longer records the check as missing.Fixes #163
Verification
Commit
e5b2605on Windows 10 22H2 build 19045.6466, VS Build Tools 2022 17.14, MSVC 14.44.35207, Windows SDK 10.0.26100, CMake 4.4.4, Python 3.12.10.Result:
The full CPU group also passes:
ctest --preset dev --no-tests=error -R '^cpu_'reported 16/16, includingcpu_native_seh,cpu_native_sectionandcpu_native_tls.Negative control: with
tools/pe_map.cppreverted to the parent commit andpe_maprebuilt, the same test fails:Evidence and follow-up
The new check is
check_unreadable_exportintests/cpu/native_map_check.py. It uses the source-builtcpu_register_probe.dll, finds the section that contains the export directory, and rewrites that section'sCharacteristicson a temporary copy: once withoutIMAGE_SCN_MEM_READ, and once withIMAGE_SCN_MEM_EXECUTEonly. Both copies must resolve no export. The unmodified image is still covered bycheck_empty_export_slot, so the control that a valid export resolves is unchanged.pe_map_releaseaccepting a pointer thatpe_map_imagedid not return is a separate question, opened as #164 so it does not widen this change.Checklist
AI-assisted.