Skip to main content

Blob

Struct Blob 

Source
pub struct Blob {
    pub load_address: u64,
    pub data: Vec<u8>,
}
Expand description

A generic binary blob: raw bytes loaded at a fixed virtual address.

This is the simplest possible BinaryFormat — it holds an arbitrary byte slice together with its load address and has no symbol information. Tests and other code that already work with raw bytes can use this instead of passing (address, bytes) tuples directly, enabling them to go through the same BinaryFormat-based pipeline as real ELF binaries.

Fields§

§load_address: u64§data: Vec<u8>

Implementations§

Source§

impl Blob

Source

pub fn new(load_address: u64, data: Vec<u8>) -> Self

Source

pub fn from_slice(load_address: u64, bytes: &[u8]) -> Self

Borrow bytes directly without copying.

Trait Implementations§

Source§

impl BinaryFormat for Blob

Source§

fn entry_points(&self) -> Vec<u64>

The only entry point is the load address itself.

Source§

fn mapped_regions(&self) -> Vec<(u64, Vec<u8>, bool, bool)>

A blob is one region; treat it as executable (raw code/data) so resolved jump targets in it are not filtered out.

Source§

fn load_address(&self) -> u64

The lowest virtual address mapped by this binary image.
Source§

fn architecture(&self) -> Arch

Name of the architecture, should use embedded information from known binary format, or raw values from the blob.
Source§

fn byte_at(&self, addr: u64) -> Option<u8>

Return the byte mapped at addr, or None if the address is unmapped.
Source§

fn bytes_at(&self, addr: u64) -> Option<&[u8]>

Return the contiguous bytes available at addr. Read more
Source§

fn segment_bounds(&self, addr: u64) -> Option<(u64, u64)>

The [start, end) bounds of the mapped region containing addr, if any. Used to key per-segment facts (e.g. executability propositions) so repeated queries in one region collapse to a single entry. Defaults to None for formats that do not expose their segments.
Source§

fn entrypoint(&self) -> Option<u64>

The binary’s primary entry point (e.g. the ELF e_entry), if the format designates one. Unlike entry_points, this is the single address where execution begins. Returns None for formats with no distinguished entry.
Source§

fn os(&self) -> TargetOs

The operating system this binary targets, inferred from the container format. Defaults to TargetOs::Unknown; PE returns Windows, ELF Linux.
Source§

fn linked_libraries(&self) -> Vec<String>

Library names this binary links against: ELF DT_NEEDED sonames, PE import-directory DLL names (original case; matching is case-insensitive). Empty when the format has no such notion (Blob).
Source§

fn symbol_name(&self, _addr: u64) -> Option<&str>

Return the symbol name for the function starting at addr, if the binary format has one (e.g. from an ELF symbol table). Returns None for formats with no symbol information.
Source§

fn is_external_symbol(&self, _addr: u64) -> bool

Returns true if addr is an external (imported) function stub, e.g. a PLT thunk. The recursive disassembler will not lift the body of external functions. Defaults to false.
Source§

fn import_library(&self, _addr: u64) -> Option<&str>

Return the name of the library providing the external function stub at addr: the PE import-directory DLL, or the ELF .gnu.version_r soname the symbol’s version requirement points at. None when the format does not record a per-symbol source library (e.g. an unversioned ELF import).
Source§

fn import_symbol_name(&self, _addr: u64) -> Option<&str>

Return the imported symbol whose resolver slot lives at addr, if any. Read more
Source§

fn hex_rows( &self, addr: u64, len: usize, width: usize, ) -> Vec<(u64, Vec<Option<u8>>)>

Return rows of bytes suitable for a hex viewer. Read more
Source§

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

Return true if addr is mapped by this binary image.
Source§

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

Return true if addr lies in an executable region of this binary image. Defaults to “mapped” for formats that don’t track per-region permissions; formats with permission information (e.g. ELF segment flags) should override this.
Source§

fn is_known_writable(&self, _addr: u64) -> bool

Return true only if addr lies in a region known to be writable (from the container’s segment flags). Passes that fold a value out of initialized memory use this to refuse mutable memory — e.g. a GOT slot the dynamic linker overwrites at load time. Defaults to false (“not proven writable”); Blob keeps the default.
Source§

fn is_known_read_only(&self, _addr: u64) -> bool

Return true only if addr lies in a region proven read-only (mapped, and the container’s own permission data says the region is not writable). Read more
Source§

fn read_bytes(&self, addr: u64, n: usize) -> Option<Vec<u8>>

Read n bytes at virtual address addr. Read more
Source§

fn read_uint(&self, addr: u64, size: usize) -> Option<u64>

Read a little-endian unsigned integer of size bytes (1..=8) at addr. Read more
Source§

fn read_cstring(&self, addr: u64, max_len: Option<usize>) -> Option<Vec<u8>>

Read a null-terminated C string at virtual address addr, returning the bytes up to (but not including) the null terminator. Read more
Source§

fn read_printable_cstring( &self, addr: u64, max_len: Option<usize>, ) -> Option<Vec<u8>>

Read a null-terminated C string at virtual address addr, requiring every byte before the null terminator to be printable ASCII. Read more
Source§

impl Clone for Blob

Source§

fn clone(&self) -> Blob

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Blob

§

impl RefUnwindSafe for Blob

§

impl Send for Blob

§

impl Sync for Blob

§

impl Unpin for Blob

§

impl UnsafeUnpin for Blob

§

impl UnwindSafe for Blob

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.