sections
flavor.psp.format_2025.pe_utils.sections
¶
PE section table utilities.
Provides utilities for updating PE section offsets and header sizes.
Functions¶
update_section_offsets
¶
Update section PointerToRawData values after DOS stub expansion.
When expanding the DOS stub, all content after the DOS stub shifts forward by padding_size bytes. This includes all section data. The section table contains PointerToRawData fields (absolute file offsets) that must be updated to point to the new section locations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytearray
|
PE executable data (modified in-place) |
required |
padding_size
|
int
|
Number of bytes added to DOS stub |
required |
Source code in flavor/psp/format_2025/pe_utils/sections.py
update_size_of_headers
¶
Update SizeOfHeaders field in the Optional Header after DOS stub expansion.
The SizeOfHeaders field specifies the combined size of the DOS stub, PE headers, and section table, rounded to the file alignment. When the DOS stub expands, this field must be updated to match the new total header size.
Windows PE loader validates that sections start at or after SizeOfHeaders. A mismatch causes loader rejection, especially on ARM64 (exit code 126).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytearray
|
PE executable data (modified in-place) |
required |
padding_size
|
int
|
Number of bytes added to DOS stub |
required |