Newer
Older
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);
}
}