|
|
|
@ -115,6 +115,21 @@ def decompile(addr):
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def decompile_context(addr, context_lines):
|
|
|
|
|
|
|
|
cfunc = decompile(addr)
|
|
|
|
|
|
|
|
if cfunc is None:
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
item = cfunc.body.find_closest_addr(addr)
|
|
|
|
|
|
|
|
y_holder = idaapi.int_pointer()
|
|
|
|
|
|
|
|
if not cfunc.find_item_coords(item, None, y_holder):
|
|
|
|
|
|
|
|
return cfunc
|
|
|
|
|
|
|
|
y = y_holder.value()
|
|
|
|
|
|
|
|
lines = cfunc.get_pseudocode()
|
|
|
|
|
|
|
|
retlines = (idaapi.tag_remove(lines[lnnum].line) for lnnum
|
|
|
|
|
|
|
|
in range(max(0, y - context_lines),min(len(lines), y + context_lines)))
|
|
|
|
|
|
|
|
return '\n'.join(retlines)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def versions():
|
|
|
|
def versions():
|
|
|
|
"""Returns IDA & Python versions"""
|
|
|
|
"""Returns IDA & Python versions"""
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
@ -131,6 +146,7 @@ register_module(idautils)
|
|
|
|
register_module(idaapi)
|
|
|
|
register_module(idaapi)
|
|
|
|
server.register_function(lambda a: eval(a, globals(), locals()), 'eval')
|
|
|
|
server.register_function(lambda a: eval(a, globals(), locals()), 'eval')
|
|
|
|
server.register_function(wrap(decompile)) # overwrites idaapi/ida_hexrays.decompile
|
|
|
|
server.register_function(wrap(decompile)) # overwrites idaapi/ida_hexrays.decompile
|
|
|
|
|
|
|
|
server.register_function(wrap(decompile_context), 'decompile_context') # support context decompile
|
|
|
|
server.register_function(versions)
|
|
|
|
server.register_function(versions)
|
|
|
|
server.register_introspection_functions()
|
|
|
|
server.register_introspection_functions()
|
|
|
|
|
|
|
|
|
|
|
|
|