summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2019-03-03 22:29:03 -0500
committerPeter LaFosse <peter@vector35.com>2019-03-06 23:37:47 -0500
commitff682853049753d233ecebbcca0d4bf9a6f1eff0 (patch)
tree584742cfae8b7f89729f614d7f3c81129f6b83f4 /python
parent6564ca9461ed83e2548dcde270fc3dc884486bd6 (diff)
Add get_data_refs_from API
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index b316f24b..02dfeb4a 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -2492,6 +2492,20 @@ class BinaryView(object):
return result
def get_data_refs(self, addr, length=None):
+ """
+ ``get_data_refs`` returns a list of virtual addresses of data which references ``addr``. Optionally specifying
+ a length. When ``length`` is set ``get_data_refs`` returns the data which references in the range ``addr``-``addr``+``length``.
+
+ :param int addr: virtual address to query for references
+ :param int length: optional length of query
+ :return: list of integers
+ :rtype: list(integer)
+ :Example:
+
+ >>> bv.get_data_refs(here)
+ [4203812]
+ >>>
+ """
count = ctypes.c_ulonglong(0)
if length is None:
refs = core.BNGetDataReferences(self.handle, addr, count)
@@ -2504,6 +2518,33 @@ class BinaryView(object):
core.BNFreeDataReferences(refs, count.value)
return result
+ def get_data_refs_from(self, addr, length=None):
+ """
+ ``get_data_refs_from`` returns a list of virtual addresses referenced by the address ``addr``. Optionally specifying
+ a length. When ``length`` is set ``get_data_refs_from`` returns the data referenced in the range ``addr``-``addr``+``length``.
+
+ :param int addr: virtual address to query for references
+ :param int length: optional length of query
+ :return: list of integers
+ :rtype: list(integer)
+ :Example:
+
+ >>> bv.get_data_refs_from(here)
+ [4200327]
+ >>>
+ """
+ count = ctypes.c_ulonglong(0)
+ if length is None:
+ refs = core.BNGetDataReferencesFrom(self.handle, addr, count)
+ else:
+ refs = core.BNGetDataReferencesFromInRange(self.handle, addr, length, count)
+
+ result = []
+ for i in range(0, count.value):
+ result.append(refs[i])
+ core.BNFreeDataReferences(refs, count.value)
+ return result
+
def get_symbol_at(self, addr, namespace=None):
"""