- Created `crusader_segment_coverage_ledger.csv` to track segment coverage status, types, and known functions. - Introduced `plan-mid.md` as a mid-project tracker outlining progress, objectives, and implementation priorities for the decompilation effort. - Added scripts in `pyghidra_plans` to assist with instruction window dumping and reference inspection for the object at `0x4588`. - Implemented functionality to scan for instruction uses of specific targets related to the decompilation project.
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
from ghidra.program.model.symbol import RefType
|
|
|
|
|
|
TARGETS = {0x4588, 0x458A}
|
|
|
|
|
|
def format_addr(addr):
|
|
return addr.toString()
|
|
|
|
|
|
listing = program.getListing()
|
|
function_manager = program.getFunctionManager()
|
|
reference_manager = program.getReferenceManager()
|
|
|
|
seen = set()
|
|
|
|
for target in TARGETS:
|
|
addr = program.getAddressFactory().getDefaultAddressSpace().getAddress(target)
|
|
|
|
print(f"TARGET {format_addr(addr)}")
|
|
refs = reference_manager.getReferencesTo(addr)
|
|
iterator = refs.iterator() if hasattr(refs, "iterator") else refs
|
|
for ref in iterator:
|
|
from_addr = ref.getFromAddress()
|
|
function = function_manager.getFunctionContaining(from_addr)
|
|
key = (str(from_addr), str(addr))
|
|
if key in seen:
|
|
continue
|
|
seen.add(key)
|
|
instruction = listing.getInstructionContaining(from_addr)
|
|
code_unit = listing.getCodeUnitContaining(from_addr)
|
|
text = instruction.toString() if instruction is not None else code_unit.toString()
|
|
function_name = function.getName() if function is not None else "<no function>"
|
|
print(f" FROM {format_addr(from_addr)} {function_name} {ref.getReferenceType()} {text}")
|