Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ghidra.app.script.GhidraScript;
- import ghidra.program.model.util.*;
- import ghidra.program.model.reloc.*;
- import ghidra.program.model.data.*;
- import ghidra.program.model.block.*;
- import ghidra.program.model.symbol.*;
- import ghidra.program.model.scalar.*;
- import ghidra.program.model.mem.*;
- import ghidra.program.model.listing.*;
- import ghidra.program.model.lang.*;
- import ghidra.program.model.pcode.*;
- import ghidra.program.model.address.*;
- public class ReferencesCleanup extends GhidraScript {
- public void run() throws Exception {
- SymbolTable st = state.getCurrentProgram().getSymbolTable();
- java.util.List<Symbol> sym = st.getGlobalSymbols("start");
- Address start = sym.get(0).getAddress();
- println(String.format("Starting at %s", start.toString()));
- ReferenceManager refMgr = currentProgram.getReferenceManager();
- ReferenceIterator iter = refMgr.getReferenceIterator(start);
- while (iter.hasNext()) {
- Reference ref = iter.next();
- Address from = ref.getFromAddress();
- Address to = ref.getToAddress();
- RefType refType = ref.getReferenceType();
- SourceType sourceType = ref.getSource();
- int index = ref.getOperandIndex();
- if (to.toString().startsWith("0")) {
- println(String.format("Ref from %s to %s: %d", from.toString(), to.toString(), index));
- refMgr.delete(ref);
- refMgr.addMemoryReference(from, to.add(0x10000), refType, sourceType, index);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement