feat(extractor): extract scene modules (SCENE:DLLS=) like engines
A module DLL has no engine factory: its CMC_ExternObject::resolve compares TYPE (CXString::equals or operator==), allocates and constructs. The runner of each type is the vftable its constructor or a virtual installs whose prepare slot chains to CMC_Runner::prepareMthHashSet (defined when analysis left it out); registrations, dispatch, signatures, per-type events and fields then come from the engine passes, limited to the module's own runners. Snapshots record module_of (the host engine DLL). An unoptimised run() keeps the switch index in a stack slot; its bounds are followed through that slot only when the register match finds none. The batch queue extracts plugins too, the inventory knows MATRIX, QMAN, INERTIA and BOARD, and the tracker marks module-mapped types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f71cd9a90f
commit
4e65268a1e
@@ -1,4 +1,4 @@
|
||||
"""Resumable, SHA-addressed engine extraction queue (POSIX)."""
|
||||
"""Resumable, SHA-addressed extraction queue for engines and scene modules (POSIX)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
@@ -115,6 +115,10 @@ def execute_worker(source, output, log, timeout, env):
|
||||
raise RuntimeError('Extractor exited with code ' + str(code))
|
||||
|
||||
|
||||
# Engines and the scene modules (SCENE:DLLS=) that add script types; the extractor handles both.
|
||||
EXTRACTED_SCOPES = ('engine', 'plugin')
|
||||
|
||||
|
||||
def run_queue(manifest, out_dir, *, ghidra_home=None, timeout=1800, limit=None,
|
||||
retry_failed=False, worker=execute_worker):
|
||||
if timeout <= 0 or (limit is not None and limit < 0):
|
||||
@@ -146,7 +150,7 @@ def _run(builds, directory, ghidra_home, timeout, limit, retry_failed, worker):
|
||||
report = {'schema': 'extraction-batch/1', 'attempted': 0, 'succeeded': 0,
|
||||
'pending': 0, 'skipped_success': 0, 'skipped_failed': 0, 'skipped_scope': 0, 'failures': []}
|
||||
for build in builds:
|
||||
if build.get('scope') != 'engine':
|
||||
if build.get('scope') not in EXTRACTED_SCOPES:
|
||||
report['skipped_scope'] += 1
|
||||
continue
|
||||
sha = build['sha256']
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
const EVENT_STATUS={emitted:'emitowany w klasie typu',emitted_base:'emitowany w Variable',engine_literal:'literał w kodzie silnika',not_found:'brak literału w emulatorze'};
|
||||
const FIELD_STATUS={read:'czytane w obsłudze typu',read_base:'czytane w Variable',engine_literal:'literał w innym kodzie',not_found:'brak literału w emulatorze'};
|
||||
const MAPPING={explicit:'Jawne (klasa C++ z fabryki)',runner_factory:'CMC_RunnerFactory (typ → runner)',class_constructor:'Runner tworzony w konstruktorze klasy',inferred:'Wywnioskowane z nazwy'};
|
||||
const MAPPING={explicit:'Jawne (klasa C++ z fabryki)',runner_factory:'CMC_RunnerFactory (typ → runner)',module:'Moduł sceny DLLS (typ → runner obiektu)',class_constructor:'Runner tworzony w konstruktorze klasy',inferred:'Wywnioskowane z nazwy'};
|
||||
const $ = id => document.getElementById(id);
|
||||
const labels = {missing:'Brak rejestracji',registered:'Zarejestrowana',stub_candidate:'Podejrzenie stubu',partial:'Częściowa',implemented:'Zaimplementowana',unverified:'Niezweryfikowana',asm_reviewed:'Przegląd ASM',runtime_tested:'Test zachowania',stale:'Dowód wymaga aktualizacji'};
|
||||
let data, selected = null;
|
||||
|
||||
+5
-1
@@ -7,6 +7,10 @@ from pathlib import Path
|
||||
import re
|
||||
|
||||
|
||||
# Scene modules loaded by `SCENE:DLLS=`; each adds script types (QMAN: TEST).
|
||||
PLUGINS = {"WORLD.DLL", "KOLOROWANKA.DLL", "MATRIX.DLL", "QMAN.DLL", "INERTIA.DLL", "BOARD.DLL"}
|
||||
|
||||
|
||||
def inventory(roots: list[Path], snapshot_dir: Path | None = None) -> dict:
|
||||
extracted = set()
|
||||
if snapshot_dir:
|
||||
@@ -29,7 +33,7 @@ def inventory(roots: list[Path], snapshot_dir: Path | None = None) -> dict:
|
||||
family, scope = name.removesuffix(".DLL"), "engine"
|
||||
elif name.startswith("BLOOMOO"):
|
||||
family, scope = "BLOOMOO", "engine"
|
||||
elif name in ("WORLD.DLL", "KOLOROWANKA.DLL"):
|
||||
elif name in PLUGINS:
|
||||
family, scope = name.removesuffix(".DLL"), "plugin"
|
||||
elif name == "SEKAI.DLL":
|
||||
family, scope = "SEKAI", "native_dependency"
|
||||
|
||||
+6
-4
@@ -345,11 +345,13 @@ def script_fields(snap: Snapshot, scopes: dict | None = None) -> dict[str, list[
|
||||
def script_owners(snap: Snapshot, owners) -> dict[str, tuple[str, str]]:
|
||||
"""Script scope -> (method owner, provenance) for one binary.
|
||||
|
||||
`runner_map` (CMC_RunnerFactory, Piklib 7.1+/BlooMoo) is the engine's own dispatch table and
|
||||
wins: several types can share a runner (INTEGER/STRING/... -> Variable). Without it (Piklib
|
||||
6.1, plugins, older extractions) the C++ class or its name is the best available guess."""
|
||||
`runner_map` (CMC_RunnerFactory, Piklib 7.1+/BlooMoo; a scene module's types and the runner
|
||||
their objects install) is the engine's own dispatch table and wins: several types can share
|
||||
a runner (INTEGER/STRING/... -> Variable). Without it (Piklib 6.1, older extractions) the C++
|
||||
class or its name is the best available guess."""
|
||||
runner_map = snap.raw.get("runner_map") or {}
|
||||
by_type_id = {e["type_id"]: e["runner"].removesuffix("_Runner") for e in runner_map.get("by_type_id", [])}
|
||||
dispatched = "module" if runner_map.get("module") else "runner_factory" # a scene module's own resolve
|
||||
class_runner = {e["class"]: e["runner"].removesuffix("_Runner") for e in runner_map.get("by_class", [])}
|
||||
bases = {e["class"]: e["base_class"] for e in snap.field_inheritance}
|
||||
known_classes = set(class_runner) | set(bases) | set(bases.values())
|
||||
@@ -359,7 +361,7 @@ def script_owners(snap: Snapshot, owners) -> dict[str, tuple[str, str]]:
|
||||
for t in snap.types:
|
||||
name = canonical(t["script_name"])
|
||||
if t.get("type_id") in by_type_id:
|
||||
mappings[name] = (by_type_id[t["type_id"]], "runner_factory")
|
||||
mappings[name] = (by_type_id[t["type_id"]], dispatched)
|
||||
continue
|
||||
owner, mapping = t.get("cpp_class"), "explicit"
|
||||
# Known extractor failure: unrelated factory entries all mapped to Behaviour.
|
||||
|
||||
Reference in New Issue
Block a user