System.Reflection.PortableExecutable Namespace

Provides classes related to reading or writing Portable Executable (PE) files.

Classes

Name Description
CoffHeader

Represents the header of a COFF file.

CorHeader

Represents the Common Language Infrastructure (CLI) header of the .NET executable image.

PEHeader

Represents the Portable Executable (PE) file header.

PEHeaders

Defines a type that reads PE (Portable Executable) and COFF (Common Object File Format) headers from a stream.

PEReader

Provides a reader for Portable Executable format (PE) files.

Structs

Name Description
DirectoryEntry

Represents a directory entry in the Portable Executable (PE) image.

PEMemoryBlock

Represents a block of memory in the Portable Executable (PE) image.

SectionHeader

Provides information about the section header of a PE/COFF file.

Enums

Name Description
Characteristics

Represents the Common Object File Format (COFF) file characteristics.

CorFlags

Represents the runtime flags for a .NET executable image.

DllCharacteristics

Describes the characteristics of a dynamic link library.

Machine

Specifies the target machine's CPU architecture.

PEMagic
PEStreamOptions

Provides options that specify how sections of a PE image are read from a stream.

SectionCharacteristics
Subsystem

Describes the subsystem requirement for the image.

Remarks

Caution

PEReader and the related reading APIs in this namespace are not designed to handle untrusted input. Malformed or malicious PE files can cause unexpected behavior, including out-of-bounds memory access, crashes, or hangs. Only use these APIs with trusted PE files, images, or other trusted inputs.

This namespace contains the following core classes:

  • The ManagedPEBuilder class, which is used to write an assembly as a PE file.
  • The PEReader class, which is used to read a PE file and to obtain a MetadataReader to read associated assembly metadata.

See also