コード例 #1
0
	def dominance_frontier(self):
		"""Dominance frontier for this basic block (read-only)"""
		count = ctypes.c_ulonglong()
		blocks = core.BNGetBasicBlockDominanceFrontier(self.handle, count)
		result = []
		for i in xrange(0, count.value):
			result.append(self._create_instance(self.view, core.BNNewBasicBlockReference(blocks[i])))
		core.BNFreeBasicBlockList(blocks, count.value)
		return result
コード例 #2
0
	def dominator_tree_children(self):
		"""List of child blocks in the dominator tree for this basic block (read-only)"""
		count = ctypes.c_ulonglong()
		blocks = core.BNGetBasicBlockDominatorTreeChildren(self.handle, count)
		result = []
		for i in xrange(0, count.value):
			result.append(self._create_instance(self.view, core.BNNewBasicBlockReference(blocks[i])))
		core.BNFreeBasicBlockList(blocks, count.value)
		return result
コード例 #3
0
	def strict_dominators(self):
		"""List of strict dominators for this basic block (read-only)"""
		count = ctypes.c_ulonglong()
		blocks = core.BNGetBasicBlockStrictDominators(self.handle, count)
		result = []
		for i in xrange(0, count.value):
			result.append(self._create_instance(self.view, core.BNNewBasicBlockReference(blocks[i])))
		core.BNFreeBasicBlockList(blocks, count.value)
		return result
コード例 #4
0
	def __iter__(self):
		count = ctypes.c_ulonglong()
		blocks = core.BNGetMediumLevelILBasicBlockList(self.handle, count)
		view = None
		if self.source_function is not None:
			view = self.source_function.view
		try:
			for i in xrange(0, count.value):
				yield MediumLevelILBasicBlock(view, core.BNNewBasicBlockReference(blocks[i]), self)
		finally:
			core.BNFreeBasicBlockList(blocks, count.value)
コード例 #5
0
	def basic_blocks(self):
		"""list of MediumLevelILBasicBlock objects (read-only)"""
		count = ctypes.c_ulonglong()
		blocks = core.BNGetMediumLevelILBasicBlockList(self.handle, count)
		result = []
		view = None
		if self.source_function is not None:
			view = self.source_function.view
		for i in xrange(0, count.value):
			result.append(MediumLevelILBasicBlock(view, core.BNNewBasicBlockReference(blocks[i]), self))
		core.BNFreeBasicBlockList(blocks, count.value)
		return result
コード例 #6
0
	def get_iterated_dominance_frontier(self, blocks):
		if len(blocks) == 0:
			return []
		block_set = (ctypes.POINTER(core.BNBasicBlock) * len(blocks))()
		for i in xrange(len(blocks)):
			block_set[i] = blocks[i].handle
		count = ctypes.c_ulonglong()
		out_blocks = core.BNGetBasicBlockIteratedDominanceFrontier(block_set, len(blocks), count)
		result = []
		for i in xrange(0, count.value):
			result.append(BasicBlock(blocks[0].view, core.BNNewBasicBlockReference(out_blocks[i])))
		core.BNFreeBasicBlockList(out_blocks, count.value)
		return result
コード例 #7
0
	def incoming_edges(self):
		"""List of basic block incoming edges (read-only)"""
		count = ctypes.c_ulonglong(0)
		edges = core.BNGetBasicBlockIncomingEdges(self.handle, count)
		result = []
		for i in xrange(0, count.value):
			branch_type = BranchType(edges[i].type)
			if edges[i].target:
				target = self._create_instance(self.view, core.BNNewBasicBlockReference(edges[i].target))
			else:
				target = None
			result.append(BasicBlockEdge(branch_type, target, self, edges[i].backEdge))
		core.BNFreeBasicBlockEdgeList(edges, count.value)
		return result
コード例 #8
0
 def _set_current_basic_block(self, ctxt, block):
     try:
         if block:
             func = core.BNGetBasicBlockFunction(block)
             if func is None:
                 block = None
             else:
                 block = basicblock.BasicBlock(
                     binaryview.BinaryView(
                         handle=core.BNGetFunctionData(func)),
                     core.BNNewBasicBlockReference(block))
                 core.BNFreeFunction(func)
         else:
             block = None
         self.perform_set_current_basic_block(block)
     except:
         log.log_error(traceback.format_exc())