ExportSymbolsScript.py
1 from ghidra.program.model.symbol.SourceType import * 2 3 functionManager = currentProgram.getFunctionManager() 4 5 file_location = askFile("Choose a file to write to", "Go baby go!") 6 7 listing = currentProgram.getListing() 8 9 def export_function_symbols(file): 10 monitor.setMessage("Exporting function symbols...") 11 12 for f in functionManager.getFunctionsNoStubs(1): 13 monitor.checkCanceled() # throws exception if canceled 14 15 if f.isExternal() or f.isThunk(): 16 continue 17 18 func_name = f.getName() 19 20 if func_name.startswith("FUN_"): 21 continue 22 23 func_start_address = f.getBody().getMinAddress().getOffset() 24 func_end_address = f.getBody().getMaxAddress().getOffset() + 1 25 26 line_template = "{name} {start_address:08X} f end={end_address:08X}\n" 27 28 func_line = line_template.format(name = func_name, start_address = func_start_address, end_address = func_end_address) 29 30 file.write(func_line) 31 32 return 33 34 with open(file_location.absolutePath, "w") as file: 35 export_function_symbols(file) 36 file.close()