text
stringlengths
1
93.6k
self.plt = None
self.text = InstructionText()
self.target = None
if self.disasm.operation and self.disasm.operation.startswith('b') and (len(self.disasm.operands) > 0):
if type(disasm.operands[-1]) != str:
self.target = disasm.operands[-1]
def isConditionalBranch(self):
return self.disasm.operation in PPC.ConditionalBranches
def isLocalJump(self):
if self.disasm.operation in ["b", "ba"]:
return True
if self.isConditionalBranch():
return True
return False
def isCall(self):
return self.disasm.operation in PPC.CallInstructions
def isBlockEnding(self):
if self.disasm.operation in (PPC.BranchInstructions + ["trap"]):
return True
if self.isLocalJump():
return True
return False
def isValid(self):
return self.disasm.operation != None
def length(self):
return 4
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]
self.text.tokens += [tokens]
return (old_lines != self.text.lines) or (old_tokens != self.text.tokens)
result = ""
operation = instr.operation
if len(operation) < 7:
operation += " " * (7 - len(operation))
result += operation + " "
for j in range(0, len(instr.operands)):
if j != 0:
result += ", "
if 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: