Example #1
0
    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
Example #2
0
 def medium_level_il(self):
     """Medium level IL for this function"""
     result = core.BNGetMediumLevelILForHighLevelILFunction(self.handle)
     if not result:
         return None
     return mediumlevelil.MediumLevelILFunction(self._arch, result,
                                                self._source_function)
Example #3
0
 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_medium_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 = mediumlevelil.MediumLevelILFunction(func.arch, handle = core.BNNewMediumLevelILFunctionReference(il))
			return self.recognize_medium_level_il(view, func, il)
		except:
			log.log_error(traceback.format_exc())
			return False