text
stringlengths
1
93.6k
result += string
result += "]"
if instr.operands[j].writeback:
result += "!"
elif type(instr.operands[j]) != str:
value = instr.operands[j]
if instr.operands[j] < 0:
string = "-0x%x" % -instr.operands[j]
else:
string = "0x%x" % instr.operands[j]
if block.analysis.functions.has_key(value):
# Pointer to existing function
func = block.analysis.functions[value]
string = func.name
if func.plt:
color = QColor(192, 0, 192)
else:
color = QColor(0, 0, 192)
if len(result) > 0:
line += [[result, Qt.black]]
x += len(result)
result = ""
line += [[string, color]]
tokens += [[x, len(string), "ptr", value, string]]
x += len(string)
elif (value >= block.exe.start()) and (value < block.exe.end()) and (not self.isLocalJump()):
# Pointer within module
if len(result) > 0:
line += [[result, Qt.black]]
x += len(result)
result = ""
if value in block.exe.symbols_by_addr:
string = block.exe.symbols_by_addr[value]
line += [[string, QColor(0, 0, 192)]]
tokens += [[x, len(string), "ptr", value, string]]
x += len(string)
else:
result += string
else:
if instr.operands[j][0] == "-":
tokens += [[x + len(result) + 1, len(instr.operands[j]) - 1, "reg", instr.operands[j][1:]]]
elif instr.operands[j][-1] == "!":
tokens += [[x + len(result), len(instr.operands[j]) - 1, "reg", instr.operands[j][:-1]]]
else:
tokens += [[x + len(result), len(instr.operands[j]), "reg", instr.operands[j]]]
result += instr.operands[j]
if (instr.operation == "ldr") and (instr.operands[1].__class__ == Arm.MemoryOperand) and (len(instr.operands[1].components) == 1) and (type(instr.operands[1].components[0]) != str) and (type(instr.operands[1].components[0]) != list):
addr = instr.operands[1].components[0]
if (addr >= block.exe.start()) and ((addr + 4) <= block.exe.end()):
result += " ; ="
value = block.exe.read_uint32(addr)
string = "0x%x" % value
if block.analysis.functions.has_key(value):
# Pointer to existing function
func = block.analysis.functions[value]
string = func.name
if func.plt:
color = QColor(192, 0, 192)
else:
color = QColor(0, 0, 192)
if len(result) > 0:
line += [[result, Qt.black]]
x += len(result)
result = ""
line += [[string, color]]
tokens += [[x, len(string), "ptr", value, string]]
x += len(string)
elif (value >= block.exe.start()) and (value < block.exe.end()) and (not self.isLocalJump()):
# Pointer within module
if len(result) > 0:
line += [[result, Qt.black]]
x += len(result)
result = ""
if value in block.exe.symbols_by_addr:
string = block.exe.symbols_by_addr[value]
line += [[string, QColor(0, 0, 192)]]
tokens += [[x, len(string), "ptr", value, string]]
x += len(string)
else:
result += string
if len(result) > 0:
line += [[result, Qt.black]]
self.text.lines += [line]
self.text.tokens += [tokens]
return (old_lines != self.text.lines) or (old_tokens != self.text.tokens)
def patch_to_nop(self, exe):
if self.addr & 1:
if self.disasm.length == 4:
exe.write(self.addr & (~1), "\x00\x46\x00\x46")
else:
exe.write(self.addr & (~1), "\x00\x46")
else:
exe.write(self.addr, "\x00\x00\xa0\xe1")
def is_patch_branch_allowed(self):
return self.isConditionalBranch()