Spaces:
Running
Running
import json | |
def dump_functions_to_json(): | |
functionManager = currentProgram().getFunctionManager() | |
functions = functionManager.getFunctions(True) | |
# Create a dictionary to store function names and their corresponding addresses | |
functions_dict = {} | |
for func in functions: | |
if func.isExternal() or func.isThunk(): | |
continue | |
func_name = func.getName() | |
func_address = func.getEntryPoint().getOffset() | |
# Add function name and address to the dictionary | |
functions_dict[func_address] = func_name | |
# Convert the dictionary to a JSON object | |
json_data = json.dumps(functions_dict, indent=4) | |
args = getScriptArgs() | |
if len(args) == 0: | |
# Print JSON output to the console | |
print(json_data) | |
else: | |
# Write JSON output to a file | |
with open(args[0], 'w') as f: | |
f.write(json_data) | |
# Run the function | |
dump_functions_to_json() | |