diff options
| author | Peter LaFosse <peter@vector35.com> | 2018-06-29 16:54:48 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2018-06-29 16:54:48 -0400 |
| commit | 635c06c68ec72e579573f87ab86996b5952bf853 (patch) | |
| tree | cd6a95bc6066f3bfb534611be7db614b3886e131 /binaryview.cpp | |
| parent | d0c07251a780ca3b638b2cdff0afa00c92aea421 (diff) | |
Add api for querying relocation
Diffstat (limited to 'binaryview.cpp')
| -rw-r--r-- | binaryview.cpp | 62 |
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()); |
