diff options
| -rw-r--r-- | binaryninjaapi.h | 2 | ||||
| -rw-r--r-- | binaryninjacore.h | 2 | ||||
| -rw-r--r-- | binaryview.cpp | 13 |
3 files changed, 16 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 68243795..8db9124a 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -6434,6 +6434,8 @@ namespace BinaryNinja { */ bool GetAddressForDataOffset(uint64_t offset, uint64_t& addr); + bool GetDataOffsetForAddress(uint64_t addr, uint64_t& offset); + /*! Creates an analysis-defined section that can help inform analysis by clarifying what types of data exist in what ranges diff --git a/binaryninjacore.h b/binaryninjacore.h index ccc47c97..c9c24723 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 69 +#define BN_CURRENT_CORE_ABI_VERSION 70 // 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 diff --git a/binaryview.cpp b/binaryview.cpp index fa3ef646..861c7eb2 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -4795,6 +4795,19 @@ bool BinaryView::GetAddressForDataOffset(uint64_t offset, uint64_t& addr) } +bool BinaryView::GetDataOffsetForAddress(uint64_t addr, uint64_t& offset) +{ + auto segment = GetSegmentAt(addr); + if (segment && segment->GetStart() <= addr && addr < segment->GetEnd()) + { + offset = 0; + offset = addr - segment->GetStart() + segment->GetDataOffset(); + return true; + } + return false; +} + + void BinaryView::AddAutoSection(const string& name, uint64_t start, uint64_t length, BNSectionSemantics semantics, const string& type, uint64_t align, uint64_t entrySize, const string& linkedSection, const string& infoSection, uint64_t infoData) |
