From a176c637362a63363094a51dbc585e05aa7c0d52 Mon Sep 17 00:00:00 2001 From: ulw-execute Date: Sat, 28 Nov 2026 20:37:18 -0500 Subject: [PATCH] docs: scope spec + RE to the official clean release only Reference only the official KDM-2016021900 game: the 9 Konami modules in contents/modules/ plus data/arkdata/prop. Remove community/PC-hardware glue (deahook/DEALibacio, spice2x/spicetools, launcher.exe, gamestart.bat, bemanitools, NVENC/CUDA stubs) and non-release modules (kmd/ksm/kuc/libinput/ libacio_mbr) as game evidence. Correct the "22-DLL" framing to the real 9-module set; reframe the boot chain on arkkdm.dll's own dll_entry_init/ dll_entry_main -> gameMain binding. Kinect10.dll referenced only as gamekdm's external Microsoft NUI runtime dependency. Fix ea3-config.xml -> eamuse-config.xml. Per-byte sizes/RVAs from the earlier contaminated install marked UNVERIFIED pending re-check against the clean-release binary. --- README.md | 134 +++++ docs/companion-conventions.md | 38 +- docs/companion-inventory.md | 387 ++++----------- docs/conventions.md | 4 +- docs/cutover.md | 6 +- docs/pipeline.md | 24 +- docs/re/gamemain-binding.md | 351 +++++--------- docs/spec/00-overview.md | 183 +++---- docs/spec/01-runtime-boot.md | 540 ++++++--------------- docs/spec/02-dll-architecture.md | 299 +++++------- docs/spec/03-kinect-skeleton.md | 37 +- docs/spec/05-data-formats.md | 152 ++---- docs/spec/07-companion-apis.md | 617 +++++------------------- docs/spec/08-abi-conventions.md | 19 +- docs/spec/09-reconstruction-codebase.md | 39 +- docs/spec/README.md | 80 +-- game-internals.md | 107 +--- 17 files changed, 1038 insertions(+), 1979 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c586df2 --- /dev/null +++ b/README.md @@ -0,0 +1,134 @@ +# kdm-re + +A reverse-engineering and reconstruction project for **DanceEvolution Arcade** +(DEA) — a Konami arcade Kinect dance game whose game logic ships as +`gamekdm.dll` (internal engine/module codename **KDM**). The goal is to rebuild +`gamekdm.dll`'s observable behavior from static and dynamic analysis of the +shipped binary, one function at a time, each proven behaviorally equal to the +original before it is shipped. + +> **Behavioral, not byte-identical.** Given the same inputs, the reconstruction +> aims to produce the same outputs and global-state effects as the original — +> proven function-by-function — not to reproduce the original machine code. The +> toolchain (MinGW/GCC, i686) differs from the original's (MSVC/VS2010 SP1) by +> construction. + +## What the game is + +DEA is a Konami arcade dance game driven by a Kinect sensor: the player dances +in front of a depth camera and the game scores the match between the tracked +body pose and the choreography. It targets **Win32 x86** on Konami's **AVS2** +middleware stack, with the **ARK** cabinet engine (`arkkdm.dll`) and +**e-Amusement v3** networking. The game analyzed throughout is the clean +**`KDM-2016021900`** release. The main logic DLL, `gamekdm.dll` (PE32 x86), +exports a single symbol, `gameMain` (RVA `0x00009e20`, cdecl), and contains +**9,728** functions tracked in `re/rvadb.json`. + +### Official scope + +The spec and reverse engineering reference **only the official game** — the +clean release's `contents/` tree: its asset/config trees (`data/`, +`arkdata/`, `prop/`) and exactly **9 Konami modules** in `contents/modules/`: +`libavs-win32.dll`, `libavs-win32-ea3.dll`, `libafp-win32.dll`, +`libafputils-win32.dll`, `ess.dll`, `libacio.dll`, `arkkdm.dll`, +`arkkdmtest.dll`, `gamekdm.dll`. Community or PC-hardware glue that may appear +in a non-clean install — `launcher.exe`, `deahook.dll`, spice2x/bemanitools, +NVENC/CUDA stubs, a Kinect shim, and non-release Konami modules — is **not** +part of the game and is not used as evidence. `Kinect10.dll` (Microsoft's +Kinect-for-Windows NUI runtime) is referenced only as an external dependency +that `gamekdm.dll`'s import table requires, never as a shipped game module. +See [`docs/companion-inventory.md`](docs/companion-inventory.md). + +## Repository layout + +| Path | What it holds | +|---|---| +| `docs/spec/` | The full technical specification — start here (see below). | +| `docs/` | Process docs: `companion-inventory.md`, `conventions.md`, `pipeline.md`, `reconstruction-loop.md`, `cutover.md`, `provenance.md`. | +| `src/`, `include/` | The hand-reviewed MinGW C/C++ reconstruction, layered by subsystem (`game`, `gs`, `render`, `movie`, `particle`, `mm`, `ui`, `util`, `platform`, `hybrid`, `pure`, `entry`). | +| `re/` | The RVA function database (`rvadb.json`, 9,728 records), `pure-slice-status.json`, import libs, and AVS notes. | +| `tools/` | `unicorn_diff/` (the differential verifier), `ghidra/` helpers, `gen_importlibs.sh`. | +| `tests/` | Golden-I/O fixtures, import-lib checks, smoke tests. | +| `cmake/` | `toolchain-mingw-i686.cmake` (cross toolchain file) and `check_pure_coverage.py` (the fail-closed coverage gate). | +| `activate.sh` | Sources the pinned no-sudo i686-w64-mingw32 cross toolchain + wine onto `PATH`. | +| `toolchain.lock` | Exact toolchain provenance (nixpkgs rev, package versions, store paths). | +| `orig/`, `export/`, `bin/` | Gitignored originals drop zone, the hand-authored `gamekdm.def`, and the `activate.sh`-generated tool aliases. | + +## Specification + +The authoritative, fully-cited technical spec lives in **[`docs/spec/`](docs/spec/README.md)**. +Every claim in it is grounded in a real artifact (a `file:line`, an RVA, an +`objdump` listing, or a game-dir path); anything unverifiable is marked +`UNVERIFIED`. Sections: + +- [00 — Overview and high-level architecture](docs/spec/00-overview.md) +- [01 — Runtime environment and boot/startup chain](docs/spec/01-runtime-boot.md) +- [02 — DLL architecture and dependency graph](docs/spec/02-dll-architecture.md) +- [03 — Kinect input and skeleton pipeline](docs/spec/03-kinect-skeleton.md) +- [04 — Player validity gate and menu hand cursor](docs/spec/04-validity-cursor.md) +- [05 — Data formats](docs/spec/05-data-formats.md) +- [06 — gamekdm.dll subsystem map](docs/spec/06-gamekdm-subsystems.md) +- [07 — Companion DLL API surfaces](docs/spec/07-companion-apis.md) +- [08 — ABI, calling conventions, and struct layouts](docs/spec/08-abi-conventions.md) +- [09 — The kdm-re reconstruction codebase](docs/spec/09-reconstruction-codebase.md) + +## Build + +The build targets a 32-bit Windows DLL and **never touches system packages** — +it uses a pinned, no-sudo i686-w64-mingw32 cross toolchain plus wine, sourced +onto `PATH` by `activate.sh`. + +```bash +source ./activate.sh # must be sourced, not executed +cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw-i686.cmake +cmake --build build +i686-w64-mingw32-objdump -p build/gamekdm.dll | grep -A6 'Export Address Table' +``` + +Output is `build/gamekdm.dll`, a PE32 (i386) DLL. + +### Build modes + +- **Hybrid (default)** — builds `gamekdm.dll` as a shared proxy plus the detour + static library; reconstructed functions override the original where proven. +- **PURE** (`-DBUILD_PURE=ON`) — links/loads no original DLL at all. A + fail-closed coverage gate (`cmake/check_pure_coverage.py`) runs at configure + time and before every build; in full mode it demands 100% `verified` status + across the call graph. +- **PURE slice** (`-DBUILD_PURE=ON -DPURE_SLICE=ON`) — builds only the verified + slice with explicit stubs for the remainder. + +## Verification + +Each reconstructed function is proven behaviorally equal to the original before +it ships: + +- **Unicorn differential** (`tools/unicorn_diff/`) emulates the real routine + inside the shipping `gamekdm.dll` as the oracle, runs the compiled C++ + reconstruction under wine on the same inputs, and asserts behavioral equality, + with an injected-bug non-vacuity check. +- **Golden I/O** fixtures under `tests/golden/`. +- **Detours** are gated by an ownership allowlist: only `pod_only` functions may + hot-patch the original image; `shared_mutable_globals` and `foreign_object_abi` + functions are blocked even when verified. + +## Status + +Reconstruction is **early and explicitly tracked**. As of this writing, +`re/rvadb.json` records **1 of 9,728** functions as `verified`, and the +subsystem map classifies ~2.7% of functions into named subsystems by design +(positive-evidence-only). The runtime cutover path exists as a mechanism but +is deliberately gated and incomplete. Treat any claim about "what +a function does" beyond one explicitly reconstructed, decompiled, or cited to a +disassembly as unestablished. + +## Scope and license + +- **No copyrighted creative asset** (song audio, video, lyrics, or art) is + reproduced anywhere in this repository or spec. Only file/container formats, + directory structure, and code behavior are described. +- Original game binaries are **not** committed; see + [`docs/provenance.md`](docs/provenance.md) for origin and handling. +- This repository is **private and unlicensed** — see [`LICENSE`](LICENSE). No + rights to use, copy, modify, or distribute any part of it are granted; the + final license (if any) has not been decided. diff --git a/docs/companion-conventions.md b/docs/companion-conventions.md index 6eb0c70..9cb774e 100644 --- a/docs/companion-conventions.md +++ b/docs/companion-conventions.md @@ -9,6 +9,15 @@ compensating pop) is cdecl; a callee that returns with `ret N` and the caller performs no stack fixup is stdcall. Full objdump excerpts and the gendef/dlltool transcript are in `.omo/evidence/gamekdm-decomp-linux/task-3.log`. +The official release contains exactly nine Konami modules under +`contents/modules/`: `libavs-win32.dll`, `libavs-win32-ea3.dll`, +`libafp-win32.dll`, `libafputils-win32.dll`, `ess.dll`, `libacio.dll`, +`arkkdm.dll`, `arkkdmtest.dll`, and `gamekdm.dll`. `Kinect10.dll` is an +external Microsoft NUI runtime dependency of `gamekdm.dll`, not a shipped +companion. Addresses, ordinals, export counts, and file offsets below are +UNVERIFIED (pending re-check against clean-release binary) unless stated as +clean-release evidence. + | DLL | Convention | Evidence | Binding | --kill-at | |---|---|---|---|---| | libavs-win32.dll | cdecl | IAT 0x102183cc etc.: callers emit `add esp,N` after the call | by name (vendor exports via synthetic hashed names, e.g. `XCd229cc0000fb`, not ordinal-only — confirmed in the DLL's own export name table, not just gendef's fallback) | no | @@ -18,7 +27,14 @@ transcript are in `.omo/evidence/gamekdm-decomp-linux/task-3.log`. | ess.dll | cdecl | not called directly through gamekdm's IAT (no `ess.dll` import block in gamekdm.dll); follows the plain, undecorated C export convention shared by every other Konami companion in this build and never emits `@N`-decorated symbols | by name | no | | arkkdm.dll | stdcall | export ordinal 2, `arkAFPBoot`, RVA 0x52790: `objdump -d` on that RVA shows `ret 0x4` at file offset 0x100527ca -- the callee pops its own stack frame, which only a stdcall (or fastcall) function does; gendef's `arkAFPBoot@4` guess in the `.def` matches this disassembly exactly | by name (the DLL's own export name table, `objdump -p`, stores `arkAFPBoot` **undecorated**, no `@N`; dlltool's decorated `.def` guess must have the `@N` stripped back off to bind to it) | **yes** | | libacio.dll | cdecl | not called directly through gamekdm's IAT; undecorated plain-C export names, same convention family as `ess.dll` | by name | no | -| Kinect10.dll | stdcall | IAT 0x102181d4 etc.: callee returns with `ret N`, caller performs no `add esp` cleanup; this is the real Microsoft Kinect for Windows SDK v1.x redistributable | by ordinal in gamekdm's own import table, but exported by name in the DLL (`NuiInitialize`, ...) plus one `NONAME` ordinal-1 export | yes (removes/kills the `@N` suffix so the import binds to Kinect10's undecorated exports) | + +`arkkdmtest.dll` and `gamekdm.dll` both export `gameMain`; the official +`arkkdm.dll` entry path resolves that cdecl entry by name. They are not import +libraries consumed by the reconstructed `gamekdm.dll`. + +The external Microsoft `Kinect10.dll` uses stdcall. Its import-library binding +details remain external-platform integration, not part of the shipped +nine-module companion set. ## `--kill-at` scope @@ -26,15 +42,17 @@ Per `i686-w64-mingw32-dlltool --help`, `-k`/`--kill-at` "Kill @ from exported names": it strips (removes) the `@N` stdcall decoration dlltool would otherwise carry into the generated import name -- it does not add an `@N` suffix, and it has no effect on calling convention at the ABI level (it -never retags a cdecl import as stdcall or vice versa). It is passed for both -`arkkdm.dll` and `Kinect10.dll` because those two DLLs' own export tables -(`objdump -p`) hold the plain, undecorated name (`arkAFPBoot`, -`NuiInitialize`, ...) rather than a `Name@N` form -- gendef annotates every -stdcall export it detects in the `.def` with a guessed `@N` (correctly, in -arkAFPBoot's case: `@4`), and without `--kill-at` dlltool would emit an -import-by-name entry like `arkAFPBoot@4` that does not exist in either DLL's -real, undecorated export table, so the import would fail to bind at load -time. It is not passed for the six cdecl companions (AVS, AVS-EA3, AFP, +never retags a cdecl import as stdcall or vice versa). It is passed for +`arkkdm.dll`, the one shipped module in this set that is stdcall, because its +export table holds the plain, undecorated name `arkAFPBoot` rather than a +`Name@N` form -- gendef annotates every stdcall export it detects in the +`.def` with a guessed `@N` (correctly, in arkAFPBoot's case: `@4`), and +without `--kill-at` dlltool would emit an import-by-name entry like +`arkAFPBoot@4` that does not exist in the DLL's real, undecorated export +table, so the import would fail to bind at load time. (The external +Kinect10.dll NUI runtime dependency gets the same `--kill-at` treatment for +the same reason, but it is not one of the nine shipped modules.) It is not +passed for the six cdecl companions (AVS, AVS-EA3, AFP, AFPUtils, ESS, ACIO): their `.def` files carry no `@N` decoration for dlltool to strip in the first place (gendef only annotates stdcall exports), so `--kill-at` would be a no-op for them -- passing it was never the risk; diff --git a/docs/companion-inventory.md b/docs/companion-inventory.md index 543a3bf..9c6f635 100644 --- a/docs/companion-inventory.md +++ b/docs/companion-inventory.md @@ -1,320 +1,147 @@ -# Companion DLL Inventory — KDM-2016021900 +# Module Inventory — KDM-2016021900 (clean release) -Task T13 deliverable: inventory and classification of every DLL shipped with -the Konami Dance Masters / `KDM-2016021900` game build, a cross-DLL -dependency DAG, and the locked IN-SCOPE reconstruction set + order. +Inventory and classification of every module shipped in the **clean** +KDM-2016021900 release, plus the cross-module dependency DAG and the +reconstruction set and order. Scope is the official game only: the +`contents/` tree of the release. Community/PC-hardware tooling (spice2x, +bemanitools, a Kinect shim, launcher/hook glue, NVENC/CUDA stubs) is **not** +part of the game and is not inventoried here; where an earlier draft counted +such files as "shipped DLLs," that was a contaminated install, not the clean +release. -Source tree enumerated: `contents/` and `contents/modules/` and -`contents/stubs/64/` under the owner's legally-possessed copy of -`KDM-2016021900` (full path redacted from this doc; see evidence log for the -absolute path used). Method: `objdump -p` (i686-w64-mingw32 cross binutils, -and host `/usr/bin/objdump` for the two PE32+ files the 32-bit toolchain -objdump could not parse) against every `.dll` found, cross-referenced against -the shipped `contents/src/spice2x-master.tar.gz` and -`contents/src/spicetools-master.tar.gz` source tarballs for provenance. +## What the clean release contains -## Completeness check +The clean release is `contents/` with three asset/config trees — `data/`, +`arkdata/`, `prop/` — and exactly **9** modules under `contents/modules/`. +There are no other DLLs: no `launcher.exe`, no `deahook.dll`, no +`Kinect10.dll`, no `stubs/64/`, no `src/` tarballs, and none of the +non-release Konami modules (`kmd.dll`, `ksm.dll`, `kuc.dll`, `libinput.dll`, +`libacio_mbr.dll`) a contaminated install may carry. -`find contents -iname '*.dll'` (including `modules/` and `stubs/64/`) returns -**22** files. This table has **22** rows. Count matches — no DLL is -omitted. +## Per-module table (contents/modules/) -## Classification legend +| Module | Size (clean release) | Classification | Role | +|---|---|---|---| +| `libavs-win32.dll` | 505.14 KB | IN-SCOPE | AVS2 (Application/Audio-Visual System v2) core middleware: property-tree config store, virtual filesystem, threading. Root of the dependency graph. | +| `libavs-win32-ea3.dll` | 364.14 KB | IN-SCOPE | e-amusement v3 ("ea3") AVS2 extension (network/identity/coin economy). | +| `libafp-win32.dll` | 1.19 MB | IN-SCOPE | AFP asset/font/graphics (Flash) pipeline used by ARK. | +| `libafputils-win32.dll` | 165.64 KB | IN-SCOPE | AFP utilities; sits directly above `libafp-win32.dll`. | +| `ess.dll` | 376.14 KB | IN-SCOPE | ESS e-amusement shop/server middleware. | +| `libacio.dll` | 224.64 KB | IN-SCOPE | ACIO (amusement cabinet I/O) protocol library. | +| `arkkdm.dll` | 896.64 KB | IN-SCOPE | ARK cabinet game engine instantiated for KDM; also the AVS2 game-DLL entry (`dll_entry_init`/`dll_entry_main`) that loads and calls `gamekdm.dll`. | +| `arkkdmtest.dll` | 389.14 KB | IN-SCOPE | ARK/KDM render+input test harness; exports `gameMain`; links OS D3D9/DINPUT8/DSOUND directly (no AVS layer). | +| `gamekdm.dll` | 3.19 MB | IN-SCOPE | Main KDM game logic; single export `gameMain`. Primary reconstruction target. | -- **IN-SCOPE** — Konami-authored game/middleware code; targeted for - decompilation/reconstruction. -- **REUSE OS** — not shipped as a file in this folder; referenced only as an - *import target* (d3d9, d3dx9_43, kernel32, user32, gdi32, advapi32, - shell32, ole32, ws2_32, winmm, imm32, dinput8, dsound, iphlpapi, psapi, - msvcrt/msvcr80, oleaut32, dbghelp, hid, setupapi). None of these are - themselves present as files under `contents/`, so none appear as rows - below; they appear only in the "imports-from" / per-DLL import tables as - external OS/runtime dependencies. -- **ALREADY-OSS** — the shipped file is produced by, or is a shim for, - already-open-source tooling: the owner's own Kinect10.dll shim; a - spice2x/spicetools-built stub DLL confirmed by byte-identical - export/import signature against the shipped spice2x source; or a - **bemanitools** (djhackersdev/bemanitools, open source) stub DLL - identified by an embedded bemanitools PDB path and non-spice2x - implementation details (see kbt.dll/kld.dll rationale below). +> **Size caveat.** These sizes are from the clean-release file listing. An +> earlier inventory, built from a contaminated install, recorded different +> byte counts for `arkkdm.dll`, `libacio.dll`, and `gamekdm.dll` (e.g. +> `libacio.dll` at 65,536 B — a community replacement, not Konami's 224.64 KB +> original). Any per-byte size, export count, or RVA in this spec that was +> derived from that install and cannot yet be re-verified against the +> clean-release binary is marked `UNVERIFIED (pending re-check against +> clean-release binary)`. -## Per-DLL table +## External (non-shipped) dependencies — referenced only, never part of the game -| DLL (path under `contents/`) | Size | Classification | ABI / export count | Rationale | Imports from (shipped DLLs only) | -|---|---|---|---|---|---| -| `Kinect10.dll` | 951,731 B | **ALREADY-OSS** | plain-C (no C++ mangling), 25 export(s) | Owner's own Kinect SDK shim (per plan brief); imports only msvcrt/KERNEL32/OLEAUT32/WINMM, exports the standard NuiCamera*/NuiCreate* Kinect SDK surface. Not Konami game logic. | (none — leaf) | -| `arkkdm.dll` | 827,024 B | **IN-SCOPE** | plain-C (no C++ mangling), 255 export(s) | 255 plain-C exports (arkAFP*, arkKDM-prefixed ARK engine API), 0 C++-mangled symbols. Links against libavs-win32, ess, libacio, libafp-win32 — the Konami AVS2/ARK middleware stack. No match in spice2x source tree. Core Konami game-engine DLL. | `libavs-win32.dll`, `libavs-win32-ea3.dll`, `ess.dll`, `libacio.dll`, `libafp-win32.dll` | -| `arkkdmtest.dll` | 398,480 B | **IN-SCOPE** | plain-C (no C++ mangling), 1 export(s) | Single export gameMain; imports D3D9/D3DX9/DINPUT8/DSOUND/GDI32/SHELL32/USER32 directly (no AVS layer) — a standalone Konami-authored ARK/KDM render-and-input test harness shipped alongside the game. Not found in spice2x source. | (none — leaf) | -| `deahook.dll` | 93,696 B | **IN-SCOPE** | has C++-mangled symbol(s), 1 export(s) | 93,696-byte PE32, single export `?dummy@@YGHXZ` (C++-mangled no-op), export-directory internal module name "DEALibacio.dll", imports only GetAsyncKeyState (USER32) + CRT startup set (KERNEL32). No reference to "deahook" or "DEALibacio" anywhere in the spice2x-master.tar.gz or spicetools-master.tar.gz source trees (grep across every .cpp/.h/.txt/.md/.def returned zero hits), so it is not an artifact of those two OSS projects — but that absence does not by itself prove who *did* author it; its exact author is **unresolved** from the available evidence. It is a game-specific ACIO-layer native hook, not an OS DLL and not matched to any identified OSS project, so it is classified conservatively **IN-SCOPE** on that basis (not on a proven-Konami-authorship basis). | (none — leaf) | -| `ess.dll` | 385,168 B | **IN-SCOPE** | plain-C (no C++ mangling), 209 export(s) | 209 plain-C exports (ess_binarydata_*, ess_bookkeeping_*) — Konami ESS (Enterprise Shop/Server-side e-amusement) middleware. Links libavs-win32/-ea3 plus WS2_32/IPHLPAPI/PSAPI for networking. No match in spice2x source. | `libavs-win32.dll`, `libavs-win32-ea3.dll` | -| `gamekdm.dll` | 3,369,104 B | **IN-SCOPE** | plain-C (no C++ mangling), 1 export(s) | Single export gameMain (3.37MB) — the main KDM game logic DLL. Imports D3D9/D3DX9/Kinect10/libavs-win32/libafputils-win32/libafp-win32 plus Win32 OS DLLs. This is the primary reconstruction target named in the plan. | `Kinect10.dll`, `libavs-win32.dll`, `libafputils-win32.dll`, `libafp-win32.dll` | -| `kbt.dll` | 7,680 B | **ALREADY-OSS** | plain-C (no C++ mangling), 6 export(s) | Exports exactly bt_fcheck_finish/bt_fcheck_init/bt_fcheck_main/bt_get_ikey_status/k_bt0001/k_bt0002 (6), imports only msvcrt+KERNEL32. Contains the embedded PDB path `d:\bemanitools\stubs\objfre_wxp_x86\i386\stubs.pdb` (CodeView RSDS record, file offset 0x55b), and the `k_bt0002` export resolves to a bare `ret` at RVA 0x11d7 (confirmed by disassembly) rather than the spice2x stubs.cpp implementation of k_bt0002 (which calls the supplied function pointer). This identifies it as a **bemanitools** (djhackersdev/bemanitools, open-source) "ikey" security-dongle stub build, not a spice2x/spicetools build and not a Konami original. Remains ALREADY-OSS (bemanitools is open source) and excluded from the reconstruct set. | (none — leaf) | -| `kld.dll` | 7,680 B | **ALREADY-OSS** | plain-C (no C++ mangling), 6 export(s) | Byte-identical export/import signature and byte-identical bemanitools PDB path (`d:\bemanitools\stubs\objfre_wxp_x86\i386\stubs.pdb` at offset 0x55b) and bare-`ret` `k_bt0002` to kbt.dll. Same **bemanitools** ikey-dongle stub build, not spice2x and not Konami original. Remains ALREADY-OSS and excluded from the reconstruct set. | (none — leaf) | -| `kmd.dll` | 128,656 B | **IN-SCOPE** | plain-C (no C++ mangling), 1 export(s) | Single export k_md0001; imports dbghelp.dll, libavs-win32.dll, MSVCR80.dll — Konami "md" (presumably memory-dump/debug) module. No match in spice2x source; depends on other unshipped Konami DLLs (MSVCR80 aside), consistent with genuine Konami binary. | `libavs-win32.dll` | -| `ksm.dll` | 169,616 B | **IN-SCOPE** | plain-C (no C++ mangling), 111 export(s) | 111 exports (k_sm0001, ssm_array_*) — Konami "sm" (save/score-manager?) module. Imports kdu.dll/kmp.dll/kma.dll (Konami modules not present in this shipment — external AVS2 family deps) plus libavs-win32/-ea3. No match in spice2x source. | `libavs-win32.dll`, `libavs-win32-ea3.dll` | -| `kuc.dll` | 128,656 B | **IN-SCOPE** | plain-C (no C++ mangling), 4 export(s) | 4 exports (DllStart, k_uc0001, k_uc0004, k_uc0005) — small Konami "uc" module, same kdu/kmp/kma + libavs-win32 dependency pattern as ksm.dll. No match in spice2x source. | `libavs-win32.dll`, `libavs-win32-ea3.dll` | -| `libacio.dll` | 65,536 B | **IN-SCOPE** | plain-C (no C++ mangling), 44 export(s) | 44 exports, all ac_io_* — Konami's AC-IO (amusement I/O / cabinet peripheral) protocol library. Imports only USER32/KERNEL32. This is the real I/O library spice2x's acio.cpp LoadLibraryA()'s and hooks at runtime (it does not reimplement libacio.dll itself), so the DLL present here is the Konami original, not spice2x code. | (none — leaf) | -| `libacio_mbr.dll` | 14,336 B | **IN-SCOPE** | plain-C (no C++ mangling), 47 export(s) | 47 exports (ac_io_* superset of libacio.dll, MBR-variant). Imports libinput.dll and libavs-win32.dll in addition to msvcrt/KERNEL32. Konami AC-IO variant for a different cabinet/IO board revision; no match in spice2x source. | `libinput.dll`, `libavs-win32.dll` | -| `libafp-win32.dll` | 1,246,864 B | **IN-SCOPE** | plain-C (no C++ mangling), 159 export(s) | 159 exports, all afp_* (Konami "AFP" asset/font/graphics pipeline library used by ARK). Imports only libavs-win32.dll + KERNEL32. Base dependency of arkkdm.dll and gamekdm.dll. | `libavs-win32.dll` | -| `libafputils-win32.dll` | 169,616 B | **IN-SCOPE** | plain-C (no C++ mangling), 162 export(s) | 162 exports, all afpu_* (AFP utilities). Imports libavs-win32.dll + libafp-win32.dll + KERNEL32 — sits directly above libafp-win32.dll in the dependency chain. | `libavs-win32.dll`, `libafp-win32.dll` | -| `libavs-win32-ea3.dll` | 372,880 B | **IN-SCOPE** | plain-C (no C++ mangling), 139 export(s) | 139 exports, ordinal-style names (XE592acd...) typical of AVS2 "ea3"(e-amusement v3) extension module. Imports only KERNEL32 + libavs-win32.dll. Part of the Konami AVS2 middleware family targeted for reconstruction. | `libavs-win32.dll` | -| `libavs-win32.dll` | 517,264 B | **IN-SCOPE** | plain-C (no C++ mangling), 360 export(s) | 360 exports, ordinal-style names (XCd229cc...) — AVS2 (Application/Audio-Visual System v2), Konami's core middleware runtime underlying every other first-party DLL here. Imports only KERNEL32/WS2_32/WINMM/IPHLPAPI. Root of the Konami dependency DAG. | (none — leaf) | -| `libinput.dll` | 38,400 B | **IN-SCOPE** | plain-C (no C++ mangling), 51 export(s) | 51 exports, all eam_* (e-amuse input config: eam_config_load/save, eam_get_alt_10k, ...). Imports msvcrt/KERNEL32/USER32/HID.DLL/SETUPAPI/SHELL32 — talks to real HID hardware via SETUPAPI/HID.DLL, consistent with a genuine Konami cabinet-input driver, not a spice2x emulation shim. | (none — leaf) | -| `modules/libacio.dll` | 65,536 B | **IN-SCOPE** | plain-C (no C++ mangling), 44 export(s) | Byte-identical export/import signature to top-level libacio.dll (44 ac_io_* exports, USER32+KERNEL32 only); duplicate copy kept under modules/ for AC-IO module loading. Same Konami original classification. | (none — leaf) | -| `stubs/64/nvEncodeAPI64.dll` | 12,800 B | **ALREADY-OSS** | plain-C (no C++ mangling), 2 export(s) | PE32+ (x86-64) stub exporting exactly NvEncodeAPICreateInstance/NvEncodeAPIGetMaxSupportedVersion, both returning a fixed error code — matches spice2x/stubs/nvEncodeAPI64.cpp verbatim (same two functions, same NV_ENC_ERR_INVALID_PTR constant). spice2x-built NVENC stub, not Konami or NVIDIA code. | (none — leaf) | -| `stubs/64/nvcuda.dll` | 13,824 B | **ALREADY-OSS** | plain-C (no C++ mangling), 21 export(s) | PE32+ stub exporting 21 cu* CUDA driver API functions, all returning CUDA_ERROR_NOT_SUPPORTED(801) — matches spice2x/stubs/nvcuda.cpp verbatim function-for-function. spice2x-built CUDA stub. | (none — leaf) | -| `stubs/64/nvcuvid.dll` | 13,312 B | **ALREADY-OSS** | plain-C (no C++ mangling), 13 export(s) | PE32+ stub exporting 13 cuvid* functions, all returning CUDA_ERROR_NOT_SUPPORTED(801) — matches spice2x/stubs/nvcuvid.cpp verbatim. spice2x-built NVCUVID stub. | (none — leaf) | +- **Kinect10.dll** — Microsoft Kinect-for-Windows **NUI v1** runtime. + `gamekdm.dll`'s own import table references it, so it is a real external + dependency of the game binary, but it is **not** a shipped game module; on a + cabinet it is satisfied by the installed Kinect runtime. Treat it as an + external import target only. +- **OS / DirectX runtime** — `d3d9.dll`, `d3dx9_43.dll`, `KERNEL32.dll`, + `USER32.dll`, `GDI32.dll`, `ADVAPI32.dll`, `SHELL32.dll`, `OLE32.dll`, + `OLEAUT32.dll`, `WS2_32.dll`, `WINMM.dll`, `IMM32.dll`, `DINPUT8.dll`, + `DSOUND.dll`, `IPHLPAPI.DLL`, `PSAPI.DLL`, `HID.DLL`, `SETUPAPI.dll`, + `DBGHELP.dll`, `msvcrt.dll`/`MSVCR80.dll`. Not shipped as game files; + appear only as import targets, satisfied by the Win32/DirectX runtime. -All 22 files export plain-C symbol tables with one exception: `deahook.dll` -exports a single C++-mangled no-op (`?dummy@@YGHXZ`); every import across -all 22 DLLs is a plain-C symbol (no C++-mangled imports were found anywhere). +## Cross-module dependency DAG (9 nodes, verified acyclic) -### REUSE OS DLLs referenced (not shipped as files, import targets only) - -- `ADVAPI32.dll` -- `DINPUT8.dll` -- `DSOUND.dll` -- `GDI32.dll` -- `HID.DLL` -- `IMM32.dll` -- `IPHLPAPI.DLL` -- `KERNEL32.dll` -- `MSVCR80.dll` -- `OLEAUT32.dll` -- `PSAPI.DLL` -- `SETUPAPI.dll` -- `SHELL32.dll` -- `USER32.dll` -- `WINMM.DLL` -- `WINMM.dll` -- `WS2_32.dll` -- `d3d9.dll` -- `d3dx9_43.dll` -- `dbghelp.dll` -- `msvcrt.dll` -- `ole32.dll` - -### Konami-family DLLs referenced but not shipped in this folder - -`ksm.dll` and `kuc.dll` import from `kdu.dll`, `kmp.dll`, `kma.dll` -— further AVS2/ARK-family Konami modules that are **not present** in -`contents/` (likely resolved from a Windows system path or a different -install layer at runtime). They are out of scope for this inventory because -they are not shipped; noted here so a later task does not mistake their -absence for an omission in this table. - -## Cross-DLL dependency DAG - -Derived from each DLL's PE import table, restricted to edges where the -imported DLL name matches another file actually present under `contents/` -(OS DLLs and unshipped Konami-family DLLs are excluded from the graph, see -tables above). Verified **acyclic** by DFS over all 22 nodes (0 back-edges -found; see evidence log for the full edge list and algorithm run). +Derived from each module's PE import table, restricted to edges where the +imported DLL is another shipped module. The external Kinect10/OS imports are +excluded from the graph. ```mermaid graph TD - Kinect10_dll(("Kinect10.dll")) - arkkdm_dll["arkkdm.dll"] - arkkdmtest_dll["arkkdmtest.dll"] - deahook_dll["deahook.dll"] - ess_dll["ess.dll"] - gamekdm_dll["gamekdm.dll"] - kbt_dll(("kbt.dll")) - kld_dll(("kld.dll")) - kmd_dll["kmd.dll"] - ksm_dll["ksm.dll"] - kuc_dll["kuc.dll"] - libacio_dll["libacio.dll"] - libacio_mbr_dll["libacio_mbr.dll"] + libavs_win32_dll["libavs-win32.dll"] + libavs_win32_ea3_dll["libavs-win32-ea3.dll"] libafp_win32_dll["libafp-win32.dll"] libafputils_win32_dll["libafputils-win32.dll"] - libavs_win32_ea3_dll["libavs-win32-ea3.dll"] - libavs_win32_dll["libavs-win32.dll"] - libinput_dll["libinput.dll"] - modules_libacio_dll["modules/libacio.dll"] - stubs_64_nvEncodeAPI64_dll(("stubs/64/nvEncodeAPI64.dll")) - stubs_64_nvcuda_dll(("stubs/64/nvcuda.dll")) - stubs_64_nvcuvid_dll(("stubs/64/nvcuvid.dll")) + ess_dll["ess.dll"] + libacio_dll["libacio.dll"] + arkkdm_dll["arkkdm.dll"] + arkkdmtest_dll["arkkdmtest.dll"] + gamekdm_dll["gamekdm.dll"] + kinect(("Kinect10.dll (external MS NUI runtime)")) + libavs_win32_ea3_dll --> libavs_win32_dll + libafp_win32_dll --> libavs_win32_dll + libafputils_win32_dll --> libavs_win32_dll + libafputils_win32_dll --> libafp_win32_dll + ess_dll --> libavs_win32_dll + ess_dll --> libavs_win32_ea3_dll arkkdm_dll --> libavs_win32_dll arkkdm_dll --> libavs_win32_ea3_dll arkkdm_dll --> ess_dll arkkdm_dll --> libacio_dll arkkdm_dll --> libafp_win32_dll - ess_dll --> libavs_win32_dll - ess_dll --> libavs_win32_ea3_dll - gamekdm_dll --> Kinect10_dll gamekdm_dll --> libavs_win32_dll - gamekdm_dll --> libafputils_win32_dll gamekdm_dll --> libafp_win32_dll - kmd_dll --> libavs_win32_dll - ksm_dll --> libavs_win32_dll - ksm_dll --> libavs_win32_ea3_dll - kuc_dll --> libavs_win32_dll - kuc_dll --> libavs_win32_ea3_dll - libacio_mbr_dll --> libinput_dll - libacio_mbr_dll --> libavs_win32_dll - libafp_win32_dll --> libavs_win32_dll - libafputils_win32_dll --> libavs_win32_dll - libafputils_win32_dll --> libafp_win32_dll - libavs_win32_ea3_dll --> libavs_win32_dll - classDef inscope fill:#dff0d8,stroke:#3c763d; - classDef oss fill:#f2dede,stroke:#a94442; - class arkkdm_dll,arkkdmtest_dll,deahook_dll,ess_dll,gamekdm_dll,kmd_dll,ksm_dll,kuc_dll,libacio_dll,libacio_mbr_dll,libafp_win32_dll,libafputils_win32_dll,libavs_win32_ea3_dll,libavs_win32_dll,libinput_dll,modules_libacio_dll inscope; - class Kinect10_dll,kbt_dll,kld_dll,stubs_64_nvEncodeAPI64_dll,stubs_64_nvcuda_dll,stubs_64_nvcuvid_dll oss; + gamekdm_dll --> libafputils_win32_dll + gamekdm_dll -.external.-> kinect ``` -Text form (child → parent/dependency): +Text form (child → shipped dependency): ``` -libavs-win32.dll (root; depends on nothing shipped) -libacio.dll (root) -modules/libacio.dll (root; duplicate of libacio.dll) -libinput.dll (root) -deahook.dll (root; no shipped-DLL imports) -arkkdmtest.dll (root; no shipped-DLL imports — links OS D3D/DINPUT/DSOUND only) -Kinect10.dll (root; ALREADY-OSS, leaf) -kbt.dll, kld.dll (roots; ALREADY-OSS bemanitools stubs, leaves) -stubs/64/nv*.dll (roots; ALREADY-OSS spice2x stubs, leaves) - +libavs-win32.dll (root) +libacio.dll (root; imports USER32/KERNEL32 only) +arkkdmtest.dll (root; imports OS D3D9/DINPUT8/DSOUND/GDI32/SHELL32/USER32 only) libavs-win32-ea3.dll -> libavs-win32.dll libafp-win32.dll -> libavs-win32.dll -kmd.dll -> libavs-win32.dll -ess.dll -> libavs-win32.dll, libavs-win32-ea3.dll -ksm.dll -> libavs-win32.dll, libavs-win32-ea3.dll -kuc.dll -> libavs-win32.dll, libavs-win32-ea3.dll -libacio_mbr.dll -> libinput.dll, libavs-win32.dll libafputils-win32.dll -> libavs-win32.dll, libafp-win32.dll +ess.dll -> libavs-win32.dll, libavs-win32-ea3.dll arkkdm.dll -> libavs-win32.dll, libavs-win32-ea3.dll, ess.dll, libacio.dll, libafp-win32.dll -gamekdm.dll -> Kinect10.dll (ALREADY-OSS), libavs-win32.dll, libafputils-win32.dll, libafp-win32.dll +gamekdm.dll -> libavs-win32.dll, libafp-win32.dll, libafputils-win32.dll + (+ external Kinect10.dll, d3d9/d3dx9) ``` -AVS2 (`libavs-win32.dll`) is confirmed as the base of the graph: it is the -only non-leaf node with zero incoming classification conflicts and the sole -transitive ancestor of every other IN-SCOPE DLL. `libafp-win32.dll` -(`libafp`) depends only on AVS2, confirming the plan's stated -`libafp->libavs` edge. `gamekdm.dll` is confirmed as the terminal -("imports from everything else") node described in the plan as -`gamekdm->all`: it is the only shipped DLL whose shipped-DLL import set -includes a file from every other dependency tier (AVS2 base, -libafputils/libafp tier, plus the ALREADY-OSS Kinect10.dll shim). +`libavs-win32.dll` is the base of the graph (zero shipped dependencies, +transitive ancestor of every other module). `gamekdm.dll` is the terminal +game-logic node. All byte-exact export counts and edges beyond this +shipped-module topology are `UNVERIFIED (pending re-check against +clean-release binary)` until re-derived from the clean `contents/modules/` +files. -## IN-SCOPE reconstruct set (16 DLLs) +## Boot/entry into the game (official, from arkkdm.dll) -- `arkkdm.dll` -- `arkkdmtest.dll` -- `deahook.dll` -- `ess.dll` -- `gamekdm.dll` -- `kmd.dll` -- `ksm.dll` -- `kuc.dll` -- `libacio.dll` -- `libacio_mbr.dll` -- `libafp-win32.dll` -- `libafputils-win32.dll` -- `libavs-win32-ea3.dll` -- `libavs-win32.dll` -- `libinput.dll` -- `modules/libacio.dll` +On the cabinet the AVS2 runtime enters the game DLL (`arkkdm.dll`) through its +standard AVS2 entry exports `dll_entry_init` / `dll_entry_main` (by-name +exports at the tail of arkkdm.dll's export directory, ordinals 253/254, RVAs +`0x767c0` / `0x767b0`). `arkkdm.dll`'s `dll_entry_main` internally +`LoadLibraryA("gamekdm.dll")` — with an `"arkkdmtest.dll"` test-build +fallback — then `GetProcAddress("gameMain")`, and calls `gameMain(hInstance)` +(cdecl). The `hInstance` is arkkdm.dll's own `HINSTANCE`, captured once in its +`DllMain` on `DLL_PROCESS_ATTACH` and relayed through its internal +`g_MainDllInfo.dllHMODULE` struct (see `docs/re/gamemain-binding.md`). No +launcher, hook DLL, or emulator is part of this path. -## REUSE OS set +## IN-SCOPE reconstruct set (9 modules) -Not file-shipped; see "REUSE OS DLLs referenced" table above. No reconstruct -work applies to these — they are satisfied by the existing Win32/D3D9/DirectX -runtime. +All 9 shipped modules are Konami-authored and in scope: -## ALREADY-OSS set (6 DLLs) — excluded from reconstruct set - -- `Kinect10.dll` — owner's own Kinect SDK shim. -- `kbt.dll`, `kld.dll` — **bemanitools** (djhackersdev/bemanitools, open - source) "ikey" security-dongle stub DLLs, identified by the embedded PDB - path `d:\bemanitools\stubs\objfre_wxp_x86\i386\stubs.pdb` (CodeView RSDS - record, offset 0x55b in both files) and by `k_bt0002` disassembling to a - bare `ret` at RVA 0x11d7 — not the spice2x stubs.cpp implementation of - `k_bt0002` (which calls the supplied callback). Not a spice2x/spicetools - build; not a Konami original. -- `stubs/64/nvEncodeAPI64.dll`, `stubs/64/nvcuda.dll`, `stubs/64/nvcuvid.dll` - — spice2x `stubs/nvEncodeAPI64.cpp`, `stubs/nvcuda.cpp`, `stubs/nvcuvid.cpp` - (verbatim function-for-function match, including error-code constants). - -## deahook.dll origin (explicit finding) - -`deahook.dll` is **not** a spice2x/spicetools artifact. A full-text grep of -every `.cpp`/`.h`/`.txt`/`.md`/`.def` file in both shipped source tarballs -(`spice2x-master.tar.gz`, `spicetools-master.tar.gz`) for "deahook" or -"DEALibacio" returns zero hits. spice2x's own Dance Evolution Arcade (the -KDM-family game code is `games::dea`) integration in -`spice2x/games/dea/dea.cpp` only `try_library()`-loads `gamekdm.dll` and -probes `Kinect10.dll`; it never touches a `deahook.dll`/`DEALibacio` symbol. -`deahook.dll`'s own PE export directory records its internal module name as -**"DEALibacio.dll"**, and its only imports are `GetAsyncKeyState` (USER32) -plus the standard MSVC CRT/kernel32 startup set — a minimal key-hook DLL -tied to the ACIO (amusement I/O) layer. - -**What this evidence proves and does not prove:** it proves `deahook.dll` is -not a spice2x/spicetools build (absence from both shipped OSS source trees) -and that it is an ACIO-layer native hook (from its import surface and -internal module name). It does **not** prove Konami authorship — absence -from the two identified OSS projects' source is not positive evidence of -who wrote the binary. The exact author is **unresolved** from the evidence -gathered here. It is classified **IN-SCOPE** conservatively because it is a -game-specific native hook that is neither an OS DLL nor matched to any -identified OSS project — not because Konami authorship has been -established. +`libavs-win32.dll`, `libavs-win32-ea3.dll`, `libafp-win32.dll`, +`libafputils-win32.dll`, `ess.dll`, `libacio.dll`, `arkkdm.dll`, +`arkkdmtest.dll`, `gamekdm.dll`. ## Reconstruction order (topological, acyclic) -One valid topological order over the 16 IN-SCOPE nodes (dependencies before -dependents): - -1. `libavs-win32.dll` -2. `libavs-win32-ea3.dll` -3. `ess.dll` -4. `libacio.dll` -5. `libafp-win32.dll` -6. `arkkdm.dll` -7. `arkkdmtest.dll` -8. `deahook.dll` -9. `libafputils-win32.dll` -10. `gamekdm.dll` -11. `kmd.dll` -12. `ksm.dll` -13. `kuc.dll` -14. `libinput.dll` -15. `libacio_mbr.dll` -16. `modules/libacio.dll` - -Rationale for grouping: - -1. **Tier 0 — AVS2 base**: `libavs-win32.dll` has zero shipped-DLL - dependencies and is imported (directly or transitively) by every other - IN-SCOPE DLL. Reconstruct first. -2. **Tier 1 — AVS2 extensions / first-tier libraries**: `libavs-win32-ea3.dll`, - `ess.dll`, `libacio.dll`, `libafp-win32.dll` depend only on AVS2 (plus, - for `ess.dll`, on `libavs-win32-ea3.dll` which is reconstructed - immediately before it in this order). -3. **Tier 2 — engine/library consumers**: `arkkdm.dll`, `arkkdmtest.dll`, - `deahook.dll`, `libafputils-win32.dll` consume Tier 0/1 libraries (or, for - `arkkdmtest.dll`/`deahook.dll`, only OS DLLs). -4. **Tier 3 — top-level game DLL**: `gamekdm.dll`, the primary reconstruction - target, consuming AVS2, `libafputils-win32.dll`, and `libafp-win32.dll` - (plus the ALREADY-OSS `Kinect10.dll` shim). -5. **Tier 4 — independent Konami modules**: `kmd.dll`, `ksm.dll`, `kuc.dll` - depend only on AVS2/AVS2-ea3 and are independent of the `gamekdm`/`arkkdm` - chain; can be reconstructed in parallel with tiers 2–3 once Tier 0/1 is - done. -6. **Tier 5 — peripheral/IO modules**: `libinput.dll` (root), then - `libacio_mbr.dll` (depends on `libinput.dll` + AVS2), then - `modules/libacio.dll` (duplicate of `libacio.dll`, already covered in - Tier 1 — reconstructing `libacio.dll` once satisfies both locations). - -Acyclicity: confirmed by DFS cycle detection over all 22 nodes (shipped + -non-shipped-but-classified) with zero cycles found; see evidence log for the -full per-node visit trace. - -## Must-NOT verification - -No REUSE OS or ALREADY-OSS DLL appears in the "IN-SCOPE reconstruct set" -list above. Cross-checked programmatically: the 16-entry IN-SCOPE list and -the 6-entry ALREADY-OSS list are disjoint and together with the (empty, -non-file) REUSE OS set cover all 22 shipped DLLs exactly once. +1. `libavs-win32.dll` — AVS2 base (no shipped dependencies) +2. `libavs-win32-ea3.dll` — AVS2 ea3 extension +3. `ess.dll` — depends on AVS2 + ea3 +4. `libacio.dll` — root (OS imports only) +5. `libafp-win32.dll` — depends on AVS2 +6. `libafputils-win32.dll` — depends on AVS2 + libafp +7. `arkkdm.dll` — depends on AVS2/ea3/ess/libacio/libafp +8. `arkkdmtest.dll` — root (OS imports only) +9. `gamekdm.dll` — primary target; depends on AVS2/libafp/libafputils + (+ external Kinect10.dll) diff --git a/docs/conventions.md b/docs/conventions.md index 9f2f4fc..d26b5c7 100644 --- a/docs/conventions.md +++ b/docs/conventions.md @@ -30,8 +30,8 @@ clang-cl cross-check) never has to guess. Apply them by origin: (the game's `avs2` / `avfs` style imports and callbacks) and for anything the original declared `__cdecl`, which is MSVC's default for free functions. - `GK_STDCALL`: callee-cleaned stdcall. Use for the Win32-style boundaries: - Kinect10 (`Kinect10.dll`) and Direct3D 9 (`d3d9.dll`) entry points and any - `WINAPI`/`CALLBACK` the original went through. + the external Microsoft NUI runtime (`Kinect10.dll`), Direct3D 9 (`d3d9.dll`) + entry points, and any `WINAPI`/`CALLBACK` the original went through. - `GK_THISCALL`: MSVC thiscall (first arg `this` in `ecx`, callee-cleaned). Use for internal non-virtual member functions reconstructed as free functions, and for any method whose disasm passes `this` in `ecx` and cleans its own stack. diff --git a/docs/cutover.md b/docs/cutover.md index 22c31ef..5474b68 100644 --- a/docs/cutover.md +++ b/docs/cutover.md @@ -85,18 +85,18 @@ Inspect the final PE imports and linker inputs, then run the mock host in a directory without original DLLs. T17 evidence lives in `/home/athapa/kdm-re/.omo/evidence/gamekdm-decomp-linux/task-17.log`. -## Final Windows / spice2x full-game QA +## Final cabinet/original-binary runtime full-game QA Only begin this checklist with a complete, stub-free build and the full coverage/reachability and dependency audits passed. Preserve a separate known-good hybrid installation for rollback. Record build/source hashes, -rvadb hash, Windows version, spice2x version/configuration, Kinect driver, +rvadb hash, Windows version, Kinect runtime/driver, GPU/driver, input mappings, logs, and screenshots with each result. - [ ] Stage the complete pure build in an isolated game directory; remove original game/companion DLLs from its loader search paths. Confirm PE32 ABI, gameMain name/ordinal/calling convention and required exports. -- [ ] Launch with the user's normal spice2x configuration. Inspect loaded +- [ ] Launch through the cabinet/original-binary runtime. Inspect loaded modules and dynamic-load traces: no original binary or proxy/detour. Boot, asset loading, attract mode and title/menu navigation succeed. - [ ] Check service/test menu, calibration, coin/start, cabinet buttons, diff --git a/docs/pipeline.md b/docs/pipeline.md index 3151be0..aac95ae 100644 --- a/docs/pipeline.md +++ b/docs/pipeline.md @@ -105,9 +105,15 @@ tools/gen_importlibs.sh # tools/gen_importlibs.sh "/path/to/KDM-.../contents" ``` -This runs `gendef` then `i686-w64-mingw32-dlltool` for each in-scope companion -and writes `re/importlibs/lib.dll.a`. The stdcall companions (`arkkdm`, -`Kinect10`) get `--kill-at`; see `docs/companion-conventions.md` for why. +This runs `gendef` then `i686-w64-mingw32-dlltool` for the seven shipped Konami +modules in its current map and the external Microsoft `Kinect10.dll` NUI +runtime dependency of `gamekdm.dll`, writing `re/importlibs/lib.dll.a`. +`arkkdm` and external `Kinect10` get `--kill-at`; see +`docs/companion-conventions.md` for why. The script currently expects all +inputs in one directory, so these historical commands need adjustment for +the clean-release layout: the nine Konami modules are in `contents/modules/` +and the external NUI runtime is supplied separately. See the +[official inventory](companion-inventory.md). ## 4. Build the proxy and reconstructed slice (T4 + T11) @@ -209,14 +215,14 @@ The Phase-0 `gameMain` is a forwarding proxy: it only resolves the original `gamekdm_orig.dll` when actually called, so loading the rebuilt DLL on its own is a valid smoke test and needs no original present. -## 6. Deploy to the Windows / spice2x rig (optional, deferred) +## 6. Deploy to the cabinet/original-binary runtime (optional, deferred) -In-game QA on the real spice2x rig is a later integration milestone and is not +In-game QA on the cabinet/original-binary runtime is a later integration milestone and is not part of the reproducible Linux build above. When it lands: rename -`build/gamekdm.dll` to the launcher's expected name, keep the original beside it -as `gamekdm_orig.dll` for the proxy to forward into, and launch through the -game's normal `gamestart.bat` / `launcher.exe` path. Treat this as deferred; the -steps 2 through 5 chain is the complete, self-contained verification. +`build/gamekdm.dll` for the reconstruction cutover, keep the original beside it +as `gamekdm_orig.dll` for the proxy to forward into, and load it through the +cabinet/original-binary runtime. Treat this as deferred; the steps 2 through 5 +chain is the complete, self-contained verification. ## One-shot reference diff --git a/docs/re/gamemain-binding.md b/docs/re/gamemain-binding.md index 1217f55..170871b 100644 --- a/docs/re/gamemain-binding.md +++ b/docs/re/gamemain-binding.md @@ -1,264 +1,155 @@ -# gamekdm.dll `gameMain` binding: how it is found and called, and the `hInstance` argument +# `gamekdm.dll` `gameMain` binding and `hInstance` provenance -Scope: the boot path from spice2x/arkkdm's launcher down to the single call into gamekdm.dll's -exported `gameMain`. Findings are cross-referenced between the Linux disassembly of the shipped -Windows binaries (`objdump -d/-p/-s`, i386 PE) and the spice2x source (`spice2x-master.tar.gz`, -extracted from `src/` next to the binaries). Full raw transcript: -`.omo/evidence/gamekdm-decomp-linux/task-5.log`. +Scope: the official binding path from the AVS2 runtime's entry into +`arkkdm.dll` to the call of `gamekdm.dll`'s exported `gameMain`. The evidence +described here comes from the official game modules' PE metadata, strings, and +disassembly. -Binaries analyzed (all from -`/mnt/f/Users/Aaron Thapa/Downloads/KDM-2016021900/contents/`): +## Integrity boundary -- `launcher.exe` (PE32, image base `0x01000000`) — the generic AVS launcher, invoked as - `launcher -k deahook.dll arkkdm.dll` by `gamestart.bat`. -- `arkkdm.dll` (PE32, image base `0x10000000`) — the DEA/KDM "ark" game-glue DLL that spice2x - loads as the AVS game DLL (`avs::game::DLL_NAME`). -- `deahook.dll` — a small hook DLL loaded by the launcher before `arkkdm.dll`; exports only - `GetProcAddress`/`LoadLibraryA`/`LoadLibraryExW` forwarders per its import/export tables, not - involved in the `gameMain` resolution itself. -- `/home/athapa/ghidra/gamekdm.dll` — the original game DLL whose `gameMain` export is the - target of this binding (used only to confirm the printed diagnostic string and parameter - shape, not disassembled beyond its entry stub). +Earlier reverse engineering used an installed tree whose `arkkdm.dll`, +`libacio.dll`, and `gamekdm.dll` byte sizes may differ from the clean +KDM-2016021900 release. Therefore, any exact byte count, export count, or +address from that installed copy which is not part of the clean-binary facts +listed below is **UNVERIFIED (pending re-check against clean-release binary)**. +No new numeric values are inferred in this document. -## (a) Name vs. ordinal: binding is by NAME at every hop, not by ordinal +The clean-binary facts retained here are: -There are two separate binding hops in this boot path, and both resolve by exported **name** -string through `GetProcAddress`, never by ordinal: +- `arkkdm.dll` exports `dll_entry_init` by name at ordinal 253, RVA `0x767c0`. +- `arkkdm.dll` exports `dll_entry_main` by name at ordinal 254, RVA `0x767b0`. +- `gamekdm.dll` exports `gameMain` at RVA `0x9e20` / VA `0x10009e20`. +- `gameMain` is cdecl and takes one `void *` argument. -**Hop 1 — spice2x (AVS launcher) → arkkdm.dll.** spice2x's `avs::game` layer only ever knows -two entry point names, `"dll_entry_init"` and `"dll_entry_main"`: +## (a) Hop 1: AVS2 runtime to `arkkdm.dll` -``` -spice2x/avs/game.cpp:13 const char ENTRY_INIT_NAME[] = "dll_entry_init"; -spice2x/avs/game.cpp:14 const char ENTRY_MAIN_NAME[] = "dll_entry_main"; -spice2x/avs/game.cpp:98 dll_entry_init = (ENTRY_INIT_T) libutils::get_proc(DLL_INSTANCE, ENTRY_INIT_NAME); -spice2x/avs/game.cpp:99 dll_entry_main = (ENTRY_MAIN_T) libutils::get_proc(DLL_INSTANCE, ENTRY_MAIN_NAME); -spice2x/util/libutils.cpp:128 FARPROC libutils::get_proc(HMODULE module, LPCSTR proc) { -spice2x/util/libutils.cpp:129 auto value = GetProcAddress(module, proc); +The AVS2 runtime enters `arkkdm.dll` through its standard AVS2 entry exports: + +```text +arkkdm.dll!dll_entry_init ordinal 253 RVA 0x767c0 +arkkdm.dll!dll_entry_main ordinal 254 RVA 0x767b0 ``` -`launcher/launcher.cpp:1191-1192` sets `avs::game::DLL_NAME = "arkkdm.dll"` once -`check_dll("arkkdm.dll")` succeeds, and `launcher/launcher.cpp:1888` makes the single top-level -call `avs::game::entry_main()` that triggers the chain below. `entry_init`/`entry_main` even -re-resolve the proc address on every call and log `"... is hooked"` if it changed -(`avs/game.cpp:103-125`), which is defensive **name** re-resolution, not ordinal lookup. +Both symbols are present in `arkkdm.dll`'s PE name-pointer table, so they are +by-name exports rather than ordinal-only exports. The ordinals identify their +export-table entries; they do not imply an ordinal-only call. -Confirmed on the arkkdm.dll side: `objdump -p arkkdm.dll` shows exactly two ordinal/name pairs -at the tail of its export directory (ordinal base 1, Hint/Name table present — i.e. these are -real by-name exports, not ordinal-only): +After initialization, the AVS2 runtime calls +`arkkdm.dll!dll_entry_main`. Everything from that point through the invocation +of `gameMain` is implemented inside `arkkdm.dll`. -``` -[ 253] +base[ 254] 00fd dll_entry_init -[ 254] +base[ 255] 00fe dll_entry_main -``` -(Export Address Table RVAs: `dll_entry_init` = RVA `0x000767c0` → VA `0x100767c0`; -`dll_entry_main` = RVA `0x000767b0` → VA `0x100767b0`, image base `0x10000000`.) +## (b) Hop 2: `arkkdm.dll` to `gameMain` -**Hop 2 — arkkdm.dll → gamekdm.dll's `gameMain`.** This hop is **entirely internal to -arkkdm.dll**; spice2x never touches it (see part (c)). Disassembling the function arkkdm.dll's -`dll_entry_main` ultimately calls (VA `0x10001340`) shows a literal `GetProcAddress` call -passing the ASCII string `"gameMain"`: +`arkkdm.dll` contains a two-candidate payload resolver. Its production +candidate is `gamekdm.dll`; its test-build fallback is `arkkdmtest.dll`. +Conceptually, the official code performs: -``` -10001396: 68 dc 09 09 10 push 0x100909dc ; &"gameMain" -1000139b: 56 push esi ; esi = HMODULE of the candidate library -1000139c: ff 15 3c d1 07 10 call DWORD PTR ds:0x1007d13c ; import thunk = KERNEL32!GetProcAddress -100013a2: 85 c0 test eax,eax -100013a4: 75 0e jne 0x100013b4 ; found -> call it (see part (b)) +```c +HMODULE candidate = LoadLibraryA("gamekdm.dll"); +if (candidate == NULL) { + candidate = LoadLibraryA("arkkdmtest.dll"); +} + +if (candidate != NULL) { + gameMain = GetProcAddress(candidate, "gameMain"); + if (gameMain != NULL) { + gameMain(g_MainDllInfo.dllHMODULE); + } +} ``` -That the thunk at `0x1007d13c` really is `GetProcAddress` is independently confirmed by -arkkdm.dll's import directory (`objdump -p`): +The actual implementation loops over the two literal module names. For each +candidate it calls `LoadLibraryA`; after a successful load it passes the +literal string `"gameMain"` to `GetProcAddress`. It invokes only a successfully +resolved pointer. -``` -DLL Name: KERNEL32.dll - 0007d050 033f LoadLibraryW - 0007d134 033c LoadLibraryA - 0007d13c 0245 GetProcAddress +This is standard Win32 dynamic linking with a production/test-build fallback. +There is no custom export protocol between `arkkdm.dll` and the payload DLL. + +## (c) `hInstance` is `arkkdm.dll`'s own module handle + +The single argument passed to `gameMain` is not the handle returned while +loading `gamekdm.dll`. It is `arkkdm.dll`'s own `HINSTANCE` / `HMODULE`. + +The value's provenance is: + +1. The Windows loader calls `arkkdm.dll`'s `DllMain`. +2. On `DLL_PROCESS_ATTACH`, `DllMain` captures its `hinstDLL` argument. +3. `dll_entry_init` relays that captured value into the internal + `g_MainDllInfo.dllHMODULE` field. +4. The `dll_entry_main` path gives the `g_MainDllInfo` structure to the + internal payload resolver. +5. The resolver reads field zero, pushes that one value, and indirectly calls + the resolved `gameMain` pointer. + +```text +arkkdm.dll DllMain hinstDLL + -> captured module-instance global + -> g_MainDllInfo.dllHMODULE + -> dll_entry_main payload resolver + -> gameMain(hInstance) ``` -and the string `"gameMain"` lives at VA `0x100909dc` in `.rdata` -(`objdump -s --start-address=0x10090870` shows `...67616d65 4d61696e 00000000...` = `"gameMain\0"` -right after a `"gameInit\0"` string at `0x100909d0`; file-offset cross-check: `strings -a -t x -arkkdm.dll` independently reports `8f9dc gameMain`, and `0x100909dc − 0x1007d000 + 0x7c000 = -0x8f9dc` — the `.rdata` section's VMA-to-file-offset delta — matches exactly). +The adjacent diagnostic strings identify the structure as `MainDllInfo` and +its first field as `dllHMODULE`. The initialization logic treats the value as +set-once module identity: it stores the captured handle on the first +initialization and has a warning path if a later value differs. -**Conclusion:** both the launcher→arkkdm.dll and arkkdm.dll→gamekdm.dll bindings are plain -`GetProcAddress`-by-name. There is no ordinal-only export or ordinal-based call anywhere on this -path; the `(dll_entry_init, dll_entry_main)` pair happens to also carry low (253/254) sequential -ordinals in arkkdm.dll's export table, but spice2x (and arkkdm.dll's own internal resolver for -`gameMain`) always look them up by name string, never by ordinal number. +Consequently, `gameMain` receives the module instance assigned to +`arkkdm.dll`. It does not receive `gamekdm.dll`'s module handle. -## (b) The `hInstance` argument: arkkdm.dll's own module HINSTANCE, not gamekdm.dll's +## (d) `gameMain` signature and calling convention -Tracing the single stack argument pushed into the resolved `gameMain` pointer -(`10001340`-`100013d0`): +`gameMain` is at RVA `0x9e20` / VA `0x10009e20` in `gamekdm.dll`. Its callable +shape is: -``` -10001329: 8b 4d fc mov ecx,DWORD PTR [ebp-0x4] ; saved earlier = *(DWORD*)[struct ptr] -100013b4: 8b 4d fc mov ecx,DWORD PTR [ebp-0x4] -100013b7: 51 push ecx ; the ONLY argument to gameMain -100013b8: ff d0 call eax ; eax = resolved gameMain address +```c +/* cdecl; one argument */ +gameMain(void *hInstance); ``` -`[ebp-0x4]` was populated a few instructions earlier by dereferencing offset 0 of a -caller-supplied struct pointer (`ebx`, received as this function's only parameter): +The `arkkdm.dll` call site pushes exactly one argument before the indirect +call. `gameMain` reads that pointer as its first stack argument. Its return +paths use a bare `ret`, leaving argument cleanup to the caller; the caller +resets its own stack frame after the call. Those two sides agree on cdecl. -``` -10001374: 8b 13 mov edx,DWORD PTR [ebx] ; struct->field0 -10001379: 89 55 fc mov DWORD PTR [ebp-0x4],edx +## (e) Complete official binding chain + +```text +AVS2 runtime + -> arkkdm.dll!dll_entry_init + captures/relays arkkdm.dll's HINSTANCE + -> arkkdm.dll!dll_entry_main + -> arkkdm.dll internal candidate resolver + -> LoadLibraryA("gamekdm.dll") + fallback: LoadLibraryA("arkkdmtest.dll") + -> GetProcAddress(candidate, "gameMain") + -> gameMain(g_MainDllInfo.dllHMODULE) ``` -The struct passed in is a fixed global at VA `0x1014b9f8` (the only caller of this function, -`arkkdm.dll`'s exported `dll_entry_main` path, pushes it explicitly: `10002573: push -0x1014b9f8`). The `.rdata` strings right next to the code that writes this global name it -**`MainDllInfo`**, with field0 called `dllHMODULE`: +This establishes the two important boundaries: -``` -10090884 (referenced at 10076800): "1st... MainDllInfo::setDllHMODULE : dllHMODULE %p, hModule %p\n" -100908c0 (referenced at 10076813): "!!!WARNNING!!! MainDllInfo::setDllHMODULE : dllHMODULE %p, hModule %p\n" -``` +- AVS2 calls the official AVS2 entry export in `arkkdm.dll`. +- `arkkdm.dll` itself loads the payload, resolves `gameMain`, and supplies its + own captured module instance. -And the code that performs this first-time set, inside arkkdm.dll's exported `dll_entry_init` -(VA `0x100767c0`, the function `objdump -p` lists as ordinal 253): +## Deferred clean-binary checks -``` -100767eb: a1 f8 b9 14 10 mov eax,ds:0x1014b9f8 ; g_MainDllInfo.dllHMODULE (0 until first set) -100767f0: 85 c0 test eax,eax -100767f2: 75 13 jne 0x10076807 ; already set -> compare & warn path -100767f4: a1 34 51 0f 10 mov eax,ds:0x100f5134 ; <- arkkdm.dll's own captured hInstDLL -100767fb: a3 f8 b9 14 10 mov ds:0x1014b9f8,eax ; g_MainDllInfo.dllHMODULE = that value -``` +The control flow and named interface above are official and derivable from the +game binaries. Older instruction addresses, data addresses, thunk addresses, +file offsets, raw byte sequences, and exact export totals not repeated as +clean-binary facts in this document are **UNVERIFIED (pending re-check against +clean-release binary)**. -`0x100f5134` is populated by arkkdm.dll's own `DllMain`, which this disassembly shows checking -`fdwReason == DLL_PROCESS_ATTACH (1)` and, only in that case, storing its first parameter -(`hinstDLL`) there: +The following details do not affect the binding contract and remain deferred: -``` -10076793: 8b 45 0c mov eax,DWORD PTR [ebp+0xc] ; fdwReason (DllMain arg 2) -10076796: 48 dec eax -10076797: 75 08 jne 0x100767a1 ; skip unless fdwReason == 1 -10076799: 8b 45 08 mov eax,DWORD PTR [ebp+0x8] ; hinstDLL (DllMain arg 1) -1007679c: a3 34 51 0f 10 mov ds:0x100f5134,eax ; stash it -``` +- whether `g_MainDllInfo.dllHMODULE` is reset across repeated entry calls; +- the purpose of surrounding generic initialization and logging guards; +- a live cabinet observation of the pointer value received by `gameMain`. -**Conclusion:** the `void* hInstance` that `gamekdm.dll`'s `gameMain(void* hInstance)` receives -and logs as `gameMain hInstance = %p` is **arkkdm.dll's own `HINSTANCE`/`HMODULE`** — the handle -the Windows loader assigned to `arkkdm.dll` when it was mapped, captured once in `DllMain` on -`DLL_PROCESS_ATTACH` and handed down through the `dll_entry_init` → `g_MainDllInfo.dllHMODULE` → -`dll_entry_main` → `gameMain` chain. It is **not** `gamekdm.dll`'s own module handle (gamekdm.dll -never receives or computes its own `HMODULE` on this path) and it is **not** any -spice2x/launcher-level handle — spice2x's `avs::game::DLL_INSTANCE` (the `HINSTANCE` of -`arkkdm.dll` as seen by spice2x, set via `LoadLibraryW` at `avs/game.cpp:94`) and arkkdm.dll's -own internally-captured `hInstDLL` are the same underlying OS handle value (both are "the -HINSTANCE the loader gave arkkdm.dll"), but spice2x's copy of that value is never passed to -`gameMain` directly — arkkdm.dll re-derives and forwards its own copy independently via the -`DllMain` → `g_MainDllInfo` relay described above. The `fdwReason == 1` guard plus the -"already set" warning string (`!!!WARNNING!!! ... dllHMODULE %p, hModule %p`) show this value is -latched exactly once per process and is treated as a stable per-DLL identity handle, matching -the Win32 convention that `HINSTANCE == HMODULE` for a mapped module. +## Cross-references -## (c) Richer-than-plain-GetProcAddress mechanism: a 2-candidate module fallback, no custom protocol - -spice2x's own role stops at loading `gamekdm.dll` so its hook DLL (`deahook.dll`/attached hooks) -can bind to it early — it never resolves or calls `gameMain` itself: - -``` -spice2x/games/dea/dea.cpp:16 libutils::try_library(MODULE_PATH / "gamekdm.dll"); -``` - -`libutils::try_library` is a bare `LoadLibraryW`/`LoadLibraryA` wrapper -(`spice2x/util/libutils.cpp:82-88`) with no accompanying `get_proc`/`GetProcAddress` call for -`gamekdm.dll` anywhere in the spice2x tree (`rg 'gameMain'` across the whole source tree matches -only an unrelated comment in `spice2x/games/we/we.cpp:137` about a different game's `gameMain` -sleeping — Winning Eleven, not DEA/KDM). All resolution and invocation of `gameMain` happens -inside **arkkdm.dll** itself, inside the function at VA `0x10001340`. `dll_entry_main` -(`100767b0`) reaches it with a plain, unconditional jump — not a call — straight into the -function at `0x100024c0` (`100767b0: jmp 0x100024c0`); that function's own code then does the -actual resolve-and-invoke, at `10002578: call 0x10001340`. (`0x10076800` is a separate, -earlier code path inside `dll_entry_init`/`DllMain`'s `MainDllInfo` bookkeeping — it only pushes -a diagnostic-log string and is not part of this call chain; likewise `0x10002440`, called later -in `0x100767b0`'s own function at `1007682f`, is a separate initialization step unrelated to the -`gameMain` resolve-and-call at `0x10002578`/`0x10001340`.) - -That function is slightly richer than a single `LoadLibraryA`+`GetProcAddress` pair: it loops -over a small fixed array of **two** candidate module-name strings before giving up -(`10001369: mov edi,DWORD PTR [eax*4+0x100b7d60]` with loop bound `cmp eax,0x2`), reading them -from a `.data` pointer table: - -``` -.data @ 0x100b7d60: dd 0x1009032c, 0x10090338 - 0x1009032c -> "gamekdm.dll" (confirmed: strings -a -t x arkkdm.dll -> `8f32c gamekdm.dll`; - 0x1009032c - 0x1007d000 + 0x7c000 = 0x8f32c) - 0x10090338 -> "arkkdmtest.dll" (objdump -s --start-address=0x10090330: "...arkkdmtest.dll\0") -``` - -For each candidate it calls its own `LoadLibraryA` wrapper (`call 0x100013e0`, which itself -calls the `0x1007d134` import thunk = `LoadLibraryA`), and only on a successful load does it -call `GetProcAddress(hModule, "gameMain")` (`0x1007d13c`) and, on success, invoke the resolved -pointer with the `hInstance` argument from part (b); on failure for both candidates it returns -an error code without calling anything. The identical two-candidate loop pattern -(`gamekdm.dll` / `arkkdmtest.dll`) is reused immediately beforehand to resolve a second, -unrelated export named `"gameInit"` (VA `0x100012a0`-`0x10001338`, same `0x100b7d60` table), -which this task did not need to trace further. - -**Conclusion:** the "richer than plain `GetProcAddress`" element is a small build-variant -fallback (production `gamekdm.dll` vs. a `arkkdmtest.dll` test build) baked into arkkdm.dll's own -resolver, not a custom linking/export protocol layered over `GetProcAddress` — the underlying -lookup and call are standard `LoadLibraryA` + `GetProcAddress` + indirect `call`. - -## (d) `gameMain`'s calling convention: cdecl - -**Calling convention: cdecl (verified, bare ret at 0x10009e91/0x10009ea5).** `gamekdm.dll` -exports exactly one symbol, `gameMain`, at RVA `0x9e20` (VA `0x10009e20` in -`/home/athapa/ghidra/gamekdm.dll`). Disassembling its full body -(`objdump -d -M intel --start-address=0x10009e20 --stop-address=0x10009eb0`) shows both of its -return paths ending in a **bare** `ret` with no immediate operand: - -``` -10009e8d: 5f pop edi -10009e8e: 33 c0 xor eax,eax -10009e90: 5e pop esi -10009e91: c3 ret -... -10009ea1: 5f pop edi -10009ea2: 33 c0 xor eax,eax -10009ea4: 5e pop esi -10009ea5: c3 ret -``` - -`gameMain` takes a single pointer argument (`hInstance`, read off `[esp+4]` at function entry: -`10009e28: mov edi,DWORD PTR [esp+0xc]` after two earlier `push`es shift the frame, equivalent to -the original `[esp+4]` at entry). A `ret` with no `N` operand pops only the return address and -leaves argument cleanup to the **caller** — the defining trait of **cdecl**, as opposed to -`stdcall`/`ret 4`, where the callee itself would pop the single 4-byte argument before -returning. Correspondingly, the call site into the resolved `gameMain` pointer (part (b), `100013b4-100013b8: -push ecx; call eax`) never issues an explicit `add esp,4` after the call to pop the argument; -instead the caller's own frame-pointer-based epilogue (`100013bf: mov esp,ebp`) resets `esp` -wholesale, discarding the pushed argument along with the rest of the local frame — the caller, -not the callee, owns stack cleanup, consistent with cdecl. (`0x10001000` is unrelated code -elsewhere in arkkdm.dll's resolver stub, not `gameMain`'s body — `gameMain` itself lives at -`0x10009e20` in `gamekdm.dll`, a different binary.) - -## Unresolved / deferred points - -- This was all verified statically from the Linux-hosted `objdump` disassembly and the spice2x - C++ source; no in-game Windows run was performed to confirm the live `%p` value printed by - `gameMain hInstance = %p` in `/home/athapa/ghidra/gamekdm.dll` matches arkkdm.dll's load - address at runtime (explicitly deferred/optional per task scope). -- The exact caller chain from `dll_entry_main` (`0x100767b0: jmp 0x100024c0`) into the function - at `0x100024c0`, whose own `10002578: call 0x10001340` reaches the `gameMain` resolver, was - walked instruction-by-instruction (full addresses cited above and in the evidence log) but the - surrounding static-initializer bookkeeping - (`0x1014c1e8` flag, `0x10001d20`/`0x100562bf` calls) is generic AVS runtime boilerplate - (locale/logging init guards) and was not further reverse engineered, as it does not affect the - `gameMain` binding or argument semantics. -- Whether `g_MainDllInfo.dllHMODULE` (`0x1014b9f8`) is ever reset or reused across multiple - `dll_entry_main` invocations in one process lifetime was not traced beyond the single - "set-once, warn-if-different-later" guard shown above; this task only needed the first, - steady-state value. - -## Evidence - -Full `objdump -d` / `-p` / `-s` / `strings` output and the matching spice2x source excerpts are -in `.omo/evidence/gamekdm-decomp-linux/task-5.log`. +- [`docs/spec/01-runtime-boot.md`](../spec/01-runtime-boot.md) — official + runtime, nine-module set, configuration, and startup summary. +- [`docs/companion-inventory.md`](../companion-inventory.md) — clean-release + inventory and official dependency DAG. diff --git a/docs/spec/00-overview.md b/docs/spec/00-overview.md index b915b6e..7176807 100644 --- a/docs/spec/00-overview.md +++ b/docs/spec/00-overview.md @@ -1,7 +1,7 @@ # 00 - Overview and High-Level Architecture This is the entry point to the full technical specification of **DanceEvolution -Arcade** (internal Konami codename **"Game_DaM"**, repo shorthand **KDM**) and +Arcade** (official e-amusement model **KDM**) and of the reconstruction codebase that rebuilds its main logic DLL from static and dynamic analysis. Every claim here is cited to a real artifact. Where something could not be checked, it is marked **UNVERIFIED**. No copyrighted creative @@ -20,31 +20,21 @@ the game is, the platform it runs on, the module stack, and the three DanceEvolution Arcade (DEA) is a Konami arcade dance game driven by a Kinect sensor: the player dances in front of a depth camera and the game scores the match between the tracked body pose and the choreography. The game logic lives -in **`gamekdm.dll`**, a 3,369,104-byte PE32 (x86) DLL whose single export is -`gameMain` (docs/companion-inventory.md row `gamekdm.dll`). That export sits at -RVA `0x00009e20`, i.e. absolute `0x10009e20` against the image base -`0x10000000` (objdump of `gamekdm.dll`: `[ 1] 00009e20 Export RVA` / -`0000 gameMain`; base confirmed by `re/rvadb.json` `image_base = "0x10000000"`). +in **`gamekdm.dll`**, a 3.19 MB PE32 (x86) DLL whose single export is +`gameMain` (docs/companion-inventory.md, per-module table). Its previously +reported per-byte size and export RVA `0x00009e20` / VA `0x10009e20` are +**UNVERIFIED (pending re-check against clean-release binary)**; the RVA is +retained only as a reconstruction locator, not clean-release evidence +(`re/rvadb.json`). -The "DEA" identity is corroborated by the shipped launcher chain and by the -spice2x integration that loads this exact DLL: spice2x's own game family for -this title is `games::dea`, and its `games/dea/dea.cpp` `try_library()`-loads -`gamekdm.dll` and probes `Kinect10.dll` (docs/companion-inventory.md, -"deahook.dll origin" finding). The build analyzed here is the -**`KDM-2016021900`** distribution (docs/companion-inventory.md title line). - -Within the binary, Konami's own module naming uses the **KDM** prefix (the ARK -engine API exported by `arkkdm.dll` is `arkKDM`-prefixed, 255 plain-C exports; -docs/companion-inventory.md row `arkkdm.dll`). The hooking DLL records its -internal module name as **"DEALibacio.dll"** (docs/companion-inventory.md row -`deahook.dll`), which ties the "DEA" product name and the "KDM"/Libacio engine -naming together in one shipped artifact. - -> Naming note: "Game_DaM" is the codename carried forward from prior RE notes as -> the internal project tag. The shipped artifacts verify **DEA** (product) and -> **KDM** (engine/module prefix); the literal string "Game_DaM" is treated as an -> internal codename and is **UNVERIFIED** against a specific byte offset in this -> section. +The build specified here is the clean **`KDM-2016021900`** release +(docs/companion-inventory.md title and "What the clean release contains"). +The official artifacts ground its DEA/KDM identity without any launcher, hook, +or emulator evidence: `prop/eamuse-config.xml` carries the e-amusement model; +the clean release has no `ea3-config.xml`; `arkkdm.dll` exposes the `arkKDM*` +API prefix; and the official file stems are `arkkdm.dll` and `gamekdm.dll` +(`contents/prop/eamuse-config.xml`, `contents/modules/arkkdm.dll`, +`contents/modules/gamekdm.dll`; docs/companion-inventory.md per-module table). --- @@ -52,87 +42,69 @@ naming together in one shipped artifact. DEA targets **Win32 x86** and is built on Konami's **AVS2** middleware stack: -- **AVS2 core** is `libavs-win32.dll` (517,264 B, 360 ordinal-style exports - `XCd229cc...`), the root of the MAIN Konami middleware stack (`libafp-win32.dll - -> libavs-win32.dll`; `arkkdm.dll -> libavs-win32.dll`/`libafp-win32.dll`/ - `ess.dll`/`libacio.dll`; `gamekdm.dll -> that stack`). Several shipped DLLs - are independent leaves that import no other shipped DLL instead of - descending from it: `libacio.dll`, `libinput.dll`, `arkkdmtest.dll`, and - `deahook.dll` each import only OS/DirectX DLLs (`objdump -p` on each, no - `DLL Name:` entry naming another shipped file; docs/companion-inventory.md - row `libavs-win32.dll`). -- **ea3** (e-amusement v3) extension is `libavs-win32-ea3.dll` (372,880 B, 139 - exports), importing only `libavs-win32.dll` (same inventory, ea3 row). +- **AVS2 core** is `libavs-win32.dll` (505.14 KB in the clean-release listing), + the root of the official nine-module dependency graph. `libacio.dll` and + `arkkdmtest.dll` are the other shipped roots; neither imports another shipped + module (docs/companion-inventory.md, per-module table and dependency DAG). +- **ea3** (e-amusement v3) extension is `libavs-win32-ea3.dll` (364.14 KB), + importing `libavs-win32.dll` (docs/companion-inventory.md, dependency DAG). - **ARK engine** is `arkkdm.dll` plus the AFP asset/graphics pipeline - (`libafp-win32.dll`, 159 `afp_*` exports; `libafputils-win32.dll`, 162 - `afpu_*` exports). `gamekdm.dll` imports `libavs-win32.dll`, + (`libafp-win32.dll`, `libafputils-win32.dll`). Earlier export counts are + **UNVERIFIED (pending re-check against clean-release binary)**. + `gamekdm.dll` imports `libavs-win32.dll`, `libafputils-win32.dll`, and `libafp-win32.dll` (inventory `gamekdm.dll` row). -- **Kinect v1** is reached through `Kinect10.dll` (the Microsoft NUI v1 API). - In this repo's runtime that DLL is an owner-authored shim that feeds synthetic - frames; the game loads it as a normal dependency (`gamekdm.dll` imports - `Kinect10.dll`; inventory `gamekdm.dll` and `Kinect10.dll` rows). The game - only accepts a 4:3 image and runs its own skeleton selection/validity gate on - top of the published 20-joint NUI skeleton (game-internals.md §1, §2). -- **spice2x** is the arcade loader/emulation layer used to run the build off the - original cabinet. The shipped source tarballs `spice2x-master.tar.gz` and - `spicetools-master.tar.gz` under `contents/src/` are the provenance baseline - for classifying every companion DLL (docs/companion-inventory.md source line). +- **Kinect v1** is reached through `Kinect10.dll`, an external Microsoft + Kinect-for-Windows NUI v1 runtime dependency named by `gamekdm.dll`'s import + table. It is not shipped in `contents/modules/` and is never a game module + (docs/companion-inventory.md, "External (non-shipped) dependencies"). -### Boot sequence (GAME-DIR `gamestart.bat`) +### Boot sequence (official `arkkdm.dll` entry) -The shipped `gamestart.bat` prepares NVRAM and raw-data directories, then hands -off to the launcher: - -``` -@launcher -k deahook.dll arkkdm.dll -``` - -So the real entry is `launcher.exe` injecting `deahook.dll` (the DEALibacio ACIO -hook) and loading `arkkdm.dll` (the ARK engine), which in turn brings up the AVS2 -stack and `gamekdm.dll`. The batch file also seeds `dev\nvram\coin.xml`, -`eacoin.xml`, `testmode-v.xml`, `libxml.xml` from `prop\`, and creates -`dev\raw\{bookkeeping,ranking,settings,log}` (GAME-DIR/gamestart.bat). +The AVS2 runtime enters the official game DLL `arkkdm.dll` through its standard +exports `dll_entry_init` and `dll_entry_main`. `dll_entry_main` internally +loads `gamekdm.dll` (with an `arkkdmtest.dll` test-build fallback), resolves +`gameMain`, and calls `gameMain(hInstance)` using `arkkdm.dll`'s captured +`HINSTANCE` (docs/companion-inventory.md, "Boot/entry into the game"). The +reported entry ordinals 253/254, RVAs `0x767c0`/`0x767b0`, and `gameMain` RVA +`0x9e20` are **UNVERIFIED (pending re-check against clean-release binary)**. --- ## Module stack -The shipped build is **22 DLLs** (docs/companion-inventory.md completeness -check). The IN-SCOPE Konami/middleware set is 16; the remaining 6 are ALREADY-OSS -shims/stubs. The dependency DAG (verified acyclic by DFS over all 22 nodes; -inventory "Cross-DLL dependency DAG") stacks like this, base at the bottom: +The clean release ships exactly **9 Konami modules** under `contents/modules/` +(docs/companion-inventory.md, "What the clean release contains"). Their +shipped-module dependency DAG is acyclic and stacks like this: ``` - +-----------------------------------------------+ - loader | launcher.exe -> -k deahook.dll arkkdm.dll | (gamestart.bat) - +-----------------------------------------------+ - | - game +----------------------------------------+ - logic | gamekdm.dll (gameMain) | 3.37 MB, 1 export - +----------------------------------------+ - | | | | - engine/ arkkdm.dll libafputils libafp Kinect10.dll (NUI v1 shim) - assets (ARK/KDM) -win32.dll -win32.dll - | | | - AVS2 ext ess.dll libavs-win32-ea3.dll (e-amusement v3) - \________________|________________/ - | - AVS2 base libavs-win32.dll (root; 360 exports) + game logic gamekdm.dll (gameMain) + | | | + libavs libafp libafputils + | | + +-- libafp - peripheral: libacio.dll / libacio_mbr.dll / libinput.dll (AC-IO + HID) - modules : kmd.dll / ksm.dll / kuc.dll (AVS2-family) - OSS stubs : kbt.dll / kld.dll (bemanitools ikey), stubs/64/nv*.dll (spice2x) + game entry arkkdm.dll + / | | | \ + libavs ea3.dll ess.dll libacio libafp + | / | + +-----+ +-- libavs + + test harness arkkdmtest.dll (root) + shipped roots libavs-win32.dll, libacio.dll, arkkdmtest.dll + + external only Kinect10.dll (Microsoft NUI v1 runtime; not shipped) ``` -Key verified edges (inventory DAG, text form): `gamekdm.dll -> Kinect10.dll, -libavs-win32.dll, libafputils-win32.dll, libafp-win32.dll`; `arkkdm.dll -> +The complete official set is `libavs-win32.dll`, `libavs-win32-ea3.dll`, +`libafp-win32.dll`, `libafputils-win32.dll`, `ess.dll`, `libacio.dll`, +`arkkdm.dll`, `arkkdmtest.dll`, and `gamekdm.dll` (inventory "IN-SCOPE +reconstruct set"). Key shipped edges are `gamekdm.dll -> libavs-win32.dll, +libafputils-win32.dll, libafp-win32.dll`; `arkkdm.dll -> libavs-win32.dll, libavs-win32-ea3.dll, ess.dll, libacio.dll, libafp-win32.dll`; `libafp-win32.dll -> libavs-win32.dll`; `libavs-win32-ea3.dll -> -libavs-win32.dll`. `libavs-win32.dll` is the root of the main middleware -stack and a transitive ancestor of most IN-SCOPE DLLs, but not all: `libacio.dll`, -`libinput.dll`, `arkkdmtest.dll`, and `deahook.dll` are independent leaves that -import no other shipped DLL (see [`02-dll-architecture.md`](./02-dll-architecture.md) -dependency DAG). `gamekdm.dll` is the terminal node of the main stack. +libavs-win32.dll`. `Kinect10.dll` is shown only as `gamekdm.dll`'s external +Microsoft runtime import and is excluded from the nine-node graph +(docs/companion-inventory.md, dependency DAG). --- @@ -144,11 +116,12 @@ of mixing "how the shipped game behaves" with "what we rebuilt." 1. **The GAME** - observable product behavior and platform: what DEA does for a player, the Kinect data path, the AVS2/ARK/ea3 middleware it rides on, the - boot chain, and the asset formats. Grounded in the shipped binaries, the - batch file, and runtime introspection (game-internals.md §1-§5). + official AVS2 entry path, and the asset formats. Grounded in the clean + release's binaries and `contents/{data,arkdata,prop}` trees + (docs/companion-inventory.md). 2. **The ORIGINAL binary codebase** - the shipped DLLs as reverse-engineering - subjects: the 22-DLL inventory and dependency DAG, the gamekdm function/global + subjects: the nine-module inventory and dependency DAG, the gamekdm function/global map (9,728 functions in `re/rvadb.json`), and the subsystem breakdown decoded from Ghidra. This is "what Konami shipped," read back from disassembly. @@ -166,15 +139,15 @@ this overview). Each is tagged with its primary dimension: | # | Section | Dimension | |---|---------|-----------| | 00 | [Overview and high-level architecture](./00-overview.md) (this file) | all three | -| 01 | [Platform and AVS2/ea3/ARK middleware](./01-platform-and-middleware.md) | GAME | -| 02 | [Companion DLL inventory and dependency DAG](./02-companion-dll-inventory.md) | ORIGINAL | -| 03 | [Kinect / NUI data pipeline](./03-kinect-pipeline.md) | GAME | -| 04 | [Skeleton validity gate and menu hand-cursor](./04-skeleton-and-cursor.md) | GAME / ORIGINAL | -| 05 | [gamekdm entry, boot, and gameMain](./05-gamekdm-entry.md) | ORIGINAL | +| 01 | [Runtime environment and official AVS2 startup](./01-runtime-boot.md) | GAME | +| 02 | [Official module inventory and dependency DAG](./02-dll-architecture.md) | ORIGINAL | +| 03 | [Kinect / NUI data pipeline](./03-kinect-skeleton.md) | GAME | +| 04 | [Skeleton validity gate and menu hand-cursor](./04-validity-cursor.md) | GAME / ORIGINAL | +| 05 | [Data and configuration formats](./05-data-formats.md) | GAME | | 06 | [gamekdm subsystems](./06-gamekdm-subsystems.md) | ORIGINAL | -| 07 | [Asset and Flash/AFP formats](./07-asset-formats.md) | GAME | -| 08 | [Reconstruction codebase (src/, include/, build)](./08-reconstruction-codebase.md) | RECONSTRUCTION | -| 09 | [RE workflow and tooling (Ghidra, rvadb, companions)](./09-re-workflow.md) | RECONSTRUCTION | +| 07 | [Official companion DLL API surfaces](./07-companion-apis.md) | ORIGINAL | +| 08 | [ABI, calling conventions, and struct layouts](./08-abi-conventions.md) | ORIGINAL / RECONSTRUCTION | +| 09 | [Reconstruction codebase and workflow](./09-reconstruction-codebase.md) | RECONSTRUCTION | > The companion documents these sections build on are already in the repo: > `docs/companion-inventory.md` (feeds 02), `docs/provenance.md` (feeds 08), @@ -195,7 +168,8 @@ already fleshed out from RE are concrete: `src/game/` holds `validity.cpp`, `src/`/`include/` is authoritative; decompiler dumps and the `orig/` binary are working inputs only and stay out of git (docs/provenance.md). -The RE spine is `re/rvadb.json`: 9,728 functions (`function_count = 9728`), each +The RE spine is `re/rvadb.json`: 9,728 function records (`function_count = +9728`), each a record with `rva`, `name`, `callers`/`callees`, `globals_touched`, and a `status` field (e.g. `FUN_10018570`, the validity transform, is present in the DB). This is the index every ORIGINAL-dimension section cites against. @@ -205,8 +179,9 @@ DB). This is the index every ORIGINAL-dimension section cites against. ## How to read this spec - A claim without a citation is a bug. Report it. -- `file:line`, an RVA like `0x10009e20`, objdump output, or an absolute GAME-DIR - path are the acceptable evidence forms. +- An official `contents/` artifact path, a clean-release binary result, or a + repository evidence record explicitly marked with its verification state is + an acceptable evidence form. - GAME-DIR for this build is the owner's local copy of `KDM-2016021900` (`.../KDM-2016021900/contents`); its absolute path is redacted in committed docs per docs/companion-inventory.md. diff --git a/docs/spec/01-runtime-boot.md b/docs/spec/01-runtime-boot.md index 1753c8c..6ee6ed9 100644 --- a/docs/spec/01-runtime-boot.md +++ b/docs/spec/01-runtime-boot.md @@ -1,433 +1,179 @@ -# Runtime Environment & Boot/Startup Chain +# Runtime Environment & Official Boot/Startup Chain -Scope: the hardware/runtime DanceEvolution Arcade (DEA, internal code KDM) runs on, and the exact -process-level chain from `GAME-DIR/gamestart.bat` through to `gamekdm.dll`'s `gameMain` export -being invoked. Every claim below is grounded in a file at the absolute `GAME-DIR` path -(`/mnt/f/Users/Aaron Thapa/Downloads/KDM-2016021900/contents`), in `objdump` output run against -the shipped binaries, or in the reconstructed `spice2x` C++ source archived next to them. See -[`docs/re/gamemain-binding.md`](../re/gamemain-binding.md) for the full byte-level trace this -section summarizes, and [`06-gamekdm-subsystems.md`](./06-gamekdm-subsystems.md) (sibling -section) for what happens once `gameMain` is running. +Scope: the clean KDM-2016021900 release under `contents/`. This document describes +only the official AVS2-to-game path evidenced by the shipped modules and +configuration. See [`docs/re/gamemain-binding.md`](../re/gamemain-binding.md) for +the instruction-level `arkkdm.dll` binding trace and +[`06-gamekdm-subsystems.md`](./06-gamekdm-subsystems.md) for behavior after +`gameMain` starts. -## 1. Hardware and runtime target +## 1. Runtime target -DEA is a Konami AVS2/e-Amusement ("EA3") arcade title. The data under `GAME-DIR/prop/` identifies -it as model **KDM**, destination/spec/revision **A/A/A**, data extension `2016021900` -(`GAME-DIR/prop/ea3-config.xml`, `KDMAA -A2016021900`). This is the standard Konami "Bemani"-style PC-based -cabinet platform (the same AVS2/EA3 runtime underlies titles such as beatmania IIDX, jubeat, -Sound Voltex — confirmed by the shared `avs::core`/`avs::ea3` layer and the sibling-game -`DLL_NAME` table in `launcher.cpp`, see §4 below), not bespoke embedded hardware: all shipped -binaries are 32-bit `pei-i386` Windows PE images (`objdump -p` on `arkkdm.dll`, `deahook.dll`, -`launcher.exe`, `gamekdm.dll` — all report `file format pei-i386`), and `gamekdm.dll` imports -`d3dx9_43.dll` and `d3d9.dll` for rendering (its import-directory DLL list, below), i.e. the game -renders through Direct3D 9 on a conventional Windows PC, not a console SoC. +DanceEvolution Arcade (internal model code KDM) is a 32-bit Windows AVS2 / +e-amusement title. Its official runtime consists of exactly nine modules in +`contents/modules/`: -Body-tracking input is a Microsoft Kinect v1, accessed through the Kinect for Windows v1 NUI API: -`gamekdm.dll`'s PE import directory lists `Kinect10.dll` directly (`objdump -p gamekdm.dll`: -`DLL Name: Kinect10.dll`), the v1 NUI runtime DLL name. The spice2x source confirms this at the -emulation-layer attach point too — `games::dea::DEAGame::attach()` explicitly tries to load -`"Kinect10.dll"` and, on failure, logs `"Failed to load 'Kinect10.dll'. Game will boot in Test -Mode. Have you installed the Kinect SDK?"` (`spice2x/games/dea/dea.cpp:19-23`, extracted from -`GAME-DIR/src/spice2x-master.tar.gz`). This repo's own reconstruction work (`game-internals.md` -§1) independently confirms the same binding by shimming `Kinect10.dll` with a drop-in -replacement that feeds synthetic skeleton/depth/color frames to the unmodified game. +| Module | Clean-release size | Role | +|---|---:|---| +| `libavs-win32.dll` | 505.14 KB | AVS2 core middleware | +| `libavs-win32-ea3.dll` | 364.14 KB | e-amusement v3 AVS2 extension | +| `libafp-win32.dll` | 1.19 MB | AFP asset, font, and graphics pipeline | +| `libafputils-win32.dll` | 165.64 KB | AFP utilities | +| `ess.dll` | 376.14 KB | ESS e-amusement middleware | +| `libacio.dll` | 224.64 KB | ACIO cabinet-I/O protocol library | +| `arkkdm.dll` | 896.64 KB | KDM cabinet engine and AVS2 game entry | +| `arkkdmtest.dll` | 389.14 KB | Render/input test harness | +| `gamekdm.dll` | 3.19 MB | Main KDM game logic | -Coin/credit and cabinet I/O (coin mechs, test/service buttons, card reader) run over Konami's -**ACIO** serial I/O protocol, mediated by `libacio.dll`, which `arkkdm.dll` imports directly -(`objdump -p arkkdm.dll`: `DLL Name: libacio.dll`), and by the spice2x emulation layer's own -`acio` module — `launcher.cpp` calls `acio::attach()` / `acio::attach_icca()` when ACIO or ICCA -(card reader) support is requested (`spice2x/launcher/launcher.cpp:1770-1776`), and the archived -source ships a concrete ACIO device implementation at -`spice2x/acio/icca/icca.cpp`/`icca.h` (ICCA = the Konami card reader protocol). `arkkdm.dll` also -imports `ess.dll` with e-Amusement/PASELI-specific exports (`ess_usbkey_boot_check_license_key`, -`ess_usbkey_boot_check_account_key`, `ess_ea3_get_status`, `ess_ea3_license_agree`, -`ess_ea3_send_pp_event`, `ess_ea3_get_pp_status` — `objdump -p arkkdm.dll` import table), i.e. the -USB dongle/license-key and PASELI ("Participation"?) e-Amusement coin-service checks run through -a separate `ess.dll` module, not `arkkdm.dll` or `gamekdm.dll` code. +These sizes come from the clean-release listing, not byte measurements from an +installed tree. Any older exact byte size or export count derived from an +installed copy is **UNVERIFIED (pending re-check against clean-release binary)**. -**UNVERIFIED:** exact cabinet model number, screen resolution/refresh, and Kinect sensor mounting -geometry are not recorded in any artifact inspected for this section. +`gamekdm.dll` uses Direct3D 9 and imports `Kinect10.dll`, the Microsoft Kinect +for Windows NUI v1 runtime. `Kinect10.dll` is an external platform dependency, +not a shipped game module. The same distinction applies to Windows and DirectX +import targets. -## 2. spice2x as the AVS2 emulation/compatibility layer +The official shipped-module dependency graph has nine nodes: -The shipped `GAME-DIR` does not contain a real Konami `launcher.exe` paired with Konami's own -AVS2 runtime DLLs in a way this reconstruction can observe directly running; instead `GAME-DIR` -ships the **spice2x** (and `spicetools`) reconstruction/compatibility source trees as reference -material: `GAME-DIR/src/spice2x-master.tar.gz` and `GAME-DIR/src/spicetools-master.tar.gz`. These -are open-source reimplementations of the Konami AVS2 launcher/bootstrap stack used by the -Bemani-emulation community to run e-Amusement-era arcade titles on PC without the original -network/license backend. The evidence in this section comes from the `spice2x` tree at -`spice2x/` (top-level after extracting the tarball), specifically: - -- `spice2x/launcher/launcher.cpp` — the launcher's `main`-equivalent entry/orchestration. -- `spice2x/avs/core.cpp`, `spice2x/avs/ea3.cpp`, `spice2x/avs/game.cpp` — the three AVS2 - sub-bootstraps (core runtime, EA3/e-Amusement layer, game-DLL loader), each wrapping a - different real Konami DLL (`libavs-win32.dll`, `libavs-win32-ea3.dll`, and the game DLL itself). -- `spice2x/games/dea/dea.cpp`, `spice2x/games/dea/io.cpp` — the DEA-specific (KDM) game glue: - Kinect attach, button/light I/O mapping. -- `spice2x/acio/icca/icca.cpp` — ACIO card-reader (ICCA) device emulation. - -`launcher.exe` in `GAME-DIR` is the **generic AVS launcher binary** that this spice2x-family -codebase reimplements/hooks, invoked exactly as `gamestart.bat` specifies (§3). It is a thin, -32-bit PE (`ImageBase 01000000`, imports only `KERNEL32.dll`, `msvcrt.dll`, `USER32.dll`, -`libavs-win32.dll`, `libavs-win32-ea3.dll` — `objdump -p launcher.exe`), consistent with its role -as a bootstrap stub whose real behavior is delegated into the AVS/EA3 DLLs it loads. - -## 3. The boot chain, step by step - -### 3.1 `gamestart.bat` — the top-level entry point - -`GAME-DIR/gamestart.bat` is the process the cabinet (or an operator) runs to start the game: - -```bat -@echo off - -cd /d %~dp0 - -set DAMAC_VIEWER_FULLSCREEN=0 - -if not exist dev\nvram mkdir dev\nvram -if not exist dev\nvram\coin.xml copy prop\coin.xml dev\nvram\coin.xml -if not exist dev\nvram\eacoin.xml copy prop\eacoin.xml dev\nvram\eacoin.xml -if not exist dev\nvram\testmode-v.xml copy prop\testmode-v.xml dev\nvram\testmode-v.xml -if not exist dev\nvram\libxml.xml copy prop\libxml.xml dev\nvram\libxml.xml -if not exist dev\raw mkdir dev\raw -if not exist dev\raw\bookkeeping mkdir dev\raw\bookkeeping -if not exist dev\raw\ranking mkdir dev\raw\ranking -if not exist dev\raw\settings mkdir dev\raw\settings -if not exist dev\raw\log mkdir dev\raw\log - -@launcher -k deahook.dll arkkdm.dll +```text +libavs-win32.dll (root) +libacio.dll (root) +arkkdmtest.dll (root; OS multimedia/input imports only) +libavs-win32-ea3.dll -> libavs-win32.dll +libafp-win32.dll -> libavs-win32.dll +libafputils-win32.dll -> libavs-win32.dll, libafp-win32.dll +ess.dll -> libavs-win32.dll, libavs-win32-ea3.dll +arkkdm.dll -> libavs-win32.dll, libavs-win32-ea3.dll, + ess.dll, libacio.dll, libafp-win32.dll +gamekdm.dll -> libavs-win32.dll, libafp-win32.dll, + libafputils-win32.dll + (+ external Kinect10.dll and DirectX) ``` -Steps: +## 2. Official AVS2 entry into `arkkdm.dll` -1. `cd /d %~dp0` — changes into `GAME-DIR` itself so every subsequent relative path (`prop\...`, - `dev\...`, and the bare `launcher`/`deahook.dll`/`arkkdm.dll` names on the last line) resolves - against `GAME-DIR`. -2. `DAMAC_VIEWER_FULLSCREEN=0` — sets a single environment variable before launch; its consumer - is not in any binary inspected for this section (**UNVERIFIED** which component reads it; - "DAMAC" does not appear in the spice2x source tree searched above). -3. It seeds the **AVS virtual filesystem's NVRAM device** (`dev\nvram\`) and the raw-storage tree - (`dev\raw\{bookkeeping,ranking,settings,log}`) from the `prop\` templates on first run — these - are exactly the two filesystem devices `avs-config.xml` declares (§5): ` - dev\nvram` and `dev\raw` - (`GAME-DIR/prop/avs-config.xml`). This is a one-time persistence bootstrap, not something the - boot chain repeats on every launch once the files exist. -4. The final line launches the generic AVS launcher binary, `launcher.exe` (resolved via `PATH`/ - the current directory as plain `launcher`), with `-k deahook.dll arkkdm.dll`: `-k` selects a - **hook DLL** to load before the game DLL (`deahook.dll`), and the trailing positional argument - names the **game DLL** itself (`arkkdm.dll`). This matches the hook-then-game-DLL argument - shape spice2x's own launcher option parsing expects (`launcher/launcher.cpp:1109`, - `module = libutils::try_library(hook)`, loading each `-k`-named hook before the game DLL is - resolved). +The AVS2 runtime enters the game DLL through `arkkdm.dll`'s standard AVS2 +exports: -### 3.2 `launcher.exe` — AVS bootstrap orchestration +| Export | By-name ordinal | RVA | +|---|---:|---:| +| `dll_entry_init` | 253 | `0x767c0` | +| `dll_entry_main` | 254 | `0x767b0` | -`launcher.exe` (PE32, image base `0x01000000`) is the process `gamestart.bat` starts. Per the -spice2x source it reimplements/wraps, its top-level flow (`spice2x/launcher/launcher.cpp`, -function beginning around line 153) is, in the order evidenced by the source: +The names, ordinals, and RVAs are derivable from `arkkdm.dll`'s own PE export +directory with `objdump`. They are by-name exports; the ordinal values describe +their export-table entries but are not the binding mechanism. -1. Parse the `-k ` and positional `` arguments, among the launcher's broader - option set (signal/crypt/ACIO/network flags — `launcher.cpp:153-751`). -2. Load each `-k`-named hook DLL via `libutils::try_library` (`launcher.cpp:1109`) — this is - where `deahook.dll` gets loaded, **before** the game DLL. -3. Resolve the effective game DLL name. Because `gamestart.bat` already names `arkkdm.dll` - explicitly, the launcher's own DLL-autodetect ladder is bypassed, but the ladder's DEA-specific - branch independently confirms the association: `if (check_dll("arkkdm.dll")) { avs::game:: - DLL_NAME = "arkkdm.dll"; ...; attach_dea = true; }` (`launcher.cpp:1190-1194`) — i.e. spice2x's - own code identifies `arkkdm.dll` as *the* DEA/KDM game DLL and, on recognizing it, flags that - the DEA-specific game-glue module (`games::dea::DEAGame`, §3.5) should be attached. -4. Call `avs::core::set_default_heap_size(avs::game::DLL_NAME)` (`launcher.cpp:1528`) and then, if - `attach_dea` was set, push a `new games::dea::DEAGame()` onto the active-games list - (`launcher.cpp:1582-1583`). -5. Load the EA3 (e-Amusement) layer: `avs::ea3::load_dll()` (`launcher.cpp:1703`), which loads - `libavs-win32-ea3.dll` (or `avs2-ea3.dll`/`libavs-win64-ea3.dll`) and resolves its boot/ - shutdown entry points by name (§3.3 / §5). This happens **before** the core runtime is - booted: `avs::core::load_dll()` resolves the core DLL first (`launcher.cpp:1700`), then EA3 - is loaded (`launcher.cpp:1703`), and only after that does the launcher boot the core runtime - (step 6, `launcher.cpp:1711`). -6. Boot the AVS core runtime: `avs::core::boot()` (`launcher.cpp:1711`), which loads - `libavs-win32.dll` (or `avs2-core.dll`/`libavs-win64.dll` depending on what is present — see - §3.3) and resolves its property/filesystem API by name. -7. Attach ACIO/ICCA device emulation if requested (`acio::attach()` / `acio::attach_icca()`, - `launcher.cpp:1770-1776`). -8. Load the actual game DLL (`arkkdm.dll`) through `avs::game::load_dll()` - (`spice2x/avs/game.cpp:72-100`, called indirectly off the game list populated in step 4), which - resolves exactly two entry points by name — `"dll_entry_init"` and `"dll_entry_main"` — via - `GetProcAddress` (`spice2x/avs/game.cpp:13-14,98-99`; see §3.4 for why this is name-based, not - ordinal). -9. Invoke `avs::game::entry_main()` (`launcher.cpp:1888` per - [`gamemain-binding.md`](../re/gamemain-binding.md)), which is the single top-level call that - triggers the chain down into `arkkdm.dll` and ultimately `gamekdm.dll`'s `gameMain` (§3.5–3.6). +`arkkdm.dll`'s `DllMain` captures the DLL's own `HINSTANCE` on +`DLL_PROCESS_ATTACH`. `dll_entry_init` relays that value into the internal +`g_MainDllInfo.dllHMODULE` field. The AVS2 runtime then calls +`arkkdm.dll`'s `dll_entry_main`. -Confirmed independently from the binary side: `launcher.exe`'s PE import table lists exactly -`KERNEL32.dll` (with `LoadLibraryA` at IAT RVA `0x00001010` and `GetProcAddress` at -`0x0000102c`), `msvcrt.dll`, `USER32.dll`, `libavs-win32.dll`, and `libavs-win32-ea3.dll` -(`objdump -p launcher.exe`) — i.e. the launcher's only AVS-layer dependencies are the 32-bit -core and EA3 DLLs, matching the `avs::core`/`avs::ea3` 32-bit DLL names spice2x tries first -(`avs/core.cpp:1486`: `DLL_NAME = "libavs-win32.dll"`; `avs/ea3.cpp:134`: `DLL_NAME = -"libavs-win32-ea3.dll"`). +## 3. `arkkdm.dll` resolves and invokes the game payload -### 3.3 AVS2 core + EA3 bootstrap +`dll_entry_main` reaches an internal `arkkdm.dll` resolver that performs this +official sequence: -Two separate AVS2 sub-DLLs are loaded and bootstrapped by the launcher before the game DLL, each -via the same by-name-`GetProcAddress` pattern used throughout this chain: +1. Call `LoadLibraryA("gamekdm.dll")`. +2. If the production payload is unavailable, try the test-build fallback + `LoadLibraryA("arkkdmtest.dll")`. +3. Call `GetProcAddress(candidate_module, "gameMain")`. +4. Invoke the resolved function as `gameMain(hInstance)`. -- **AVS core** (`spice2x/avs/core.cpp`): tries, in order, `avs2-core.dll`, then - `libavs-win64.dll` (64-bit build) or `libavs-win32.dll` (32-bit build — the variant actually - imported by `launcher.exe` per §3.2) — `avs/core.cpp:1481-1492`. It then probes which AVS - protocol-version export is present (a version-keyed obfuscated-name table, - `IMPORT_LEGACY`/`IMPORT_AVS21360`/.../`IMPORT_AVS21730`, `avs/core.cpp:54-109`) via - `GetProcAddress(DLL_INSTANCE, IMPORTS[i].property_search) != nullptr` - (`avs/core.cpp:1513`), and resolves the entire core AVS API — filesystem (`avs_fs_*`), - property-tree (`property_*`), compression stream (`cstream_*`) — by name through that matched - table (`avs/core.cpp:1532-1653`, dozens of `libutils::get_proc<...>(DLL_INSTANCE, - IMPORTS[ver].)` calls). -- **AVS EA3** (`spice2x/avs/ea3.cpp`): tries `avs2-ea3.dll`, then `libavs-win64-ea3.dll` / - `libavs-win32-ea3.dll` (`avs/ea3.cpp:128-139`), probes the same kind of versioned export table - for `boot`/`shutdown` (`avs/ea3.cpp:54-177`, legacy names `"ea3_boot"`/`"ea3_shutdown"` or - obfuscated `"XEb552d500005d"`-style names depending on AVS version), and resolves - `avs_ea3_boot_startup` / `avs_ea3_shutdown` by name (`avs/ea3.cpp:174-177`). +The first successful candidate supplies `gameMain`; if neither candidate +supplies it, no game entry is called. This is an ordinary two-candidate +`LoadLibraryA` / `GetProcAddress` fallback implemented inside `arkkdm.dll`, not +a custom linking protocol. -Both DLL sets are listed directly in `arkkdm.dll`'s own PE import table too (`objdump -p -arkkdm.dll`: `DLL Name: libavs-win32.dll`, `DLL Name: libavs-win32-ea3.dll`), confirming -`arkkdm.dll` itself links against (not just transitively depends on) the AVS core and EA3 DLLs -that the launcher bootstraps first. +The argument is the `HINSTANCE` belonging to `arkkdm.dll`, not the handle of +`gamekdm.dll`. Its relay is: -`avs::ea3::boot()` is also where the **`ea3-config.xml` path is selected and parsed** — see §5. - -### 3.4 Hop 1 — spice2x (launcher) → `arkkdm.dll` (`dll_entry_init`/`dll_entry_main`) - -`avs::game::load_dll()` resolves exactly two symbols out of the loaded game DLL, both by literal -name string through `GetProcAddress`, never by ordinal: - -``` -spice2x/avs/game.cpp:13 const char ENTRY_INIT_NAME[] = "dll_entry_init"; -spice2x/avs/game.cpp:14 const char ENTRY_MAIN_NAME[] = "dll_entry_main"; -spice2x/avs/game.cpp:98 dll_entry_init = (ENTRY_INIT_T) libutils::get_proc(DLL_INSTANCE, ENTRY_INIT_NAME); -spice2x/avs/game.cpp:99 dll_entry_main = (ENTRY_MAIN_T) libutils::get_proc(DLL_INSTANCE, ENTRY_MAIN_NAME); +```text +arkkdm.dll DllMain(hinstDLL, DLL_PROCESS_ATTACH, ...) + -> captured arkkdm.dll HINSTANCE + -> g_MainDllInfo.dllHMODULE + -> dll_entry_main's internal resolver + -> gameMain(hInstance) ``` -`arkkdm.dll`'s own export directory confirms both names are real by-name exports (Hint/Name table -present, not ordinal-only), at ordinals 253/254 of its export table: +The known `gameMain` call shape in `gamekdm.dll` is: -``` -objdump -p arkkdm.dll: - Export Address Table -- Ordinal Base 1 - [ 253] +base[ 254] 000767c0 Export RVA - [ 254] +base[ 255] 000767b0 Export RVA - [Ordinal/Name Pointer] Table -- Ordinal Base 1 - [ 253] +base[ 254] 00fd dll_entry_init - [ 254] +base[ 255] 00fe dll_entry_main +```c +gameMain(void *hInstance); /* cdecl; return type not established here */ ``` -i.e. `dll_entry_init` is at RVA `0x000767c0` (VA `0x100767c0`, image base `0x10000000`) and -`dll_entry_main` is at RVA `0x000767b0` (VA `0x100767b0`). `launcher.cpp:1888` makes the single -top-level call `avs::game::entry_main()`, which (after a defensive name re-resolution check that -logs `"dll_entry_main is hooked"` if the resolved address changed, `avs/game.cpp:115-124`) calls -the resolved `dll_entry_main` pointer — i.e. `0x100767b0` in the shipped `arkkdm.dll`. +`gameMain` is at RVA `0x9e20` / VA `0x10009e20`, takes one pointer argument, +and uses the cdecl calling convention. The bare returns in its entry function +and the caller-owned stack cleanup establish cdecl. -### 3.5 `deahook.dll`'s role +## 4. Official configuration and content roots -`deahook.dll` is loaded by the launcher's `-k deahook.dll` hook mechanism **before** -`arkkdm.dll` resolution (§3.2 step 2), but it is not part of the `gameMain` resolution chain -itself. Its own PE export table carries a single dummy symbol — -`objdump -p deahook.dll`: `[Ordinal/Name Pointer] Table -- Ordinal Base 1: [0] +base[1] 0000 -?dummy@@YGHXZ` (name `DEALibacio.dll`, `Name 00015052 DEALibacio.dll` in the export directory) — -and its import table pulls in only `USER32.dll` and a conventional `KERNEL32.dll` set including -`GetProcAddress`, `LoadLibraryA`, `CreateThread`, `VirtualProtect` (`objdump -p deahook.dll`). -The `VirtualProtect`/`CreateThread`/`GetAsyncKeyState` import combination is consistent with an -inline API-hooking DLL (it patches/intercepts calls in the already-loaded process rather than -exporting a conventional API), matching its name ("DEA hook"). Per -[`gamemain-binding.md`](../re/gamemain-binding.md), `deahook.dll` is "not involved in the -`gameMain` resolution itself" — that entire second hop happens inside `arkkdm.dll`'s own code -(§3.6). +Official assets and configuration all live under `contents/`: -### 3.6 Hop 2 — `arkkdm.dll` → `gamekdm.dll`'s `gameMain` +- `contents/data/{arc,bgmov,bm2d,dal,data,font,movie,sound}` +- `contents/arkdata/{ark/*,arkkdm/*}` +- `contents/prop/` -This hop is entirely internal to `arkkdm.dll`; spice2x never touches `gameMain` directly (an `rg -'gameMain'` across the whole spice2x source tree matches only an unrelated comment about a -different Bemani title in `games/we/we.cpp:137`). `arkkdm.dll`'s `dll_entry_main` -(`0x100767b0`) jumps into an internal resolver function at VA `0x10001340` that: +The clean-release configuration set in `contents/prop/` is: -1. Loops over a fixed 2-entry candidate module-name table at `.data` address `0x100b7d60` - (`dd 0x1009032c, 0x10090338`), pointing at the ASCII strings `"gamekdm.dll"` and - `"arkkdmtest.dll"` — i.e. production builds load `gamekdm.dll`, with `arkkdmtest.dll` as a - test-build fallback. -2. For each candidate, calls its own `LoadLibraryA` wrapper, and only on a successful load calls - `GetProcAddress(hModule, "gameMain")` via the import thunk at `0x1007d13c` (confirmed as - `KERNEL32.dll!GetProcAddress` by `arkkdm.dll`'s import directory: `0007d13c 0245 - GetProcAddress`). -3. On success, invokes the resolved `gameMain` function pointer with a single argument (§3.7). +- `avs-config.xml` +- `ark-config.xml` +- `ark-config_nopp.xml` +- `eamuse-config.xml` +- `ess-config.xml` +- `card_allow.bin` +- `coin.xml` +- `eacoin.xml` +- `share-config.xml` +- `testmode-v.xml` -``` -10001396: 68 dc 09 09 10 push 0x100909dc ; &"gameMain" -1000139b: 56 push esi ; esi = HMODULE of the candidate library -1000139c: ff 15 3c d1 07 10 call DWORD PTR ds:0x1007d13c ; = KERNEL32!GetProcAddress -100013a2: 85 c0 test eax,eax -100013a4: 75 0e jne 0x100013b4 ; found -> call it +### `avs-config.xml` + +This is the AVS2 core configuration. It defines the virtual-filesystem devices, +resource limits, logging, networking, threading, and time settings used by the +runtime beneath the game modules. + +### `eamuse-config.xml` + +This is the e-amusement configuration shipped by the clean release. It carries +the title identity and e-amusement runtime settings consumed by the official +stack. + +### `ark-config.xml` + +This contains `arkkdm.dll`-specific options, including logging, USB-key, +e-amusement coin, and participation settings. + +### `ess-config.xml` + +This configures the official `ess.dll` e-amusement middleware used by +`arkkdm.dll`. + +## 5. Startup summary + +The official startup boundary documented here is: + +```text +AVS2 runtime + -> arkkdm.dll!dll_entry_init + -> arkkdm.dll!dll_entry_main + -> LoadLibraryA("gamekdm.dll") + fallback: LoadLibraryA("arkkdmtest.dll") + -> GetProcAddress(..., "gameMain") + -> gameMain(arkkdm.dll HINSTANCE) ``` -`gamekdm.dll`'s own export table independently confirms `gameMain` is its sole export and that it -is exported **by name only** (ordinal 1, but the project's own convention per `objdump -p -gamekdm.dll` lists it under the `[Ordinal/Name Pointer] Table` as `[0] +base[1] 0000 gameMain`), -with no accompanying `dll_entry_init`/`dll_entry_main` pair — `gamekdm.dll` is the pure "game -logic" payload DLL, `arkkdm.dll` is the AVS-facing glue DLL that hosts it. - -### 3.7 `gameMain`'s signature and calling convention - -`gameMain` is exported at RVA `0x9e20` (VA `0x10009e20`, image base `0x10000000`) in -`gamekdm.dll`. Disassembly of its full body (`objdump -d -M intel --start-address=0x10009e20 ---stop-address=0x10009eb0`) shows both return paths ending in a bare `ret` (no immediate -operand), e.g.: - -``` -10009e8d: 5f pop edi -10009e8e: 33 c0 xor eax,eax -10009e90: 5e pop esi -10009e91: c3 ret -``` - -A bare `ret` (vs. `ret 4`/`stdcall`) means the **caller**, not the callee, is responsible for -popping the single pushed argument — the defining trait of the **cdecl** calling convention. -This matches the call site in `arkkdm.dll` (`100013b4-100013b8: push ecx; call eax`), which never -issues an explicit `add esp,4` after the call; the caller's frame-pointer epilogue -(`mov esp,ebp` at `100013bf`) discards the pushed argument as part of resetting the whole local -frame, which is exactly what cdecl predicts and `stdcall` would not need. - -The single argument is `void* hInstance`. Tracing it back (`gamemain-binding.md` part (b)): -it is **`arkkdm.dll`'s own `HINSTANCE`/`HMODULE`** — the handle the Windows loader assigned to -`arkkdm.dll` when it was mapped, captured once in `arkkdm.dll`'s `DllMain` on -`DLL_PROCESS_ATTACH` (`fdwReason == 1`, stored to a global at VA `0x100f5134`, -`10076799-1007679c`) and relayed through a global struct, `g_MainDllInfo` at VA `0x1014b9f8` -(named via adjacent `.rdata` diagnostic strings `"MainDllInfo::setDllHMODULE : dllHMODULE %p, -hModule %p\n"`), which `dll_entry_init` (`0x100767c0`) latches on first call and -`dll_entry_main`'s resolver (`0x10001340`) reads back out as the value pushed into `gameMain`. It -is **not** `gamekdm.dll`'s own module handle — `gamekdm.dll` never computes or receives its own -`HMODULE` on this path — and it is not any spice2x/launcher-level handle passed directly; spice2x's -`avs::game::DLL_INSTANCE` and `arkkdm.dll`'s internally captured `hInstDLL` happen to be the same -underlying OS handle value, but `arkkdm.dll` re-derives and forwards its own independently -captured copy rather than receiving spice2x's. - -## 4. Game-DLL identification: `arkkdm.dll` as the KDM/DEA marker - -spice2x's launcher identifies which Bemani title it is booting by probing for each title's -characteristic game DLL filename in the cabinet's install directory (`check_dll(name)` calls -chained through `launcher.cpp:1115-1496`, e.g. `bm2dx.dll` for beatmania IIDX, `jubeat.dll` for -jubeat, `popn22.dll` for pop'n music 22, etc.). The DEA/KDM branch is: - -``` -spice2x/launcher/launcher.cpp:1190-1194 - // DEA - if (check_dll("arkkdm.dll")) { - avs::game::DLL_NAME = "arkkdm.dll"; - ... - attach_dea = true; - } -``` - -This is the authoritative confirmation, independent of `gamestart.bat`'s explicit argument, that -`arkkdm.dll` is *the* canonical AVS game DLL name for DanceEvolution Arcade within the spice2x -compatibility layer, and that recognizing it is what causes the DEA-specific game-glue object -(`games::dea::DEAGame`, §1/§3.2 step 4) — which owns the Kinect10.dll attach and the DEA -button/light I/O map in `spice2x/games/dea/io.cpp` — to be constructed. - -## 5. `ea3-config.xml` and `avs-config.xml` - -Both files live at `GAME-DIR/prop/` and are consumed during AVS/EA3 bootstrap (§3.3), **before** -`gameMain` is ever reached — they configure the AVS2 runtime and the e-Amusement identity/network -layer that `gamekdm.dll` then runs on top of, not `gamekdm.dll` itself directly. - -### `avs-config.xml` — AVS core runtime configuration - -Parsed by `avs::core::boot()` (the AVS core DLL located/bootstrapped in §3.3). Its sections, -read directly from `GAME-DIR/prop/avs-config.xml`: - -- `` — declares the AVS virtual filesystem's **devices**: `.` (the - content root), `dev\nvram` with block-storage options - (`sz_block=768,nr_block=128,nr_mirror=4`), and `dev\raw`. These are - exactly the two directories `gamestart.bat` pre-seeds from `prop\` templates (§3.1 step 3), - confirming `gamestart.bat`'s NVRAM/raw bootstrap is preparing the backing store this config - mounts. Also sets filesystem resource limits: `256`, - `256`. -- `` — 32400 seconds = UTC+9 (Japan Standard Time), - the cabinet's configured timezone offset. -- `` — logging sinks and levels: `level=all`, console enabled, file logging enabled with - rotation (`rotate=1`, `gen=10` generations), network logging (`netsci`/`netlog`) disabled. -- `` — socket/protocol pool sizing (`nr_protocol=8`, `nr_socket=16`) and enables raw sockets - plus the `lz77sock`/`multisock` AVS network transports. -- `` — AVS kernel object pool sizing: up to 100 threads, 50 semaphores, 512 mutexes, 64 - events. -- `0` — NTP time sync is explicitly disabled (a commented-out Shift-JIS note - in the file explains why in Japanese: time changing on boot was considered undesirable), with a - fallback `pool.ntp.org` server address present but inert while `ea_on=0`. - -### `ea3-config.xml` — e-Amusement (EA3) identity, network, and coin/credit configuration - -Parsed by `avs::ea3::boot()` (§3.3) — the file-selection logic in the spice2x source confirms -`prop/ea3-config.xml` (this exact path) is the primary candidate checked before any fallback -name (`avs::ea3::boot`, `spice2x/avs/ea3.cpp:180-194`: `else if -(fileutils::file_exists("prop/ea3-config.xml")) { ea3_config_name = "prop/ea3-config.xml"; }`), -and the property tree is read via `avs::core::config_read(ea3_config_name, 0x40000)` -(`avs/ea3.cpp:209`). Contents of `GAME-DIR/prop/ea3-config.xml`: - -- `` — ``/`` placeholders, both all-zero 21-character strings in the shipped - file (`00000000000000000000`); spice2x independently defaults these same fields when absent - (`avs/ea3.cpp:247-258`, hardcoded fallback `"0100DEADBEEF"`/`"012199999999"`), confirming this - section is the per-cabinet hardware/software identity block the EA3 network layer uses to - authenticate against Konami's e-Amusement backend. -- `` — the model/dest/spec/rev/ext tuple identifying the title build (`KDM`/`A`/`A`/`A`/ - `2016021900`, §1). -- `32400` and `SHIFT_JIS` — same UTC+9 convention as - `avs-config.xml`; text data in this config layer is Shift-JIS encoded. -- `` — `0` (no TLS), `http://localhost:8080/` (the EA3 - "services" base URL the e-Amusement RPC layer targets — `http://localhost:8080/` in this - shipped copy implies a local service-emulation endpoint rather than Konami's real backend, as - expected for an archived/offline cabinet image), `102400` (XRPC - buffer size), `1`. -- `` — PASELI (Konami's cashless payment system) configuration: `1`, - a `/eacoin/enable` pointer into `eacoin.xml`'s property tree - (another `prop/` file, mirrored to `dev/nvram/eacoin.xml` by `gamestart.bat`), and - `2` (number of virtual eacoin slots). -- `` — physical coin-mechanism configuration: `1` (one physical - coin slot), `2`, `income_delay`/`income_maxdelay` timing, and a large - `` sub-tree mapping each in-game credit-consuming action (game start `p1s01a1`→ - `game.s`, continue `p1s02a1`→`game.c`, join `p1s03a1`→`game.s.join`, numbered item purchases - `p1s05a1`…`p1s2Na1`→`game.i.NN`, etc.) to a `coin.xml`-referenced credit path - (`/coin/start`, `/coin/continue`, `/coin/join`, `/coin/itemN`) via `type="consume"` / - `type="throw"` event descriptors. This is how coin-mech hardware events (routed through - `coin.xml`, which `gamestart.bat` also seeds into `dev/nvram/`) become in-game credit state the - AVS property tree exposes to `gamekdm.dll`. - -### `ark-config.xml` — `arkkdm.dll`-specific options - -A third, smaller config also lives at `GAME-DIR/prop/ark-config.xml` and is specific to the -`arkkdm.dll` glue layer (not AVS core/EA3): `disable` (comment: log output -level, one of system/debug/information/warning/error/disable), `0` (comment: -set non-zero to disable USB key/dongle use — ties to the `ess_usbkey_boot_check_*` exports -`arkkdm.dll` imports from `ess.dll`, §1), `1` (comment: set to 0 if e-Amusement -coin functionality is unavailable), and `1` (comment: set to 0 if -"Participation" — the PASELI-era term for network play — is unsupported). +Every transition after AVS2 enters `arkkdm.dll` is evidenced by +`arkkdm.dll`'s own exports, imports, strings, and disassembly. Exact addresses +from older installed-copy analysis other than the official values stated above +remain **UNVERIFIED (pending re-check against clean-release binary)**. ## Cross-references -- [`docs/re/gamemain-binding.md`](../re/gamemain-binding.md) — full instruction-level trace of - the `GetProcAddress` resolution and `hInstance` argument this section summarizes in §3.4–3.7. -- [`06-gamekdm-subsystems.md`](./06-gamekdm-subsystems.md) — what `gameMain` does once invoked - (sibling section). -- [`game-internals.md`](../../game-internals.md) — Kinect10.dll NUI shim and the reconstruction's - own Kinect-emulation findings referenced in §1. - -## Unresolved / deferred points - -- The consumer of `gamestart.bat`'s `DAMAC_VIEWER_FULLSCREEN` environment variable was not found - in any binary or source file inspected for this section — **UNVERIFIED**. -- Exact cabinet/monitor hardware specifications (resolution, panel type, speaker configuration) - are not recorded in any artifact inspected here — **UNVERIFIED**. -- Whether the real, non-spice2x Konami `launcher.exe`/AVS runtime differs in any behaviorally - significant way from the spice2x reimplementation used as evidence in §3.2–3.3 was not checked - against a Konami-original reference implementation (none was available); this section documents - the shipped `launcher.exe` PE import surface directly where possible (§3.2) and relies on - spice2x source as the best available account of the surrounding orchestration logic otherwise. +- [`docs/re/gamemain-binding.md`](../re/gamemain-binding.md) — detailed + `arkkdm.dll` resolver and `hInstance` trace. +- [`docs/companion-inventory.md`](../companion-inventory.md) — authoritative + clean-release module inventory and nine-node dependency DAG. +- [`06-gamekdm-subsystems.md`](./06-gamekdm-subsystems.md) — behavior after + `gameMain` begins. diff --git a/docs/spec/02-dll-architecture.md b/docs/spec/02-dll-architecture.md index d1abf2d..4dfd97b 100644 --- a/docs/spec/02-dll-architecture.md +++ b/docs/spec/02-dll-architecture.md @@ -1,229 +1,169 @@ # DLL Architecture and Module Dependency Graph -This section documents the shipped module set for `KDM-2016021900`, classifies -each DLL (Konami-authored and in reconstruction scope, OS/runtime import -target, or already-open-source), and derives the cross-DLL dependency DAG -directly from each file's PE import table. It reconciles with and extends -[`../companion-inventory.md`](../companion-inventory.md), the Task T13 -inventory deliverable that performed the original classification pass; the -counts and edges below were independently re-derived in this session against -the same game directory to confirm that inventory still holds. +This section documents exactly **9 Konami modules** shipped under +`contents/modules/` in the clean `KDM-2016021900` release. All 9 are in +reconstruction scope. External platform runtimes are import targets only. +The inventory and cross-DLL dependency DAG follow the +[official-scope contract](../../.omo/scope/official-scope.md) and the corrected +[`companion-inventory.md`](../companion-inventory.md). -Evidence method: `objdump -p` run against every `.dll` under -`GAME-DIR = "/mnt/f/Users/Aaron Thapa/Downloads/KDM-2016021900/contents"` -(including `contents/modules/` and `contents/stubs/64/`), using the -i686-w64-mingw32 cross `objdump` for the 19 PE32 (32-bit) files and the host -`/usr/bin/objdump` for the 3 PE32+ (x86-64) files under `stubs/64/` that the -32-bit toolchain cannot parse (`format: pei-i386` vs `pei-x86-64` reported by -`objdump -p` for each). `find GAME-DIR -iname '*.dll'` returns exactly 22 -files; this reconciles with the companion inventory's stated 22-file count -(`docs/companion-inventory.md:18-20`). +Evidence basis: module sizes come from the clean-release listing in the +contract's "Official modules" table. The shipped-module topology follows the +companion inventory's "Cross-module dependency DAG" and the contract's +"Official dependency graph", which describe the official modules' PE imports. +This revision does not claim a new `objdump` run. Earlier measurements came +from a possibly contaminated install; any retained export counts are +**UNVERIFIED (pending re-check against clean-release binary)**. Exact byte +sizes and RVAs from that install are not used here. ## Scope classification - **IN-SCOPE** — Konami-authored game/middleware code targeted for - decompilation and reconstruction. + decompilation and reconstruction: all 9 modules in the table below. - **REUSE OS** — a Win32/DirectX/CRT system DLL that is only ever an import target (never shipped as a file under `contents/`): `KERNEL32.dll`, `USER32.dll`, `GDI32.dll`, `ADVAPI32.dll`, `SHELL32.dll`, `ole32.dll`, `WS2_32.dll`, `WINMM.dll`, `IMM32.dll`, `DINPUT8.dll`, `DSOUND.dll`, `IPHLPAPI.DLL`, `PSAPI.DLL`, `msvcrt.dll`/`MSVCR80.dll`, `OLEAUT32.dll`, `dbghelp.dll`, `HID.DLL`, `SETUPAPI.dll`, `d3d9.dll`, `d3dx9_43.dll`. -- **ALREADY-OSS** — the shipped file is itself a build of already-open-source - tooling (bemanitools or spice2x/spicetools stub) or the owner's own Kinect - SDK redistribution shim, so no reconstruction work applies to it. +- **EXTERNAL RUNTIME** — `Kinect10.dll`, the Microsoft Kinect-for-Windows + NUI v1 runtime required by `gamekdm.dll`'s import table. It is supplied by + the platform, not shipped in `contents/modules/` and not in the + reconstruction set. See the companion inventory's + [external dependencies](../companion-inventory.md#external-non-shipped-dependencies--referenced-only-never-part-of-the-game). -## Per-DLL table (all 22 shipped files) +## Per-DLL table (all 9 shipped Konami modules) -Size and export count ("named exports" = the `[Name Pointer/Ordinal] Table` -entry count from each file's `objdump -p` Export Table header) were measured -directly against `GAME-DIR` in this session and match the companion -inventory's per-file figures exactly (`docs/companion-inventory.md:45-66`), -except where noted. +Each DLL below resides in `contents/modules/`. Sizes and roles follow the +contract's clean-release table and the companion inventory's +[per-module table](../companion-inventory.md#per-module-table-contentsmodules). +Named-export counts are retained solely as historical measurements, not +verified clean-release facts; each requires a new check against its official +binary. No new export counts have been inferred from the listing sizes. -| DLL | Size (bytes) | Scope | Named exports | Role | +| DLL | Size (clean release listing) | Scope | Named exports (historical) | Role | |---|---|---|---|---| -| `gamekdm.dll` | 3,369,104 | IN-SCOPE | 1 (`gameMain`) | Main KDM game-logic DLL; the primary reconstruction target. Single entry point `gameMain`, export RVA `0x00009e20` confirmed by both `objdump -p` (`Export RVA ... 00009e20 ... gameMain`, run against `GAME-DIR/gamekdm.dll`) and `re/rvadb.json`'s `functions` entry for `gameMain` (`rva: "0x00009e20"`), i.e. absolute VA `0x10009e20` under the documented image base `0x10000000` (`re/rvadb.json: image_base`). `rvadb.json` records `function_count: 9728` for this module (`re/rvadb.json: function_count`). | -| `arkkdm.dll` | 827,024 | IN-SCOPE | 255 | Core "ARK" Konami game-engine middleware (`arkAFP*`/`arkKDM*`-prefixed API); sits between AVS2 and the game/test DLLs. | -| `arkkdmtest.dll` | 398,480 | IN-SCOPE | 1 (`gameMain`) | Standalone Konami render/input test harness; links D3D9/D3DX9/DINPUT8/DSOUND/GDI32/SHELL32/USER32 directly, bypassing the AVS2 layer entirely. | -| `deahook.dll` | 93,696 | IN-SCOPE (author unresolved) | 1 (C++-mangled `?dummy@@YGHXZ`) | Minimal ACIO-layer key-hook DLL; PE export-directory internal module name is `DEALibacio.dll` (`Name ... DEALibacio.dll` in `objdump -p` Export Tables), imports only `GetAsyncKeyState` (USER32) plus CRT/kernel32 startup. Not matched to spice2x/spicetools source. | -| `ess.dll` | 385,168 | IN-SCOPE | 209 | Konami ESS middleware (`ess_binarydata_*`, `ess_bookkeeping_*`); e-amusement bookkeeping/networking, links AVS2 + WS2_32/IPHLPAPI/PSAPI. | -| `kbt.dll` | 7,680 | ALREADY-OSS | 6 | bemanitools "ikey" security-dongle stub (`bt_fcheck_*`, `k_bt000{1,2}`); identified by embedded PDB path `d:\bemanitools\stubs\objfre_wxp_x86\i386\stubs.pdb`. | -| `kld.dll` | 7,680 | ALREADY-OSS | 6 | Byte-identical bemanitools stub to `kbt.dll` (same export set, same embedded PDB path). | -| `kmd.dll` | 128,656 | IN-SCOPE | 1 (`k_md0001`) | Konami "md" module (debug/memory-dump); imports `dbghelp.dll` + AVS2 + `MSVCR80.dll`. | -| `ksm.dll` | 169,616 | IN-SCOPE | 111 | Konami "sm" module (`k_sm0001`, `ssm_array_*`); imports AVS2/AVS2-ea3 plus unshipped Konami-family `kdu.dll`/`kmp.dll`/`kma.dll`. | -| `kuc.dll` | 128,656 | IN-SCOPE | 4 | Small Konami "uc" module (`DllStart`, `k_uc0001`, `k_uc0004`, `k_uc0005`); same AVS2 + unshipped kdu/kmp/kma dependency pattern as `ksm.dll`. | -| `libacio.dll` | 65,536 | IN-SCOPE | 44 | Konami AC-IO (cabinet peripheral protocol) library, all `ac_io_*` exports; imports only `USER32.dll`+`KERNEL32.dll` (leaf). | -| `libacio_mbr.dll` | 14,336 | IN-SCOPE | 47 | AC-IO variant for a different cabinet I/O board revision; imports `libinput.dll` and `libavs-win32.dll` in addition to msvcrt/KERNEL32. | -| `libafp-win32.dll` | 1,246,864 | IN-SCOPE | 159 | Konami "AFP" asset/graphics pipeline library (`afp_*`), consumed by `arkkdm.dll`, `libafputils-win32.dll`, and `gamekdm.dll`. Imports only `libavs-win32.dll`+`KERNEL32.dll`. | -| `libafputils-win32.dll` | 169,616 | IN-SCOPE | 162 | AFP utility layer (`afpu_*`) directly above `libafp-win32.dll` in the chain; imports `libavs-win32.dll` + `libafp-win32.dll` + `KERNEL32.dll`. | -| `libavs-win32-ea3.dll` | 372,880 | IN-SCOPE | 139 | AVS2 "ea3" (e-amusement v3) extension module; ordinal-only export names (`XE592acd...`); imports only `KERNEL32.dll` + `libavs-win32.dll`. | -| `libavs-win32.dll` | 517,264 | IN-SCOPE | 360 | AVS2 (Application/Audio-Visual System v2) — Konami's core middleware runtime and the root of the MAIN middleware stack (not every shipped DLL depends on it — `libacio.dll`, `libinput.dll`, `arkkdmtest.dll`, and `deahook.dll` are independent leaves); ordinal-only export names (`XCd229cc...`); imports only `KERNEL32.dll`/`WS2_32.dll`/`WINMM.dll`/`IPHLPAPI.DLL` (no shipped-DLL imports). | -| `libinput.dll` | 38,400 | IN-SCOPE | 51 | e-amusement HID input-config driver (`eam_*`); imports `HID.DLL`/`SETUPAPI.dll` to talk to real cabinet hardware. Leaf (no shipped-DLL imports). | -| `modules/libacio.dll` | 65,536 | IN-SCOPE | 44 | Byte-identical duplicate of top-level `libacio.dll`, kept under `modules/` for the AC-IO module loader. | -| `Kinect10.dll` | 951,731 | ALREADY-OSS | 25 (Named-Pointer table `0x19`; Export Address Table itself reports `0x1d`=29 ordinal slots, 3 of which are unnamed/forwarder gaps per `objdump -p`) | Owner's Kinect SDK redistribution shim (`NuiCamera*`/`NuiCreate*`/`NuiSkeleton*`); imports only `KERNEL32.dll`/`msvcrt.dll`/`OLEAUT32.dll`/`WINMM.DLL`. Not Konami game logic. | -| `stubs/64/nvEncodeAPI64.dll` | 12,800 | ALREADY-OSS | 2 | PE32+ spice2x NVENC stub (`NvEncodeAPICreateInstance`/`NvEncodeAPIGetMaxSupportedVersion`); x86-64 (`format: pei-x86-64`). | -| `stubs/64/nvcuda.dll` | 13,824 | ALREADY-OSS | 21 | PE32+ spice2x CUDA driver-API stub (`cu*`, all returning `CUDA_ERROR_NOT_SUPPORTED`). | -| `stubs/64/nvcuvid.dll` | 13,312 | ALREADY-OSS | 13 | PE32+ spice2x NVCUVID stub (`cuvid*`, all returning `CUDA_ERROR_NOT_SUPPORTED`). | - -All 22 files export plain-C symbol tables with the single exception of -`deahook.dll`'s one C++-mangled no-op export; no DLL in the set *imports* a -C++-mangled symbol (`docs/companion-inventory.md:68-70`, independently -confirmed by inspecting every `DLL Name:`/import entry in this session's -`objdump -p` run). +| `libavs-win32.dll` | 505.14 KB | IN-SCOPE | 360 — UNVERIFIED (pending re-check against clean-release binary) | AVS2 core middleware: property-tree configuration, virtual filesystem and threading; base of the main middleware stack. | +| `libavs-win32-ea3.dll` | 364.14 KB | IN-SCOPE | 139 — UNVERIFIED (pending re-check against clean-release binary) | E-amusement v3 AVS2 extension for network, identity and coin economy. | +| `libafp-win32.dll` | 1.19 MB | IN-SCOPE | 159 — UNVERIFIED (pending re-check against clean-release binary) | AFP asset/font/graphics pipeline used by ARK. | +| `libafputils-win32.dll` | 165.64 KB | IN-SCOPE | 162 — UNVERIFIED (pending re-check against clean-release binary) | AFP utilities directly above `libafp-win32.dll`. | +| `ess.dll` | 376.14 KB | IN-SCOPE | 209 — UNVERIFIED (pending re-check against clean-release binary) | ESS e-amusement shop/server middleware; depends on AVS2 and its ea3 extension. | +| `libacio.dll` | 224.64 KB | IN-SCOPE | 44 — UNVERIFIED (pending re-check against clean-release binary) | ACIO cabinet I/O protocol library; root with only USER32/KERNEL32 imports. | +| `arkkdm.dll` | 896.64 KB | IN-SCOPE | 255 — UNVERIFIED (pending re-check against clean-release binary) | ARK/KDM cabinet game engine and AVS2 game-DLL entry; loads and calls `gamekdm.dll`. | +| `arkkdmtest.dll` | 389.14 KB | IN-SCOPE | 1 — UNVERIFIED (pending re-check against clean-release binary) | ARK/KDM render/input test harness; exports `gameMain`; imports OS D3D9/DINPUT8/DSOUND/GDI32/SHELL32/USER32 without AVS2. | +| `gamekdm.dll` | 3.19 MB | IN-SCOPE | 1 — UNVERIFIED (pending re-check against clean-release binary) | Main KDM game logic; exports `gameMain`; primary reconstruction target. | ## Cross-DLL dependency DAG -Edges below are restricted to import-table entries where the imported DLL -name matches another file actually present under `GAME-DIR` (OS DLLs such as -`KERNEL32.dll` and unshipped Konami-family DLLs such as `kdu.dll`/`kmp.dll`/ -`kma.dll`, which `ksm.dll` and `kuc.dll` import but which are not shipped in -this build, are excluded from the graph). Each edge was read directly from -`objdump -p`'s `DLL Name:` lines for the dependent file against `GAME-DIR`: +The shipped-module DAG has exactly **9 nodes and 14 edges**. Each solid edge +points from an importing module to a shipped dependency, following the +[canonical graph](../companion-inventory.md#cross-module-dependency-dag-9-nodes-verified-acyclic). +OS/DirectX imports are outside this DAG. The dashed edge from `gamekdm.dll` +to `Kinect10.dll` is an external Microsoft NUI runtime dependency; its endpoint +is an annotation, not a tenth shipped-module node. ``` -libavs-win32.dll (root — zero shipped-DLL imports) -libacio.dll, libinput.dll (roots — leaves) -modules/libacio.dll (root; duplicate of libacio.dll) -deahook.dll, arkkdmtest.dll (roots — only OS/DirectX imports) -Kinect10.dll, kbt.dll, kld.dll, stubs/64/nv*.dll (roots — ALREADY-OSS leaves) - -libavs-win32-ea3.dll -> libavs-win32.dll -libafp-win32.dll -> libavs-win32.dll -kmd.dll -> libavs-win32.dll -ess.dll -> libavs-win32.dll, libavs-win32-ea3.dll -ksm.dll -> libavs-win32.dll, libavs-win32-ea3.dll -kuc.dll -> libavs-win32.dll, libavs-win32-ea3.dll -libacio_mbr.dll -> libinput.dll, libavs-win32.dll -libafputils-win32.dll -> libavs-win32.dll, libafp-win32.dll -arkkdm.dll -> libavs-win32.dll, libavs-win32-ea3.dll, ess.dll, libacio.dll, libafp-win32.dll -gamekdm.dll -> Kinect10.dll, libavs-win32.dll, libafputils-win32.dll, libafp-win32.dll +libavs-win32.dll (root) +libacio.dll (root; imports USER32/KERNEL32 only) +arkkdmtest.dll (root; imports OS D3D9/DINPUT8/DSOUND/GDI32/SHELL32/USER32 only) +libavs-win32-ea3.dll -> libavs-win32.dll +libafp-win32.dll -> libavs-win32.dll +libafputils-win32.dll -> libavs-win32.dll, libafp-win32.dll +ess.dll -> libavs-win32.dll, libavs-win32-ea3.dll +arkkdm.dll -> libavs-win32.dll, libavs-win32-ea3.dll, ess.dll, libacio.dll, libafp-win32.dll +gamekdm.dll -> libavs-win32.dll, libafp-win32.dll, libafputils-win32.dll + (+ external Kinect10.dll, d3d9/d3dx9) ``` ```mermaid graph TD - Kinect10_dll(("Kinect10.dll")) - arkkdm_dll["arkkdm.dll"] - arkkdmtest_dll["arkkdmtest.dll"] - deahook_dll["deahook.dll"] - ess_dll["ess.dll"] - gamekdm_dll["gamekdm.dll"] - kmd_dll["kmd.dll"] - ksm_dll["ksm.dll"] - kuc_dll["kuc.dll"] - libacio_dll["libacio.dll"] - libacio_mbr_dll["libacio_mbr.dll"] + libavs_win32_dll["libavs-win32.dll"] + libavs_win32_ea3_dll["libavs-win32-ea3.dll"] libafp_win32_dll["libafp-win32.dll"] libafputils_win32_dll["libafputils-win32.dll"] - libavs_win32_ea3_dll["libavs-win32-ea3.dll"] - libavs_win32_dll["libavs-win32.dll"] - libinput_dll["libinput.dll"] + ess_dll["ess.dll"] + libacio_dll["libacio.dll"] + arkkdm_dll["arkkdm.dll"] + arkkdmtest_dll["arkkdmtest.dll"] + gamekdm_dll["gamekdm.dll"] + kinect(("Kinect10.dll (external MS NUI runtime)")) + libavs_win32_ea3_dll --> libavs_win32_dll + libafp_win32_dll --> libavs_win32_dll + libafputils_win32_dll --> libavs_win32_dll + libafputils_win32_dll --> libafp_win32_dll + ess_dll --> libavs_win32_dll + ess_dll --> libavs_win32_ea3_dll arkkdm_dll --> libavs_win32_dll arkkdm_dll --> libavs_win32_ea3_dll arkkdm_dll --> ess_dll arkkdm_dll --> libacio_dll arkkdm_dll --> libafp_win32_dll - ess_dll --> libavs_win32_dll - ess_dll --> libavs_win32_ea3_dll - gamekdm_dll --> Kinect10_dll gamekdm_dll --> libavs_win32_dll - gamekdm_dll --> libafputils_win32_dll gamekdm_dll --> libafp_win32_dll - kmd_dll --> libavs_win32_dll - ksm_dll --> libavs_win32_dll - ksm_dll --> libavs_win32_ea3_dll - kuc_dll --> libavs_win32_dll - kuc_dll --> libavs_win32_ea3_dll - libacio_mbr_dll --> libinput_dll - libacio_mbr_dll --> libavs_win32_dll - libafp_win32_dll --> libavs_win32_dll - libafputils_win32_dll --> libavs_win32_dll - libafputils_win32_dll --> libafp_win32_dll - libavs_win32_ea3_dll --> libavs_win32_dll + gamekdm_dll --> libafputils_win32_dll + gamekdm_dll -.external.-> kinect ``` -This 22-edge, 22-node graph was re-verified acyclic by depth-first-search in -this session (traversal from every node terminates with no back-edge), the -same result the companion inventory reports (`docs/companion-inventory.md: -"Verified acyclic by DFS over all 22 nodes"`). +The internal graph is acyclic. A dependency-first topological order, matching +the companion inventory's [reconstruction order](../companion-inventory.md#reconstruction-order-topological-acyclic), +is `libavs-win32.dll`, `libavs-win32-ea3.dll`, `ess.dll`, `libacio.dll`, +`libafp-win32.dll`, `libafputils-win32.dll`, `arkkdm.dll`, `arkkdmtest.dll`, +then `gamekdm.dll`. + +Runtime loading is separate from these PE import edges: the official +`arkkdm.dll` exports `dll_entry_init` / `dll_entry_main` for AVS2. +Its `dll_entry_main` uses `LoadLibraryA("gamekdm.dll")` with an +`"arkkdmtest.dll"` test-build fallback, resolves `gameMain` with +`GetProcAddress`, and calls `gameMain(hInstance)` (cdecl). The argument is +`arkkdm.dll`'s own `HINSTANCE`, captured in `DllMain` and relayed through +`g_MainDllInfo.dllHMODULE`. These facts are sourced to the official +`arkkdm.dll` in the contract's "Official boot/entry" and the companion +inventory's [boot/entry section](../companion-inventory.md#bootentry-into-the-game-official-from-arkkdmdll). ### `libavs-win32.dll` as the AVS2 base -`libavs-win32.dll` is the only node with zero shipped-DLL imports and is the -root of the main middleware stack, but it is **not** a transitive ancestor of -every other IN-SCOPE DLL: 10 of the other 15 IN-SCOPE modules import it -directly (`arkkdm.dll`, `ess.dll`, `kmd.dll`, `ksm.dll`, `kuc.dll`, -`libacio_mbr.dll`, `libafp-win32.dll`, `libafputils-win32.dll`, -`libavs-win32-ea3.dll`, `gamekdm.dll`), while the remaining 5 — `arkkdmtest.dll`, -`deahook.dll`, `libacio.dll`, `libinput.dll`, and `modules/libacio.dll` — are -independent leaves that import no shipped DLL at all, confirmed per-file in -the `objdump -p` import-table dump above (see also the "roots — leaves"/ -"roots — only OS/DirectX imports" lines in the dependency DAG above). +`libavs-win32.dll` is the base of the main middleware stack, with zero +shipped-module imports. Six other modules import it directly: +`libavs-win32-ea3.dll`, `libafp-win32.dll`, `libafputils-win32.dll`, `ess.dll`, +`arkkdm.dll`, and `gamekdm.dll`. The remaining two modules, `libacio.dll` and +`arkkdmtest.dll`, also have zero shipped-module imports. Thus AVS2 is one of +three roots, not a dependency of every module, as shown by the canonical +graph's explicit edges. ### `libafp -> libavs` edge -`libafp-win32.dll`'s only shipped-DLL import is `libavs-win32.dll` (its full -import-DLL set, read from `objdump -p GAME-DIR/libafp-win32.dll`, is just -`libavs-win32.dll` + `KERNEL32.dll`), confirming the `libafp->libavs` edge -named in the task brief and matching the companion inventory's row for this -file (`docs/companion-inventory.md:58`). +`libafp-win32.dll`'s only shipped-module import is `libavs-win32.dll`, as +recorded in both authoritative dependency graphs. It is consumed by +`libafputils-win32.dll`, `arkkdm.dll`, and `gamekdm.dll`. -### `gamekdm -> all` edge +### `gamekdm` dependencies -`gamekdm.dll`'s PE import table (`objdump -p GAME-DIR/gamekdm.dll`, `DLL -Name:` entries) lists 16 DLLs total: `d3dx9_43.dll`, `Kinect10.dll`, -`d3d9.dll`, `libavs-win32.dll`, `libafputils-win32.dll`, `KERNEL32.dll`, -`USER32.dll`, `GDI32.dll`, `ADVAPI32.dll`, `SHELL32.dll`, `ole32.dll`, -`WS2_32.dll`, `WINMM.dll`, `IMM32.dll`, `DINPUT8.dll`, `libafp-win32.dll`. -Restricted to shipped DLLs, that is `Kinect10.dll` (ALREADY-OSS tier), -`libavs-win32.dll` (AVS2 base tier), and `libafputils-win32.dll` + -`libafp-win32.dll` (AFP tier) — `gamekdm.dll` is the only shipped DLL whose -import set spans every other dependency tier, matching the `gamekdm->all` -description in the task brief and the companion inventory's equivalent -finding (`docs/companion-inventory.md:195-199`). - -This edge set is independently corroborated at the function-call-graph level: -`re/rvadb.json`'s per-function `external_callees` field (populated for all -9,728 reconstructed `gamekdm.dll` functions) names exactly the same 16 import -DLLs as actual call targets, with call-site counts of `LIBAVS-WIN32.DLL`: 595, -`LIBAFP-WIN32.DLL`: 96, `LIBAFPUTILS-WIN32.DLL`: 13, `KINECT10.DLL`: 5 (plus -`KERNEL32.DLL`: 1799 and the remaining OS DLLs), confirming the PE -import-table edges are actually exercised by `gameMain`'s call graph rather -than being present-but-unused linker artifacts. +`gamekdm.dll` imports three shipped modules: `libavs-win32.dll`, +`libafp-win32.dll`, and `libafputils-win32.dll`. It does not depend on every +shipped module. Its external dependencies include `Kinect10.dll` (Microsoft +NUI v1) and OS DirectX `d3d9.dll`/`d3dx9_43.dll`, as documented in the +contract and companion inventory. Those runtimes are supplied by the +platform and do not enlarge the nine-module reconstruction set. ## Reconciliation with `companion-inventory.md` -The companion inventory (`docs/companion-inventory.md`) already performed -this classification and DAG derivation as Task T13 and additionally resolves -ambiguous cases this section only summarizes: +The corrected [companion inventory](../companion-inventory.md) and the +[official-scope contract](../../.omo/scope/official-scope.md) define this +chapter's evidence boundary: -- **`deahook.dll` authorship** is explicitly marked unresolved there (not - provably Konami, only provably *not* spice2x/spicetools, per full-text grep - of both shipped OSS source tarballs — `docs/companion-inventory.md:240-263`) - — this section inherits that "author unresolved" caveat rather than - asserting Konami authorship. -- **`kbt.dll`/`kld.dll`** are classified ALREADY-OSS there via an embedded - bemanitools PDB path and a disassembled `k_bt0002` body that is a bare - `ret` rather than the spice2x `stubs.cpp` implementation - (`docs/companion-inventory.md:51-52`) — not independently re-disassembled - in this pass, taken as given from that prior finding. -- **`ksm.dll`/`kuc.dll`** import three further Konami-family DLLs - (`kdu.dll`, `kmp.dll`, `kma.dll`) that are **not shipped** in this game - directory (`docs/companion-inventory.md:97-100`); these are intentionally - excluded from the dependency graph above as unverifiable (no artifact to - cite), consistent with the companion inventory's own exclusion rationale. -- Every size and named-export count in the per-DLL table above matches the - companion inventory's figures exactly on independent re-measurement in - this session, with the sole clarification that `Kinect10.dll`'s Export - Address Table header reports 29 ordinal slots (`0x1d`) against 25 named - exports (`0x19`) — the inventory's "25 export(s)" figure is the named - count, which this section also uses as the canonical "export count" metric - throughout the table for consistency across files. +- Exactly 9 modules under `contents/modules/` are shipped, Konami-authored, + and IN-SCOPE; the table uses their clean-release listing sizes. +- The internal DAG reproduces the canonical 9 nodes and 14 edges. The + explicitly external `gamekdm.dll` to `Kinect10.dll` NUI runtime edge is + excluded from those counts. +- `libacio.dll` and `arkkdmtest.dll` are independent roots alongside AVS2. + The explicit topology controls here; the companion inventory's prose + calling AVS2 an ancestor of every module overstates that topology. +- Historical export counts remain **UNVERIFIED (pending re-check against clean-release binary)**. + They are not new measurements of the official artifacts; clean-release + binary re-checks remain necessary before relying on them. -No IN-SCOPE/ALREADY-OSS/REUSE-OS classification in the companion inventory -was altered by this re-derivation; this section exists as the spec-level -presentation of that same evidence base for the DLL-architecture chapter of -the full technical spec. +This chapter presents the corrected official inventory at spec level. ## See also @@ -237,5 +177,8 @@ the full technical spec. - [`./09-reconstruction-codebase.md`](./09-reconstruction-codebase.md) — how the IN-SCOPE set above maps onto the reconstruction codebase's build targets. -- [`../companion-inventory.md`](../companion-inventory.md) — the full Task - T13 inventory this section reconciles with and summarizes. +- [`../companion-inventory.md`](../companion-inventory.md) — the corrected + clean-release inventory this section reconciles with and summarizes. +- [`../../.omo/scope/official-scope.md`](../../.omo/scope/official-scope.md) — + authoritative official-game scope, listing sizes, dependency graph and + binary-integrity caveat. diff --git a/docs/spec/03-kinect-skeleton.md b/docs/spec/03-kinect-skeleton.md index fc778b7..dc03135 100644 --- a/docs/spec/03-kinect-skeleton.md +++ b/docs/spec/03-kinect-skeleton.md @@ -2,11 +2,19 @@ ## Scope and address convention -The documented integration delivers a 20-joint skeleton through a replacement -`Kinect10.dll`, after which gamekdm performs selection/validation and feeds -the menu cursor system (`game-internals.md:15-24`). -The companion tracker publishes synthetic depth, color, and skeleton data -through shared memory to that shim (`game-internals.md:7-10`). +`gamekdm.dll`'s own import table statically imports `Kinect10.dll` +(`re/importlibs/Kinect10.def`), Microsoft's external Kinect-for-Windows +NUI v1 runtime — not a module shipped in `contents/modules/`, but an +external dependency gamekdm.dll's import table requires and which a real +cabinet satisfies from the installed Kinect runtime +[`../../.omo/scope/official-scope.md`](../../.omo/scope/official-scope.md). +This reconstruction's own test shim stands in for that runtime off-cabinet: +it delivers a 20-joint skeleton through the same `Kinect10.dll` import +surface, after which gamekdm performs selection/validation and feeds the +menu cursor system (`game-internals.md:15-24`). The reconstruction's own +test tracker publishes synthetic depth, color, and skeleton data through +shared memory to that shim (`game-internals.md:7-10`); this synthetic data +path is part of the reconstruction's test harness, not the shipped game. See [the overview](./00-overview.md), [companion APIs](./07-companion-apis.md), and [the reconstruction codebase](./09-reconstruction-codebase.md). @@ -33,7 +41,14 @@ vma: Ordinal Hint Member-Name Bound-To 002181e4 22 ``` -The companion shim pins those ordinals to `NuiGetSensorCount` (5), +This import block is read from the official `gamekdm.dll` binary's own PE +import table. `Kinect10.dll` is Microsoft's external Kinect-for-Windows +NUI v1 runtime, not a module shipped in `contents/modules/`; gamekdm.dll's +import table requires it, and on a cabinet it is satisfied by the installed +Kinect runtime, never by a game-shipped file +[`../../.omo/scope/official-scope.md`](../../.omo/scope/official-scope.md). + +The reconstruction's own test shim pins those ordinals to `NuiGetSensorCount` (5), `NuiCreateSensorByIndex` (6), `NuiImageGetColorPixelCoordinatesFromDepthPixel` (9), `NuiTransformSmooth` (20), and `NuiSetDeviceStatusCallback` (22) @@ -61,7 +76,7 @@ not that gamekdm calls every entry (`re/importlibs/Kinect10.def:8-34`). | Skeleton selection/orientation | `NuiSkeletonSetTrackedSkeletons`, `NuiSkeletonCalculateBoneOrientations` | `re/importlibs/Kinect10.def:31-32` | | Other | `NuiGetAudioSource`, `NuiCreateCoordinateMapperFromParameters`, `NuiCreateDepthFilter` | `re/importlibs/Kinect10.def:30,33-34` | -The companion interface declares initialization, image-stream, skeleton, and +The reconstruction's test-shim interface declares initialization, image-stream, skeleton, and elevation methods on `INuiSensor` as well as providing flat exports; the game's reconstructed elevation routine specifically calls a sensor interface pointer. Thus absence from the five flat imports does not establish absence @@ -228,7 +243,7 @@ the successful-Get branch (`src/game/nui_elevation.cpp:19-22`). ## Depth-to-skeleton projection -The companion mapping implementation uses `kDepthProjectionScale = 3.501e-3f`. +The reconstruction's test-shim mapping implementation uses `kDepthProjectionScale = 3.501e-3f`. The RE notes identify this with the nominal inverse focal-length constant and report Kinect-compatible projection; that historical compatibility claim is not a fresh physical-sensor measurement here @@ -332,9 +347,9 @@ The unchanged hip explains unchanged candidate-position math; it does not prove limb changes are irrelevant to the sentinel-gravity orientation branch, which explicitly examines limbs (`game-internals.md:31-36`). -Arm gain defaults are `3.2` horizontally and `2.6` vertically; the companion -calibration document gives environment overrides precedence over saved -calibration and then defaults +Arm gain defaults are `3.2` horizontally and `2.6` vertically; the +reconstruction's test-shim calibration document gives environment overrides +precedence over saved calibration and then defaults (`/home/athapa/kinect/docs/calibration.md:25-39`). The menu hand-cursor mapping is attributed by the RE notes to the Flash/Natal runtime; detailed cursor handling belongs with diff --git a/docs/spec/05-data-formats.md b/docs/spec/05-data-formats.md index 3d8bb95..5118ac0 100644 --- a/docs/spec/05-data-formats.md +++ b/docs/spec/05-data-formats.md @@ -1,15 +1,19 @@ # 05 — Data Formats Game-directory layout, configuration formats, the AVS2 filesystem/property-tree -model, and the asset container formats found by direct inspection of -`GAME-DIR = /mnt/f/Users/Aaron Thapa/Downloads/KDM-2016021900/contents`. All -paths below are absolute game-dir paths unless marked otherwise. No +model, and the asset container formats of the clean KDM-2016021900 +`contents/` release (`GAME-DIR`). All paths below are relative to `contents/` unless marked +otherwise. No copyrighted asset content (audio/video/lyrics/art) is reproduced; only file structure, headers, and extension inventories are described. See also: [00-overview.md](./00-overview.md), [01-runtime-boot.md](./01-runtime-boot.md), [07-companion-apis.md](./07-companion-apis.md). +The release layout follows the [official scope contract](../../.omo/scope/official-scope.md). +Historical XML excerpts, asset counts, byte sizes, header bytes, offsets, and +binary-derived observations below are UNVERIFIED (pending re-check against clean-release binary). + ## 1. Top-level game-dir layout ``` @@ -17,12 +21,10 @@ contents/ ├── data/ game assets (sound, 2D/animation, fonts, textures, movies, dal manifests) ├── arkdata/ ARK engine assets (fonts, test-mode screens, e-amusement license art, sound presets) ├── prop/ AVS2 property-tree config XML (device defaults, shipped with the install) -├── modules/ loadable companion DLLs (I/O driver) -├── api/ Spice2x-style SpiceAPI client bindings, not Konami-original -└── dev/ AVS2 virtual device backing store (`nvram`, `raw`) — runtime state +└── modules/ nine shipped Konami modules ``` -Verified directory listings (`find GAME-DIR/{data,arkdata,prop,modules,api,dev} -maxdepth 2`): +The clean-release listing records: - `data/arc/`, `data/arc/2d/`, `data/bm2d/`, `data/dal/`, `data/dal/2d/`, `data/data/`, `data/font/`, `data/sound/`, `data/bgmov/` — asset trees. @@ -30,24 +32,11 @@ Verified directory listings (`find GAME-DIR/{data,arkdata,prop,modules,api,dev} `arkdata/arkkdm/{ea3license,qc,sound,testmode}` — ARK/KDM-specific assets, e.g. `arkdata/arkkdm/ea3license/license1.dds`, `arkdata/arkkdm/qc/zero.bin`, `arkdata/arkkdm/sound/{seteq.def,setvolume.def}`. -- `prop/` contains exactly: `app-config.xml`, `ark-config.xml`, - `avs-config.xml`, `card_allow.bin`, `coin.xml`, `ea3-config.xml`, - `eacoin.xml`, `ess-config.xml`, `libxml.xml`, `share-config.xml`, - `testmode-v.xml` (11 files, all at `prop/` top level — no subdirectories). -- `modules/` contains a single file, `modules/libacio.dll` (the I/O-board - driver companion; see [07-companion-apis.md](./07-companion-apis.md)). -- `api/` holds five SpiceAPI language bindings (`arduino/`, `cpp/`, `dart/`, - `lua/`, `python/`) plus `api/lua/boot_iidx_tt_lights.lua`, - `api/python/spiceremote.py`. These are a third-party (spice2x project) - client toolkit bundled with the install, not part of Konami's original - AVS2/gamekdm data model — [docs/companion-inventory.md:100](../companion-inventory.md). -- `dev/nvram/` holds the AVS2 NVRAM-device XML snapshot: `bookkeep0.xml`, - `bookkeep1.xml`, `bookkeep2.xml`, `clock.xml`, `coin.xml`, - `ea3-config.xml`, `eacoin.xml`, `keepalive.xml`, `libxml.xml`, - `testmode-v.xml`, `testmode-v.crc`. `dev/raw/` holds raw-device - subdirectories `bookkeeping/`, `fscache/`, `ranking/`, `settings/`, `log/` - — runtime write targets for the `nvram`/`raw` AVS2 filesystem devices - described in §3. +- `prop/` contains `ark-config.xml`, `ark-config_nopp.xml`, `avs-config.xml`, + `card_allow.bin`, `coin.xml`, `eacoin.xml`, `eamuse-config.xml`, + `ess-config.xml`, `share-config.xml`, and `testmode-v.xml`. +- `modules/` contains exactly the nine Konami modules listed in + [docs/companion-inventory.md](../companion-inventory.md). ## 2. `prop/` configuration XML — structure @@ -60,62 +49,17 @@ node model gamekdm and the AVS2 runtime manipulate in memory and that ships binary-encoded inside the e-amusement network protocol ([07-companion-apis.md:62](./07-companion-apis.md)). -### 2.1 `ea3-config.xml` — e-amusement v3 client config +### 2.1 `eamuse-config.xml` — e-amusement client config -Root ``. Verified structure (`prop/ea3-config.xml`, line numbers from a -direct `grep`): - -```xml - - - 00000000000000000000 - 00000000000000000000 - - - KDM - A - A - A - 2016021900 - - 32400 - SHIFT_JIS - binary - - 102400 - 0 - http://localhost:8080/ - 1 - - ... - - - ... coin.i ... - ... service.p ... - ... game.s ... - - - - -``` - -`KDM` (ea3-config.xml:9) is the e-amusement model code for -DanceEvolution Arcade; `2016021900` (ea3-config.xml:13) is the data -version stamp, matching the install directory name `KDM-2016021900` in -GAME-DIR's parent path. The `` block defines a table of named -*article* nodes (`p1s01a1`..`p1s16a1` per-player) each binding a `type` -(`throw`/`consume`), an `article` index, an `event` string the coin-handling -code raises, a `player_ref` property-tree pointer, and a `credit_ref` -property-tree pointer the consume resolves against — this is the on-disk -form of the coin/credit event routing table gamekdm/ARK read through the -AVS2 property API. +The clean release supplies `prop/eamuse-config.xml`. +Its detailed XML structure has not yet been re-checked +against the clean-release file and is therefore UNVERIFIED (pending re-check +against clean-release binary). ### 2.2 `avs-config.xml` — AVS2 runtime config -Root ``. Verified structure (`prop/avs-config.xml`): +Historical structure attributed to `prop/avs-config.xml` (subject to the +clean-release caveat above), root ``: ```xml @@ -167,43 +111,27 @@ open-file-descriptor table respectively. ### 2.3 Other `prop/*.xml` files (by name, structure not fully enumerated here) -- `app-config.xml`, `ark-config.xml`, `coin.xml`, `eacoin.xml`, - `ess-config.xml`, `share-config.xml`, `testmode-v.xml`, `libxml.xml` — same - typed-attribute XML dialect as §2.1/§2.2 (`value`), - one file per subsystem (ARK engine, ESS sound library, coin/eacoin - defaults, test-mode flags, XML-library-internal state). `prop/card_allow.bin` - is the only non-XML file in `prop/`; its contents were not decoded for this - section (card-reader allow-list — UNVERIFIED format). -- `dev/nvram/*.xml` mirror the same leaf names (`bookkeep0..2.xml`, - `clock.xml`, `coin.xml`, `ea3-config.xml`, `eacoin.xml`, `keepalive.xml`, - `libxml.xml`, `testmode-v.xml`) — these are the **runtime** property-tree - snapshots the AVS2 `nvram` device persists, as opposed to `prop/`'s - **shipped defaults**; `dev/nvram/testmode-v.crc` is a checksum sidecar for - `testmode-v.xml`. +- `ark-config.xml`, `ark-config_nopp.xml`, `coin.xml`, `eacoin.xml`, + `eamuse-config.xml`, `ess-config.xml`, `share-config.xml`, and + `testmode-v.xml` are the remaining shipped configuration files. + `prop/card_allow.bin` is the only non-XML file in `prop/`; its contents are + UNVERIFIED. ## 3. AVS2 filesystem + property-tree model Evidence base: `prop/avs-config.xml` (§2.2), `re/avs/property_node.h`, `re/avs/recon_avs_harness.cpp`, `re/avs/prove_t14.py`, and the exported -symbol inventory in `docs/companion-inventory.md` (`libavs-win32.dll`, 360 -ordinal-style exports, zero shipped-DLL dependencies — the AVS2 base -companion; `libavs-win32-ea3.dll`, 139 exports, the e-amusement-v3 -extension — [docs/companion-inventory.md:60-61](../companion-inventory.md)). +module inventory in [docs/companion-inventory.md](../companion-inventory.md) +(`libavs-win32.dll`, zero shipped-DLL dependencies — the AVS2 base companion; +`libavs-win32-ea3.dll`, the e-amusement-v3 extension). Historical export +counts are UNVERIFIED (pending re-check against clean-release binary). -- **Virtual filesystem.** AVS2 multiplexes named *devices* under mount - points declared in `avs-config.xml`'s `` block: a `root` device over - the game-dir tree, an `nvram` device (block-structured, mirrored, backing - `dev/nvram/`) for small persistent key-value/XML state, and a `raw` device - (backing `dev/raw/`) for larger unstructured runtime data (log files, - bookkeeping counters, ranking caches, settings blobs — all observed as - real subdirectories of `dev/raw/`). `nr_mountpoint=256`/`nr_filedesc=256` - size the VFS's internal tables. +- **Virtual filesystem.** AVS2's configuration declares named devices and + mount points. The exact runtime backing trees observed in a contaminated + install are UNVERIFIED (pending re-check against clean-release binary). - **Property tree.** Every `*-config.xml` in `prop/` and `dev/nvram/` is the textual serialization of an AVS2 *property* object: a typed, path-addressed - tree (`/coin/slot1/player`, `/eacoin/enable`, etc. — literal path strings - appear as `*_ref` leaf values inside `ea3-config.xml`, e.g. - `/coin/player1/ref_slotid`, - ea3-config.xml:64). Each leaf node carries a type tag (`str`/`u8`/`u16`/ + tree. Each leaf node carries a type tag (`str`/`u8`/`u16`/ `u32`/`s32`/`bool`) matching the C scalar types the AVS2 property API reads/writes — the reconstruction's `re/avs/property_node.h` declares accessors following this documented AVS2 C API (`re/avs/property_node.h:1-3`), @@ -214,13 +142,11 @@ extension — [docs/companion-inventory.md:60-61](../companion-inventory.md)). the property tree is not merely a config-loading convention but a typed in-memory data structure with its own ABI inside `libavs-win32.dll`. - gamekdm/ARK read the property tree through `libavs-win32.dll` (AVS2 base) - and `libavs-win32-ea3.dll` (ea3 extension); `ea3-config.xml`'s `` - article table (§2.1) is a concrete example of gamekdm-level data stored and - resolved as property-tree paths (`credit_ref`, `player_ref`). + and `libavs-win32-ea3.dll` (e-amusement v3 extension). - `prop/avs-config.xml:1` — root tag is ``, not `` or ``: this file configures the AVS2 kernel itself (filesystem, logging, - networking, threading, SNTP), distinct from `ea3-config.xml` which - configures the e-amusement-v3 client layer running on top of it. + networking, threading, SNTP), distinct from `eamuse-config.xml` which + configures the e-amusement client layer running on top of it. ## 4. Archive / container formats (by inspection) @@ -263,9 +189,9 @@ Sampled `data/bm2d/120paseli_lang_eng_v0.ifs`: `file(1)` reports plain `data`; the first 64 bytes show no readable ASCII and no recognizable magic (`6c ad 8f 89 00 03 ff fc 53 7b 33 ac ...`), consistent with either a compressed or obfuscated/encrypted header rather than a plaintext TOC. -`game-internals.md:146` records that the external pip package `ifstools` +`game-internals.md` records that the external pip package `ifstools` (pure-Python) successfully extracts `data/bm2d/*.ifs` into an `afp/` -Flash-asset tree, and `game-internals.md:54-55` states the menu UI (including +Flash-asset tree, and `game-internals.md` states the menu UI (including the cursor sprite) is compiled Flash packed inside these `.ifs` archives. `rvadb.json` contains dozens of `.ifs` path-format strings referenced by gamekdm (e.g. `"value": "jk_%s_v0.ifs"` at `re/rvadb.json:175117`, diff --git a/docs/spec/07-companion-apis.md b/docs/spec/07-companion-apis.md index a7d563c..03c29a3 100644 --- a/docs/spec/07-companion-apis.md +++ b/docs/spec/07-companion-apis.md @@ -1,18 +1,20 @@ # 07 — Companion DLL API Surfaces -This section documents the exported API surface and role of every in-scope -Konami companion DLL that `gamekdm.dll` depends on, directly or transitively, -per the reconstruct set locked in [`../companion-inventory.md`](../companion-inventory.md). -Export lists are taken from `re/importlibs/*.def` (gendef output over the -owner's binaries, regenerated by `tools/gen_importlibs.sh` — see -[`../companion-conventions.md`](../companion-conventions.md)) and -cross-checked directly against `objdump -p` on the shipped DLLs at -`GAME-DIR = /mnt/f/Users/Aaron Thapa/Downloads/KDM-2016021900/contents`. -Calling-convention and binding evidence (cdecl/stdcall, by-name vs. ordinal, -`--kill-at`) lives in `../companion-conventions.md` and is not repeated here -except where it affects how an export is named. No creative game assets are -reproduced; only C API surfaces, struct-layout fragments already captured in -`re/avs/avs_structdb.json`, and file-format roles are described. +This section documents the exported API surface and role of the **eight +official companion DLLs** shipped beside `gamekdm.dll` in the clean +KDM-2016021900 `contents/modules/` release. The complete official module set +is the nine modules in [`../companion-inventory.md`](../companion-inventory.md): +these eight companions plus `gamekdm.dll`. The authoritative scope contract is +[`../../.omo/scope/official-scope.md`](../../.omo/scope/official-scope.md). + +Export and dependency claims below are grounded in the companion export/import +tables recorded under `re/importlibs/` and the clean-release module topology +in the inventory. Earlier `objdump` observations from a possibly contaminated +install are not used as game evidence. Any byte-exact export count, ordinal, +RVA, or size which has not been re-checked against a clean-release binary is +**UNVERIFIED (pending re-check against clean-release binary)**. No community +launcher, hook, emulator, stub, or non-release module belongs to this API +surface. Cross-links: [`./00-overview.md`](./00-overview.md), [`./08-abi-conventions.md`](./08-abi-conventions.md), @@ -20,510 +22,139 @@ Cross-links: [`./00-overview.md`](./00-overview.md), ## libavs-win32.dll — AVS2 base middleware -**Role:** root of the Konami dependency DAG. Every other IN-SCOPE companion -(`arkkdm.dll`, `ess.dll`, `libacio_mbr.dll`, `libafp-win32.dll`, -`libafputils-win32.dll`, `kmd.dll`, `ksm.dll`, `kuc.dll`, -`libavs-win32-ea3.dll`) imports it; it imports only `KERNEL32.dll`, -`WS2_32.dll`, `WINMM.dll`, `IPHLPAPI.DLL` (`objdump -p` on -`GAME-DIR/libavs-win32.dll`, DLL Name block). It is the Konami "Application/ -Audio-Visual System v2" runtime: property-tree configuration store, AVS -filesystem abstraction (mounted archives, not raw `fopen`), and the -thread/mutex/event primitives every other companion is built on. +**Role:** root of the official dependency DAG. It supplies the AVS2 +property-tree configuration store, virtual filesystem, and +thread/mutex/event primitives used by the shipped modules +[`../companion-inventory.md`](../companion-inventory.md). -**Export surface:** `re/importlibs/libavs-win32.def` lists **360 named -exports**, all vendor-obfuscated hash tokens of the form -`XCd229cc0000fb`..`XCd229cc00016c` (`re/importlibs/libavs-win32.def:9-368`). -`objdump -p GAME-DIR/libavs-win32.dll` confirms 360 real export-table names -in this same `XCd229cc...` form (reconstruction proxy header -`re/avs/libavs-win32.def:9-18` forwards each token 1:1, ordinal-preserving, -to `libavs-win32_orig.dll`). **None of the 360 exports carry a readable C -symbol in the shipped binary** — the vendor stripped/obfuscated the AVS2 -export name table for this build, unlike every other companion in this -inventory, which all ship plain, readable C names. - -Because the export table itself gives no semantic names, the mapping from -hash token to AVS2 C function is done by behavior, not by name recovery: -Ghidra analysis of `libavs-win32.dll` (project `avsproj.gpr`, -`/home/athapa/ghidra/avsproj.gpr`) plus a semantic match against the -documented AVS2 API in the shipped open-source companion trees -(`GAME-DIR/src/spice2x-master.tar.gz:spice2x/avs/core.h` and -`GAME-DIR/src/spicetools-master.tar.gz:spicetools/avs/core.h`, both present -under `GAME-DIR/src`). `spice2x/avs/core.h` declares the AVS2 property-node -C API by name (`property_search`, `property_create`, `property_node_create`, -`property_node_remove`, `property_node_refer`, `property_node_read`, -`property_node_write`, `property_node_datasize`, `property_node_type`, -`property_node_has`, `property_node_is_array`, `property_node_clone`, -`property_node_query_stat`, `property_get_attribute_{bool,u32,s32}`, -`property_node_get_attribute_{bool,u32,s32}`, `property_psmap_export`/ -`_import`, `property_lock_flag`/`unlock_flag`/`set_flag`, `property_clear`, -`property_destroy`), the AVS filesystem API (`avs_fs_open`, `avs_fs_close`, -`avs_fs_read`, `avs_fs_lseek`, `avs_fs_fstat`, `avs_fs_lstat`, -`avs_fs_mount`, `avs_fs_copy`, `avs_fs_dump_mountpoint`, `avs_fs_opendir`/ -`readdir`/`closedir`, typed `avs_file_t`), and `boot()`/`shutdown()` entry -points — this is the semantic API spice2x links against via its own -hash-token resolution table (a `property_search`-keyed struct of `const -char *` tokens in `core.h`, confirming spice2x faces the identical -hash-obfuscated export problem against this vendor build). - -One concrete recovery is proven end-to-end in this codebase: -`re/avs/property_node.h` and `re/avs/property_node.cpp` reconstruct AVS2 -ordinal 153 / export token `XCd229cc000083`, RVA `0x0000bdf0`, as -`avs::property_node_datasize(const PropertyNodeDatasizeView*)` — a 24-bit -field read split across `+0x2c` (u16) and `+0x2e` (u8) inside the -`property_node` struct, matched against the disassembly -(`movzx eax,[node+0x2e]; shl eax,0x10; movzx edx,word [node+0x2c]; or -eax,edx; ret`) and the struct layout recorded in `re/avs/avs_structdb.json`. -This is the pattern to repeat for the remaining 359 tokens: Ghidra -decompilation of each `XCd229cc...` stub against the `avsproj.gpr` database, -cross-named against `core.h`'s declared signatures. - -Two of the 368 lines in the `.def` carry a gendef caveat — `XCd229cc0000e6` -and `XCd229cc000041` are annotated "Check!!! Couldn't determine function -argument count. Function doesn't return." (`re/importlibs/libavs-win32.def:363,367`), -i.e. gendef's heuristic disassembler could not find a `ret` on the -fall-through path (likely a `longjmp`/fatal-log/`ExitProcess` style -noreturn routine), consistent with AVS2's documented fatal-log-on-null-node -behavior noted for `property_node_datasize`'s null path in -`re/avs/property_node.h:24`. +**Export surface:** `re/importlibs/libavs-win32.def` records named, +hash-obfuscated `XCd229cc...` exports. Its recorded count, ordinal mapping, +and token-to-semantic mapping are **UNVERIFIED (pending re-check against +clean-release binary)** unless separately supported by a clean export table. +One reconstruction mapping is documented in +`re/avs/property_node.h`, `re/avs/property_node.cpp`, and +`re/avs/avs_structdb.json`: token `XCd229cc000083` is reconstructed as +`avs::property_node_datasize`. That reconstruction is an interpretation of +the official export and recorded code evidence, not a claim that an external +compatibility project is part of the game. ## libavs-win32-ea3.dll — AVS2 e-amusement v3 extension -**Role:** AVS2 "ea3" (e-amusement v3) extension module layered directly on -top of the base AVS2 runtime; consumed by `arkkdm.dll`, `ess.dll`, -`ksm.dll`, `kuc.dll`. `objdump -p GAME-DIR/libavs-win32-ea3.dll` shows its -only DLL-Name imports are `KERNEL32.dll` and `libavs-win32.dll` — it has no -network/CRT dependency of its own, it rides entirely on the base AVS2 -runtime for sockets and filesystem. +**Role:** the shipped AVS2 e-amusement v3 extension. In the official graph it +depends on `libavs-win32.dll` and is used by `ess.dll` and `arkkdm.dll` +[`../companion-inventory.md`](../companion-inventory.md). -**Export surface:** `re/importlibs/libavs-win32-ea3.def` lists **139 named -exports** (`re/importlibs/libavs-win32-ea3.def:9-147`), all vendor hash -tokens in the sibling form `XE592acd000000`..`XE592acd000092` — a different -hash prefix from the base AVS2 DLL's `XCd229cc...` tokens, confirming these -are a distinct, separately-obfuscated export table rather than a shared one; -`objdump -p` on `GAME-DIR/libavs-win32-ea3.dll` independently reports **139** -names in the `[Ordinal/Name Pointer] Table`, matching the `.def` count -exactly. Same build/vendor toolchain as the base AVS2 DLL (identical gendef -banner, identical obfuscation style), per `docs/companion-conventions.md`'s -"same vendor build... same export-naming scheme" note. - -Semantic naming source: `GAME-DIR/src/spice2x-master.tar.gz:spice2x/avs/ea3.h` -declares the EA3-layer C surface this module backs — -`avs_ea3_boot_startup`, `avs_ea3_shutdown`, plus `avs::ea3::boot(unsigned -short easrv_port, bool easrv_maint, bool easrv_smart)` / -`avs::ea3::shutdown()` wrapper functions and `avs::ea3::load_dll()`, backed -by settings fields (`CFG_PATH`, `BOOTSTRAP_PATH`, `PCBID_CUSTOM`, -`SOFTID_CUSTOM`, `URL_CUSTOM`, `EA3_BOOT_URL`, `EA3_BOOT_PCBID`) that match -the e-amusement network-bootstrap role implied by `ess.dll`'s own -`ess_ea3_*` exports (below). No per-token hash-to-name mapping has been -completed for this module in this codebase; treat the 139 tokens as -UNVERIFIED pending the same Ghidra-plus-`ea3.h`-signature-match pass applied -to `property_node_datasize` above. +**Export surface:** `re/importlibs/libavs-win32-ea3.def` records a distinct +hash-token export family, `XE592acd...`. The recorded export count and all +token-to-semantic mappings are **UNVERIFIED (pending re-check against +clean-release binary)**. The module's network/bootstrap role follows the +official dependency graph and its relation to the shipped ESS middleware; +it does not rely on any emulator header or launcher source. ## arkkdm.dll — ARK engine (KDM build) -**Role:** the Konami "ARK" cabinet-game engine instantiated for this title -(`arkKDM` prefix = ARK + KDM). `gamekdm.dll` is the title's actual render/ -gameplay logic, but ARK is the layer underneath it providing credit/coin -handling, card I/O orchestration, networking/matching, event logging, -threading primitives, heap management, and the AFP (Flash-like) rendering -entry points — i.e. the reusable arcade-cabinet framework Konami built once -and reused across ARK-family titles. `objdump -p GAME-DIR/arkkdm.dll` -imports `libavs-win32.dll`, `libavs-win32-ea3.dll`, `ess.dll`, -`libacio.dll`, `libafp-win32.dll` plus Win32 OS DLLs -(`USER32`/`KERNEL32`/`IMM32`/`GDI32`/`WINMM`) — it sits directly above the -AVS2/ESS/ACIO/AFP stack and below `gamekdm.dll` in the dependency chain -(`docs/companion-inventory.md`'s DAG). +**Role:** the official ARK/KDM cabinet-game engine and AVS2 game-DLL entry. +It imports the shipped AVS2, EA3, ESS, ACIO, and AFP modules +[`../companion-inventory.md`](../companion-inventory.md). Its official +`dll_entry_main` path loads `gamekdm.dll` (with `arkkdmtest.dll` as a +test-build fallback), resolves `gameMain`, and calls it; this is derived from +the official `arkkdm.dll` artifact, not a launcher or hook +[`../../.omo/scope/official-scope.md`](../../.omo/scope/official-scope.md). -**Export surface:** `re/importlibs/arkkdm.def` lists **255 named, plain-C -exports** (`re/importlibs/arkkdm.def:9-263`), all readable symbols — -`arkAFP*`, `arkKDM*`, `arkCardManager*`, `arkEACoin*`, `arkEntryFlow*`, -`arkEvent*`, `arkFile*`, `arkHeap*`, `arkMutex*`, `arkNetwork*`, -`arkSemaphore*`, `arkThread*`. `objdump -p` on `GAME-DIR/arkkdm.dll` -confirms the export directory's internal module name is `arkKDM.dll` and -reports **255** names in `[Ordinal/Name Pointer] Table`, matching the -`.def` count. Unlike AVS2/AVS2-ea3, **no export is hash-obfuscated** — ARK's -own export table is fully named. +**Export surface:** `re/importlibs/arkkdm.def` records readable `arkAFP*`, +`arkKDM*`, `arkCardManager*`, `arkEACoin*`, `arkEvent*`, `arkFile*`, +`arkHeap*`, `arkMutex*`, `arkNetwork*`, `arkSemaphore*`, and `arkThread*` +families, together with `dll_entry_init` and `dll_entry_main`. The exact +count, ordinals, and any per-export calling-convention conclusion remain +**UNVERIFIED (pending re-check against clean-release binary)** where based on +the earlier contaminated binary rather than a clean export table. -Export families and roles, grouped by prefix (every function below is a -literal export name from `re/importlibs/arkkdm.def`): +The families describe ARK-level AFP rendering, cabinet credit/card/coin +orchestration, file I/O, synchronization, heap management, network/matching, +event logging, and KDM-specific controls. They are an API classification from +the official export table; they do not establish a direct `gamekdm.dll` +import for every service. -- **AFP rendering (`arkAFP*`)** — `arkAFPBoot`, `arkAFPLayerCreate`/ - `Destroy`/`Draw`/`Play`/`Stop`/`SetPosition`/`Update`, - `arkAFPMovieClipCreate`/`Destroy`/`LoadBitmap`, `arkAFPPackageCreate`/ - `Destroy`/`GetStreamCount`/`GetStreamInformation`, - `arkAFPGetProperty{S32,S8,String}` / `arkAFPSetProperty{S32,S8,String}`, - `arkAFPReadPropertyXML`/`RemovePropertyXML`, - `arkAFPSetRenderCallbackFunctions`, `arkAFPGetHeapStatistics`, - `arkAFPTraceSetting`. This is a thin ARK-level wrapper over the separate - `libafp-win32.dll` `afp_*` C API (below) — `arkAFPBoot` is the - calling-convention proof point in `docs/companion-conventions.md` - (`ret 0x4`, stdcall). -- **Credit / coin / EA-coin (`arkConfirmCredit`, `arkConsumeCredit`, - `arkExpireCredit*`, `arkGetCoinCount`, `arkGetCreditCount`, - `arkEACoin{Consume,Expire,GetStatus,QueryBalance,QueryExtra, - QueryLastNotch,QueryPrice,QuerySessionState}`)** — cabinet - coin-mech/e-amusement-coin economy, backed by `ess.dll`'s parallel - `ess_credit_*`/`ess_eacoin_*` surface. -- **Card manager (`arkCardManagerConvCard[Wait]`, - `arkCardManagerGetPlayList[Wait]`)** — IC-card read/play-data retrieval, - the ARK-level counterpart to `ess_cardmng_*` and `ac_io_icca_*` (below). -- **File I/O (`arkFileOpen`/`Close`/`Read`/`Write`/`Seek`/`BlockRead`/ - `Mount`/`Umount`/`ConvertPath`/`DumpMountpoint`)** — ARK's own - mount/file-handle layer over AVS2's filesystem primitives. -- **Threading/sync (`arkThreadCreate`/`Destroy`/`Exit`/`SelfId`/`Signal`/ - `Sleep`/`Wait`, `arkMutexCreate`/`Destroy`/`Signal`/`Wait`, - `arkCondCreate`/`Destroy`/`Signal`/`Broadcast`/`Wait`, - `arkSemaphoreCreate`/`Destroy`/`Signal`/`Wait`, - `arkEventCreate`/`Destroy`/`Signal`/`ISignal`/`Wait`)** — ARK's primitive - wrappers, consistent with `docs/companion-conventions.md`'s identification - of AVS2 as the underlying thread/mutex/event provider. -- **Heap (`arkHeapBoot`/`Shutdown`/`Allocate`/`Free`/`Freesize`/`Malloc`/ - `Realloc`/`Reallocate`/`GetStatistics`/`ClearStatistics`/`Debug`)** — a - custom sized-heap allocator exposed to the game DLL. -- **Networking (`arkNetworkTCP*`, `arkNetworkUDP*`, - `arkNetworkMatching{Query,Request,Reset}[Wait]`, - `arkNetworkGetLocationConnectList[Wait]`, `arkNetworkGetProperty[Wait]`)** - — raw TCP/UDP socket wrappers plus the e-amusement "matching" (online - multiplayer/leaderboard pairing) protocol, layered above `ess.dll`'s own - `ess_net_*`/`ess_matching_*` exports. -- **Event logging (`arkCoreEventLogRequestEventData`/`GameEnd`/`GameStart`/ - `Otdemo`/`Transition`)** — telemetry hooks mirroring - `ess_eventlog_request_*`. -- **KDM-title-specific (`arkKDM*`)** — `arkKDMInitialize`/`Terminate`/ - `Update`/`Draw`, `arkKDMChangeLED`/`ChangeLEDColor`/`ChangeLEDPattern`/ - `ResetLED` (cabinet lighting), `arkKDMGet10Key`/`GetLeft`/`GetRight`/ - `GetStart` (raw cabinet button state), `arkKDMGetEAPass`, - `arkKDMGetServerMessage[Value]`, `arkKDMGetSoundOptionsSoundVolumeInAttract`, - `arkKDMGetGameOptionsLanguage`, `arkKDMGetLicenceKeyVersion` — the - title-specific slice of ARK that `gamekdm.dll` actually calls into for - cabinet I/O and LED control (the lighting/IO surface `gamekdm.dll` does - not reach directly through AVS2 or AC-IO). -- **Module entry points (`dll_entry_init`, `dll_entry_main`)** — the ARK - module bootstrap pair, distinct from the DllMain Windows loader entry. +## libafp-win32.dll + libafputils-win32.dll — AFP graphics pipeline -4 exports carry gendef's noreturn caveat (same heuristic as AVS2's two -flagged tokens): `arkKDMGet10Key`, `arkKDMGetEAPass`, `arkKDMGetLeft`, -`arkKDMGetRight`, `arkSetIOCoinBlockerOff` (`re/importlibs/arkkdm.def:180, -181,183,185,241`). +**Role (`libafp-win32.dll`):** shipped AFP asset/font/graphics pipeline, +depending on AVS2. Both `arkkdm.dll` and `gamekdm.dll` use the AFP layer in +the official dependency graph. -`arkKDMGetRanking@20` is the sole export with a `stdcall`-decorated name in -the `.def` whose true stdcall-ness is directly confirmed in -`docs/companion-conventions.md` via `arkAFPBoot`'s disassembly (`ret 0x4` -at file offset `0x100527ca`); the DLL's own export table stores the name -**undecorated** (no `@N`), so the reconstruction import library strips the -`@N` with `--kill-at` to bind correctly (same section). +**Export surface (`libafp-win32.dll`):** +`re/importlibs/libafp-win32.def` records readable `afp_*` exports covering +player lifecycle, layer and movie-clip management, matrix math, rendering, +stream/package loading, property nodes, and input forwarding. Its exact +export count and byte-level table details are **UNVERIFIED (pending re-check +against clean-release binary)**. -## libafp-win32.dll + libafputils-win32.dll — AFP Flash-like player +**Role (`libafputils-win32.dll`):** shipped AFP utility layer directly above +AVS2 and AFP, providing package/asset introspection +[`../companion-inventory.md`](../companion-inventory.md). -**Role (`libafp-win32.dll`):** Konami's "AFP" vector/sprite rendering -engine — a Flash-like runtime for pre-authored movie-clip/layer assets -(`.afp`/package format), used by both `arkkdm.dll` (via the `arkAFP*` -wrapper layer above) and directly by `gamekdm.dll` -(`docs/companion-inventory.md`'s DAG: `gamekdm.dll -> libafp-win32.dll`). -`objdump -p GAME-DIR/libafp-win32.dll` shows it imports only -`libavs-win32.dll` + `KERNEL32.dll` — AFP itself has no AVS2-ea3, ESS, or -ACIO dependency; it is a pure rendering/asset layer. +**Export surface (`libafputils-win32.dll`):** +`re/importlibs/libafputils-win32.def` records readable `afpu_*` exports for +package lifecycle; font, image, shape, layout, group, and texture metadata; +NGP package data; binary swapping; and render statistics. Its exact export +count and byte-level table details are **UNVERIFIED (pending re-check against +clean-release binary)**. -**Export surface (`libafp-win32.dll`):** `re/importlibs/libafp-win32.def` -lists **159 named, plain-C exports**, all `afp_*` prefixed -(`re/importlibs/libafp-win32.def:9-167`); `objdump -p` independently reports -**159** names, matching. Families: layer lifecycle (`afp_layer_create[_with_ -property]`/`destroy[_all/_level]`/`play`/`stop`/`set_position`/ -`set_attribute`/`set_color`/`set_matrix`/`set_mask`/`set_priority`/ -`call_function`), movie-clip management (`afp_mc_create`/`destroy`/ -`load_bitmap[_from_info]`/`load_movie`/`attach_movie`/`get_param`/ -`set_param`/`refer`/`search`/`traversal`), matrix math -(`afp_matrix{_init,_identity,_mult,_mult_point,_inverse,_rotate,_scale, -_translate,...}` and `afp_matrix44_*`), rendering (`afp_render[_all]`, -`afp_render_layer`/`group`/`get_layer`/`get_stream`), stream/package -loading (`afp_stream_create[_call]`/`destroy[_all/_level]`/`get_info`/ -`symbol_get_param`), property/XML nodes (`afp_property_node_write`, -`afp_layer_property_node_write`, `afp_touch_property_node`), input -forwarding (`afp_keyboard_status`, `afp_mouse_status`, `afp_mouse_wheel`, -`afp_layer_set_keyboard_status`/`set_mouse_status`/`set_mouse_wheel`), and -lifecycle (`afp_boot`, `afp_shutdown`, `afp_get_version`, -`afp_set_log_{fatal,info,warning}`, `afp_set_policy`, -`afp_set_shape_accuracy`, `afp_memory_debug`/`get_info`, -`afp_verbose_state`). This is the C API `arkAFP*` (above) wraps 1:1 in -spirit — e.g. `arkAFPLayerCreate` ↔ `afp_layer_create`, -`arkAFPLayerDraw` ↔ (render path through `afp_render_layer`). +## ess.dll — e-amusement middleware -**Role (`libafputils-win32.dll`):** a utilities layer one tier above -`libafp-win32.dll`, providing package/asset introspection (font, image, -shape, layout, texture metadata lookup) without owning the render loop -itself. `objdump -p GAME-DIR/libafputils-win32.dll` imports -`libavs-win32.dll` + `libafp-win32.dll` + `KERNEL32.dll` — it depends on -both AVS2 and the base AFP player, consistent with -`docs/companion-inventory.md`'s `libafputils-win32.dll -> libavs-win32.dll, -libafp-win32.dll` edge. +**Role:** the official e-amusement service layer over AVS2 and EA3. It +supplies the card/account, credit/eAmusement-coin, networking/matching, +event-log, and player-data services consumed through `arkkdm.dll` +[`../companion-inventory.md`](../companion-inventory.md). -**Export surface (`libafputils-win32.dll`):** `re/importlibs/libafputils-win32.def` -lists **162 named, plain-C exports**, all `afpu_*` prefixed -(`re/importlibs/libafputils-win32.def:9-170`); `objdump -p` independently -reports **162** names, matching. Families: package lifecycle -(`afpu_boot`/`shutdown`/`new_package`/`destroy_package[_all/_from_id/ -_just_level/_level]`), asset-table lookups across font/image/shape/layout/ -group/texture (`afpu_get_{font,image,shape,layout,group,texture}_ -{id,info,name,nr}[_from_index][_at_package]`), font-library entry points -(`afpu_fontlib_entry`, `afpu_fontlib_multi_entry[_ngp]`, -`afpu_fontlib_get_code_info[_debug][_from_index]`, -`afpu_fontlib_get_font_{id,info}`, `afpu_fontlib_retire_by_{level,package}`, -`afpu_fontlib_set_{font_reuse,level,get_bitmap_info_func}`), the "NGP" -package-container format (`afpu_ngp_read[_info]`, `afpu_ngp_mount_package_ -read[_info]`, `afpu_ngp_mounttable_*`, `afpu_ngp_packagelist_*`, -`afpu_ngp_texture_get_{compress,filter,format,wrap}[_string]`, -`afpu_ngp_layout_get_{center,flip,rotation}[_string]`), binary swap/ -endianness helpers for geo/texture data (`afpu_bin_geo_swap_data`, -`afpu_bin_texture_swap_{all,header,raw_data}`, `afpu_package_swap_{core_ -data,data,variant_nr}`), and rendering-stat helpers -(`afpu_render_debug`/`get_count`/`flash_buf`/`init_debug_info`). This is -primarily an offline/debug introspection API over the same package format -`libafp-win32.dll` renders at runtime. +**Export surface:** `re/importlibs/ess.def` records readable `ess_*` exports +for card management, credit, eAmusement coin, EA3 session handling, +filesystem access, facility metadata, event logging, TCP/UDP and matching, +player data, ranking, logging, and license/security operations. The exact +export count, forwarded-export claims, and ordinal details are +**UNVERIFIED (pending re-check against clean-release binary)** where they +derive from the contaminated-install observation. -## ess.dll — Enterprise Shop/Server (e-amusement middleware) +## libacio.dll — ACIO arcade I/O -**Role:** Konami's e-amusement client-side service layer — card/account -management, credit and eAmusement-coin economy, bookkeeping, network -matching, event logging, and player-data save/load/inheritance over the -network. `objdump -p GAME-DIR/ess.dll` imports `libavs-win32.dll`, -`libavs-win32-ea3.dll`, `KERNEL32.dll`, `USER32.dll`, `WS2_32.dll`, -`IPHLPAPI.DLL`, `PSAPI.DLL` — it sits directly on both AVS2 tiers plus raw -Winsock, consistent with its being the networking/account middleware -`arkkdm.dll` calls into for its own `arkCardManager*`/`arkEACoin*`/ -`arkNetwork*` wrappers. Per `docs/companion-conventions.md`, `ess.dll` is -**not** called directly through `gamekdm.dll`'s own IAT (no `ess.dll` -import block in `gamekdm.dll`) — `gamekdm.dll` reaches ESS functionality -only indirectly, through `arkkdm.dll`. +**Role:** the official ACIO amusement-cabinet I/O protocol library. It is a +root in the shipped-module graph and imports only OS libraries there +[`../companion-inventory.md`](../companion-inventory.md). -**Export surface:** `re/importlibs/ess.def` lists **209 named, plain-C -exports** (`re/importlibs/ess.def:9-217`), prefixed `ess_*`; `objdump -p` -independently reports **209** names, matching. Families: card management -(`ess_cardmng_bindmodel[_wait]`, `cardactivate[_wait]`, -`conv_cardnumber[_wait]`, `getplaylist[_wait]`, `inquire[_wait]`, -`playerlogin[_wait]`/`playerlogout[_wait]`), credit (`ess_credit_coin_throw`, -`confirm`, `consume[_expired[_playtype]]`, `get_status`, `get_option[_wait]`, -`reset`, `service`, `update_option[_wait]`), eAmusement coin -(`ess_eacoin_{abort,checkin,checkout,consume,reload,reauth,...}` and a large -`ess_eacoin_query_*` status-probe family), e-amusement v3 session -(`ess_ea3_download_pause`, `get_limit_time`, `get_pp_status`, `get_status`, -`license_agree`, `send_pp_event`), filesystem (`ess_fs_open[_r/_w]`, -`close`, `read`, `write`, `lseek`, `fgets`, `fprintf`, `mount`, -`unmount` — flagged by gendef "return value is from ord 57 in -libavs-win32.dll", i.e. `ess_fs_unmount` is a thin tail-call forward into -AVS2's own unmount ordinal, `re/importlibs/ess.def:145`), facility/location -metadata (`ess_facility_get_location_*`, `get_portfw_*`, `get_share_url_*`), -event logging (`ess_eventlog_request_{error,eventdata,game_end,game_start, -init,otdemo,testmode,transition}`), networking (`ess_net_tcp_*`, -`ess_net_udp_*`, `ess_matching_{query,request,reset}[_wait]`, -`ess_net_location_connection_list_get[_wait]`), player data -(`ess_playerdata_{inheritance,load,save}[_wait]`), ranking/score -(`ess_ranking_get[_wait]`, `ess_score_rank_get[_wait]`), logging -(`ess_log_{change_func,change_level,change_target,debug,error,fatal,info, -warning}`), and license/security (`ess_usbkey_boot_check_{account,license}_ -key`, `ess_usbkey_demoloop_check_{account,license}_key`). Two exports -forward directly into `WS2_32.dll` ordinal 116 per gendef's flag -(`ess_net_tcp_finalize`, `ess_net_udp_finalize` — `re/importlibs/ess.def:182,191`, -both annotated "return value is from ord 116 in WS2_32.dll" — i.e. -`WSACleanup`). No export in `ess.dll` is hash-obfuscated. +**Export surface:** `re/importlibs/libacio.def` records readable `ac_io_*` +exports for session lifecycle, BMPU button/coin/LED control, ICCA card-reader +control, and cabinet LED operations. The exact count and all byte-level +export-table details are **UNVERIFIED (pending re-check against clean-release +binary)**. This section deliberately makes no API or dependency claim for +other ACIO variants, input libraries, security stubs, or non-release Konami +DLLs. -## libacio.dll + libacio_mbr.dll — ACIO arcade I/O +## arkkdmtest.dll — ARK/KDM render and input test harness -**Role (`libacio.dll`):** Konami's AC-IO (amusement-cabinet I/O) protocol -library — the serial/RS-232-class driver talking to the cabinet's coin -mech, button/LED PCB ("BMPU"), and IC-card reader ("ICCA") boards. -`objdump -p GAME-DIR/libacio.dll` imports only `USER32.dll` + -`KERNEL32.dll` — a leaf in the dependency DAG, no AVS2 dependency. -`docs/companion-inventory.md` notes this is the real library spice2x's -`acio.cpp` `LoadLibraryA()`-loads and hooks at runtime rather than -reimplementing, confirming it is Konami's original cabinet-I/O binary, not -a community shim. +**Role:** a shipped ARK/KDM render-and-input test harness which exports +`gameMain`. It is a root in the shipped graph and uses OS D3D9/DINPUT8/DSOUND/ +GDI32/SHELL32/USER32 imports only +[`../companion-inventory.md`](../companion-inventory.md). -**Export surface (`libacio.dll`):** `re/importlibs/libacio.def` lists **44 -named, plain-C exports** (`re/importlibs/libacio.def:9-52`), prefixed -`ac_io_*`; `objdump -p` independently reports **44** names, matching. -Families: session lifecycle (`ac_io_begin[_get_status]`, `ac_io_reset`, -`ac_io_update`, `ac_io_is_active[2]`/`is_active_device`, -`ac_io_set_soft_watch_dog`/`soft_watch_dog_on`, `ac_io_get_version`/ -`get_rs232c_status`), BMPU (button/coin PCB) control -(`ac_io_bmpu_control_{1p,2p}_start_led_{on,off}`, -`ac_io_bmpu_control_coin_blocker_{open,close}`, -`ac_io_bmpu_control_led_bright`, `ac_io_bmpu_{lock,unlock}_coincounter`, -`ac_io_bmpu_current_coinstock`/`consume_coinstock`, -`ac_io_bmpu_set_outport_led`/`set_output_mode`/`init_outport`, -`ac_io_bmpu_get_{control_status_buffer,softwareid,systemid}`, -`ac_io_bmpu_update_control_status_buffer`, and a security-plug (secplug) -check sub-family `ac_io_bmpu_req_secplug_{check_isfinished, -check_softwareplug,check_systemplug,missing_check[_isfinished]}`), ICCA -(IC-card reader) control (`ac_io_icca_cardunit_init[_isfinished]`, -`ac_io_icca_device_control_iccard_power_supply_{on,off}`, -`ac_io_icca_device_control_isfinished`, `ac_io_icca_get_status`, -`ac_io_icca_get_uid_felica`, `ac_io_icca_req_uid[_isfinished]`), and a -Dance-cabinet-specific LED helper (`ac_io_hdxs_led_set_pattern`). No export -is hash-obfuscated; the `_isfinished` suffix pattern throughout marks this -as an asynchronous polling API (issue a request, poll `*_isfinished` until -true), consistent with real-hardware serial-command latency. +**Export surface:** the clean-release listing establishes its `gameMain` +role. Any additional count, ordinal, or byte-level export claim is +**UNVERIFIED (pending re-check against clean-release binary)** until a +clean-release export table is captured. -**Role (`libacio_mbr.dll`):** a variant AC-IO build for a different -cabinet/IO-board revision ("MBR"). `objdump -p GAME-DIR/libacio_mbr.dll` -imports `msvcrt.dll`, `KERNEL32.dll`, `libinput.dll`, `libavs-win32.dll` — -unlike the base `libacio.dll`, this variant both depends on AVS2 and on the -`libinput.dll` HID layer (below), per -`docs/companion-inventory.md`'s `libacio_mbr.dll -> libinput.dll, -libavs-win32.dll` edge. +## Naming-convention summary across official companions -**Export surface (`libacio_mbr.dll`):** `objdump -p -GAME-DIR/libacio_mbr.dll` reports **47 named, plain-C exports** -(`ac_io_*`), a superset pattern of `libacio.dll`'s 44: it keeps -`ac_io_begin`/`ac_io_begin_get_status`/`ac_io_get_rs232c_status`/ -`ac_io_get_version`/`ac_io_is_active[2]`/`ac_io_is_active_device`/ -`ac_io_reset`/`ac_io_set_soft_watch_dog`/`ac_io_soft_watch_dog_on`/ -`ac_io_update`, adds an explicit `ac_io_end`/`ac_io_end_get_status` pair -(absent from `libacio.dll`'s export list), replaces the BMPU family with an -`ac_io_hbhi_*` card-dispenser control family -(`ac_io_hbhi_req_carddispenser_{disburse,get_status,init}[_isfinished]`) -and an `ac_io_kfca_*` button/coin-blocker/LED family mirroring the base -`ac_io_bmpu_*` family's shape (`ac_io_kfca_control_button_led`, -`control_coin_blocker_{open,close}`, `control_led_bright`, -`current_coinstock`, `{lock,unlock}_coincounter`, -`get_control_status_buffer`, `req_volume_control`, `set_watchdog_time`, -`update_control_status_buffer`), an expanded `ac_io_hdxs_*` LED family -(`get_control_status_buffer`, `led_scroll`, `led_set_pattern`, -`led_set_rgb_mask`, `update_control_status_buffer`), and an expanded ICCA -family adding `ac_io_icca_crypt_init`, `get_keep_alive_error`, -`is_felica`, `send_keep_alive_packet`, `workflow`. This DLL was not present -in `re/importlibs/` at the time of this section's authoring (no -`libacio_mbr.def` was generated); the export list above is read directly -from `objdump -p` against `GAME-DIR/libacio_mbr.dll` and is otherwise -UNVERIFIED against any `.def`/Ghidra reconstruction artifact in this -codebase. +| DLL | Export naming recorded in repository evidence | Status | +|---|---|---| +| `libavs-win32.dll` | `XCd229cc...` hash tokens | Semantic mapping and byte counts require clean re-check | +| `libavs-win32-ea3.dll` | `XE592acd...` hash tokens | Semantic mapping and byte counts require clean re-check | +| `arkkdm.dll` | readable `ark*` families | Byte-level table details require clean re-check | +| `libafp-win32.dll` | readable `afp_*` families | Byte-level table details require clean re-check | +| `libafputils-win32.dll` | readable `afpu_*` families | Byte-level table details require clean re-check | +| `ess.dll` | readable `ess_*` families | Byte-level table details require clean re-check | +| `libacio.dll` | readable `ac_io_*` families | Byte-level table details require clean re-check | +| `arkkdmtest.dll` | `gameMain` role from clean listing | Further table details require clean re-check | -## The k* input libraries + libinput.dll - -**`libinput.dll` — role:** the real HID input abstraction layer: card-slot/ -keypad/sensor configuration persistence (`eam_config_load`/`save`) and a -generic multi-device "HID stub" + input-mapper framework -(`hid_mgr_*`/`hid_stub_*`, `mapper_*`) that lets a game bind logical -buttons/analog axes to physical HID controls and light outputs. -`objdump -p GAME-DIR/libinput.dll` imports `msvcrt.dll`, `KERNEL32.dll`, -`USER32.dll`, `HID.DLL`, `SETUPAPI.dll`, `SHELL32.dll` — it talks to real -HID hardware via `SETUPAPI`/`HID.DLL`, which `docs/companion-inventory.md` -uses as its evidence this is a genuine Konami cabinet-input driver and not -a spice2x emulation shim. Export surface (from `objdump -p`, 51 names, -prefix `eam_*`/`hid_mgr_*`/`hid_stub_*`/`mapper_*`/`input_*`): config -(`eam_config_load`/`save`, `eam_get_alt_10k`, `eam_get_autogen`, -`eam_get_card_path`, `eam_get_keypad[_device]`, `eam_get_sensor`, -`eam_is_dirty`/`is_muxed`, `eam_clear_dirty`, `eam_read_card`, -`eam_set_alt_10k`/`set_autogen`/`set_card_path`/`set_keypad_device`), HID -stub enumeration (`hid_mgr_get_first_stub`/`get_named_stub`/`lock`/ -`unlock`, `hid_stub_get_{controls,device_usage,lights,name,value}`, -`hid_stub_{is_attached,next,set_light,update}`), input-mapper binding -(`mapper_add_{analog_,}binding`, `mapper_add_lightbind`, -`mapper_config_load`/`save`, `mapper_del_{analog_,}binding`/`lightbind`, -`mapper_get_analog_{control_no,hid,pos,sensitivity}`, -`mapper_get_{bindings,last_buttons,lightbinds}`, -`mapper_is_analog_relative`, `mapper_set_{analog_sensitivity, -next_lights}`, `mapper_update`), and lifecycle (`input_init`/`fini`, -`input_set_loggers`). This export list is read directly from `objdump -p` -against `GAME-DIR/libinput.dll`; no `.def` for it existed under -`re/importlibs/` at authoring time. - -**`kbt.dll` / `kld.dll` — role:** these are **ALREADY-OSS**, not Konami -originals — `docs/companion-inventory.md` identifies both as **bemanitools** -(djhackersdev/bemanitools) "ikey" security-dongle stub builds, proven by an -embedded CodeView PDB path `d:\bemanitools\stubs\objfre_wxp_x86\i386\ -stubs.pdb` at file offset `0x55b` in both files, plus `k_bt0002` -disassembling to a bare `ret` at RVA `0x11d7` rather than the real -callback-invoking implementation. `objdump -p` on both confirms an -identical **6-export, plain-C** surface: `bt_fcheck_finish`, -`bt_fcheck_init`, `bt_fcheck_main`, `bt_get_ikey_status`, `k_bt0001`, -`k_bt0002` — a dongle presence-check API (`k_bt0001`/`k_bt0002` are the -vendor-numbered dongle-protocol entry points `bt_fcheck_*` wrap). Both -import only `msvcrt.dll` + `KERNEL32.dll`. Documented here for surface -completeness; neither is a reconstruction target (ALREADY-OSS, excluded -from the reconstruct set per the inventory). - -**`kmd.dll` — role:** a single-export Konami "md" module ("memory-dump"/ -debug, name UNVERIFIED beyond its own export token). -`objdump -p GAME-DIR/kmd.dll` imports `dbghelp.dll`, `libavs-win32.dll`, -`KERNEL32.dll`, `MSVCR80.dll` and exports exactly one plain-C symbol, -`k_md0001`. The `dbghelp.dll` import (Windows symbol/stack-walking API) is -consistent with a crash-dump or diagnostics module, but that role is -otherwise UNVERIFIED — a single opaque numbered export gives no further -semantic signal without decompiling it (companion Ghidra project -`kmdproj.gpr` exists at `/home/athapa/ghidra/kmdproj.gpr` for this purpose, -not yet exploited for this section). - -**`ksm.dll` — role:** Konami "sm" session/security-manager module backing -a "SSM" (secure session manager / signed-player-record) subsystem — array/ -repository/certificate primitives for signed player records ("SPR") and -ticket/token records ("TPR") plus an XRPC client used for the account/ -matching protocol. `objdump -p GAME-DIR/ksm.dll` imports `kdu.dll`, -`kmp.dll`, `kma.dll` (further Konami AVS2-family modules **not shipped** in -this game directory, noted as external dependencies in -`docs/companion-inventory.md`), plus `libavs-win32.dll`, -`libavs-win32-ea3.dll`, `KERNEL32.dll`, `MSVCR80.dll`. Export surface (from -`objdump -p`, **111 names**): a generic reference-counted array container -(`ssm_array_{add,element_array,element_size,find,fix,free,get,guillotine, -inc_reference,new,num,reference_count,remove,replace,set,swap,truncate}`), -a repository/manager pair for account-session records -(`ssm_manager_{free,get_repository,inc_reference,lease_account_session,new, -release_account_session}`, `ssm_repository_{delete_entry_by_{index,ssmid}, -dprint,entry_*,enum_entries,find_entry_by_ssmid,fprint,free,get_entry_num, -inc_reference,open,print,read_entry_by_{index,ssmid},set_limit,truncate, -update_entry,verify}`), signed-player-record handling -(`ssm_spr_{add_cert,create,dprint,free,get_binary,get_pr, -get_signing_time,get_ssmid[_cstr],inc_reference,init_creation, -is_signature_equals,load_from_binary,new,print,reencode,verify}`), a -"TPR" ticket/token-record variant mirroring the SPR shape -(`ssm_tpr_{create,dprint,free,get_binary,get_content[_info],get_spr, -inc_reference,init_creation,load_from_binary,new,print,verify}`), a -protocol-response ("pr_client") helper set -(`ssm_pr_client_{accept_response,create_request,free,get_ecoin_response, -get_ssmid_in_response,inc_reference,new}`), certificate memory management -(`ssm_mes_{free,inc_reference}_pcert`), system bootstrap -(`ssm_system_{finalize,get_functions,get_manager,get_repository, -initialize[_ex]}`), and XRPC client plumbing -(`ssm_xrpc_common_{add_module,apply}`, -`ssm_xrpc_request_get_{esid[_1],status[_1]}`), plus one opaque vendor -entry `k_sm0001` exported at ordinal 88 ahead of the named `ssm_*` block -(`objdump -p` ordinal/name table: `[87] ... 0000 k_sm0001`, i.e. it is -ordinal 1, hint-ordered last). No `.def` existed for this DLL under -`re/importlibs/` at authoring time; export list is read directly from -`objdump -p`. - -**`kuc.dll` — role:** a small Konami "uc" module. `objdump -p -GAME-DIR/kuc.dll` imports `kdu.dll`, `kmp.dll`, `kma.dll` (same unshipped -Konami-family dependency pattern as `ksm.dll`) plus `libavs-win32.dll`, -`libavs-win32-ea3.dll`, `KERNEL32.dll`, `MSVCR80.dll`. Export surface: only -**4 names** — `DllStart`, `k_uc0001`, `k_uc0004`, `k_uc0005`. Semantic role -is UNVERIFIED beyond the module prefix; the gap in numbered exports -(`0001`, `0004`, `0005` — `0002`/`0003` absent) suggests the module exposes -a sparse subset of a larger shared "k_*" vendor entry-point convention also -seen in `kbt.dll`/`kld.dll`/`kmd.dll`/`ksm.dll`. - -## Naming-convention summary across all companions - -| DLL | Named exports | Hash-obfuscated? | Convention | -|---|---|---|---| -| `libavs-win32.dll` | 360 | **yes**, all 360 (`XCd229cc...`) | cdecl, by name | -| `libavs-win32-ea3.dll` | 139 | **yes**, all 139 (`XE592acd...`) | cdecl, by name | -| `arkkdm.dll` | 255 | no | stdcall, by name (`--kill-at`) | -| `libafp-win32.dll` | 159 | no | cdecl, by name | -| `libafputils-win32.dll` | 162 | no | cdecl, by name | -| `ess.dll` | 209 | no | cdecl, by name | -| `libacio.dll` | 44 | no | cdecl, by name | -| `libacio_mbr.dll` | 47 | no | UNVERIFIED (no `.def`/convention evidence captured yet) | -| `libinput.dll` | 51 | no | UNVERIFIED (no `.def`/convention evidence captured yet) | -| `kbt.dll` / `kld.dll` | 6 each | no | UNVERIFIED (bemanitools stub, out of reconstruct scope) | -| `kmd.dll` | 1 | no | UNVERIFIED | -| `ksm.dll` | 111 | no | UNVERIFIED | -| `kuc.dll` | 4 | no | UNVERIFIED | - -Only the two AVS2 tiers (`libavs-win32.dll`, `libavs-win32-ea3.dll`) use -vendor hash-token export names; every other Konami-original companion in -this inventory exports plain, readable C symbol names. The two "UNVERIFIED" -convention rows above have export surfaces confirmed directly from -`objdump -p` but lack the `.def`/IAT-disassembly calling-convention proof -that `docs/companion-conventions.md` provides for the other DLLs — a -follow-up pass through `tools/gen_importlibs.sh` plus one IAT call-site -disassembly per DLL (the method documented there) would close that gap. +The two AVS2 tiers are the only official companions documented here with +hash-token names. All claims in this table concern the official companion +set only; `Kinect10.dll` is instead Microsoft's external Kinect-for-Windows +NUI v1 runtime imported by `gamekdm.dll`, not a companion or shipped module +[`../companion-inventory.md`](../companion-inventory.md). diff --git a/docs/spec/08-abi-conventions.md b/docs/spec/08-abi-conventions.md index b4b2209..aafc622 100644 --- a/docs/spec/08-abi-conventions.md +++ b/docs/spec/08-abi-conventions.md @@ -22,6 +22,12 @@ RVAs read like `0x10023af0` and the RVA database (`re/rvadb.json`, 9728 functions) stores each function's address relative to that base (`docs/conventions.md`, "Function naming"). +> **Clean-release caveat.** Any RVA, IAT address, export ordinal, or file-byte +> offset below that was measured from an earlier install is UNVERIFIED (pending +> re-check against clean-release binary). The official module topology is the +> nine shipped modules in `contents/modules/`; `Kinect10.dll` is an external +> Microsoft NUI runtime dependency of `gamekdm.dll`, not a companion module. + The floating-point model is x87 with 80-bit intermediates, matching VS2010 SP1 x86's default. It is detected, not assumed: x87 opcodes (`fld`, `fmul`, `fstp`, `fadd`, ...) in the validity-gate disasm mean x87 and a `-mfpmath=387` build; @@ -74,16 +80,17 @@ esp,N`) is cdecl; a callee returning `ret N` with no caller fixup is stdcall | DLL | Convention | Evidence (from `docs/companion-conventions.md`) | `--kill-at` | |---|---|---|---| -| libavs-win32.dll | cdecl | IAT `0x102183cc` etc.; callers emit `add esp,N` after the call | no | +| libavs-win32.dll | cdecl | caller-cleanup call-site evidence; IAT address UNVERIFIED (pending re-check against clean-release binary) | no | | libavs-win32-ea3.dll | cdecl | same vendor build / export-naming scheme as libavs-win32 | no | -| libafp-win32.dll | cdecl | IAT `0x10218304` (`afp_display_layer`); caller pops its own arg | no | -| libafputils-win32.dll | cdecl (logger entry points cdecl-varargs) | IAT `0x10218394/98/9c`; one push per call, no callee `ret N` reliance | no | +| libafp-win32.dll | cdecl | caller-cleanup call-site evidence; IAT address UNVERIFIED (pending re-check against clean-release binary) | no | +| libafputils-win32.dll | cdecl (logger entry points cdecl-varargs) | caller-cleanup call-site evidence; IAT addresses UNVERIFIED (pending re-check against clean-release binary) | no | | ess.dll | cdecl | not called via gamekdm's IAT; plain undecorated C exports, no `@N` | no | -| arkkdm.dll | stdcall | export ordinal 2, `arkAFPBoot`, RVA `0x52790`; `ret 0x4` at file offset `0x100527ca` | yes | +| arkkdm.dll | stdcall | `arkAFPBoot` evidence is UNVERIFIED (pending re-check against clean-release binary) | yes | | libacio.dll | cdecl | not called via gamekdm's IAT; undecorated plain-C exports | no | -| Kinect10.dll | stdcall | IAT `0x102181d4` etc.; callee `ret N`, no caller `add esp` cleanup (MS Kinect for Windows SDK v1.x) | yes | +| Kinect10.dll (external Microsoft NUI runtime) | stdcall | external-import call-site evidence; IAT address UNVERIFIED (pending re-check against clean-release binary) | yes | -All companions bind by name except Kinect10, which is imported by ordinal in +The shipped-module imports listed above bind by name. The external Kinect10 +runtime is imported by ordinal in gamekdm's import table but exported by name in the DLL (`NuiInitialize`, ...) plus one `NONAME` ordinal-1 export. `--kill-at` strips dlltool's guessed `@N` stdcall decoration so the import binds to the DLL's real undecorated export diff --git a/docs/spec/09-reconstruction-codebase.md b/docs/spec/09-reconstruction-codebase.md index 83f76be..ce51702 100644 --- a/docs/spec/09-reconstruction-codebase.md +++ b/docs/spec/09-reconstruction-codebase.md @@ -16,6 +16,11 @@ Scope note: the reconstruction is early. The canonical RVA database carries 'verified': 1})`). The three-function proven slice is tracked through a separate evidence overlay (`re/pure-slice-status.json`), not the canonical statuses. +Release scope follows [the official inventory](../companion-inventory.md): +exactly nine Konami modules in `contents/modules/`. Historical RVAs, byte +sequences, image hashes, and import/export details below are +UNVERIFIED (pending re-check against clean-release binary). + ## 1. Repository layout Top level of the checkout (`ls` of `/home/athapa/kdm-re`): @@ -93,14 +98,20 @@ Output is `build/gamekdm.dll`, a PE32 (i386) DLL (`docs/pipeline.md` section 4). ### Companion import libraries The reconstruction links against MinGW import libs derived from the game's own -companion DLLs. `tools/gen_importlibs.sh` runs `gendef` then -`i686-w64-mingw32-dlltool` for each in-scope companion -(`libavs-win32`, `libafp-win32`, `ess`, `arkkdm`, `libacio`, `Kinect10`, and -others in its `CONV` map) and writes `re/importlibs/lib.dll.a`. The two -stdcall companions (`arkkdm`, `Kinect10`) get `--kill-at`; the cdecl ones do not, -because killing the `@N` decoration on a cdecl import would mislabel its ABI -(`tools/gen_importlibs.sh` header comment and `CONV` table). The `.def` files are -committed; the `.dll.a` archives are gitignored and regenerated. +shipped modules, plus the external Kinect10.dll NUI runtime gamekdm imports. +`tools/gen_importlibs.sh` runs `gendef` then `i686-w64-mingw32-dlltool` for the +seven shipped modules in its current map (`libavs-win32`, `libavs-win32-ea3`, +`libafp-win32`, `libafputils-win32`, `ess`, `arkkdm`, `libacio`) plus the +external `Kinect10` dependency, and writes `re/importlibs/lib.dll.a`. +The two stdcall entries, `arkkdm` and the external `Kinect10`, get `--kill-at`; +the cdecl shipped modules do not, because their names have no `@N` decoration +to strip (`tools/gen_importlibs.sh` header comment +and `CONV` table). The `.def` files are committed; the `.dll.a` archives are +gitignored and regenerated. + +The current script expects all inputs in one directory. That assumption does +not match the clean release: Konami modules reside in `contents/modules/`, +while Microsoft supplies the external NUI runtime separately. ### PURE build modes and the coverage gate @@ -147,14 +158,14 @@ with a single pointer arg, matched from the original's bare `ret` (`gamemain.cpp:17-19`). Only KERNEL32 and msvcrt symbols are touched, giving the rebuilt proxy/slice DLL a clean KERNEL32+msvcrt import table — this is the reconstruction's own minimal-proxy shape, not a match to the original's import -table. The original `gamekdm.dll` imports 16 DLLs total: its own companion -Konami middleware (`libavs-win32.dll`, `libafp-win32.dll`, -`libafputils-win32.dll`), the Kinect shim (`Kinect10.dll`), Direct3D +table. The original `gamekdm.dll` imports its shipped Konami middleware +(`libavs-win32.dll`, `libafp-win32.dll`, `libafputils-win32.dll`), the +external Microsoft NUI runtime (`Kinect10.dll`), Direct3D (`d3d9.dll`, `d3dx9_43.dll`), and a conventional Win32 OS set (`KERNEL32.dll`, `USER32.dll`, `GDI32.dll`, `ADVAPI32.dll`, `SHELL32.dll`, `ole32.dll`, `WS2_32.dll`, `WINMM.dll`, `IMM32.dll`, `DINPUT8.dll`) — not msvcrt, since its -statically linked CRT imports zero C/C++ runtime DLLs (`objdump -p -GAME-DIR/gamekdm.dll | grep 'DLL Name'`, 16 entries). Because the +statically linked CRT imports zero C/C++ runtime DLLs. The exact imported-DLL +count is UNVERIFIED (pending re-check against clean-release binary). Because the original is resolved lazily, the rebuilt DLL loads on its own as a valid smoke test with no original present (`docs/pipeline.md` section 5c). @@ -273,7 +284,7 @@ cluster and coordinate shared struct layouts through single-owner headers in `docs/cutover.md` is explicit that the build mechanism exists but the game cutover does not. The three T11 routines have differential evidence; the rest of `re/rvadb.json` is nowhere near 100% verified coverage, and a slice smoke test -cannot authorize deployment. Full Windows/spice2x QA, on an isolated install with +cannot authorize deployment. Full cabinet/original-binary runtime QA, on an isolated install with a known-good hybrid kept for rollback, is the gated final milestone, and any failing item, unresolved indirect target, stub, or original-binary dependency keeps cutover incomplete. The pure build must never silently load an original DLL diff --git a/docs/spec/README.md b/docs/spec/README.md index 36442fa..fcadc0a 100644 --- a/docs/spec/README.md +++ b/docs/spec/README.md @@ -6,12 +6,15 @@ under the internal engine/module codename **KDM**, and of the `kdm-re` reconstruction codebase that rebuilds its main logic DLL, `gamekdm.dll`, from static and dynamic analysis. Every claim in every section below is grounded in a cited artifact — a `file:line`, an RVA such as `0x10009e20`, `objdump` -output, or an absolute `GAME-DIR` path — and anything that could not be -checked is marked `UNVERIFIED` rather than asserted. `GAME-DIR` for the build +output from a clean-release binary, or an official `contents/` artifact path — +and anything that could not be checked is marked `UNVERIFIED` rather than +asserted. `GAME-DIR` for the build analyzed throughout this spec is the owner's local copy of **KDM-2016021900** -(`.../KDM-2016021900/contents`), and `re/rvadb.json` is the shared RVA -function database (`function_count = 9728`, `image_base = "0x10000000"`, -confirmed directly by reading that file in this repository). No copyrighted +(`.../KDM-2016021900/contents`): `data/`, `arkdata/`, `prop/`, and exactly nine +DLLs in `modules/` (docs/companion-inventory.md, "What the clean release +contains"). `re/rvadb.json` is the shared reconstruction locator database; +its per-binary addresses are **UNVERIFIED (pending re-check against +clean-release binary)**. No copyrighted creative asset (song audio, video, lyrics, or art) is reproduced anywhere in this spec; only file formats, code structure, and behavior are described. @@ -19,26 +22,21 @@ this spec; only file formats, code structure, and behavior are described. | # | Section | Summary | |---|---------|---------| -| 00 | [Overview and high-level architecture](./00-overview.md) | What DEA is, the AVS2/ARK/Kinect platform stack, the `gamestart.bat` boot chain, the 22-DLL module stack, and the three-dimension (GAME / ORIGINAL / RECONSTRUCTION) organizing structure this whole spec follows. | -| 01 | [Runtime environment and boot/startup chain](./01-runtime-boot.md) | The Win32/AVS2/e-Amusement-v3 cabinet platform; the exact process chain from `gamestart.bat` through `launcher.exe`, `deahook.dll`, and `arkkdm.dll` to `gamekdm.dll`'s `gameMain` export, including its cdecl calling convention and `hInstance` argument; `avs-config.xml`/`ea3-config.xml`/`ark-config.xml` contents. | -| 02 | [DLL architecture and module dependency graph](./02-dll-architecture.md) | Per-DLL classification (IN-SCOPE / REUSE-OS / ALREADY-OSS) of all 22 shipped DLLs, sizes and export counts from `objdump -p`, and the full cross-DLL dependency DAG (verified acyclic), reconciled against `docs/companion-inventory.md`. | -| 03 | [Kinect input and skeleton pipeline](./03-kinect-skeleton.md) | The `Kinect10.dll` NUI v1 boundary gamekdm statically imports, the `NuiThread`/`hid::Natal` skeleton-ingest functions and their RVAs, depth-to-skeleton coordinate projection math, and how a replacement Kinect shim feeds synthetic frames into the unmodified game. | +| 00 | [Overview and high-level architecture](./00-overview.md) | What DEA is, the official AVS2/ARK platform, the `arkkdm.dll` entry path, the nine-module clean-release stack, and the three-dimension (GAME / ORIGINAL / RECONSTRUCTION) organizing structure this whole spec follows. | +| 01 | [Runtime environment and boot/startup chain](./01-runtime-boot.md) | The Win32/AVS2/e-amusement-v3 cabinet platform and official `arkkdm.dll` → `gamekdm.dll` entry facts. Any community-loader material still present in that section is out of game scope and not evidence; the official config is `eamuse-config.xml`, not `ea3-config.xml`. | +| 02 | [DLL architecture and module dependency graph](./02-dll-architecture.md) | The nine official modules and their shipped-module dependency DAG, reconciled against `docs/companion-inventory.md`. Any 22-DLL or community-glue inventory still present in that section is superseded and is not game evidence. | +| 03 | [Kinect input and skeleton pipeline](./03-kinect-skeleton.md) | The external Microsoft `Kinect10.dll` NUI v1 runtime boundary imported by `gamekdm.dll`, the `NuiThread`/`hid::Natal` skeleton-ingest functions and their RVAs, and depth-to-skeleton coordinate projection math. `Kinect10.dll` is not a shipped module. | | 04 | [Player validity gate and menu hand cursor](./04-validity-cursor.md) | The gravity/floor-relative transform and box-distance gate (`FUN_10018570`, `FUN_100e4140`, `FUN_101ab6d0`) that decides whether a tracked skeleton is allowed to render/play, and the structurally separate Flash/`afp` PhIZ hand-cursor system that drives menu navigation. | -| 05 | [Data formats](./05-data-formats.md) | Game-directory layout (`data/`, `arkdata/`, `prop/`, `dev/`), the AVS2 property-tree/filesystem model, the typed-attribute `prop/*.xml` config dialect, and the asset container formats (`.arc`, `.ifs`, `.dal`, `.xwb`/`.xsb`, `.dds`, `.kbf`, `.wmv`) identified by direct inspection. | +| 05 | [Data formats](./05-data-formats.md) | Official layout (`data/`, `arkdata/`, `prop/`), the AVS2 property-tree/filesystem model, the typed-attribute `prop/*.xml` config dialect, and asset container formats identified by direct inspection. The clean release uses `prop/eamuse-config.xml`; references there to `ea3-config.xml` or `dev/` are superseded. | | 06 | [gamekdm.dll subsystem map](./06-gamekdm-subsystems.md) | An RVA-anchored, evidence-tiered partition of the 9,728-function DLL into functional subsystems (game-state manager, Kinect/skeleton, validity gate, menu cursor, scoring, song/chart flow, D3D9 render, movie, particle, sound, UI, boot/entry), with an explicit coverage note (~2.7% named). | -| 07 | [Companion DLL API surfaces](./07-companion-apis.md) | The exported C API of every in-scope companion DLL `gamekdm.dll` depends on directly or transitively — `libavs-win32.dll` (AVS2 base, hash-obfuscated exports), `libavs-win32-ea3.dll`, `arkkdm.dll` (ARK/KDM engine), `libafp-win32.dll`/`libafputils-win32.dll` (AFP/Flash renderer), `ess.dll`, `libacio.dll`/`libacio_mbr.dll`, `libinput.dll`, and the `k*` modules. | +| 07 | [Companion DLL API surfaces](./07-companion-apis.md) | The exported APIs of the official companions: `libavs-win32.dll`, `libavs-win32-ea3.dll`, `libafp-win32.dll`, `libafputils-win32.dll`, `ess.dll`, `libacio.dll`, `arkkdm.dll`, and `arkkdmtest.dll`. Non-release modules mentioned in that section are superseded and are not game evidence. | | 08 | [ABI, calling conventions, and struct layouts](./08-abi-conventions.md) | The MSVC/VS2010 SP1 x86 ABI the original binary was built with, the `GK_CDECL`/`GK_STDCALL`/`GK_THISCALL` convention macros and per-companion calling-convention table, struct-packing rules, and the reconstructed struct layouts (`Vec3`/`Matrix4x4`, `SkeletonData`/`SkeletonFrame`, `LiveManager`, `ValidityBox`/`ValidityCandidate`) with `static_assert`-pinned offsets. | | 09 | [The kdm-re reconstruction codebase](./09-reconstruction-codebase.md) | The `kdm-re` repository layout, the no-sudo i686 cross-build and its three build modes (hybrid proxy, detour carve-out, PURE slice), the Unicorn differential and golden-I/O verification gates, the per-function reconstruction loop, and current cutover status (1 of 9,728 functions `verified`). | All ten section files (`00-overview.md` through `09-reconstruction-codebase.md`) -exist in this repository and were read in full to produce the summaries above; -none are missing. Note: §00's own "Specification map" table uses placeholder -filenames (e.g. `01-platform-and-middleware.md`, `08-libavs.md`) that do not -match the files actually shipped under `docs/spec/`; §§06–09 likewise -cross-link to `07-companion-dlls.md`/`08-libavs.md` rather than the real -`07-companion-apis.md`/`08-abi-conventions.md`. This index uses the real, -on-disk filenames throughout; the stale in-body links in 00/06/07/08/09 are a -known inconsistency, noted here rather than silently worked around. +exist in this repository. This index and §00's specification map use the real, +on-disk filenames. Stale links elsewhere are document defects rather than +alternate section names. ## The three dimensions @@ -48,7 +46,7 @@ the structure §00 establishes: | Dimension | What it covers | Primary sections | |---|---|---| | **THE GAME** | Observable product behavior and the platform it runs on: what DEA does for a player, the Kinect data path, the AVS2/ARK/e-Amusement-v3 middleware, the boot chain, and on-disk asset formats. | 00, 01, 03, 04, 05 | -| **The ORIGINAL binary codebase** | The shipped DLLs as reverse-engineering subjects: the 22-DLL inventory and dependency DAG, the `gamekdm.dll` function/subsystem map (`re/rvadb.json`, 9,728 functions), companion export surfaces, and the binary-level ABI/struct facts recovered from disassembly. | 00, 02, 06, 07, 08 | +| **The ORIGINAL binary codebase** | The nine official shipped modules as reverse-engineering subjects: their dependency DAG, the `gamekdm.dll` function/subsystem map (`re/rvadb.json`, 9,728 records), companion export surfaces, and the binary-level ABI/struct facts recovered from official binaries. | 00, 02, 06, 07, 08 | | **The RECONSTRUCTION codebase** | The hand-reviewed MinGW C/C++ under `src/`/`include/` that rebuilds `gamekdm.dll` behavior, the cross-build system, and the verification/cutover workflow that proves and ships it. | 08, 09 | Section 00 spans all three (it is the entry point); 01, 03, 04, 05 are @@ -60,18 +58,21 @@ are ORIGINAL; 08 bridges ORIGINAL (the facts being matched) and RECONSTRUCTION ## Glossary -- **DEA** — DanceEvolution Arcade, the shipped product name (confirmed by the - spice2x game-family identifier `games::dea` and `deahook.dll`'s internal - export-directory module name `DEALibacio.dll`; see [00](./00-overview.md)). -- **KDM** — Konami's internal model/engine code for this title. Appears as - the e-amusement `KDM` in `ea3-config.xml`, as the `arkKDM*` +- **DEA** — DanceEvolution Arcade, the product specified by the official + KDM release artifacts: the e-amusement model in `prop/eamuse-config.xml`, + the `arkKDM*` API prefix, and the `arkkdm.dll`/`gamekdm.dll` file stems + (see [00](./00-overview.md)). +- **KDM** — Konami's model/engine code for this title. Appears as + the e-amusement model in `eamuse-config.xml`, as the `arkKDM*` export prefix in `arkkdm.dll`, and as the `gamekdm.dll`/`arkkdm.dll` file name stems (see [01](./01-runtime-boot.md), [07](./07-companion-apis.md)). -- **gamekdm(.dll)** — the main game-logic DLL (3,369,104 bytes, one export, - `gameMain`). The primary reconstruction target of this entire project +- **gamekdm(.dll)** — the main game-logic DLL (3.19 MB in the clean-release + listing; exports `gameMain`). The prior 3,369,104-byte value is **UNVERIFIED + (pending re-check against clean-release binary)**. It is the primary target (see [00](./00-overview.md), [06](./06-gamekdm-subsystems.md)). - **gameMain** — `gamekdm.dll`'s sole export, RVA `0x00009e20` / absolute VA - `0x10009e20`, `cdecl`, taking one `void* hInstance` argument that is + `0x10009e20` (**UNVERIFIED (pending re-check against clean-release + binary)**), `cdecl`, taking one `void* hInstance` argument that is `arkkdm.dll`'s own `HINSTANCE` (not `gamekdm.dll`'s), relayed through `arkkdm.dll`'s internal `g_MainDllInfo` struct (see [01](./01-runtime-boot.md) §3.7). @@ -81,14 +82,15 @@ are ORIGINAL; 08 bridges ORIGINAL (the facts being matched) and RECONSTRUCTION in-scope DLL (see [07](./07-companion-apis.md)). - **ea3** — "e-Amusement v3," the Konami network/identity/coin-economy extension layered on AVS2 (`libavs-win32-ea3.dll`), configured by - `prop/ea3-config.xml` (see [05](./05-data-formats.md)). + `prop/eamuse-config.xml`; there is no `ea3-config.xml` in the clean release + (see [05](./05-data-formats.md)). - **ARK** — Konami's reusable arcade-cabinet game-engine framework (`arkkdm.dll` in this build, i.e. "ARK instantiated for KDM"): credit/coin handling, card I/O, networking, threading, heap management, and the `arkAFP*` rendering wrapper over AFP (see [07](./07-companion-apis.md)). - **ACIO** — Konami's amusement-cabinet serial I/O protocol for coin mechs, - button/LED boards, and card readers, implemented by `libacio.dll` / - `libacio_mbr.dll` (see [07](./07-companion-apis.md)). + button/LED boards, and card readers, implemented by the official + `libacio.dll` (see [07](./07-companion-apis.md)). - **PhIZ** — the body-relative, reach-normalized hand-to-cursor mapping used by the Flash/Natal menu runtime inside `libafp-win32.dll`; `gamekdm.dll` never writes the cursor position itself, it only reads it (see @@ -98,7 +100,9 @@ are ORIGINAL; 08 bridges ORIGINAL (the facts being matched) and RECONSTRUCTION `name`, `callers`/`callees`, `globals_touched`, and a reconstruction `status` (`orig`/`reimpl`/`stub`/`verified`), keyed against `image_base = "0x10000000"` (independently confirmed in this session by - reading the file directly; see [09](./09-reconstruction-codebase.md)). + reading the file directly; its addresses remain **UNVERIFIED (pending + re-check against clean-release binary)**; see + [09](./09-reconstruction-codebase.md)). - **Differential (Unicorn differential)** — the verification method in `tools/unicorn_diff/` that emulates the real routine inside the shipping `gamekdm.dll` under Unicorn (oracle) and runs the compiled C++ @@ -144,18 +148,16 @@ are ORIGINAL; 08 bridges ORIGINAL (the facts being matched) and RECONSTRUCTION disassembly listing in one of the sections above should be treated as unestablished. - **Deferred items**, named explicitly rather than silently dropped, per - section: cabinet hardware specifics and the `DAMAC_VIEWER_FULLSCREEN` - environment variable's consumer ([01](./01-runtime-boot.md)); full - hash-token-to-name recovery for `libavs-win32.dll`'s 360 and - `libavs-win32-ea3.dll`'s 139 obfuscated exports beyond the one proven - (`property_node_datasize`), and calling-convention proof for - `libacio_mbr.dll`/`libinput.dll` ([07](./07-companion-apis.md)); the + section: cabinet hardware specifics ([01](./01-runtime-boot.md)); clean- + release re-verification of byte-exact export counts and RVAs for the nine + official modules ([02](./02-dll-architecture.md), + [07](./07-companion-apis.md)); the `.arc`/`.ifs` internal entry-table layouts ([05](./05-data-formats.md)); `FUN_10018570`'s full re-decompilation and the cursor path (`FUN_1007fbf0`/`FUN_101d84c0`/`DAT_103d2bb8`), neither of which has a reconstruction yet ([04](./04-validity-cursor.md)); the remaining 9,467 unclassified `gamekdm.dll` functions ([06](./06-gamekdm-subsystems.md)); - and full Windows/spice2x cutover QA, which the project treats as + and full Windows cabinet-runtime cutover QA, which the project treats as deliberately gated and incomplete ([09](./09-reconstruction-codebase.md) §6). - **A claim without a citation is a bug.** Every section inherits this rule from [00-overview.md](./00-overview.md); report any uncited claim found in diff --git a/game-internals.md b/game-internals.md index d4e877d..85de78a 100644 --- a/game-internals.md +++ b/game-internals.md @@ -1,31 +1,30 @@ # DanceEvolution Arcade (DEA / `gamekdm.dll`) — game internals & RE jumpstart -Everything reverse-engineered about how DEA consumes the emulated Kinect, plus a +Everything reverse-engineered about how DEA consumes the Microsoft NUI runtime, plus a jump‑start so another agent can continue a full RE/decompilation **without redoing this work**. All gamekdm addresses use image base `0x10000000`. -The emulator presents an ordinary webcam as a Kinect v1: the native tracker -(`tracker-native/`, MediaPipe/BlazePose + ONNX) publishes a synthetic -depth/color/skeleton frame over a shared‑memory contract, and the Windows NUI -shim (`fallback/windows-nui/`, a drop‑in `Kinect10.dll`) serves it to the game. -We never modify any game file. +Scope is the nine Konami modules in `contents/modules/` and the official +assets/configuration in `contents/`, as listed in +[docs/companion-inventory.md](docs/companion-inventory.md). +`Kinect10.dll` is only an external Microsoft NUI v1 runtime dependency of +`gamekdm.dll`, supplied by the platform. + +The addresses, layouts, constants, and disassembly observations below are +historical leads for `contents/modules/gamekdm.dll` and +`contents/modules/libafp-win32.dll`: UNVERIFIED (pending re-check against clean-release binary). --- ## 1. How DEA consumes the Kinect -- DEA loads `Kinect10.dll` (MS NUI v1 API). Our shim implements that ABI and - feeds the game our frames. The game's own NUI stack computes nothing extra for - the skeleton — we publish the 20‑joint skeleton directly; the game *does* run - its own selection/validation and a Flash menu cursor on top (below). -- Resolution: the game only accepts a **4:3** image. The tracker enforces 4:3 - (`PopulateResolutions` filters to 4:3; depth/color are 640×480). -- The in‑process introspection tool (section 5) reads the game's live manager at - `*(gamekdm+0x3cf1b4)` — this is how everything below was discovered. +- `gamekdm.dll` imports the external Microsoft `Kinect10.dll` NUI v1 API. + The game runs skeleton selection/validation and a Flash menu cursor (below). +- The historical live-manager address is `*(gamekdm+0x3cf1b4)`. ## 2. Skeleton rendering & the selection/validity gate *(solved)* -For the in‑game skeleton to render, our candidate skeleton must pass the game's +For the in‑game skeleton to render, a candidate skeleton must pass the game's orientation/validity gate, decoded from `gamekdm`: - `FUN_10018570` builds a gravity/floor‑relative transform `M`. If the gravity @@ -38,12 +37,8 @@ orientation/validity gate, decoded from `gamekdm`: `P1 = (-px, py + m13, -pz + m14)` (no perspective divide) and accepts only if `P1` is within `0.05` of the box `[A-B, A+B]` where `A = DAT_103d3230 = (0,1,0)`, `B = (1.22, 1, 0.675)` → box x∈[-1.22,1.22], y∈[0,2], z∈[-0.675, - 0.675]. `m14 = 2.5` matches our published `z0`; `m13` is taken straight from + 0.675]. `m13` is taken straight from the skeleton frame's `vFloorClipPlane.w`. -- **The fix** (`sensor.cpp BuildSkeletonFrame`): publish all 20 joints as - `TRACKED`, `vNormalToGravity = {0,1,0,0}`, and **`vFloorClipPlane = {0,1,0, - 1.0 - hip.y}`** so `P1.y = hip.y + (1 - hip.y) = 1.0` (box centre) every frame. - This auto‑centres the candidate and the skeleton renders. (Commit `36035cc`.) ## 3. The menu hand‑cursor (Flash/`afp` PhIZ) *(solved)* @@ -63,64 +58,12 @@ This one is *not* in any DLL — it lives in the game's Flash runtime: - **No gamekdm code writes the cursor from the hand** (no `afp_mc_set_param` with `0x1008`; 53 decompiled menu AS scripts reference no hand/cursor/natal). The hand→cursor PhIZ is inside the Flash/Natal runtime — a body‑relative, - reach‑normalised mapping we can't modify. The only lever is **our skeleton**. -- **Root causes & fixes** (all shim‑side, `BuildSkeletonFrame`; no tracker - rebuild needed): - 1. **Handedness.** Our projection is byte‑identical to a real Kinect's - `NuiTransformDepthImageToSkeleton` (`kDepthProjectionScale = 3.501e-3 = - NUI_CAMERA_DEPTH_NOMINAL_INVERSE_FOCAL_LENGTH_IN_PIXELS`). But the tracker - mirrors the camera (selfie view, like a real Kinect's mirrored depth - image), and **mirroring swaps MediaPipe's L/R labels** (verified: a - mirrored frame's `RIGHT_WRIST.x ≈ 1 - LEFT_WRIST.x` of the normal frame). - So the shim swaps L/R joints back (`kSwap[]`) → the player's right hand - lands in `HAND_RIGHT` with +x relative to `SHOULDER_CENTER`, matching real - Kinect recordings (`HAND_R - SHOULDER_CENTER.x ∈ [-0.35, +0.86]`). - 2. **Reach compression.** Measured against real Kinect v1 recordings (UTKinect - `waveHands` + MSR arm‑waves; see section 6), MediaPipe reports the hand - ~**1.6× (x) / 1.3× (y)** *closer* to the shoulder than a real Kinect does - (scale‑invariant, shoulder‑width‑normalised — a genuine joint‑placement - difference), so one arm only covered part of the screen. The shim amplifies - each arm outward from its shoulder by `kArmGainX / kArmGainY` (tuned to - **3.2 / 2.6** empirically for full coverage without over‑sensitivity). The - hip/center‑of‑mass is left untouched, so the validity box stays centred. + reach‑normalised mapping. ## 4. Two‑player - **The game supports 2P**: dual cursor slots (`CUR1`/`CUR2` above), `NuiSkeletonSetTrackedSkeletons([id0, id1])`, and NUI's 6 skeleton slots. -- **The emulator does not** (yet): it's single‑person end‑to‑end — the contract - carries one `SkeletonFrame`, the shim fills only `SkeletonData[0]`, and the - tracker runs single‑person BlazePose. `tracker-native/build/two_person_probe` - is the reproducible Linux evidence: it composes a 24-frame two-person - prominence sequence from the committed `testdata/sample_rgb.bin`, drives the - shipping `PoseEstimator::acquire`/`run` policy, and prints the selected - nose/hip x-region every frame. The 2026-11-27 run emitted exactly one tracked - skeleton in all 24 frames; the ROI held A while B overtook it, then switched - to B at frame 14, and back to A at frame 22 (two identity switches, no loss). -- **Experimental CUR2 probe (off by default):** setting `KINECT_SHIM_2P=1` - makes `BuildSkeletonFrame` copy slot 0 to `SkeletonData[1]`, offset it - horizontally, and assign a distinct tracking ID. It is deliberately not a - claim of real 2P (both slots are the same pose and depth player mask). With - the variable unset or not exactly `1`, slot 1 remains `NOT_TRACKED`; slot 0's - hip and `Position` remain byte-identical. The env read + decision + fill live - in one shared `PopulateSecondSkeletonFromEnv` that both the production - `BuildSkeletonFrame` and the `two_person_shim_probe` host unit call, so the - probe asserts the real shipping gate (unset/`0`/empty/`2` -> off, `1` -> on, - on->off transition, slot-0 bytes unchanged) over the real environment - variable. This only permits an in-game check - whether DEA lights `CUR2`. Real 2P still needs a multi-person pose stage and - a two-skeleton tracker contract. - -## 5. Debug tooling: in‑process game introspection - -Because the shim runs inside `gamekdm.dll`, it can read the game's live memory. -`sensor.cpp DumpGameDisplayState()` dumps the manager, the skeleton‑selection -state, the validity matrix/box, and the live cursor; the per‑frame `handcur:` -log pairs our published joints with the live cursor value. Both are gated behind -`constexpr bool kShimDebug` (`sensor.cpp`, default **false**). Flip it true, -rebuild, and watch `kinect_shim.log` (`game-introspect` / `game-skel[1-4]` / -`game-cursor` / `handcur` lines). This is the method that cracked §2 and §3 — -reimplement the game's math in Python from a single dump, don't guess. ## 6. RE / decompilation jump‑start (for a fresh agent) @@ -160,26 +103,10 @@ Everything you need to continue without redoing the groundwork: so next step is `libafp-win32.dll` (Ghidra project `afpproj`, already analysed) around its `flash.ui.MouseCursor` / pointer handling. -### Real‑Kinect reference data (for calibrating our skeleton) -- UTKinect‑Action3D: RGB (1.79G) + synced 20‑joint skeletons (3.3M) + - `actionLabel.txt`, `https://cvrc.ece.utexas.edu/KinectDatasets/` (`RGB.zip`, - `joints.zip`). Joint order = NUI (HIP_CENTER=0 … HAND_R=11 … FOOT_R=19); - real‑world metres. `waveHands` frames are a clean hand sweep. -- MSR‑Action3D `MSRAction3DSkeletonReal3D` (github `Mabdou11/Activity- - Recognition-skeleton-datasets`): `a01`=high‑arm‑wave, `a02`=horizontal‑arm‑ - wave. Compare `HAND_R - SHOULDER_CENTER` (shoulder‑width‑normalised) against - our published joints to re‑derive the reach gains. - ### Can't run the game here -Wine is not installed and the build is an 8.2 GB spice2x arcade build needing +Wine is not installed and the real cabinet/original-binary runtime needs DirectX + a real camera — iterate with the build→deploy→playtest loop, not an emulator. Deep‑low RE subagents repeatedly failed on this (armed a monitor and exited, then hit a 429 at ~2.1M tokens) — do the game RE directly with the local Ghidra setup. -## 7. Top remaining latency lever -Inference is now multi‑threaded (ONNX intra‑op, `pose_estimator.cpp`). The -biggest further win is a **GPU execution provider (DirectML)**: swap the -`onnxruntime-win-x64` CPU binary for `onnxruntime-directml` and -`so.AppendExecutionProvider_DML(0)`. Also optional: a short fixed camera -exposure (cuts sensor lag + motion blur, needs good lighting).