From 9f898cac33044cb3e514a6352789b0c77eea1d91 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Fri, 14 Jul 2017 14:06:34 -0400 Subject: Adding convenience function 'get_functions_containing' --- python/binaryview.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'python') 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 -- cgit v1.3.1