forked from maiyao1988/IDAScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_all_code.py
More file actions
30 lines (23 loc) · 729 Bytes
/
get_all_code.py
File metadata and controls
30 lines (23 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
funName = idc.AskStr("JNI_OnLoad", "function name")
funAddr = LocByName(funName)
if funAddr == BADADDR:
print("funName %s not found"%funName)
raise RuntimeError("funName %s not found"%funName)
#
funEndAddr = FindFuncEnd(funAddr)
heads = Heads(funAddr, funEndAddr)
script_path = os.path.split(os.path.realpath(__file__))[0]
name = os.path.splitext(idc.get_root_filename())[0]
out_path = "%s/codes-%s-%s.txt"%(script_path, name, funName)
count = 0
with open(out_path, "w") as f:
for h in heads:
if GetMnem(h) != '':
line = "[0x%08X] %s\n"%(h, GetDisasm(h))
f.write(line)
count = count+1
#
#
#
print("ins count %d"%count)
print("file output to %s"%out_path)