lief::runtime::module

Trait Module

pub trait Module {
    // Provided methods
    fn name(&self) -> String { ... }
    fn path(&self) -> String { ... }
    fn imagebase(&self) -> u64 { ... }
    fn size(&self) -> u64 { ... }
    fn end(&self) -> u64 { ... }
    fn contains(&self, addr: u64) -> bool { ... }
    fn dump(&self) -> Vec<u8> { ... }
    fn dump_to_file<P: AsRef<Path>>(&self, path: P) -> Vec<u8> { ... }
}
Expand description

This trait is shared by all system-specific modules. It provides a common interface for accessing module metadata.

Provided Methods§

fn name(&self) -> String

Name of the module (e.g. libc.so.6, kernel32.dll, libsystem_c.dylib)

fn path(&self) -> String

Absolute path to the module file

fn imagebase(&self) -> u64

Base address where the module is loaded in memory

fn size(&self) -> u64

Virtual size of the current module

fn end(&self) -> u64

End address of the module

fn contains(&self, addr: u64) -> bool

Check if the current module contains the given address

fn dump(&self) -> Vec<u8>

Return the content of the module as it is currently mapped in memory.

The returned buffer spans Module::imagebase over Module::size bytes. An empty buffer is returned if the imagebase or the size is null.

fn dump_to_file<P: AsRef<Path>>(&self, path: P) -> Vec<u8>

Same as Module::dump but also write the content into the file located at path.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl Module for Modules

§

impl Module for lief::runtime::android::Module

§

impl Module for lief::runtime::linux::Module

§

impl Module for lief::runtime::osx::Module

§

impl Module for lief::runtime::windows::Module