Files
Thomas MartinandClaude Opus 5.5 0cfd512cf4 Add disc extractor, reverse-engineering tools and feasibility audit
- tools/extract.py: pure-Python extractor for SLES-54645 (ISO9660, SLZ chains,
  SLE decryption, module/overlay export with ELF segment validation, IRX, index)
- tools/slz.py: tri-Ace SLZ types 0-3 and SLE decryption, reimplemented from
  the game's own routines
- scripts/, ghidra_scripts/: exploration scripts used during the audit
- toolchain/Dockerfile: analysis container (binutils MIPS, Python)
- docs/AUDIT.md: phase 1 and 2 feasibility audit (GO for static recompilation)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 18:57:22 +02:00

32 lines
1.4 KiB
Java

// Lists every instruction using one of the given immediate values, grouped by function.
// Args: <hex value> [hex value...]
// @category VP2S
import java.util.*;
import ghidra.app.script.GhidraScript;
import ghidra.program.model.listing.*;
import ghidra.program.model.scalar.Scalar;
public class FindScalar extends GhidraScript {
@Override
public void run() throws Exception {
Set<Long> wanted = new HashSet<>();
for (String a : getScriptArgs()) wanted.add(Long.parseLong(a.replaceFirst("^0x", ""), 16));
FunctionManager fm = currentProgram.getFunctionManager();
InstructionIterator it = currentProgram.getListing().getInstructions(true);
while (it.hasNext() && !monitor.isCancelled()) {
Instruction ins = it.next();
for (int op = 0; op < ins.getNumOperands(); op++) {
Scalar s = ins.getScalar(op);
// MIPS immediates are 16-bit and often sign-extended: also match on the low 16 bits
if (s != null && (wanted.contains(s.getUnsignedValue()) || wanted.contains(s.getValue())
|| wanted.contains(s.getValue() & 0xffffL))) {
Function f = fm.getFunctionContaining(ins.getAddress());
println(String.format("%s %s : %s", f == null ? "?" : f.getEntryPoint(), ins.getAddress(), ins));
}
}
}
}
}