MSVC 7.1 (cl 13.10.3077) under Wine, PE/COFF matcher with relocation verification, side-by-side diff, progress, Ghidra-seeded symbol map (15,323 functions), and the first three matched functions (/O1). Co-Authored-By: Claude Opus 5.5 <[email protected]>
29 lines
1.4 KiB
Java
29 lines
1.4 KiB
Java
// Exports every function Ghidra found as: start_va size name kind
|
|
// kind: fn | thunk | lib (FID-identified library code)
|
|
// Usage: analyzeHeadless <proj> <name> -import eqgame.exe -postScript ExportFunctions.java <out.txt>
|
|
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);
|
|
}
|
|
}
|