Files
reverse-engineering-anything/src/domain/peCoffHeader.ts
T
Matt Van Hornandgensokyo-dev 637e4cb60c feat(native): inspect DWARF compile units offline
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>
2026-11-17 10:04:46 +00:00

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),
});
};