Commit 797ab5c2 authored by Andrea Gussoni's avatar Andrea Gussoni
Browse files

Add Ghidra decompilation plugin

parent cef588a1
private void exportToC(DecompileResults results ) {
try {
ClangTokenGroup grp = results.getCCodeMarkup();
if (grp != null) {
File tmpFile = new File("~/headless-sources" +
"/" + results.getFunction().getName() + ".c");
PrintWriter writer = new PrintWriter(new FileOutputStream(tmpFile));
PrettyPrinter printer = new PrettyPrinter(results.getFunction(), grp);
DecompiledFunction decompFunc = printer.print(true);
writer.write(decompFunc.getC());
writer.close();
}
}
catch (IOException e) {
System.out.println(e.getStackTrace());
}
}
@Override
public void run() throws Exception {
var program = this.getCurrentProgram();
DecompInterface ifc = new DecompInterface();
ifc.openProgram(program);
for (var func : program.getFunctionManager().getFunctions(true)) {
var results = ifc.decompileFunction(func, 100000, null);
exportToC(results);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment