diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-16 19:59:05 +0200 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-05-17 08:58:53 +0200 |
| commit | f3dce0828c95e11af1f7d23ca56be6037b86de3c (patch) | |
| tree | 07c59a8e7cd7ec022580d825fbd0cb8d2dbe8888 | |
| parent | 64706bbd526c22e38b0be34f5d2b5a75766a6c02 (diff) | |
Add `BNIsMemoryMapActivated` API
So that users of the memory map API can know if a view has activated the memory map and adjust behavior accordingly.
| -rw-r--r-- | binaryninjaapi.h | 5 | ||||
| -rw-r--r-- | binaryninjacore.h | 1 | ||||
| -rw-r--r-- | python/binaryview.py | 5 | ||||
| -rw-r--r-- | rust/src/binary_view/memory_map.rs | 5 |
4 files changed, 16 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index c911dc50..95c54095 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -7067,6 +7067,11 @@ namespace BinaryNinja { BNSetLogicalMemoryMapEnabled(m_object, enabled); } + bool IsActivated() + { + return BNIsMemoryMapActivated(m_object); + } + bool AddBinaryMemoryRegion(const std::string& name, uint64_t start, Ref<BinaryView> source, uint32_t flags = 0) { return BNAddBinaryMemoryRegion(m_object, name.c_str(), start, source->GetObject(), flags); diff --git a/binaryninjacore.h b/binaryninjacore.h index 91e366f4..1cd87b37 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -4091,6 +4091,7 @@ extern "C" BINARYNINJACOREAPI char* BNGetBaseMemoryMapDescription(BNBinaryView* view); BINARYNINJACOREAPI char* BNGetMemoryMapDescription(BNBinaryView* view); BINARYNINJACOREAPI void BNSetLogicalMemoryMapEnabled(BNBinaryView* view, bool enabled); + BINARYNINJACOREAPI bool BNIsMemoryMapActivated(BNBinaryView* view); BINARYNINJACOREAPI bool BNAddBinaryMemoryRegion(BNBinaryView* view, const char* name, uint64_t start, BNBinaryView* data, uint32_t flags); BINARYNINJACOREAPI bool BNAddDataMemoryRegion(BNBinaryView* view, const char* name, uint64_t start, BNDataBuffer* data, uint32_t flags); BINARYNINJACOREAPI bool BNAddRemoteMemoryRegion(BNBinaryView* view, const char* name, uint64_t start, BNFileAccessor* accessor, uint32_t flags); diff --git a/python/binaryview.py b/python/binaryview.py index ccd4fba3..00188902 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -2381,6 +2381,11 @@ class MemoryMap: """ core.BNSetLogicalMemoryMapEnabled(self.handle, enabled) + @property + def is_activated(self): + """Whether the memory map is activated for the associated view.""" + return core.BNIsMemoryMapActivated(self.handle) + def add_memory_region(self, name: str, start: int, source: Union['os.PathLike', str, bytes, bytearray, 'BinaryView', 'databuffer.DataBuffer', 'fileaccessor.FileAccessor'], flags: SegmentFlag = 0) -> bool: """ Adds a memory region to the memory map. Depending on the source parameter, the memory region is created as one of the following types: diff --git a/rust/src/binary_view/memory_map.rs b/rust/src/binary_view/memory_map.rs index 34ebd572..cedea26e 100644 --- a/rust/src/binary_view/memory_map.rs +++ b/rust/src/binary_view/memory_map.rs @@ -40,6 +40,11 @@ impl MemoryMap { unsafe { BNSetLogicalMemoryMapEnabled(self.view.handle, enabled) }; } + /// Whether the memory map is activated for the associated view. + pub fn is_activated(&self) -> bool { + unsafe { BNIsMemoryMapActivated(self.view.handle) } + } + pub fn add_binary_memory_region( &mut self, name: &str, |
