ejschwartz commited on
Commit
dee983b
·
1 Parent(s): b1add05

Add script to list functions

Browse files
Files changed (1) hide show
  1. scripts/dump_functions.py +34 -0
scripts/dump_functions.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ def dump_functions_to_json():
4
+ functionManager = currentProgram().getFunctionManager()
5
+ functions = functionManager.getFunctions(True)
6
+
7
+ # Create a dictionary to store function names and their corresponding addresses
8
+ functions_dict = {}
9
+
10
+ for func in functions:
11
+ func_name = func.getName()
12
+ func_address = func.getEntryPoint().toString()
13
+
14
+ # Add function name and address to the dictionary
15
+ functions_dict[func_address] = func_name
16
+
17
+ # Convert the dictionary to a JSON object
18
+ json_data = json.dumps(functions_dict, indent=4)
19
+
20
+ args = getScriptArgs()
21
+
22
+ if len(args) == 0:
23
+
24
+ # Print JSON output to the console
25
+ print(json_data)
26
+
27
+ else:
28
+
29
+ # Write JSON output to a file
30
+ with open(args[0], 'w') as f:
31
+ f.write(json_data)
32
+
33
+ # Run the function
34
+ dump_functions_to_json()