コード例 #1
0
    def get_disassembly_text(self, settings=None):
        """
		``get_disassembly_text`` returns a list of binaryninja.function.DisassemblyTextLine objects for the current basic block.

		:param DisassemblySettings settings: (optional) DisassemblySettings object
		:Example:

			>>> current_basic_block.get_disassembly_text()
			[<0x100000f30: _main:>, <0x100000f30: push    rbp>, ... ]
		"""
        settings_obj = None
        if settings:
            settings_obj = settings.handle

        count = ctypes.c_ulonglong()
        lines = core.BNGetBasicBlockDisassemblyText(self.handle, settings_obj,
                                                    count)
        result = []
        for i in range(0, count.value):
            addr = lines[i].addr
            if (lines[i].instrIndex != 0xffffffffffffffff) and hasattr(
                    self, 'il_function'):
                il_instr = self.il_function[lines[i].instrIndex]  # pylint: disable=no-member
            else:
                il_instr = None
            color = highlight.HighlightColor._from_core_struct(
                lines[i].highlight)
            tokens = binaryninja.function.InstructionTextToken.get_instruction_lines(
                lines[i].tokens, lines[i].count)
            result.append(
                binaryninja.function.DisassemblyTextLine(
                    tokens, addr, il_instr, color))
        core.BNFreeDisassemblyTextLines(lines, count.value)
        return result
コード例 #2
0
ファイル: flowgraph.py プロジェクト: rmspeers/binaryninja-api
 def __iter__(self):
     count = ctypes.c_ulonglong()
     lines = core.BNGetFlowGraphNodeLines(self.handle, count)
     block = self.basic_block
     try:
         for i in range(0, count.value):
             addr = lines[i].addr
             if (lines[i].instrIndex != 0xffffffffffffffff) and (
                     block is not None) and hasattr(block, 'il_function'):
                 il_instr = block.il_function[lines[i].instrIndex]
             else:
                 il_instr = None
             tokens = []
             for j in range(0, lines[i].count):
                 token_type = InstructionTextTokenType(
                     lines[i].tokens[j].type)
                 text = lines[i].tokens[j].text
                 value = lines[i].tokens[j].value
                 size = lines[i].tokens[j].size
                 operand = lines[i].tokens[j].operand
                 context = lines[i].tokens[j].context
                 confidence = lines[i].tokens[j].confidence
                 address = lines[i].tokens[j].address
                 tokens.append(
                     function.InstructionTextToken(token_type, text, value,
                                                   size, operand, context,
                                                   address, confidence))
             yield function.DisassemblyTextLine(tokens, addr, il_instr)
     finally:
         core.BNFreeDisassemblyTextLines(lines, count.value)
コード例 #3
0
ファイル: flowgraph.py プロジェクト: rmspeers/binaryninja-api
 def lines(self):
     """Flow graph block list of text lines"""
     count = ctypes.c_ulonglong()
     lines = core.BNGetFlowGraphNodeLines(self.handle, count)
     block = self.basic_block
     result = []
     for i in range(0, count.value):
         addr = lines[i].addr
         if (lines[i].instrIndex != 0xffffffffffffffff) and (
                 block is not None) and hasattr(block, 'il_function'):
             il_instr = block.il_function[lines[i].instrIndex]
         else:
             il_instr = None
         color = highlight.HighlightColor._from_core_struct(
             lines[i].highlight)
         tokens = []
         for j in range(0, lines[i].count):
             token_type = InstructionTextTokenType(lines[i].tokens[j].type)
             text = lines[i].tokens[j].text
             value = lines[i].tokens[j].value
             size = lines[i].tokens[j].size
             operand = lines[i].tokens[j].operand
             context = lines[i].tokens[j].context
             confidence = lines[i].tokens[j].confidence
             address = lines[i].tokens[j].address
             tokens.append(
                 function.InstructionTextToken(token_type, text, value,
                                               size, operand, context,
                                               address, confidence))
         result.append(
             function.DisassemblyTextLine(tokens, addr, il_instr, color))
     core.BNFreeDisassemblyTextLines(lines, count.value)
     return result
