From 635c06c68ec72e579573f87ab86996b5952bf853 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Fri, 29 Jun 2018 16:54:48 -0400 Subject: Add api for querying relocation --- binaryview.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index f663d337..7aa2118f 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -273,6 +273,40 @@ Segment::Segment(BNSegment* seg) } +vector> Segment::GetRelocationRanges() const +{ + size_t count = 0; + BNRange* ranges = BNSegmentGetRelocationRanges(m_object, &count); + vector> result(count); + for (size_t i = 0; i < count; i++) + { + result.push_back({ranges[i].start, ranges[i].end}); + } + BNFreeRelocationRanges(ranges); + return result; +} + + +vector> Segment::GetRelocationRangesAtAddress(uint64_t addr) const +{ + size_t count = 0; + BNRange* ranges = BNSegmentGetRelocationRangesAtAddress(m_object, addr, &count); + vector> result(count); + for (size_t i = 0; i < count; i++) + { + result.push_back({ranges[i].start, ranges[i].end}); + } + BNFreeRelocationRanges(ranges); + return result; +} + + +uint64_t Segment::GetRelocationsCount() const +{ + return BNSegmentGetRelocationsCount(m_object); +} + + uint64_t Segment::GetStart() const { return BNSegmentGetStart(m_object); @@ -909,6 +943,34 @@ void BinaryView::DefineRelocation(Architecture* arch, BNRelocationInfo& info, Re } +vector> BinaryView::GetRelocationRanges() const +{ + size_t count = 0; + BNRange* ranges = BNGetRelocationRanges(m_object, &count); + vector> result(count); + for (size_t i = 0; i < count; i++) + { + result.push_back({ranges[i].start, ranges[i].end}); + } + BNFreeRelocationRanges(ranges); + return result; +} + + +vector> BinaryView::GetRelocationRangesAtAddress(uint64_t addr) const +{ + size_t count = 0; + BNRange* ranges = BNGetRelocationRangesAtAddress(m_object, addr, &count); + vector> result(count); + for (size_t i = 0; i < count; i++) + { + result.push_back({ranges[i].start, ranges[i].end}); + } + BNFreeRelocationRanges(ranges); + return result; +} + + void BinaryView::RegisterNotification(BinaryDataNotification* notify) { BNRegisterDataNotification(m_object, notify->GetCallbacks()); -- cgit v1.3.1