mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 05:02:40 +00:00
Add bounded offline DWARF compilation-unit inspection with source provenance, explicit coverage, caller-selected controls and shared ELF compression framing. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning) Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
21 lines
647 B
TypeScript
21 lines
647 B
TypeScript
import { BinaryReader } from "./binaryContainer.js";
|
|
import { err, ok } from "./result.js";
|
|
|
|
/** Fixed 20-byte COFF record, excluding the PE signature; callers own admission. */
|
|
export const readPeCoffHeader = (bytes: Buffer) => {
|
|
if (bytes.length < 20)
|
|
return err({
|
|
kind: "malformed" as const,
|
|
message: "PE COFF header is truncated",
|
|
});
|
|
const record = new BinaryReader(bytes, true, "pe");
|
|
return ok({
|
|
machine: record.u16(0),
|
|
sectionCount: record.u16(2),
|
|
symbolTableOffset: record.u32(8),
|
|
symbolCount: record.u32(12),
|
|
optionalHeaderSize: record.u16(16),
|
|
characteristics: record.u16(18),
|
|
});
|
|
};
|