* 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.
3.8 KiB
PE TLS callbacks and load configuration
Use inspect_pe_load_config to locate declared TLS callbacks and inspect the load
configuration of an explicit local PE32 or PE32+ image. No disassembler, Windows
host, or target execution is required.
rea inspect-pe-load-config /absolute/path/to/application.exe --json
rea inspect-pe-load-config /absolute/path/to/application.exe --max-callbacks 256 --json
MCP accepts { "path": "/absolute/path/to/application.exe" }. CLI paths may be
relative to the current directory; MCP paths must be absolute.
The complete Evidence includes the artifact path, SHA-256, directory file ranges,
and callback-array file ranges. tls reports the raw data range, index address,
zero-fill size, characteristics and null-terminated callback array. Callback VAs
are hexadecimal strings to preserve 64-bit precision. RVA, mapped file offset,
and section are derived locations; unknown mappings are null.
TLS template file offsets require file-backed bytes within the declared image;
file-alignment padding outside a section's virtual extent leaves the offset
unknown while retaining the stored address range.
load_config reports fields only when its declared Size covers the entire
field. MSVC x86 images often declare a 64-byte load-config data directory while
the structure's own Size is larger; like the Windows loader, REA reads Size
bytes when they are file-backed in one run, and reports both
directory.size and size. structure_location is the file range of the
Size bytes REA checked; Evidence locations include it beside the declared
directory range when the two differ. Unavailable fields are null; a covered zero pointer remains "0x0".
The report includes the security cookie, PE32 SafeSEH table/count, CFG pointers
and table/count, address-taken IAT and long-jump tables/counts, EH continuation
table/count, and XFG check pointer. CHPE and dynamic relocation pointers are raw
values. The dynamic relocation table offset (DWORD) and section (WORD) are
reported separately when Size covers them, including zero values; REA does
not infer a VA from that pair or decode the target and mitigation-table entries.
Guard flags retain the raw DWORD, recognized names, unknown bits, and the CFG
entry stride. Mitigation claims derived from those flags carry
evidence_kind: "inferred"; they do not prove runtime enforcement. The image is
never executed. Missing directories are observed absence of those declarations,
not proof that no callback or mitigation exists by another mechanism.
The default read budget is 64 MiB (max_file_bytes, ceiling 512 MiB). The default
callback budget is 64 (max_callbacks, ceiling 4096). An exact-budget array is
accepted if its next slot is null. A TLS directory Size below its structure is
read at its RVA, cited as tls.structure_location, and reported in
header_anomalies, and a zero directory RVA is
absent, as the loader treats them; see
PE header admission.
Truncated, ambiguous or unmapped directory and
callback-array storage fails closed, as does budget exhaustion; no partial
success is returned. An unmapped callback target retains its VA/RVA with an
unknown file offset. Load-config versions beyond the supported fields remain
undecoded.
Layout references: Microsoft PE format, IMAGE_LOAD_CONFIG_DIRECTORY32, and IMAGE_LOAD_CONFIG_DIRECTORY64.
For a real cross-compiled fixture, run npm run verify:pe:load-config with Zig
on PATH (or REA_ZIG set to its path). The script builds PE32 and PE32+ samples
and inspects them through the public CLI without running them.