// Exports every function Ghidra found as: start_va size name kind // kind: fn | thunk | lib (FID-identified library code) // Usage: analyzeHeadless -import eqgame.exe -postScript ExportFunctions.java import ghidra.app.script.GhidraScript; import ghidra.program.model.address.*; import ghidra.program.model.listing.*; import ghidra.program.model.symbol.*; import java.io.*; public class ExportFunctions extends GhidraScript { @Override public void run() throws Exception { String out = getScriptArgs().length > 0 ? getScriptArgs()[0] : "functions.txt"; try (PrintWriter w = new PrintWriter(new FileWriter(out))) { for (Function f : currentProgram.getFunctionManager().getFunctions(true)) { if (f.isExternal()) continue; Address entry = f.getEntryPoint(); AddressRange r = f.getBody().getRangeContaining(entry); long size = r == null ? 0 : r.getMaxAddress().subtract(entry) + 1; String kind = f.isThunk() ? "thunk" : "fn"; Symbol s = f.getSymbol(); if (s.getSource() == SourceType.ANALYSIS && !s.getName().startsWith("FUN_")) kind = "lib"; w.printf("0x%08x 0x%x %s %s%n", entry.getOffset(), size, f.getName(true).replace(' ', '_'), kind); } } println("exported to " + out); } }