コード例 #4
0
	def __iter__(self):
		count = ctypes.c_ulonglong()
		lines = core.BNGetFlowGraphNodeLines(self.handle, count)
		block = self.basic_block
		try:
			for i in range(0, count.value):
				addr = lines[i].addr
				if (lines[i].instrIndex != 0xffffffffffffffff) and (block is not None) and hasattr(block, 'il_function'):
					il_instr = block.il_function[lines[i].instrIndex]
				else:
					il_instr = None
				tokens = function.InstructionTextToken.get_instruction_lines(lines[i].tokens, lines[i].count)
				yield function.DisassemblyTextLine(tokens, addr, il_instr)
		finally:
			core.BNFreeDisassemblyTextLines(lines, count.value)
コード例 #5
0
	def lines(self):
		"""HLIL text lines (read-only)"""
		count = ctypes.c_ulonglong()
		lines = core.BNGetHighLevelILExprText(self._function.handle, self._expr_index, self._as_ast, count, None)
		result = []
		for i in range(0, count.value):
			addr = lines[i].addr
			if lines[i].instrIndex != 0xffffffffffffffff:
				il_instr = self._function[lines[i].instrIndex]
			else:
				il_instr = None
			color = binaryninja.highlight.HighlightColor._from_core_struct(lines[i].highlight)
			tokens = binaryninja.function.InstructionTextToken.get_instruction_lines(lines[i].tokens, lines[i].count)
			result.append(binaryninja.function.DisassemblyTextLine(tokens, addr, il_instr, color))
		core.BNFreeDisassemblyTextLines(lines, count.value)
		return result
コード例 #6
0
	def lines(self):
		"""Flow graph block list of text lines"""
		count = ctypes.c_ulonglong()
		lines = core.BNGetFlowGraphNodeLines(self.handle, count)
		block = self.basic_block
		result = []
		for i in range(0, count.value):
			addr = lines[i].addr
			if (lines[i].instrIndex != 0xffffffffffffffff) and (block is not None) and hasattr(block, 'il_function'):
				il_instr = block.il_function[lines[i].instrIndex]
			else:
				il_instr = None
			color = highlight.HighlightColor._from_core_struct(lines[i].highlight)
			tokens = function.InstructionTextToken.get_instruction_lines(lines[i].tokens, lines[i].count)
			result.append(function.DisassemblyTextLine(tokens, addr, il_instr, color))
		core.BNFreeDisassemblyTextLines(lines, count.value)
		return result
コード例 #7
0
	def get_disassembly_text(self, settings=None):
		"""
		``get_disassembly_text`` returns a list of binaryninja.function.DisassemblyTextLine objects for the current basic block.

		:param DisassemblySettings settings: (optional) DisassemblySettings object
		:Example:

			>>> current_basic_block.get_disassembly_text()
			[<0x100000f30: _main:>, <0x100000f30: push    rbp>, ... ]
		"""
		settings_obj = None
		if settings:
			settings_obj = settings.handle

		count = ctypes.c_ulonglong()
		lines = core.BNGetBasicBlockDisassemblyText(self.handle, settings_obj, count)
		result = []
		for i in range(0, count.value):
			addr = lines[i].addr
			if (lines[i].instrIndex != 0xffffffffffffffff) and hasattr(self, 'il_function'):
				il_instr = self.il_function[lines[i].instrIndex]
			else:
				il_instr = None
			color = highlight.HighlightColor._from_core_struct(lines[i].highlight)
			tokens = []
			for j in range(0, lines[i].count):
				token_type = InstructionTextTokenType(lines[i].tokens[j].type)
				text = lines[i].tokens[j].text
				value = lines[i].tokens[j].value
				size = lines[i].tokens[j].size
				operand = lines[i].tokens[j].operand
				context = lines[i].tokens[j].context
				confidence = lines[i].tokens[j].confidence
				address = lines[i].tokens[j].address
				tokens.append(binaryninja.function.InstructionTextToken(token_type, text, value, size, operand, context, address, confidence))
			result.append(binaryninja.function.DisassemblyTextLine(tokens, addr, il_instr, color))
		core.BNFreeDisassemblyTextLines(lines, count.value)
		return result