diff options
Diffstat (limited to 'tools/ghidra/gsp-fwimage-570.144/scripts/DumpFuncs.java')
| -rw-r--r-- | tools/ghidra/gsp-fwimage-570.144/scripts/DumpFuncs.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/ghidra/gsp-fwimage-570.144/scripts/DumpFuncs.java b/tools/ghidra/gsp-fwimage-570.144/scripts/DumpFuncs.java new file mode 100644 index 0000000..6948492 --- /dev/null +++ b/tools/ghidra/gsp-fwimage-570.144/scripts/DumpFuncs.java @@ -0,0 +1,35 @@ +import ghidra.app.script.GhidraScript; +import ghidra.program.model.address.Address; +import ghidra.program.model.listing.Function; +import ghidra.program.model.listing.FunctionManager; +import ghidra.app.decompiler.DecompInterface; +import ghidra.app.decompiler.DecompileResults; +import ghidra.util.task.TaskMonitor; + +public class DumpFuncs extends GhidraScript { + @Override + protected void run() throws Exception { + String[] args = getScriptArgs(); + FunctionManager fm = currentProgram.getFunctionManager(); + DecompInterface decompiler = new DecompInterface(); + decompiler.openProgram(currentProgram); + for (String arg : args) { + String s = arg.trim(); + Address addr = toAddr(s); + Function func = fm.getFunctionContaining(addr); + if (func == null) { + func = createFunction(addr, null); + } + println("### FUNC " + s + " -> " + (func != null ? func.getName() + " @ " + func.getEntryPoint() : "NOT FOUND")); + if (func != null) { + DecompileResults res = decompiler.decompileFunction(func, 120, monitor); + if (res != null && res.decompileCompleted()) { + println(res.getDecompiledFunction().getC()); + } else { + println("// decompile failed: " + (res != null ? res.getErrorMessage() : "null")); + } + } + } + decompiler.dispose(); + } +} |
