Beispiel #1
0
	def lines(self, lines):
		if isinstance(lines, str):
			lines = lines.split('\n')
		line_buf = (core.BNDisassemblyTextLine * len(lines))()
		for i in range(0, len(lines)):
			line = lines[i]
			if isinstance(line, str):
				line = function.DisassemblyTextLine([function.InstructionTextToken(InstructionTextTokenType.TextToken, line)])
			if not isinstance(line, function.DisassemblyTextLine):
				line = function.DisassemblyTextLine(line)
			if line.address is None:
				if len(line.tokens) > 0:
					line_buf[i].addr = line.tokens[0].address
				else:
					line_buf[i].addr = 0
			else:
				line_buf[i].addr = line.address
			if line.il_instruction is not None:
				line_buf[i].instrIndex = line.il_instruction.instr_index
			else:
				line_buf[i].instrIndex = 0xffffffffffffffff
			color = line.highlight
			if not isinstance(color, HighlightStandardColor) and not isinstance(color, highlight.HighlightColor):
				raise ValueError("Specified color is not one of HighlightStandardColor, highlight.HighlightColor")
			if isinstance(color, HighlightStandardColor):
				color = highlight.HighlightColor(color)
			line_buf[i].highlight = color._get_core_struct()
			line_buf[i].count = len(line.tokens)
			line_buf[i].tokens = function.InstructionTextToken.get_instruction_lines(line.tokens)
		core.BNSetFlowGraphNodeLines(self.handle, line_buf, len(lines))
Beispiel #2
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 = []
             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)
Beispiel #3
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 = []
         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
Beispiel #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)
Beispiel #5
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