summaryrefslogtreecommitdiff
path: root/python/binaryview.py
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 /python/binaryview.py
parentd0c07251a780ca3b638b2cdff0afa00c92aea421 (diff)
Add api for querying relocation
Diffstat (limited to 'python/binaryview.py')
-rw-r--r--python/binaryview.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 0b090a9a..ba99f9f9 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -466,6 +466,33 @@ class Segment(object):
def data_end(self):
return core.BNSegmentGetDataEnd(self.handle)
+ @property
+ def reloction_count(self):
+ return core.BNSegmentGetRelocationsCount(self.handle)
+
+ @property
+ def relocation_ranges(self):
+ """List of relocation range tuples (read-only)"""
+
+ count = ctypes.c_ulonglong()
+ ranges = core.BNSegmentGetRelocationRanges(self.handle, count)
+ result = []
+ for i in xrange(0, count.value):
+ result.append((ranges[i].start, ranges[i].end))
+ core.BNFreeRelocationRanges(ranges, count)
+ return result
+
+ def relocation_ranges_at(self, addr):
+ """List of relocation range tuples (read-only)"""
+
+ count = ctypes.c_ulonglong()
+ ranges = core.BNSegmentGetRelocationRangesAtAddress(self.handle, addr, count)
+ result = []
+ for i in xrange(0, count.value):
+ result.append((ranges[i].start, ranges[i].end))
+ core.BNFreeRelocationRanges(ranges, count)
+ return result
+
def __len__(self):
return core.BNSegmentGetLength(self.handle)
@@ -1074,6 +1101,29 @@ class BinaryView(object):
def max_function_size_for_analysis(self, size):
core.BNSetMaxFunctionSizeForAnalysis(self.handle, size)
+ @property
+ def relocation_ranges(self):
+ """List of relocation range tuples (read-only)"""
+
+ count = ctypes.c_ulonglong()
+ ranges = core.BNGetRelocationRanges(self.handle, count)
+ result = []
+ for i in xrange(0, count.value):
+ result.append((ranges[i].start, ranges[i].end))
+ core.BNFreeRelocationRanges(ranges, count)
+ return result
+
+ def relocation_ranges_at(self, addr):
+ """List of relocation range tuples for a given address"""
+
+ count = ctypes.c_ulonglong()
+ ranges = core.BNGetRelocationRangesAtAddress(self.handle, addr, count)
+ result = []
+ for i in xrange(0, count.value):
+ result.append((ranges[i].start, ranges[i].end))
+ core.BNFreeRelocationRanges(ranges, count)
+ return result
+
def __len__(self):
return int(core.BNGetViewLength(self.handle))