mirror of
https://github.com/TheBozos/VP2S_Recomp.git
synced 2026-12-01 12:54:45 -10:00
- 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]>
32 lines
1.4 KiB
Java
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));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|