blob: 68a8a526191fe76264401a1393aefb6b3235baf0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
}
}
}
}
|