-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc.py
More file actions
42 lines (34 loc) · 1.46 KB
/
Copy pathfunc.py
File metadata and controls
42 lines (34 loc) · 1.46 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
import csv
import ida_kernwin
import idc
import os
output_file_path = ida_kernwin.ask_file(1, "*.csv", "Select the CSV file to update, checked functions will be preserved")
def is_valid_name(name: str) -> bool:
return not name.startswith(("sub_", "nullsub_", "j_"))
# Load the existing csv if it exists
existing_data = {}
if output_file_path and os.path.exists(output_file_path):
with open(output_file_path, 'r', newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
address = row['Address']
existing_data[address] = row
if output_file_path:
with open(output_file_path, 'w', newline='') as csvfile:
fieldnames = ['Address', 'Quality', 'Size', 'Name']
csvwriter = csv.DictWriter(csvfile, fieldnames=fieldnames)
csvwriter.writeheader()
for func_addr in Functions():
func_name = idc.get_func_name(func_addr)
func_size = idc.get_func_attr(func_addr, FUNCATTR_END) - func_addr
address = f'0x{hex(func_addr)[2:].zfill(16)}'
quality = existing_data.get(address, {}).get('Quality', 'U')
csvwriter.writerow({
'Address': address,
'Quality': quality,
'Size': str(func_size).zfill(6),
'Name': func_name if is_valid_name(func_name) else ''
})
print(f"CSV file '{output_file_path}' has been updated.")
else:
print("Operation cancelled by the user.")