From 6d3fe290eb20e31a33e929933c01d2ca3eb43da1 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Sat, 10 Sep 2016 00:36:27 -0400 Subject: Add API for list of basic blocks starting at an address --- python/__init__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'python') diff --git a/python/__init__.py b/python/__init__.py index 7978fd2c..33202a2c 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -2288,6 +2288,22 @@ class BinaryView(object): core.BNFreeBasicBlockList(blocks, count.value) return result + def get_basic_blocks_starting_at(self, addr): + """ + ``get_basic_blocks_at`` get a list of :py:Class:`BasicBlock` objects which start at the provided virtual address. + + :param int addr: virtual address of BasicBlock desired + :return: a list of :py:Class:`BasicBlock` objects + :rtype: list(BasicBlock) + """ + count = ctypes.c_ulonglong(0) + blocks = core.BNGetBasicBlocksStartingAtAddress(self.handle, addr, count) + result = [] + for i in xrange(0, count.value): + result.append(BasicBlock(self, core.BNNewBasicBlockReference(blocks[i]))) + core.BNFreeBasicBlockList(blocks, count.value) + return result + def get_recent_basic_block_at(self, addr): block = core.BNGetRecentBasicBlockForAddress(self.handle, addr) if block is None: -- cgit v1.3.1