mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 06:25:44 +00:00
`createPefileReadCompatibility` models pefile's section reads so an import hash is published only when both readers see the same bytes. Its layout gate rejected any section whose `PointerToRawData` was not 512-aligned — but pefile 2024.8.26's `get_PointerToRawData_adj()` skips that rounding when `SectionAlignment < 0x1000` and `PointerToRawData == VirtualAddress`, the `LdrpWx86FormatVirtualImage` layout ntoskrnl-era drivers use. The gate already modelled the sub-page case two lines above (`SectionAlignment < 0x1000 ? FileAlignment : SectionAlignment`), then rejected it against an absolute 512 rule — and `docs/pe-imports.md` scopes the withhold to an incomplete table or a different row sequence, not to a file offset. Measured on a minimal image with `SectionAlignment = FileAlignment = 0x80` and `.idata` at RVA 0x300 == file offset 0x300: | | before | after | | --- | --- | --- | | coverage | `complete` | `complete` | | issues | `[]` | `[]` | | `imphash.md5` | `null` | `92cef6cc91a85825f3c8a0516517c66f` | The withheld hash is the only thing that differed: both readers were already reading the same bytes. The exception is exact rather than approximate — a section with the same sub-page alignment whose `PointerToRawData` differs from its `VirtualAddress` still withholds, because pefile does round it there. That case is the second new test. pefile's current `master` broadened the condition to every sub-page image; this matches the 2024.8.26 revision the module documents, which is the narrower and safer rule. `tests/fixtures/binaryDiagnostics/peImports.ts` takes an optional `layout`, so the shared builder produces the geometry instead of a test hand-encoding a second image. Its default is unchanged — `SectionAlignment`/`FileAlignment` are written only when supplied, so every existing fixture keeps its exact bytes. `src/native/pe` — 265 passing. Restoring the absolute 512 rule fails the sub-page case.