Skip to content

Commit f3dce08

Browse files
committed
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.
1 parent 64706bb commit f3dce08

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

binaryninjaapi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7067,6 +7067,11 @@ namespace BinaryNinja {
70677067
BNSetLogicalMemoryMapEnabled(m_object, enabled);
70687068
}
70697069

7070+
bool IsActivated()
7071+
{
7072+
return BNIsMemoryMapActivated(m_object);
7073+
}
7074+
70707075
bool AddBinaryMemoryRegion(const std::string& name, uint64_t start, Ref<BinaryView> source, uint32_t flags = 0)
70717076
{
70727077
return BNAddBinaryMemoryRegion(m_object, name.c_str(), start, source->GetObject(), flags);

binaryninjacore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4091,6 +4091,7 @@ extern "C"
40914091
BINARYNINJACOREAPI char* BNGetBaseMemoryMapDescription(BNBinaryView* view);
40924092
BINARYNINJACOREAPI char* BNGetMemoryMapDescription(BNBinaryView* view);
40934093
BINARYNINJACOREAPI void BNSetLogicalMemoryMapEnabled(BNBinaryView* view, bool enabled);
4094+
BINARYNINJACOREAPI bool BNIsMemoryMapActivated(BNBinaryView* view);
40944095
BINARYNINJACOREAPI bool BNAddBinaryMemoryRegion(BNBinaryView* view, const char* name, uint64_t start, BNBinaryView* data, uint32_t flags);
40954096
BINARYNINJACOREAPI bool BNAddDataMemoryRegion(BNBinaryView* view, const char* name, uint64_t start, BNDataBuffer* data, uint32_t flags);
40964097
BINARYNINJACOREAPI bool BNAddRemoteMemoryRegion(BNBinaryView* view, const char* name, uint64_t start, BNFileAccessor* accessor, uint32_t flags);

python/binaryview.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,6 +2381,11 @@ def set_logical_memory_map_enabled(self, enabled: bool) -> None:
23812381
"""
23822382
core.BNSetLogicalMemoryMapEnabled(self.handle, enabled)
23832383

2384+
@property
2385+
def is_activated(self):
2386+
"""Whether the memory map is activated for the associated view."""
2387+
return core.BNIsMemoryMapActivated(self.handle)
2388+
23842389
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:
23852390
"""
23862391
Adds a memory region to the memory map. Depending on the source parameter, the memory region is created as one of the following types:

rust/src/binary_view/memory_map.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ impl MemoryMap {
4040
unsafe { BNSetLogicalMemoryMapEnabled(self.view.handle, enabled) };
4141
}
4242

43+
/// Whether the memory map is activated for the associated view.
44+
pub fn is_activated(&self) -> bool {
45+
unsafe { BNIsMemoryMapActivated(self.view.handle) }
46+
}
47+
4348
pub fn add_binary_memory_region(
4449
&mut self,
4550
name: &str,

0 commit comments

Comments
 (0)