Esempio n. 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
Esempio n. 2
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