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