Struct lief::coff::Binary

pub struct Binary { /* private fields */ }

Implementations§

§

impl Binary

pub fn parse(path: &str) -> Option<Self>

Parse from a file path given as a string

pub fn header(&self) -> Header<'_>

The COFF header

pub fn sections(&self) -> Sections<'_>

Iterator over the different sections located in this COFF binary

pub fn relocations(&self) -> Relocations<'_>

Iterator over all the relocations used by this COFF binary

pub fn symbols(&self) -> Symbols<'_>

Iterator over the COFF’s symbols

pub fn functions(&self) -> Functions<'_>

Iterator over the functions implemented in this COFF

pub fn string_table(&self) -> Strings<'_>

Iterator over the COFF’s strings

pub fn find_string(&self, offset: u32) -> Option<String<'_>>

Try to find the COFF string at the given offset in the COFF string table.

This offset must include the first 4 bytes holding the size of the table. Hence, the first string starts a the offset 4.

pub fn find_function(&self, name: &str) -> Option<Symbol<'_>>

Try to find the function (symbol) with the given name

pub fn find_demangled_function(&self, name: &str) -> Option<Symbol<'_>>

Try to find the function (symbol) with the given demangled name

pub fn disassemble_slice( &self, slice: &[u8], address: u64 ) -> InstructionsIt<'_>

Disassemble code provided by the given slice at the specified address parameter.

See also crate::assembly::Instruction and crate::assembly::Instructions

pub fn disassemble_function(&self, name: &str) -> InstructionsIt<'_>

Disassemble code for the given function name

let insts = binary.disassemble_function("int __cdecl bar(int, int)");
for inst in insts {
    println!("{}", inst.to_string());
}

See also crate::assembly::Instruction and crate::assembly::Instructions

pub fn disassemble_symbol(&self, symbol: &Symbol<'_>) -> InstructionsIt<'_>

Disassemble code for the given symbol

let symbol = binary.find_demangled_function("int __cdecl bar(int, int)").unwrap();
let insts = binary.disassemble_symbol(&symbol);
for inst in insts {
    println!("{}", inst.to_string());
}

See also crate::assembly::Instruction and crate::assembly::Instructions

Trait Implementations§

§

impl Debug for Binary

§

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

Formats the value using the given formatter. Read more
§

impl Display for Binary

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Binary

§

impl !Send for Binary

§

impl !Sync for Binary

§

impl Unpin for Binary

§

impl UnwindSafe for Binary

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.