31 lines
1.2 KiB
Java
31 lines
1.2 KiB
Java
// GhidraScript: DumpPointers.java
|
|
// Usage:
|
|
// analyzeHeadless <projDir> <projName> -process <progName> -noanalysis -readOnly \
|
|
// -scriptPath tools/ghidra_scripts -postScript DumpPointers.java 0x006f8990 16
|
|
|
|
import ghidra.app.script.GhidraScript;
|
|
import ghidra.program.model.address.Address;
|
|
import ghidra.program.model.listing.Function;
|
|
|
|
public class DumpPointers extends GhidraScript {
|
|
@Override
|
|
public void run() throws Exception {
|
|
String[] args = getScriptArgs();
|
|
if (args == null || args.length < 1) {
|
|
printerr("DumpPointers: needs address and optional count");
|
|
return;
|
|
}
|
|
Address at = toAddr(Long.decode(args[0]));
|
|
int count = args.length >= 2 ? Integer.decode(args[1]) : 32;
|
|
for (int i = 0; i < count; i++) {
|
|
Address slot = at.add(i * 4L);
|
|
long ptr = getInt(slot) & 0xffffffffL;
|
|
Address dst = toAddr(ptr);
|
|
Function f = getFunctionAt(dst);
|
|
if (f == null) f = getFunctionContaining(dst);
|
|
String name = f == null ? "" : f.getName() + " @ " + f.getEntryPoint();
|
|
println(String.format("%s +0x%02x -> %08x %s", slot, i * 4, ptr, name));
|
|
}
|
|
}
|
|
}
|