text stringlengths 1 93.6k |
|---|
tokens += [[x, len(string), "ptr", value, string]]
|
x += len(string)
|
else:
|
result += string
|
else:
|
if plus:
|
result += '+'
|
value = instr.operands[j].immediate & 0xffffffff
|
string = "0x%.8x" % value
|
if (self.addr_size == 4) and hasattr(block.exe, "plt") and block.exe.plt.has_key(value):
|
# Pointer to PLT entry
|
self.plt = block.exe.plt[value]
|
if len(result) > 0:
|
line += [[result, Qt.black]]
|
x += len(result)
|
result = ""
|
string = block.exe.decorate_plt_name(self.plt)
|
line += [[string, QColor(0, 0, 192)]]
|
tokens += [[x, len(string), "ptr", value, string]]
|
x += len(string)
|
elif (self.addr_size == 4) and (value >= block.exe.start()) and (value < block.exe.end()):
|
# 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
|
result += ']'
|
else:
|
tokens += [[x + len(result), len(instr.operands[j].operand), "reg", instr.operands[j].operand]]
|
result += instr.operands[j].operand
|
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 get_prefix_count(self):
|
for count in range(0, len(self.opcode)):
|
if self.opcode[count] in ["\x26", "\x2e", "\x36", "\x3e", "\x64", "\x65", "\x66", "\x67", "\xf0", "\xf2", "\xf3"]:
|
continue
|
if (self.addr_size == 8) and (self.opcode[count] >= '\x40') and (self.opcode[count] <= "\x4f"):
|
continue
|
return count
|
return len(self.opcode)
|
def patch_to_nop(self, exe):
|
exe.write(self.addr, "\x90" * len(self.opcode))
|
def is_patch_branch_allowed(self):
|
return self.isConditionalBranch()
|
def patch_to_always_branch(self, exe):
|
prefix_count = self.get_prefix_count()
|
if self.opcode[prefix_count] == "\x0f":
|
# Two byte branch
|
exe.write(self.addr, ("\x90" * (prefix_count + 1)) + "\xb9" + self.opcode[prefix_count+2:])
|
else:
|
# One byte branch
|
exe.write(self.addr, ("\x90" * prefix_count) + "\xeb" + self.opcode[prefix_count+1:])
|
def patch_to_invert_branch(self, exe):
|
prefix_count = self.get_prefix_count()
|
if self.opcode[prefix_count] == "\x0f":
|
# Two byte branch
|
exe.write(self.addr, self.opcode[0:prefix_count+1] + chr(ord(self.opcode[prefix_count+1]) ^ 1) +
|
self.opcode[prefix_count+2:])
|
else:
|
# One byte branch
|
exe.write(self.addr, self.opcode[0:prefix_count] + chr(ord(self.opcode[prefix_count]) ^ 1) +
|
self.opcode[prefix_count+1:])
|
def is_patch_to_zero_return_allowed(self):
|
return self.isCall()
|
def patch_to_zero_return(self, exe):
|
exe.write(self.addr, "\x31\xc0" + ("\x90" * (len(self.opcode) - 2)))
|
def is_patch_to_fixed_return_value_allowed(self):
|
return self.isCall() and (len(self.opcode) >= 5)
|
def patch_to_fixed_return_value(self, exe, value):
|
if len(self.opcode) < 5:
|
return
|
exe.write(self.addr, "\xb8" + struct.pack("<I", value & 0xffffffff) + ("\x90" * (len(self.opcode) - 5)))
|
class PPCInstruction:
|
def __init__(self, opcode, addr, disasm):
|
self.opcode = opcode
|
self.addr = addr
|
self.disasm = disasm
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.