diff options
| author | Brian Potchik <brian@vector35.com> | 2024-11-27 12:48:19 -0500 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2024-11-27 12:48:19 -0500 |
| commit | 98ba687dfcc26bef50728cbcf04d6224513ac008 (patch) | |
| tree | 876bf55be418e160fcc01b7aa1786807a122cc43 | |
| parent | 34bd2341f9fb8d5e8bc57639cb0ec547c3b8596b (diff) | |
Add support for a logical memory map representation.
| -rw-r--r-- | binaryninjaapi.h | 5 | ||||
| -rw-r--r-- | binaryninjacore.h | 3 | ||||
| -rw-r--r-- | python/binaryview.py | 20 |
3 files changed, 27 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 50e2838c..4d759a17 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -6914,6 +6914,11 @@ namespace BinaryNinja { MemoryMap(BNBinaryView* view): m_object(view) {} ~MemoryMap() = default; + void SetLogicalMemoryMapEnabled(bool enabled) + { + BNSetLogicalMemoryMapEnabled(m_object, enabled); + } + 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 bb60b931..da068fbe 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -37,7 +37,7 @@ // Current ABI version for linking to the core. This is incremented any time // there are changes to the API that affect linking, including new functions, // new types, or modifications to existing functions or types. -#define BN_CURRENT_CORE_ABI_VERSION 84 +#define BN_CURRENT_CORE_ABI_VERSION 85 // Minimum ABI version that is supported for loading of plugins. Plugins that // are linked to an ABI version less than this will not be able to load and @@ -4006,6 +4006,7 @@ extern "C" // Memory Map BINARYNINJACOREAPI char* BNGetBaseMemoryMapDescription(BNBinaryView* view); BINARYNINJACOREAPI char* BNGetMemoryMapDescription(BNBinaryView* view); + BINARYNINJACOREAPI void BNSetLogicalMemoryMapEnabled(BNBinaryView* view, bool enabled); 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 88cedf41..44e2efcc 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -2189,6 +2189,21 @@ class MemoryMap: """Formatted string of the base memory map, consisting of unresolved auto and user segments (read-only).""" return self.format_description(self.description(base=True)) + def set_logical_memory_map_enabled(self, enabled: bool) -> None: + """ + Enable or disable the logical memory map. + + When enabled, the memory map will present a simplified, logical view that merges and abstracts virtual memory + regions based on criteria such as contiguity and flag consistency. This view is designed to provide a higher-level + representation for user analysis, hiding underlying mapping details. + + When disabled, the memory map will revert to displaying the virtual view, which corresponds directly to the individual + segments mapped from the raw file without any merging or abstraction. + + :param enabled: True to enable the logical view, False to revert to the virtual view. + """ + core.BNSetLogicalMemoryMapEnabled(self.handle, enabled) + 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 into the memory map. There are three types of memory regions that can be added: @@ -9812,6 +9827,11 @@ to a the type "tagRECT" found in the typelibrary "winX64common" @property def memory_map(self): + """ + ``memory_map`` returns the MemoryMap object for the current BinaryView. The `MemoryMap` object is a proxy object + that provides a high-level view of the memory map, allowing you to query and manipulate memory regions. This proxy + ensures that the memory map always reflects the latest state of the core `MemoryMap` object in the underlying `BinaryView`. + """ return MemoryMap(handle=self.handle) def stringify_unicode_data( |
