Trait lief::generic::Binary

pub trait Binary {
    // Provided methods
    fn entrypoint(&self) -> u64 { ... }
    fn imagebase(&self) -> u64 { ... }
    fn is_pie(&self) -> bool { ... }
    fn has_nx(&self) -> bool { ... }
    fn original_size(&self) -> u64 { ... }
    fn debug_info(&self) -> Option<DebugInfo<'_>> { ... }
    fn disassemble(&self, address: u64, size: u64) -> InstructionsIt<'_>  { ... }
    fn disassemble_symbol(&self, name: &str) -> InstructionsIt<'_>  { ... }
    fn disassemble_address(&self, address: u64) -> InstructionsIt<'_>  { ... }
    fn disassemble_slice(
        &self,
        slice: &[u8],
        address: u64
    ) -> InstructionsIt<'_>  { ... }
}

Provided Methods§

fn entrypoint(&self) -> u64

Binary’s entrypoint

fn imagebase(&self) -> u64

Default base address where the binary should be mapped

fn is_pie(&self) -> bool

Whether the current binary is an executable and position independent

fn has_nx(&self) -> bool

Whether the binary defines a non-executable stack

fn original_size(&self) -> u64

Original file size of the binary

fn debug_info(&self) -> Option<DebugInfo<'_>>

Return the debug info if present. It can be either a crate::pdb::DebugInfo or crate::dwarf::DebugInfo.

For ELF and Mach-O binaries, it returns the given DebugInfo object only if the binary embeds the DWARF debug info in the binary itself.

For PE file, this function tries to find the external PDB using the crate::pe::debug::CodeViewPDB::filename output (if present). One can also use crate::pdb::load or crate::pdb::DebugInfo::from to get PDB debug info.

This function requires LIEF's extended version otherwise it always return `None`

fn disassemble(&self, address: u64, size: u64) -> InstructionsIt<'_>

Disassemble code starting a the given virtual address and with the given size.

let insts = binary.disassemble(0xacde, 100);
for inst in insts {
    println!("{}", inst.to_string());
}

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

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

Disassemble code for the given symbol name

let insts = binary.disassemble_symbol("__libc_start_main");
for inst in insts {
    println!("{}", inst.to_string());
}

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

fn disassemble_address(&self, address: u64) -> InstructionsIt<'_>

Disassemble code at the given virtual address

let insts = binary.disassemble_address(0xacde);
for inst in insts {
    println!("{}", inst.to_string());
}

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

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

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

let insts = binary.disassemble_address(0xacde);
for inst in insts {
    println!("{}", inst.to_string());
}

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

Implementors§

§

impl Binary for lief::elf::Binary

§

impl Binary for lief::macho::Binary

§

impl Binary for lief::pe::Binary