binaryninja::binary_view::memory_map

Struct MemoryMap

source
pub struct MemoryMap { /* private fields */ }
Expand description

MemoryMap provides access to the system-level memory map describing how a BinaryView is loaded into memory.

§Architecture Note

This Rust MemoryMap struct is a proxy that accesses the BinaryView’s current MemoryMap state through the FFI boundary. The proxy provides a simple mutable interface: when you call modification operations (add_memory_region, remove_memory_region, etc.), the proxy automatically accesses the updated MemoryMap. Internally, the core uses immutable copy-on-write data structures, but the proxy abstracts this away.

When you access a BinaryView’s MemoryMap, you always see the current state. For lock-free access during analysis, AnalysisContext provides memory layout query methods (is_valid_offset, is_offset_readable, get_start, get_length, etc.) that operate on an immutable snapshot of the MemoryMap cached when the analysis was initiated.

A MemoryMap can contain multiple, arbitrarily overlapping memory regions. When modified, address space segmentation is automatically managed. If multiple regions overlap, the most recently added region takes precedence by default.

Implementations§

source§

impl MemoryMap

source

pub fn new(view: Ref<BinaryView>) -> Self

source

pub fn base_description(&self) -> String

JSON string representation of the base MemoryMap, consisting of unresolved auto and user segments.

source

pub fn description(&self) -> String

JSON string representation of the MemoryMap.

source

pub fn set_logical_enabled(&mut self, enabled: bool)

source

pub fn is_activated(&self) -> bool

Whether the memory map is activated for the associated view.

Returns true if this MemoryMap represents a parsed BinaryView with real segments (ELF, PE, Mach-O, etc.). Returns false for Raw BinaryViews or views that failed to parse segments.

This is determined by whether the BinaryView has a parent view - parsed views have a parent Raw view, while Raw views have no parent.

Use this to gate features that require parsed binary structure (sections, imports, relocations, etc.). For basic analysis queries (start, length, is_offset_readable, etc.), use the MemoryMap directly regardless of activation state - all BinaryViews have a usable MemoryMap.

source

pub fn add_binary_memory_region( &mut self, name: &str, start: u64, view: &BinaryView, segment_flags: Option<SegmentFlags>, ) -> bool

source

pub fn add_data_memory_region( &mut self, name: &str, start: u64, data: &DataBuffer, segment_flags: Option<SegmentFlags>, ) -> bool

Adds the memory region using a DataBuffer.

This will add the contents of the DataBuffer to the database.

source

pub fn add_remote_memory_region<A: Accessor>( &mut self, name: &str, start: u64, accessor: &mut FileAccessor<A>, segment_flags: Option<SegmentFlags>, ) -> bool

Adds the memory region using a FileAccessor.

This does not add the region contents to the database, instead accesses to the contents are done “remotely” to a FileAccessor.

NOTE: The FileAccessor MUST live as long as the region is available, currently there is no gurentee by the type checker that the file accessor is tied to that of the memory region.

source

pub fn add_unbacked_memory_region( &mut self, name: &str, start: u64, length: u64, segment_flags: Option<SegmentFlags>, fill: Option<u8>, ) -> bool

Adds an unbacked memory region with a given length and fill byte.

source

pub fn remove_memory_region(&mut self, name: &str) -> bool

source

pub fn active_memory_region_at(&self, addr: u64) -> String

source

pub fn memory_region_flags(&self, name: &str) -> SegmentFlags

source

pub fn set_memory_region_flags( &mut self, name: &str, flags: SegmentFlags, ) -> bool

source

pub fn is_memory_region_enabled(&self, name: &str) -> bool

source

pub fn set_memory_region_enabled(&mut self, name: &str, enabled: bool) -> bool

source

pub fn is_memory_region_rebaseable(&self, name: &str) -> bool

source

pub fn set_memory_region_rebaseable( &mut self, name: &str, enabled: bool, ) -> bool

source

pub fn memory_region_fill(&self, name: &str) -> u8

source

pub fn set_memory_region_fill(&mut self, name: &str, fill: u8) -> bool

source

pub fn reset(&mut self)

Trait Implementations§

source§

impl Hash for MemoryMap

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for MemoryMap

source§

fn eq(&self, other: &MemoryMap) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for MemoryMap

source§

impl StructuralPartialEq for MemoryMap

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

source§

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