summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2017-07-14 14:06:34 -0400
committerPeter LaFosse <peter@vector35.com>2017-07-15 14:17:17 -0400
commit9f898cac33044cb3e514a6352789b0c77eea1d91 (patch)
treeae62170ab2e31f4f681b308cbddfe68034cf0b93 /python
parent6857160ff18733d7a218101ab1d67ede04c1018b (diff)
Adding convenience function 'get_functions_containing'
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 3242b89c..c2163162 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -1911,11 +1911,27 @@ class BinaryView(object):
return None
return DataVariable(var.address, types.Type(var.type), var.autoDiscovered)
+ def get_functions_containing(self, addr):
+ """
+ ``get_functions_containing`` returns a list of functions which contain the given address or None on failure.
+
+ :param int addr: virtual address to query.
+ :rtype: list of Function objects or None
+ """
+ basic_blocks = self.get_basic_blocks_at(addr)
+ if len(basic_blocks) == 0:
+ return None
+
+ result = []
+ for block in basic_blocks:
+ result.append(block.function)
+ return result
+
def get_function_at(self, addr, plat=None):
"""
- ``get_function_at`` gets a binaryninja.Function object for the function at the virtual address ``addr``:
+ ``get_function_at`` gets a Function object for the function that starts at virtual address ``addr``:
- :param int addr: virtual address of the desired function
+ :param int addr: starting virtual address of the desired function
:param Platform plat: plat of the desired function
:return: returns a Function object or None for the function at the virtual address provided
:rtype: Function