-
Notifications
You must be signed in to change notification settings - Fork 3
/
RemoveAllReferencesFromAddress.java
42 lines (38 loc) · 1.27 KB
/
RemoveAllReferencesFromAddress.java
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
31
32
33
34
35
36
37
38
39
40
41
42
//Remove all references from address.
//@author saruman9
//@category References
//@keybinding ctrl 1
//@menupath
//@toolbar
import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressIterator;
import ghidra.program.model.symbol.Reference;
import ghidra.util.Msg;
public class RemoveAllReferencesFromAddress extends GhidraScript {
@Override
protected void run() throws Exception {
if (currentProgram == null) {
Msg.showError(this,
null,
"Error",
"This script should be run from a tool with open program.");
return;
}
if (currentSelection != null) {
AddressIterator addresses = currentSelection.getAddresses(true);
while (addresses.hasNext()) {
Address address = addresses.next();
removeReferencesFromAddress(address);
}
} else {
removeReferencesFromAddress(currentAddress);
}
}
private void removeReferencesFromAddress(Address addressFrom) {
Reference[] references = getReferencesFrom(addressFrom);
for (Reference reference : references) {
removeReference(reference);
}
}
}