blob: 65d4b7f2eebab65f1b2614f769fdc773e3947620 (
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
30
|
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.program.model.symbol.Reference;
import ghidra.program.model.symbol.ReferenceIterator;
import ghidra.program.model.symbol.ReferenceManager;
public class Xrefs extends GhidraScript {
@Override
protected void run() throws Exception {
String[] args = getScriptArgs();
ReferenceManager rm = currentProgram.getReferenceManager();
FunctionManager fm = currentProgram.getFunctionManager();
for (String arg : args) {
Address target = toAddr(arg.trim());
println("### XREFS to " + target);
ReferenceIterator it = rm.getReferencesTo(target);
int n = 0;
while (it.hasNext()) {
Reference r = it.next();
Address from = r.getFromAddress();
Function f = fm.getFunctionContaining(from);
println(" from " + from + " (" + (f != null ? f.getName() + "@" + f.getEntryPoint() : "?") + ") type=" + r.getReferenceType());
n++;
}
println(" total=" + n);
}
}
}
|