summaryrefslogtreecommitdiff
path: root/binaryview.cpp
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2018-06-29 16:54:48 -0400
committerPeter LaFosse <peter@vector35.com>2018-06-29 16:54:48 -0400
commit635c06c68ec72e579573f87ab86996b5952bf853 (patch)
treecd6a95bc6066f3bfb534611be7db614b3886e131 /binaryview.cpp
parentd0c07251a780ca3b638b2cdff0afa00c92aea421 (diff)
Add api for querying relocation
Diffstat (limited to 'binaryview.cpp')
-rw-r--r--binaryview.cpp62
1 files changed, 62 insertions, 0 deletions
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<pair<uint64_t, uint64_t>> Segment::GetRelocationRanges() const
+{
+ size_t count = 0;
+ BNRange* ranges = BNSegmentGetRelocationRanges(m_object, &count);
+ vector<pair<uint64_t, uint64_t>> result(count);
+ for (size_t i = 0; i < count; i++)
+ {
+ result.push_back({ranges[i].start, ranges[i].end});
+ }
+ BNFreeRelocationRanges(ranges);
+ return result;
+}
+
+
+vector<pair<uint64_t, uint64_t>> Segment::GetRelocationRangesAtAddress(uint64_t addr) const
+{
+ size_t count = 0;
+ BNRange* ranges = BNSegmentGetRelocationRangesAtAddress(m_object, addr, &count);
+ vector<pair<uint64_t, uint64_t>> 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<pair<uint64_t, uint64_t>> BinaryView::GetRelocationRanges() const
+{
+ size_t count = 0;
+ BNRange* ranges = BNGetRelocationRanges(m_object, &count);
+ vector<pair<uint64_t, uint64_t>> result(count);
+ for (size_t i = 0; i < count; i++)
+ {
+ result.push_back({ranges[i].start, ranges[i].end});
+ }
+ BNFreeRelocationRanges(ranges);
+ return result;
+}
+
+
+vector<pair<uint64_t, uint64_t>> BinaryView::GetRelocationRangesAtAddress(uint64_t addr) const
+{
+ size_t count = 0;
+ BNRange* ranges = BNGetRelocationRangesAtAddress(m_object, addr, &count);
+ vector<pair<uint64_t, uint64_t>> 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());