summaryrefslogtreecommitdiffstats
path: root/tools/ghidra/gsp-fwimage-570.144/scripts/Disasm.java
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ghidra/gsp-fwimage-570.144/scripts/Disasm.java')
-rw-r--r--tools/ghidra/gsp-fwimage-570.144/scripts/Disasm.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/ghidra/gsp-fwimage-570.144/scripts/Disasm.java b/tools/ghidra/gsp-fwimage-570.144/scripts/Disasm.java
new file mode 100644
index 0000000..68a8a52
--- /dev/null
+++ b/tools/ghidra/gsp-fwimage-570.144/scripts/Disasm.java
@@ -0,0 +1,29 @@
+import ghidra.app.script.GhidraScript;
+import ghidra.program.model.address.Address;
+import ghidra.program.model.listing.Instruction;
+import ghidra.program.model.listing.Listing;
+
+public class Disasm extends GhidraScript {
+ @Override
+ protected void run() throws Exception {
+ Listing listing = currentProgram.getListing();
+ String[] args = getScriptArgs();
+ for (String arg : args) {
+ String[] parts = arg.split(":");
+ Address start = toAddr(parts[0]);
+ int count = parts.length > 1 ? Integer.decode(parts[1]) : 60;
+ println("### DISASM " + start + " count=" + count);
+ Address cur = start;
+ for (int i = 0; i < count; i++) {
+ Instruction insn = listing.getInstructionAt(cur);
+ if (insn == null) {
+ try { disassemble(cur); } catch (Exception e) { println(" disasm stop: " + e); break; }
+ insn = listing.getInstructionAt(cur);
+ }
+ if (insn == null) { println(" no instruction at " + cur); break; }
+ println(" " + insn.getAddress() + ": " + insn.toString());
+ cur = insn.getMaxAddress().add(1);
+ }
+ }
+ }
+}