From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Format:PE (Portable Executable)" |
|---|
| claim | "pefile models the Windows loader as using a section's PointerToRawData rounded down to a multiple of 0x200 (val & ~0x1FF); in pefile this is applied whatever FileAlignment is (the FileAlignment >= 0x200 test there only decides whether to warn that a non-power-of-two alignment is invalid). Parsers that use the raw value read wrong bytes in files crafted to rely on this. When SectionAlignment is below 0x1000 the specification requires FileAlignment to equal it; pefile only warns if it differs, and then rounds section virtual addresses down to FileAlignment instead of SectionAlignment." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:PE (Portable Executable)" |
|---|
| observed_in | |
|---|
|
|---|
| data | | effect | "effective raw offset = PointerToRawData & ~0x1FF (pefile applies it unconditionally)" |
|---|
| condition | "none in pefile; the specification only calls FileAlignment values below 0x200 invalid" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "adjust_PointerToRawData returns val & ~0x1FF; adjust_SectionAlignment/cache_adjust_SectionAlignment use FileAlignment when SectionAlignment < 0x1000" |
|---|
| repo | "https://github.com/erocarrera/pefile" |
|---|
| commit | "58186a92164842cf758822e067bc79c59b3c80d9" |
|---|
| path | "pefile.py" |
|---|
| lines | "7915-7955, 58-71" |
|---|
|
| type | "documentation" |
|---|
| detail | "Microsoft PE Format, FileAlignment: 'If the SectionAlignment is less than the architecture's page size, then FileAlignment must match SectionAlignment.' The rounding itself is pefile's model of the loader, not verified by loading a file here" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "PointerToRawData rounding" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T10:17:25.306Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T06:59:26.613Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read pefile.py at 58186a9 lines 55-71 (cache_adjust_SectionAlignment) and 7915-7955: adjust_PointerToRawData returns val & ~0x1FF after only a power-of-two warning gated by FileAlignment >= MIN_VALID_FILE_ALIGNMENT (0x200); SectionAlignment <0x1000 only warns and uses file_alignment for rounding. Matches the corrected text." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T04:48:46.476Z" |
|---|
| summary | "pefile rounds unconditionally (val & ~0x1FF); the FileAlignment >= 0x200 test only gates a power-of-two warning. Read adjust_PointerToRawData and adjust_SectionAlignment fully." |
|---|
| changed | |
|---|
|
|
|---|