From 5fc08034ea071119c5407898c81d0aa012512430 Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Thu, 18 Jul 2024 23:06:19 -0400 Subject: MemoryMap update with new segment model. --- binaryninjaapi.h | 105 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 29 deletions(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index f7362240..e0fbfb50 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -4218,11 +4218,6 @@ namespace BinaryNinja { uint32_t GetFlags() const; bool IsAutoDefined() const; - std::vector> GetRelocationRanges() const; - std::vector> GetRelocationRangesAtAddress(uint64_t addr) const; - std::vector> GetRelocationsInRange(uint64_t addr, uint64_t size) const; - uint64_t GetRelocationsCount() const; - void SetLength(uint64_t length); void SetDataOffset(uint64_t dataOffset); void SetDataLength(uint64_t dataLength); @@ -4823,7 +4818,29 @@ namespace BinaryNinja { */ uint64_t GetNextValidOffset(uint64_t offset) const; + /*! GetImageBase queries for the image base in the BinaryView + + \return the image base of the BinaryView + */ + uint64_t GetImageBase() const; + + /*! GetOriginalImageBase queries for the original image base in the BinaryView, unaffected by any rebasing operations + + \return the original image base of the BinaryView + */ + uint64_t GetOriginalImageBase() const; + + /*! SetOriginalBase sets the original image base in the BinaryView, unaffected by any rebasing operations. + * This is only intended to be used by Binary View implementations to provide this value. Regular users should + * NOT change this value. + + \param imageBase the original image base of the binary view + */ + void SetOriginalImageBase(uint64_t imageBase); + + /*! GetOriginalBase queries for the original image base in the BinaryView, unaffected by any rebasing operations + \deprecated This API has been deprecated in favor of GetOriginalImageBase in 4.0.xxxx \return the original image base of the BinaryView */ @@ -4832,6 +4849,7 @@ namespace BinaryNinja { /*! SetOriginalBase sets the original image base in the BinaryView, unaffected by any rebasing operations. * This is only intended to be used by Binary View implementations to provide this value. Regular users should * NOT change this value. + \deprecated This API has been deprecated in favor of SetOriginalImageBase in 4.0.xxxx \param base the original image base of the binary view */ @@ -4926,6 +4944,7 @@ namespace BinaryNinja { void DefineRelocation(Architecture* arch, BNRelocationInfo& info, Ref target, uint64_t reloc); std::vector> GetRelocationRanges() const; std::vector> GetRelocationRangesAtAddress(uint64_t addr) const; + std::vector> GetRelocationRangesInRange(uint64_t addr, size_t size) const; bool RangeContainsRelocation(uint64_t addr, size_t size) const; std::vector> GetRelocationsAt(uint64_t addr) const; @@ -6499,6 +6518,25 @@ namespace BinaryNinja { */ std::vector GetUniqueSectionNames(const std::vector& names); + /*! Get the list of allocated ranges + \deprecated This API has been deprecated in favor of GetMappedAddressRanges in 4.0.xxxx + + \return The list of allocated ranges + */ + std::vector GetAllocatedRanges(); + + /*! Get the list of ranges mapped into the address space + + \return The list of mapped ranges + */ + std::vector GetMappedAddressRanges(); + + /*! Get the list of ranges that are mapped into the address space and are backed by a target object + + \return The list of backed ranges + */ + std::vector GetBackedAddressRanges(); + /*! Get the comment placed at an address \param addr Address at which to check for a comment @@ -6519,12 +6557,6 @@ namespace BinaryNinja { */ void SetCommentForAddress(uint64_t addr, const std::string& comment); - /*! Get the list of allocated ranges - - \return The list of allocated ranges - */ - std::vector GetAllocatedRanges(); - void StoreMetadata(const std::string& key, Ref value, bool isAuto = false); Ref QueryMetadata(const std::string& key); void RemoveMetadata(const std::string& key); @@ -6704,19 +6736,19 @@ namespace BinaryNinja { MemoryMap(BNBinaryView* view): m_object(view) {} ~MemoryMap() = default; - bool AddBinaryMemoryRegion(const std::string& name, uint64_t start, Ref source) + bool AddBinaryMemoryRegion(const std::string& name, uint64_t start, Ref source, uint32_t flags = 0) { - return BNAddBinaryMemoryRegion(m_object, name.c_str(), start, source->GetObject()); + return BNAddBinaryMemoryRegion(m_object, name.c_str(), start, source->GetObject(), flags); } - bool AddDataMemoryRegion(const std::string& name, uint64_t start, const DataBuffer& source) + bool AddDataMemoryRegion(const std::string& name, uint64_t start, const DataBuffer& source, uint32_t flags = 0) { - return BNAddDataMemoryRegion(m_object, name.c_str(), start, source.GetBufferObject()); + return BNAddDataMemoryRegion(m_object, name.c_str(), start, source.GetBufferObject(), flags); } - bool AddRemoteMemoryRegion(const std::string& name, uint64_t start, FileAccessor* source) + bool AddRemoteMemoryRegion(const std::string& name, uint64_t start, FileAccessor* source, uint32_t flags = 0) { - return BNAddRemoteMemoryRegion(m_object, name.c_str(), start, source->GetCallbacks()); + return BNAddRemoteMemoryRegion(m_object, name.c_str(), start, source->GetCallbacks(), flags); } bool RemoveMemoryRegion(const std::string& name) @@ -6724,19 +6756,37 @@ namespace BinaryNinja { return BNRemoveMemoryRegion(m_object, name.c_str()); } - bool IsMemoryRegionEnabled(const std::string& name, uint64_t start) + std::string GetActiveMemoryRegionAt(uint64_t addr) + { + char* name = BNGetActiveMemoryRegionAt(m_object, addr); + std::string result = name; + BNFreeString(name); + return result; + } + + bool IsMemoryRegionEnabled(const std::string& name) + { + return BNIsMemoryRegionEnabled(m_object, name.c_str()); + } + + bool SetMemoryRegionEnabled(const std::string& name, bool enabled) + { + return BNSetMemoryRegionEnabled(m_object, name.c_str(), enabled); + } + + bool IsMemoryRegionRebaseable(const std::string& name) { - return BNIsMemoryRegionEnabled(m_object, name.c_str(), start); + return BNIsMemoryRegionRebaseable(m_object, name.c_str()); } - bool SetMemoryRegionEnabled(const std::string& name, uint64_t start, bool enabled) + bool SetMemoryRegionRebaseable(const std::string& name, bool rebaseable) { - return BNSetMemoryRegionEnabled(m_object, name.c_str(), start, enabled); + return BNSetMemoryRegionRebaseable(m_object, name.c_str(), rebaseable); } - bool SetMemoryRegionFill(const std::string& name, uint64_t start, uint8_t fill) + bool SetMemoryRegionFill(const std::string& name, uint8_t fill) { - return BNSetMemoryRegionFill(m_object, name.c_str(), start, fill); + return BNSetMemoryRegionFill(m_object, name.c_str(), fill); } void Reset() @@ -8111,16 +8161,13 @@ namespace BinaryNinja { // These three binary view type constant APIs are deprecated and should no longer be used. Their implementations // have been removed, and they now have no effects. - /*! \deprecated This API has been deprecated. The implementation has been removed, and this function no - longer has any effect + /*! \deprecated This API has been deprecated. The implementation has been removed, and this function no longer has any effect */ bool IsBinaryViewTypeConstantDefined(const std::string& type, const std::string& name); - /*! \deprecated This API has been deprecated. The implementation has been removed, and this function no - longer has any effect + /*! \deprecated This API has been deprecated. The implementation has been removed, and this function no longer has any effect */ uint64_t GetBinaryViewTypeConstant(const std::string& type, const std::string& name, uint64_t defaultValue = 0); - /*! \deprecated This API has been deprecated. The implementation has been removed, and this function no - longer has any effect + /*! \deprecated This API has been deprecated. The implementation has been removed, and this function no longer has any effect */ void SetBinaryViewTypeConstant(const std::string& type, const std::string& name, uint64_t value); -- cgit v1.3.1