mirror of
https://github.com/idapython/src
synced 2026-06-08 14:47:00 +00:00
38 lines
772 B
Python
38 lines
772 B
Python
"""
|
|
summary: decompile & print current function
|
|
|
|
description:
|
|
Decompile the function under the cursor
|
|
|
|
level: beginner
|
|
"""
|
|
|
|
import ida_hexrays
|
|
import ida_lines
|
|
import ida_funcs
|
|
import ida_kernwin
|
|
|
|
def main():
|
|
if not ida_hexrays.init_hexrays_plugin():
|
|
return False
|
|
|
|
print("Hex-rays version %s has been detected" % ida_hexrays.get_hexrays_version())
|
|
|
|
f = ida_funcs.get_func(ida_kernwin.get_screen_ea());
|
|
if f is None:
|
|
print("Please position the cursor within a function")
|
|
return True
|
|
|
|
cfunc = ida_hexrays.decompile(f);
|
|
if cfunc is None:
|
|
print("Failed to decompile!")
|
|
return True
|
|
|
|
sv = cfunc.get_pseudocode();
|
|
for sline in sv:
|
|
print(ida_lines.tag_remove(sline.line));
|
|
|
|
return True
|
|
|
|
main()
|