mirror of
https://github.com/TheBozos/VP2S_Recomp.git
synced 2026-12-01 07:38:48 -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]>
56 lines
2.4 KiB
Java
56 lines
2.4 KiB
Java
// Locates functions referencing key strings (file access) and the 'SLZ' magic constant.
|
|
// @category VP2S
|
|
|
|
import java.util.*;
|
|
import ghidra.app.script.GhidraScript;
|
|
import ghidra.program.model.address.Address;
|
|
import ghidra.program.model.listing.*;
|
|
import ghidra.program.model.scalar.Scalar;
|
|
import ghidra.program.model.symbol.Reference;
|
|
|
|
public class FindKeyFunctions extends GhidraScript {
|
|
|
|
private static final String[] STRINGS = {"pfs0:vp2.bin", "cdrom0:\\IOPRP300.IMG;1", "hdd0:PP.SLES-54645", "pfs0:/res"};
|
|
// 'SLZ' as little-endian u32 prefix (0x005A4C53) and its upper half used by lui
|
|
private static final long[] CONSTS = {0x5A4C53L, 0x5A4CL, 0x4C53L};
|
|
|
|
@Override
|
|
public void run() throws Exception {
|
|
Listing listing = currentProgram.getListing();
|
|
FunctionManager fm = currentProgram.getFunctionManager();
|
|
|
|
for (String s : STRINGS) {
|
|
Address a = find(null, s.getBytes("ASCII"));
|
|
if (a == null) { println("string not found: " + s); continue; }
|
|
Set<String> users = new TreeSet<>();
|
|
for (Reference r : getReferencesTo(a)) {
|
|
Function f = fm.getFunctionContaining(r.getFromAddress());
|
|
users.add(f == null ? r.getFromAddress().toString() : f.getEntryPoint() + " " + f.getName());
|
|
}
|
|
println(String.format("'%s' @ %s used by %s", s, a, users));
|
|
}
|
|
|
|
Map<Long, Set<String>> hits = new HashMap<>();
|
|
InstructionIterator it = listing.getInstructions(true);
|
|
while (it.hasNext() && !monitor.isCancelled()) {
|
|
Instruction ins = it.next();
|
|
for (int op = 0; op < ins.getNumOperands(); op++) {
|
|
Scalar sc = ins.getScalar(op);
|
|
if (sc == null) continue;
|
|
long v = sc.getUnsignedValue();
|
|
for (long c : CONSTS) {
|
|
if (v == c) {
|
|
Function f = fm.getFunctionContaining(ins.getAddress());
|
|
hits.computeIfAbsent(c, k -> new TreeSet<>())
|
|
.add((f == null ? "?" : f.getEntryPoint().toString()) + ":" + ins.getAddress() + " " + ins);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (Map.Entry<Long, Set<String>> e : hits.entrySet()) {
|
|
println(String.format("const 0x%X: %s", e.getKey(), e.getValue()));
|
|
}
|
|
if (hits.isEmpty()) println("no SLZ constant found in main ELF code");
|
|
}
|
|
}
|