def basic_block(self): """Basic block associated with this part of the flow graph""" block = core.BNGetFlowGraphBasicBlock(self.handle) if not block: return None func_handle = core.BNGetBasicBlockFunction(block) if not func_handle: core.BNFreeBasicBlock(block) return None view = binaryview.BinaryView( handle=core.BNGetFunctionData(func_handle)) func = function.Function(view, func_handle) if core.BNIsLowLevelILBasicBlock(block): block = lowlevelil.LowLevelILBasicBlock( view, block, lowlevelil.LowLevelILFunction( func.arch, core.BNGetBasicBlockLowLevelILFunction(block), func)) elif core.BNIsMediumLevelILBasicBlock(block): block = mediumlevelil.MediumLevelILBasicBlock( view, block, mediumlevelil.MediumLevelILFunction( func.arch, core.BNGetBasicBlockMediumLevelILFunction(block), func)) else: block = basicblock.BasicBlock(block, view) return block
def il_function(self): if self.is_low_level_il: il_func = core.BNGetFlowGraphLowLevelILFunction(self.handle) if not il_func: return None function = self.function if function is None: return None return lowlevelil.LowLevelILFunction(function.arch, il_func, function) if self.is_medium_level_il: il_func = core.BNGetFlowGraphMediumLevelILFunction(self.handle) if not il_func: return None function = self.function if function is None: return None return mediumlevelil.MediumLevelILFunction(function.arch, il_func, function) if self.is_high_level_il: il_func = core.BNGetFlowGraphHighLevelILFunction(self.handle) if not il_func: return None function = self.function if function is None: return None return highlevelil.HighLevelILFunction(function.arch, il_func, function) return None
def _recognize_low_level_il(self, ctxt, data, func, il): try: file_metadata = filemetadata.FileMetadata(handle = core.BNGetFileForView(data)) view = binaryview.BinaryView(file_metadata = file_metadata, handle = core.BNNewViewReference(data)) func = function.Function(view, handle = core.BNNewFunctionReference(func)) il = lowlevelil.LowLevelILFunction(func.arch, handle = core.BNNewLowLevelILFunctionReference(il)) return self.recognize_low_level_il(view, func, il) except: log.log_error(traceback.format_exc()) return False
def low_level_il(self): """Low level IL for this function""" result = core.BNGetLowLevelILForMediumLevelIL(self.handle) if not result: return None return lowlevelil.LowLevelILFunction(self.arch, result, self.source_function)