Struct goblin::pe::header::CoffHeader

source ·
#[repr(C)]
pub struct CoffHeader { pub machine: u16, pub number_of_sections: u16, pub time_date_stamp: u32, pub pointer_to_symbol_table: u32, pub number_of_symbol_table: u32, pub size_of_optional_header: u16, pub characteristics: u16, }
Expand description

In winnt.h, it’s IMAGE_FILE_HEADER. COFF Header.

Together with the Header::signature and the Header::optional_header, it forms the IMAGE_NT_HEADERS.

§Position in a modern PE file

The COFF header is located after the Header::signature, which in turn is located after the non-standard “Rich header”, if present, and after the DosStub, according to the standard.

COFF header is followed by the Header::optional_header.

Fields§

§machine: u16§number_of_sections: u16

The number of sections. This indicates the size of the section table, which immediately follows the headers. Note that the Windows loader limits the number of sections to 96. Source.

§time_date_stamp: u32

The low 32 bits of the time stamp of the image. This represents the date and time the image was created by the linker. The value is represented in the number of seconds elapsed since midnight (00:00:00), January 1, 1970, Universal Coordinated Time, according to the system clock.

§pointer_to_symbol_table: u32

The offset of the symbol table, in bytes, or zero if no COFF symbol table exists.

Typically, this field is set to 0 because COFF debugging information is deprecated. Source.

§number_of_symbol_table: u32

The number of symbols in the symbol table.

Typically, this field is set to 0 because COFF debugging information is deprecated. Source.

§size_of_optional_header: u16

The size of the optional header, in bytes. This value should be zero for object files.

The goblin::pe::optional_header::OptionalHeader is meant to represent either the 32-bit or the 64-bit optional header. The size of the optional header is used to determine which one it is.

§characteristics: u16

The characteristics of the image.

The constants for the characteristics are available in the goblin::pe::characteristic module.

Implementations§

source§

impl CoffHeader

source

pub fn parse(bytes: &[u8], offset: &mut usize) -> Result<Self>

source

pub fn sections( &self, bytes: &[u8], offset: &mut usize ) -> Result<Vec<SectionTable>>

Parse the COFF section headers.

For COFF, these immediately follow the COFF header. For PE, these immediately follow the optional header.

source

pub fn symbols<'a>(&self, bytes: &'a [u8]) -> Result<Option<SymbolTable<'a>>>

Return the COFF symbol table.

source

pub fn strings<'a>(&self, bytes: &'a [u8]) -> Result<Option<Strtab<'a>>>

Return the COFF string table.

Trait Implementations§

source§

impl Clone for CoffHeader

source§

fn clone(&self) -> CoffHeader

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CoffHeader

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CoffHeader

source§

fn default() -> CoffHeader

Returns the “default value” for a type. Read more
source§

impl FromCtx<Endian> for CoffHeader

source§

fn from_ctx(src: &[u8], ctx: Endian) -> Self

source§

impl<'a> IntoCtx<Endian> for &'a CoffHeader

source§

fn into_ctx(self, dst: &mut [u8], ctx: Endian)

source§

impl IntoCtx<Endian> for CoffHeader

source§

fn into_ctx(self, dst: &mut [u8], ctx: Endian)

source§

impl PartialEq for CoffHeader

source§

fn eq(&self, other: &CoffHeader) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SizeWith<Endian> for CoffHeader

source§

impl<'a> TryFromCtx<'a, Endian> for CoffHeader
where CoffHeader: 'a,

§

type Error = Error

source§

fn try_from_ctx( src: &'a [u8], ctx: Endian ) -> Result<(Self, usize), Self::Error>

source§

impl<'a> TryIntoCtx<Endian> for &'a CoffHeader

§

type Error = Error

source§

fn try_into_ctx(self, dst: &mut [u8], ctx: Endian) -> Result<usize, Self::Error>

source§

impl TryIntoCtx<Endian> for CoffHeader

§

type Error = Error

source§

fn try_into_ctx(self, dst: &mut [u8], ctx: Endian) -> Result<usize, Self::Error>

source§

impl Copy for CoffHeader

source§

impl StructuralPartialEq for CoffHeader

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.