Add segment coverage ledger and mid-project plan for Crusader decompilation

- 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.
This commit is contained in:
MaddoScientisto 2026-03-21 16:19:46 +01:00
commit 519af09912
42 changed files with 2444 additions and 3 deletions

View file

@ -0,0 +1,76 @@
TARGETS = [
"0004:5b8c",
"0004:5bbf",
"0004:5ea7",
"0004:6430",
"0009:92ad",
"0009:b1cd",
"000a:493e",
"000a:4a68",
"000a:b9e5",
"000a:ba66",
"000d:9d5e",
"000d:a3b7",
]
BEFORE_COUNT = 6
AFTER_COUNT = 8
listing = program.getListing()
address_factory = program.getAddressFactory()
def as_address(text):
segment_text, offset_text = text.split(":")
return address_factory.getAddress(f"{segment_text}:{offset_text}")
def collect_window(center):
instructions = []
current = listing.getInstructionContaining(center)
if current is None:
current = listing.getInstructionAt(center)
if current is None:
current = listing.getInstructionBefore(center)
if current is not None and current.getNext() is not None and current.getNext().getAddress() <= center:
current = current.getNext()
if current is None:
return instructions
cursor = current
for _ in range(BEFORE_COUNT):
cursor = cursor.getPrevious()
if cursor is None:
break
if cursor is None:
cursor = current
while cursor.getPrevious() is not None and len(instructions) < BEFORE_COUNT:
cursor = cursor.getPrevious()
while cursor is not None:
instructions.append(cursor)
if cursor == current:
break
cursor = cursor.getNext()
cursor = current.getNext()
while cursor is not None and len(instructions) < BEFORE_COUNT + AFTER_COUNT + 1:
instructions.append(cursor)
cursor = cursor.getNext()
return instructions
for target_text in TARGETS:
target = as_address(target_text)
print(f"=== {target} ===")
window = collect_window(target)
if not window:
print("<no instruction window>\n")
continue
for insn in window:
marker = "=>" if insn.getAddress() == target else " "
print(f"{marker} {insn.getAddress()} {insn}")
print("")

View file

@ -0,0 +1,34 @@
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}")

View file

@ -0,0 +1,17 @@
TARGET_HEX = ("4588", "458a")
listing = program.getListing()
function_manager = program.getFunctionManager()
instruction = listing.getInstructions(True)
while instruction.hasNext():
insn = instruction.next()
text = insn.toString().lower()
if not any(token in text for token in TARGET_HEX):
continue
address = insn.getAddress()
function = function_manager.getFunctionContaining(address)
function_name = function.getName() if function is not None else "<no function>"
print(f"{address} {function_name} {insn}")