text
stringlengths
1
93.6k
tokens += [[x + len(result), len(instr.operands[j]), "reg", instr.operands[j]]]
result += instr.operands[j]
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):
exe.write(self.addr, "\x60\x00\x00\x00")
def is_patch_branch_allowed(self):
return self.isConditionalBranch()
def patch_to_always_branch(self, exe):
pass
def patch_to_invert_branch(self, exe):
pass
def is_patch_to_zero_return_allowed(self):
return self.isCall()
def patch_to_zero_return(self, exe):
pass
def is_patch_to_fixed_return_value_allowed(self):
return self.isCall()
def patch_to_fixed_return_value(self, exe, value):
pass
class ArmInstruction:
def __init__(self, opcode, addr, disasm):
self.opcode = opcode
self.addr = addr
self.disasm = disasm
self.plt = None
self.text = InstructionText()
self.target = None
if self.disasm.operation and ((self.disasm.operation == "b") or (self.disasm.operation == "bx") or (self.disasm.operation == "bl") or (self.disasm.operation == "blx")) and (type(self.disasm.operands[0]) != str):
self.target = disasm.operands[0]
elif self.disasm.operation and ((self.disasm.operation[0:2] == "b.") or (self.disasm.operation[0:3] == "bx.") or (self.disasm.operation[0:3] == "bl.") or (self.disasm.operation[0:4] == "blx.")) and (type(self.disasm.operands[0]) != str):
self.target = disasm.operands[0]
def isConditionalBranch(self):
if self.disasm.operation and ((self.disasm.operation[0:2] == "b.") or (self.disasm.operation[0:3] == "bx.")) and (self.target is not None):
return True
return False
def isLocalJump(self):
if self.disasm.operation and ((self.disasm.operation == "b") or (self.disasm.operation == "bx")) and (self.target is not None):
return True
return self.isConditionalBranch()
def isCall(self):
return self.disasm.operation and ((self.disasm.operation == "bl") or (self.disasm.operation == "blx") or (self.disasm.operation[0:3] == "bl.") or (self.disasm.operation[0:4] == "blx."))
def isBlockEnding(self):
if self.isLocalJump():
return True
if self.disasm.operation and ((self.disasm.operation == "b") or (self.disasm.operation == "bx")):
return True
if self.disasm.operation and (self.disasm.operation[0:3] == "ldm") and ("pc" in self.disasm.operands[1:]):
return True
if self.disasm.operation and (self.disasm.operation == "ldr") and (self.disasm.operands[0] == "pc"):
return True
if self.disasm.operation and (self.disasm.operation == "pop") and ("pc" in self.disasm.operands):
return True
return False
def isValid(self):
return self.disasm.operation != None
def length(self):
return self.disasm.length
def format_text(self, block, options):
old_lines = []
old_tokens = []
self.text.lines = []
self.text.tokens = []
line = []
tokens = []
x = 0
instr = self.disasm
if "address" in options:
string = "%.8x " % self.addr
line += [[string, QColor(0, 0, 128)]]
x += len(string)
if instr.operation == None:
line += [["??", Qt.black]]
self.text.lines += [line]