Skip to content

Instantly share code, notes, and snippets.

@alexander-hanel
Created February 12, 2024 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexander-hanel/10264b06e73f19c68fd1f0b853a21513 to your computer and use it in GitHub Desktop.
Save alexander-hanel/10264b06e73f19c68fd1f0b853a21513 to your computer and use it in GitHub Desktop.
A hackish way to extract arguments passed to a function from hex-rays decompiler output
import idautils
ea = 0x000000140013188
name = ida_name.get_ea_name(ea)
print("found")
# get xrefs to function
xrefs = [x for x in idautils.CodeRefsTo(ea, 0)]
for func in xrefs:
args = []
cfunc = idaapi.decompile(func)
sv = cfunc.get_pseudocode()
comment_len = ida_name.get_ea_name(func)
comment_flag = False
c = 1
for index, sline in enumerate(sv):
tt = idaapi.tag_remove(sline.line)
if name in tt and comment_flag != True:
args.append(tt.rstrip().lstrip())
comment_flag = True
continue
# print lines
if comment_flag:
if ";" in tt:
break
args.append(tt.rstrip().lstrip())
print(hex(func), args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment