Struct lief::pe::factory::Factory

pub struct Factory { /* private fields */ }
Expand description

Factory for creating PE binaries from scratch

use lief::pe;

if let Some(mut factory) = pe::Factory::create(pe::PE_TYPE::PE32_PLUS) {
    let section = pe::Section::new_with_name(".text");
    factory.add_section(&section);
    factory.set_entrypoint(0x1000);
    if let Some(binary) = factory.get() {
        // use binary
    }
}

Implementations§

§

impl Factory

pub fn create(pe_type: PE_TYPE) -> Option<Factory>

Create a new factory for the given PE type (PE32 or PE32+)

pub fn add_section(&mut self, section: &Section<'_>)

Add a section to the PE being built

pub fn set_arch(&mut self, arch: MachineType)

Set the target architecture

pub fn set_entrypoint(&mut self, ep: u64)

Set the entry point address

pub fn get(&mut self) -> Option<Binary>

Build and return the PE binary

pub fn is_32bit(&self) -> bool

Whether the factory is creating a 32-bit PE

pub fn is_64bit(&self) -> bool

Whether the factory is creating a 64-bit PE

pub fn section_align(&self) -> u32

Return the section alignment

pub fn file_align(&self) -> u32

Return the file alignment

Trait Implementations§

§

impl Debug for Factory

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, 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.