Files
morluto f585acc748 fix(pe)!: share one loader-equivalent PE header owner across static readers (#14253)
* fix(pe)!: share one loader-equivalent PE header owner across static readers

Resources and certificates now admit headers through readPeImage, and
resources map RVAs through the shared file-backed mapping. The owner reads
the optional header at fixed offsets, caps data directories at 16, and lets
a PE signature at e_lfanew override a DOS relocation table. Export, import,
TLS and resource directories are read at their RVA whatever Size declares.
Disregarded declarations are reported in header_anomalies.

BREAKING CHANGE: import and delay-import walks continue to the null
descriptor past a short directory Size instead of stopping with a
malformed_entry issue, and inspect-pe-resources reports an unsupported
optional-header magic as unsupported_target.

* fix(pe): keep valid DOS relocation tables owning e_lfanew

Only a relocation table that describes no DOS load module yields e_lfanew
to a PE signature; update MZ/PE conformance to the shared owner.

* fix(pe): walk resource trees within file-backed bytes and cite TLS reads

The resource walk is bounded by the file-backed run from the directory RVA
rather than its Size, and a Size that ends before the bytes walked is a
directory_size_below_structure anomaly. The TLS result carries
structure_location for the structure read past a short Size, and Evidence
cites it.

* test(pe): use a resource cycle as damage now that a short Size is read

* fix(pe): read resource trees past an oversized Size and keep damaged MZ headers malformed

An oversized resource Size is reported without requiring its unused bytes
to map. A Windows-header candidate is malformed when the DOS module is also
invalid, and the guide states that a valid DOS relocation table owns
e_lfanew.
2026-11-23 23:27:22 -05:00
..