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 <noreply@anthropic.com>
This commit is contained in:
Patryk Gensch
2026-10-24 21:03:10 +02:00
co-authored by Claude Opus 5.5
parent 95ad4edb5c
commit d6d6010f4e
+9 -8
View File
@@ -403,19 +403,19 @@ def extract_methods_by_name(program):
elif f.getName() == "run": elif f.getName() == "run":
runs.append((f, runner)) runs.append((f, runner))
methods = [m for rows in with_ids.values() for m in rows] 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: 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): for m in _extract_name_methods_from_run(program, f, _owner_from_runner(runner), runner):
if (runner, m["name"]) not in seen: if (runner, m["name"].upper()) not in seen:
seen.add((runner, m["name"])) seen.add((runner, m["name"].upper()))
methods.append(m) methods.append(m)
return methods return methods
def _method_ids(program, func, owner, runner): 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 <dst>, id` on a match -
a register in optimised builds, a stack local in unoptimised ones (Pinokio)."""
out = [] out = []
seen = set() seen = set()
pending = None 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])): if len(flows) == 1 and any(n == "equalsIgnoreCase" for _, n in _labels(program, flows[0])):
armed, pending = pending, None armed, pending = pending, None
elif armed is not None and mn == "MOV" and instr.getNumOperands() == 2 \ elif armed is not None and mn == "MOV" and instr.getNumOperands() == 2 \
and "[" not in instr.getDefaultOperandRepresentation(0) \ and "[" not in instr.getDefaultOperandRepresentation(1) and instr.getScalar(1) is not None:
and instr.getScalar(1) is not None and not instr.getReferencesFrom(): # 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()) value = _s32(instr.getScalar(1).getValue())
if 0 <= value < 0x10000 and armed not in seen: if 0 <= value < 0x10000 and armed not in seen:
seen.add(armed) seen.add(armed)