Skip to content

Pe (Program) dataclass

PE file

get_sections(self) async

Return the children PeSections.

Source code in ofrak/core/pe/
async def get_sections(self) -> Iterable[PeSection]:
    """Return the children ``PeSection``s."""
    return await self.resource.get_children_as_view(

get_optional_header(self) async

Return the optional header of the PE file, or None if there isn't one.

Source code in ofrak/core/pe/
async def get_optional_header(self) -> Optional[PeOptionalHeader]:
    """Return the optional header of the PE file, or None if there isn't one."""
        return await self.resource.get_only_child_as_view(
    except NotFoundError:
        return None

Pe32OptionalHeader (PeWinOptionalHeader) dataclass

32 bit PE optional header with the base_of_data field.

Pe64POptionalHeader (PeWinOptionalHeader) dataclass

64 bit PE optional header without the base_of_data field.

PeDataDirectory (ResourceView) dataclass

PE data directory (image only)

PeFileHeader (ResourceView) dataclass

PE file header, a.k.a. COFF file header

PeMsDosHeader (ResourceView) dataclass

PE MS-DOS header

PeOptionalHeader (ResourceView) dataclass

Base of PE optional header. Includes NT-specific attributes. This header class is valid for 64 Bit non-Windows PE files, however our pe_file package populates the additional Windows fields so this is for all intents and purposes an abstract class. More Info:

Required for image files; object files don't have it.

PeOptionalHeaderMagic (Enum)

Magic values for the PE optional header

PeSection (PeSectionStructure, NamedProgramSection) dataclass

PE section

PeSectionFlag (Enum)

Flags making up PeSectionHeader.m_characteristics.

Refer to for documentation.

PeSectionHeader (PeSectionStructure) dataclass

PE section header

name: str property readonly

The section name as a string, e.g. ".text" for b".text".

get_body(self) async

Get the PeSection associated with this section header.

Source code in ofrak/core/pe/
async def get_body(self) -> PeSection:
    """Get the PeSection associated with this section header."""
    return await self.resource.get_only_sibling_as_view(
                    PeSectionStructure.SectionIndex, self.section_index

PeSectionStructure (ResourceView) dataclass

Superclass for both the section headers and the sections themselves, linking them via the section index.

PeWinOptionalHeader (PeOptionalHeader) dataclass

PE Optional Header with all fields for Windows. These fields are not necessary, yet will be parsed by the pefile package regardless.