From d6d6010f4e6c8db004e2499a327e8830e98a5d5d Mon Sep 17 00:00:00 2001 From: Patryk Gensch <43010113+patryk025@users.noreply.github.com> Date: Sat, 24 Oct 2026 21:03:10 +0200 Subject: [PATCH] fix(extractor): keep every Piklib 6.1 name and read ids of unoptimised builds getMethodId ids are now completed by run(CXString) names instead of replacing them, so a partial parse never drops methods. Pinokio's unoptimised build stores the id into a stack local, which the register- only and no-reference filters rejected (225 -> 103 methods). Co-Authored-By: Claude Opus 5.5 --- ghidra_scripts/extract_engine_surface.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ghidra_scripts/extract_engine_surface.py b/ghidra_scripts/extract_engine_surface.py index b1c8fb6..c0e04a2 100644 --- a/ghidra_scripts/extract_engine_surface.py +++ b/ghidra_scripts/extract_engine_surface.py @@ -403,19 +403,19 @@ def extract_methods_by_name(program): elif f.getName() == "run": runs.append((f, runner)) methods = [m for rows in with_ids.values() for m in rows] - seen = set() + # run(CXString) names complete getMethodId's: a name it lacks is kept without an id. + seen = set((m["runner"], m["name"].upper()) for m in methods) for f, runner in runs: - if runner in with_ids: - continue for m in _extract_name_methods_from_run(program, f, _owner_from_runner(runner), runner): - if (runner, m["name"]) not in seen: - seen.add((runner, m["name"])) + if (runner, m["name"].upper()) not in seen: + seen.add((runner, m["name"].upper())) methods.append(m) return methods def _method_ids(program, func, owner, runner): - """getMethodId's chain: `equalsIgnoreCase(name, "lit")`, then `MOV reg, id` on a match.""" + """getMethodId's chain: `equalsIgnoreCase(name, "lit")`, then `MOV , id` on a match - + a register in optimised builds, a stack local in unoptimised ones (Pinokio).""" out = [] seen = set() pending = None @@ -431,8 +431,9 @@ def _method_ids(program, func, owner, runner): if len(flows) == 1 and any(n == "equalsIgnoreCase" for _, n in _labels(program, flows[0])): armed, pending = pending, None elif armed is not None and mn == "MOV" and instr.getNumOperands() == 2 \ - and "[" not in instr.getDefaultOperandRepresentation(0) \ - and instr.getScalar(1) is not None and not instr.getReferencesFrom(): + and "[" not in instr.getDefaultOperandRepresentation(1) and instr.getScalar(1) is not None: + # No reference check: a stack-local destination carries a stack reference, and + # the < 0x10000 bound below already rules out address immediates. value = _s32(instr.getScalar(1).getValue()) if 0 <= value < 0x10000 and armed not in seen: seen.add(armed)