GhidraRPXLoader/ghidra_scripts/fix_primary_imports.java
2023-11-01 18:39:00 +01:00

38 lines
1.1 KiB
Java
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Sets all imported references to primary
//@author GaryOderNichts
//@category wiiu
//@keybinding
//@menupath
//@toolbar
import ghidra.app.script.GhidraScript;
import ghidra.program.model.mem.*;
import ghidra.program.model.lang.*;
import ghidra.program.model.pcode.*;
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.listing.*;
import ghidra.program.model.address.*;
public class fix_primary_imports extends GhidraScript {
public void run() throws Exception {
ReferenceManager refManager = currentProgram.getReferenceManager();
ReferenceIterator it = refManager.getReferenceIterator(currentProgram.getMinAddress());
while (it.hasNext()) {
Reference ref = it.next();
if (ref.getSource() == SourceType.IMPORTED) {
println("Setting primary reference for " + ref.getFromAddress().toString());
refManager.setPrimary(ref, true);
}
}
}
}