docs(spec): full DanceEvolution Arcade + codebase specification
10 grounded sections (overview, runtime/boot, DLL architecture, Kinect/skeleton, validity+cursor, data formats, gamekdm subsystem map, companion APIs, ABI/structs, reconstruction codebase) + master index, mined from the RVA DB / Ghidra / game dir / reconstructed slices. Independently grounding-reviewed (13/20 sample resolved on first pass; 7 contradicted claims then corrected and re-verified).
This commit is contained in:
1 parent
728ca0a2c0
commit
f2bfaf8639
11 files changed
+3389
No files matched your search
@@ -0,0 +1,214 @@
|
||||
# 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
|
||||
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
|
||||
asset (song audio, video, lyric, or art) is reproduced; only file structure and
|
||||
code behavior are described.
|
||||
|
||||
The sibling sections (01..09, listed in the [Specification map](#specification-map)
|
||||
below) drill into each area. This file gives the shape of the whole thing: what
|
||||
the game is, the platform it runs on, the module stack, and the three
|
||||
"dimensions" the spec is organized around.
|
||||
|
||||
---
|
||||
|
||||
## What DanceEvolution Arcade is
|
||||
|
||||
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"`).
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
## Platform
|
||||
|
||||
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).
|
||||
- **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`,
|
||||
`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).
|
||||
|
||||
### Boot sequence (GAME-DIR `gamestart.bat`)
|
||||
|
||||
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).
|
||||
|
||||
---
|
||||
|
||||
## 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:
|
||||
|
||||
```
|
||||
+-----------------------------------------------+
|
||||
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)
|
||||
|
||||
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)
|
||||
```
|
||||
|
||||
Key verified edges (inventory DAG, text form): `gamekdm.dll -> Kinect10.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.
|
||||
|
||||
---
|
||||
|
||||
## The three dimensions of this spec
|
||||
|
||||
The specification is deliberately split along three axes. Every sibling section
|
||||
belongs to one of them. Keeping them separate prevents the common RE-doc failure
|
||||
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).
|
||||
|
||||
2. **The ORIGINAL binary codebase** - the shipped DLLs as reverse-engineering
|
||||
subjects: the 22-DLL 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.
|
||||
|
||||
3. **The RECONSTRUCTION codebase** - the hand-reviewed C/C++ under `src/` and
|
||||
`include/` that rebuilds `gamekdm.dll` behavior, plus the RE workflow, tool
|
||||
setup, and build/cutover process that produces it. `orig/` holds the
|
||||
owner's legally-possessed binary inputs and is never committed
|
||||
(docs/provenance.md).
|
||||
|
||||
### Specification map
|
||||
|
||||
Sibling sections (relative links; files 01..09 are the planned companions to
|
||||
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 |
|
||||
| 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 |
|
||||
|
||||
> The companion documents these sections build on are already in the repo:
|
||||
> `docs/companion-inventory.md` (feeds 02), `docs/provenance.md` (feeds 08),
|
||||
> `docs/pipeline.md`, `docs/cutover.md`, `docs/reconstruction-loop.md`, and
|
||||
> `docs/conventions.md` (feed 08/09), plus `game-internals.md` (feeds 03/04).
|
||||
|
||||
---
|
||||
|
||||
## Reconstruction codebase at a glance
|
||||
|
||||
The reconstruction lives under `src/` (subdirs: `entry`, `game`, `gs`, `hybrid`,
|
||||
`mm`, `movie`, `particle`, `platform`, `pure`, `render`, `ui`, `util`) and
|
||||
`include/` (`abi`, `gk`), built via the top-level `CMakeLists.txt`. The parts
|
||||
already fleshed out from RE are concrete: `src/game/` holds `validity.cpp`,
|
||||
`box_distance.cpp`, and `nui_elevation.cpp`, the exact gate math decoded from
|
||||
`FUN_10018570`, `FUN_100e4140`/`FUN_101ab6d0`, and the validity box
|
||||
`DAT_103d3230` (game-internals.md §2, §6). The hand-reviewed source in
|
||||
`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
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
## 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.
|
||||
- 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.
|
||||
- Creative assets are described structurally only; no song media or art is
|
||||
reproduced anywhere in this spec.
|
||||
@@ -0,0 +1,433 @@
|
||||
# Runtime Environment & 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.
|
||||
|
||||
## 1. Hardware and 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`, `<soft><model>KDM</model><dest>A</dest><spec>A</spec>
|
||||
<rev>A</rev><ext>2016021900</ext></soft>`). 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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
**UNVERIFIED:** exact cabinet model number, screen resolution/refresh, and Kinect sensor mounting
|
||||
geometry are not recorded in any artifact inspected for this section.
|
||||
|
||||
## 2. spice2x as the AVS2 emulation/compatibility layer
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
Steps:
|
||||
|
||||
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): `<nvram><device>
|
||||
dev\nvram</device></nvram>` and `<raw><device>dev\raw</device></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).
|
||||
|
||||
### 3.2 `launcher.exe` — AVS bootstrap orchestration
|
||||
|
||||
`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:
|
||||
|
||||
1. Parse the `-k <hook.dll>` and positional `<game.dll>` 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).
|
||||
|
||||
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.3 AVS2 core + EA3 bootstrap
|
||||
|
||||
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:
|
||||
|
||||
- **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].<field>)` 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`).
|
||||
|
||||
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.
|
||||
|
||||
`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);
|
||||
```
|
||||
|
||||
`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:
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
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`.
|
||||
|
||||
### 3.5 `deahook.dll`'s role
|
||||
|
||||
`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).
|
||||
|
||||
### 3.6 Hop 2 — `arkkdm.dll` → `gamekdm.dll`'s `gameMain`
|
||||
|
||||
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:
|
||||
|
||||
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 <none> 0245
|
||||
GetProcAddress`).
|
||||
3. On success, invokes the resolved `gameMain` function pointer with a single argument (§3.7).
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
`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`:
|
||||
|
||||
- `<fs>` — declares the AVS virtual filesystem's **devices**: `<root><device>.</device>` (the
|
||||
content root), `<nvram><device>dev\nvram</device></nvram>` with block-storage options
|
||||
(`sz_block=768,nr_block=128,nr_mirror=4`), and `<raw><device>dev\raw</device></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: `<nr_mountpoint>256</nr_mountpoint>`,
|
||||
`<nr_filedesc>256</nr_filedesc>`.
|
||||
- `<time><gmt_offset>32400</gmt_offset></time>` — 32400 seconds = UTC+9 (Japan Standard Time),
|
||||
the cabinet's configured timezone offset.
|
||||
- `<log>` — logging sinks and levels: `level=all`, console enabled, file logging enabled with
|
||||
rotation (`rotate=1`, `gen=10` generations), network logging (`netsci`/`netlog`) disabled.
|
||||
- `<net>` — socket/protocol pool sizing (`nr_protocol=8`, `nr_socket=16`) and enables raw sockets
|
||||
plus the `lz77sock`/`multisock` AVS network transports.
|
||||
- `<thread>` — AVS kernel object pool sizing: up to 100 threads, 50 semaphores, 512 mutexes, 64
|
||||
events.
|
||||
- `<sntp><ea_on>0</ea_on>` — 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`:
|
||||
|
||||
- `<id>` — `<pcbid>`/`<softid>` 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.
|
||||
- `<soft>` — the model/dest/spec/rev/ext tuple identifying the title build (`KDM`/`A`/`A`/`A`/
|
||||
`2016021900`, §1).
|
||||
- `<timezone>32400</timezone>` and `<encoding>SHIFT_JIS</encoding>` — same UTC+9 convention as
|
||||
`avs-config.xml`; text data in this config layer is Shift-JIS encoded.
|
||||
- `<network>` — `<ssl>0</ssl>` (no TLS), `<services>http://localhost:8080/</services>` (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), `<sz_xrpc_buf>102400</sz_xrpc_buf>` (XRPC
|
||||
buffer size), `<url_slash>1</url_slash>`.
|
||||
- `<eacoin>` — PASELI (Konami's cashless payment system) configuration: `<enable>1</enable>`,
|
||||
a `<control_ref>/eacoin/enable</control_ref>` pointer into `eacoin.xml`'s property tree
|
||||
(another `prop/` file, mirrored to `dev/nvram/eacoin.xml` by `gamestart.bat`), and
|
||||
`<nr_vslot>2</nr_vslot>` (number of virtual eacoin slots).
|
||||
- `<pos>` — physical coin-mechanism configuration: `<nr_coinslot>1</nr_coinslot>` (one physical
|
||||
coin slot), `<nr_article>2</nr_article>`, `income_delay`/`income_maxdelay` timing, and a large
|
||||
`<coin>` 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): `<loglevel>disable</loglevel>` (comment: log output
|
||||
level, one of system/debug/information/warning/error/disable), `<nousbkey>0</nousbkey>` (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), `<eacoin>1</eacoin>` (comment: set to 0 if e-Amusement
|
||||
coin functionality is unavailable), and `<participation>1</participation>` (comment: set to 0 if
|
||||
"Participation" — the PASELI-era term for network play — is unsupported).
|
||||
|
||||
## 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.
|
||||
@@ -0,0 +1,241 @@
|
||||
# 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.
|
||||
|
||||
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`).
|
||||
|
||||
## Scope classification
|
||||
|
||||
- **IN-SCOPE** — Konami-authored game/middleware code targeted for
|
||||
decompilation and reconstruction.
|
||||
- **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.
|
||||
|
||||
## Per-DLL table (all 22 shipped files)
|
||||
|
||||
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.
|
||||
|
||||
| DLL | Size (bytes) | Scope | Named exports | 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).
|
||||
|
||||
## 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`:
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
```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"]
|
||||
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"]
|
||||
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
|
||||
```
|
||||
|
||||
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"`).
|
||||
|
||||
### `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).
|
||||
|
||||
### `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`).
|
||||
|
||||
### `gamekdm -> all` edge
|
||||
|
||||
`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.
|
||||
|
||||
## 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:
|
||||
|
||||
- **`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.
|
||||
|
||||
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.
|
||||
|
||||
## See also
|
||||
|
||||
- [`./00-overview.md`](./00-overview.md) — spec overview and scope.
|
||||
- [`./01-runtime-boot.md`](./01-runtime-boot.md) — process boot sequence that
|
||||
loads this module set.
|
||||
- [`./07-companion-apis.md`](./07-companion-apis.md) — per-DLL API surface
|
||||
detail for the companion (non-`gamekdm`) modules listed here.
|
||||
- [`./08-abi-conventions.md`](./08-abi-conventions.md) — calling-convention
|
||||
and linkage conventions used across these module boundaries.
|
||||
- [`./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.
|
||||
@@ -0,0 +1,375 @@
|
||||
# 03 - Kinect Input and Skeleton Pipeline
|
||||
|
||||
## 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`).
|
||||
See [the overview](./00-overview.md), [companion APIs](./07-companion-apis.md),
|
||||
and [the reconstruction codebase](./09-reconstruction-codebase.md).
|
||||
|
||||
Addresses written as `FUN_100...` or `DAT_103...` are preferred virtual
|
||||
addresses (VAs); the image base is `0x10000000`, so `FUN_1000f510` has RVA
|
||||
`0x0000f510`. This distinguishes the VA-style `rva=` comments in the
|
||||
reconstructed source from the relative values in the database
|
||||
(`game-internals.md:5`; `src/game/nui_elevation.cpp:5`;
|
||||
`re/rvadb.json`, fields `image_base` and function `rva`).
|
||||
|
||||
## Kinect10.dll boundary
|
||||
|
||||
The inspected game binary statically imports five Kinect10.dll ordinals.
|
||||
The following is the Kinect import block from `objdump -p` of
|
||||
`/mnt/f/Users/Aaron Thapa/Downloads/KDM-2016021900/contents/gamekdm.dll`:
|
||||
|
||||
```text
|
||||
DLL Name: Kinect10.dll
|
||||
vma: Ordinal Hint Member-Name Bound-To
|
||||
002181d4 5 <none> <none>
|
||||
002181d8 6 <none> <none>
|
||||
002181dc 20 <none> <none>
|
||||
002181e0 9 <none> <none>
|
||||
002181e4 22 <none> <none>
|
||||
```
|
||||
|
||||
The companion shim pins those ordinals to `NuiGetSensorCount` (5),
|
||||
`NuiCreateSensorByIndex` (6),
|
||||
`NuiImageGetColorPixelCoordinatesFromDepthPixel` (9),
|
||||
`NuiTransformSmooth` (20), and `NuiSetDeviceStatusCallback` (22)
|
||||
(`/home/athapa/kinect/fallback/windows-nui/Kinect10.def:4-21`).
|
||||
The repository import-library definition lists decorated names and explicitly
|
||||
requires `--kill-at`; its `@4`/`@8` name suffixes must not be read as the shim's
|
||||
export ordinals (`re/importlibs/Kinect10.def:5-34`).
|
||||
|
||||
### Full declared surface
|
||||
|
||||
The following table covers all 25 named entries and the anonymous slot in
|
||||
the repository definition. Presence here establishes the declared ABI surface,
|
||||
not that gamekdm calls every entry (`re/importlibs/Kinect10.def:8-34`).
|
||||
|
||||
| Group | Entries, without decoration | Evidence |
|
||||
| --- | --- | --- |
|
||||
| Anonymous slot | `ord_1 @1 NONAME` | `re/importlibs/Kinect10.def:9` |
|
||||
| Discovery | `NuiGetSensorCount`, `NuiCreateSensorByIndex`, `NuiCreateSensorById` | `re/importlibs/Kinect10.def:10-11,26` |
|
||||
| Lifecycle/events | `NuiInitialize`, `NuiSetFrameEndEvent`, `NuiShutdown`, `NuiSetDeviceStatusCallback` | `re/importlibs/Kinect10.def:19-21,27` |
|
||||
| Elevation | `NuiCameraElevationGetAngle`, `NuiCameraElevationSetAngle` | `re/importlibs/Kinect10.def:12-13` |
|
||||
| Pixel mapping | `NuiImageGetColorPixelCoordinatesFromDepthPixel`, `NuiImageGetColorPixelCoordinatesFromDepthPixelAtResolution` | `re/importlibs/Kinect10.def:14-15` |
|
||||
| Image frames | `NuiImageStreamGetNextFrame`, `NuiImageStreamOpen`, `NuiImageStreamReleaseFrame` | `re/importlibs/Kinect10.def:16-18` |
|
||||
| Stream flags | `NuiImageStreamSetImageFrameFlags`, `NuiImageStreamGetImageFrameFlags` | `re/importlibs/Kinect10.def:28-29` |
|
||||
| Skeleton frames | `NuiSkeletonGetNextFrame`, `NuiSkeletonTrackingDisable`, `NuiSkeletonTrackingEnable`, `NuiTransformSmooth` | `re/importlibs/Kinect10.def:22-25` |
|
||||
| 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
|
||||
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
|
||||
of functionality (`/home/athapa/kinect/fallback/windows-nui/include/nui_interfaces.h:41-103`;
|
||||
`src/game/nui_elevation.h:7-27`; `src/game/nui_elevation.cpp:8,20`).
|
||||
The exact dispatch path for every other method is **UNVERIFIED** here.
|
||||
|
||||
### Recorded initialization
|
||||
|
||||
A saved shim trace records sensor enumeration, creation of sensor index 0,
|
||||
initialization with flags `0x0000000B`, and a frame-end event
|
||||
(`/home/athapa/kinect/.re/shim_log_init.txt:2-6`).
|
||||
Those flags combine depth/player index `0x1`, color `0x2`, and skeleton `0x8`
|
||||
according to the shim declarations
|
||||
(`/home/athapa/kinect/fallback/windows-nui/include/nui_abi.h:45-50`).
|
||||
|
||||
The same trace records depth at **320x240, 2 bytes/pixel**, color at
|
||||
**640x480, 4 bytes/pixel**, and `ring=3` for both, with separate image events.
|
||||
Skeleton tracking is enabled with `0x2`, declared as
|
||||
`TITLE_SETS_TRACKED_SKELETONS`
|
||||
(`/home/athapa/kinect/.re/shim_log_init.txt:7-11`;
|
||||
`/home/athapa/kinect/fallback/windows-nui/include/nui_abi.h:52-56`).
|
||||
These are observations of that capture, not proof of all operating modes.
|
||||
|
||||
`game-internals.md` section 1 describes 4:3 images and says depth/color are
|
||||
640x480 (`game-internals.md:21-22`).
|
||||
Both captured stream sizes are 4:3, but the captured depth size differs.
|
||||
A later transition to 640x480 depth is **UNVERIFIED**; this section does not
|
||||
resolve the discrepancy by assuming a boot-versus-steady-state change
|
||||
(`/home/athapa/kinect/.re/shim_log_init.txt:7-8`).
|
||||
|
||||
## NuiThread and skeleton transfer
|
||||
|
||||
### Function identification
|
||||
|
||||
The retained diagnostic names can be tied to function bodies through their
|
||||
actual instruction references. The table distinguishes function entry RVAs
|
||||
from the string RVAs loaded by those functions; the database confirms each
|
||||
function's `globals_touched` reference (`re/rvadb.json`, function records
|
||||
`0x0000f0a0`, `0x0000f300`, and `0x000103d0`, and corresponding data-symbol
|
||||
records).
|
||||
|
||||
| Routine | Entry RVA / preferred VA | String RVA | Instruction evidence |
|
||||
| --- | --- | --- | --- |
|
||||
| `NuiThread::updateFrame` | `0x0000f0a0` / `0x1000f0a0` | `0x002a48a0` | VA `0x1000f0db` loads `0x102a48a0` |
|
||||
| `NuiThread::updateSkeleton` | `0x0000f300` / `0x1000f300` | `0x002a48b8` | VA `0x1000f33b` loads `0x102a48b8` |
|
||||
| `hid::Natal::copySkeleton` | `0x000103d0` / `0x100103d0` | `0x002a4918` | VA `0x10010421` loads `0x102a4918` |
|
||||
|
||||
The instruction evidence is preserved in
|
||||
`/home/athapa/kinect/.re/gamekdm.asm:18351-18371,18555-18575,19865-19892`.
|
||||
The database records `FUN_1000ebd0 -> FUN_1000ef50`, with the latter calling
|
||||
the frame, skeleton, stream (`0x0000f400`), and elevation (`0x0000f510`)
|
||||
routines (`re/rvadb.json`, function records at RVAs `0x0000ebd0` and
|
||||
`0x0000ef50`).
|
||||
|
||||
### Event dispatch and skeleton acquisition
|
||||
|
||||
The dispatcher at RVA `0x0000ef50` checks the sensor pointer at
|
||||
`thread+0x15fc`, then calls `WaitForMultipleObjects` with five handles
|
||||
starting at `thread+0x50`, wait-all false, and timeout `0x7530` (30,000 ms).
|
||||
An absent sensor writes state value 3; an out-of-range wait result writes
|
||||
state value 6. These are numeric states, without inferred enum names
|
||||
(VAs `0x1000ef61-0x1000ef99`, `0x1000f07f`;
|
||||
`re/rvadb.json`, RVA `0x0000ef50`, `external_callees`;
|
||||
`/home/athapa/kinect/.re/gamekdm.asm:18232-18266,18323-18328`).
|
||||
|
||||
Wait result 3 tests bit 0 of `thread+0x2c`: when enabled, it calls
|
||||
`updateSkeleton` and then `updateFrame`; otherwise it resets the event at
|
||||
`thread+0x5c` and still calls `updateFrame`.
|
||||
Results 1 and 2 call the stream routine with index `result-1` before
|
||||
`updateFrame`. Result 4 also calls `updateFrame`. Thus publication is
|
||||
event-driven, and these branches do not establish a fixed refresh rate
|
||||
(VAs `0x1000ef9f-0x1000f02c`;
|
||||
`/home/athapa/kinect/.re/gamekdm.asm:18266-18318`).
|
||||
|
||||
`updateSkeleton` passes zero wait time and destination `thread+0x68` to
|
||||
sensor vtable offset `0x4c`, matching `INuiSensor::NuiSkeletonGetNextFrame`.
|
||||
On a nonnegative return it writes state 7; if `thread+0x15f8` is set, it
|
||||
calls vtable offset `0x48` with the tracking-ID array at `thread+0x15f0`,
|
||||
matching `NuiSkeletonSetTrackedSkeletons`.
|
||||
Returns `0x80070015` and `0x8007048f` write state 4; the shown code does
|
||||
not give every failed read that state
|
||||
(VAs `0x1000f36b-0x1000f3b8`;
|
||||
`/home/athapa/kinect/.re/gamekdm.asm:18585-18612`;
|
||||
`/home/athapa/kinect/fallback/windows-nui/include/nui_interfaces.h:41-103`).
|
||||
|
||||
### Frame publication and consumer copy
|
||||
|
||||
`updateFrame` copies `0x29a` DWORDs, or `0xa68` bytes, from `thread+0x68`
|
||||
to `thread+0xb30`. This matches the declared NUI skeleton-frame size:
|
||||
48 bytes of frame metadata plus six 436-byte skeleton records.
|
||||
The metadata includes timestamp, frame number, flags, floor plane, and
|
||||
gravity; each skeleton includes identity, position, 20 joint vectors,
|
||||
20 joint states, and quality flags
|
||||
(VAs `0x1000f11b-0x1000f129`;
|
||||
`/home/athapa/kinect/fallback/windows-nui/include/nui_abi.h:26-36,145-165`).
|
||||
|
||||
Publication brackets the copy with conditional calls through imports at
|
||||
VAs `0x10218414` and `0x10218418`, and increments/decrements `thread+0x4c`.
|
||||
The database identifies those imports as AVS ordinals 17 and 18; their
|
||||
precise synchronization contract is **UNVERIFIED** here.
|
||||
After processing two image-frame slots, it signals the event at
|
||||
`thread+0x64`. The image-slot loop releases a previous frame through
|
||||
sensor vtable offset `0x28` before copying the next frame descriptor
|
||||
(VAs `0x1000f107-0x1000f1c9`;
|
||||
`re/rvadb.json`, RVA `0x0000f0a0`, `external_callees`;
|
||||
`/home/athapa/kinect/fallback/windows-nui/include/nui_interfaces.h:58-62`).
|
||||
|
||||
The consumer-side `FUN_1000fa20` calls `copySkeleton` at RVA `0x000103d0`;
|
||||
its database record also references the manager-pointer global at RVA
|
||||
`0x003cf1b4`. The notes identify the live manager as
|
||||
`*(gamekdm+0x3cf1b4)` (`re/rvadb.json`, RVA `0x0000fa20`,
|
||||
`callees` and `globals_touched`; `game-internals.md` section 1, lines 23-24).
|
||||
|
||||
`copySkeleton` has both coordinate-copy and coordinate-transform branches:
|
||||
it tests bit 1 of its object's `+0x08` flags, loads joint vectors, and
|
||||
either performs floating-point products/sums or copies coordinates directly.
|
||||
It also checks skeleton tracking state against 2 and writes zero joint
|
||||
state when that check fails. This is processing of supplied joint data;
|
||||
section 1's statement that the game receives the skeleton directly should
|
||||
not be interpreted as a promise of a raw `memcpy` throughout the pipeline
|
||||
(VAs `0x10010439-0x10010446`, `0x100105e2-0x10010605`,
|
||||
`0x10010893-0x100108b9`;
|
||||
`/home/athapa/kinect/.re/gamekdm.asm:19895-19904,20000-20022,20167-20183`;
|
||||
`game-internals.md:17-20`).
|
||||
|
||||
The full semantics of that optional transform and the intervening manager
|
||||
buffer ownership are **UNVERIFIED** here. At the reconstructed validity
|
||||
boundary, `UpdateValidityCandidates` explicitly reads
|
||||
`manager.skeleton_frame.skeletons[index]`
|
||||
(`src/game/validity.cpp:23-27`).
|
||||
|
||||
## Camera elevation reconstruction
|
||||
|
||||
`UpdateCameraElevation` reconstructs VA `0x1000f510` / RVA `0x0000f510`.
|
||||
The header associates its logical fields with original object offsets;
|
||||
these comments do not make the compact reconstructed struct a byte-for-byte
|
||||
original object layout (`src/game/nui_elevation.h:19-34`).
|
||||
|
||||
| Logical field | Original offset | Meaning in reconstruction |
|
||||
| --- | --- | --- |
|
||||
| `desired_angle` | `+0x38` | Requested setting |
|
||||
| `applied_angle` | `+0x3c` | Last setting issued |
|
||||
| `smoothed_angle` | `+0x40` | Published estimate |
|
||||
| `accumulator` | `+0x44` | IIR state, sentinel `-0x168` |
|
||||
| `sensor` | `+0x15fc` | Sensor control interface |
|
||||
|
||||
Field evidence is `src/game/nui_elevation.h:23-31`.
|
||||
The two-method `ICameraElevation` is a reconstruction interface; the header
|
||||
records original sensor dispatch offsets `0x3c` for Get and `0x38` for Set.
|
||||
It does not claim the two-method interface duplicates the complete original
|
||||
sensor vtable (`src/game/nui_elevation.h:7-16`).
|
||||
|
||||
On successful `GetAngle` (`status >= 0`), the routine seeds a sentinel
|
||||
accumulator from the reading, then computes
|
||||
`averaged = (current + 2 * accumulator) / 3`, publishing and retaining it.
|
||||
The source ties signed truncation toward zero to instructions at VA
|
||||
`0x1000f53c`; the sentinel comparison is at VA `0x1000f527`
|
||||
(`src/game/nui_elevation.cpp:7-18`; `src/game/nui_elevation.h:30-31`).
|
||||
|
||||
When desired and applied values differ, it calls `SetAngle` and updates
|
||||
`applied_angle` without checking that call's result. This branch is outside
|
||||
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 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
|
||||
(`/home/athapa/kinect/core/mapping/mapping.cpp:9`;
|
||||
`game-internals.md:69-71`).
|
||||
|
||||
For pixel coordinates `(u,v)`, image dimensions `(W,H)`, and packed depth
|
||||
`d`, the implementation computes the following before clamping
|
||||
(`/home/athapa/kinect/core/mapping/mapping.cpp:142-157`):
|
||||
|
||||
```text
|
||||
s = 3.501e-3
|
||||
z = (d >> 3) / 1000
|
||||
x = (u - W/2) * (320/W) * s * z
|
||||
y = -(v - H/2) * (240/H) * s * z
|
||||
w = 1
|
||||
```
|
||||
|
||||
The low three bits encode player index; the shift removes them.
|
||||
The shim declares joint coordinates in metres and a player-index shift of 3
|
||||
(`/home/athapa/kinect/fallback/windows-nui/include/nui_abi.h:26-40`).
|
||||
The mapping clamps x to `[-2.2,2.2]`, y to `[-1.6,1.6]`, and z to `[0,4]`
|
||||
(`/home/athapa/kinect/core/mapping/mapping.cpp:9-15,100-106`).
|
||||
Its inverse divides by the same scale and a guarded depth, and rounds
|
||||
back to pixel/depth integers
|
||||
(`/home/athapa/kinect/core/mapping/mapping.cpp:159-180`).
|
||||
|
||||
The golden harness documents five depth-projection fixtures derived from
|
||||
this mapping and round-trip inputs; their expected coordinates are computed,
|
||||
not independent raw Kinect measurements
|
||||
(`tests/golden/README.md:20-23`; `tests/golden/gen_fixtures.py:7-18`).
|
||||
For example, evaluating the fixture generator's formula at 640x480 gives
|
||||
`(0,0,2.5)` for `(320,240,20000)` and
|
||||
`(-0.448128,0.336096,0.8)` for `(0,0,6400)`
|
||||
(`tests/golden/gen_fixtures.py:51-67`).
|
||||
|
||||
## From skeleton frame to validity
|
||||
|
||||
The shim initializes all six slots as untracked and fills slot 0 when it has
|
||||
a player. Slot 0 receives the source tracking ID and hip-center position;
|
||||
its skeleton and all copied joints are marked tracked
|
||||
(`/home/athapa/kinect/fallback/windows-nui/src/sensor.cpp:895-943`;
|
||||
`/home/athapa/kinect/fallback/windows-nui/include/nui_abi.h:34-36`).
|
||||
It supplies `vNormalToGravity = (0,1,0,0)` and
|
||||
`vFloorClipPlane = (0,1,0,1-hip.y)`
|
||||
(`/home/athapa/kinect/fallback/windows-nui/src/sensor.cpp:888-893`).
|
||||
|
||||
The RE notes identify VA `0x10018570` / RVA `0x00018570` as the transform
|
||||
builder. With sentinel gravity at `manager+0x2c`, it derives orientation from
|
||||
tracked joints: weighted tracked coverage must exceed `0.85`, then five
|
||||
limb-direction dot products must exceed `0.9`. The provided up-gravity vector
|
||||
takes the simpler gravity branch (`game-internals.md:31-36`).
|
||||
These thresholds are cited from prior RE; that transform builder was not
|
||||
re-decompiled for this document.
|
||||
|
||||
The candidate consumer is VA `0x100e4140` / RVA `0x000e4140`, calling the
|
||||
box-distance helper at VA `0x101ab6d0` / RVA `0x001ab6d0`
|
||||
(`re/rvadb.json`, function records at those RVAs;
|
||||
`src/game/validity.h:17-22`).
|
||||
The reconstructed consumer reads each skeleton's tracking ID, clears validity
|
||||
when identity changes, and chooses a tracked position or a missing-position
|
||||
sentinel (`src/game/validity.cpp:26-43`).
|
||||
It compares squared distance with squared tolerance, using separate entry
|
||||
and retained tolerances; missing positions are invalid
|
||||
(`src/game/validity.cpp:44-61`; `src/game/validity.h:11-14`).
|
||||
|
||||
The distance helper clamps a point against center-plus/minus-extent bounds
|
||||
and sums squared residuals. Despite the struct field names `minimum` and
|
||||
`maximum`, their roles here are center and extent
|
||||
(`src/game/box_distance.cpp:6-28`).
|
||||
The documented captured gate uses center `A=(0,1,0)`, extent
|
||||
`B=(1.22,1,0.675)`, and distance tolerance `0.05`; the tolerance is Euclidean
|
||||
distance to the box, not three independent axis margins
|
||||
(`game-internals.md:37-42`; `src/game/box_distance.cpp:14-28`).
|
||||
|
||||
For the documented level-gravity configuration, the notes reduce the first
|
||||
transform to `P1=(-px, py+m13, -pz+m14)`, with `m14=2.5` and `m13` taken from
|
||||
the floor plane's w component. This is a recorded configuration, not the
|
||||
general matrix formula implemented by the consumer
|
||||
(`game-internals.md:37-42`; `src/game/validity.cpp:8-17`).
|
||||
Setting the floor offset to `1-hip.y` makes `P1.y=1`; a hip depth of `2.5`
|
||||
makes `P1.z=0`. X bounds and depth placement still matter
|
||||
(`game-internals.md:43-46`; `tests/golden/gen_fixtures.py:24-30`).
|
||||
|
||||
For an accepted candidate, the reconstruction stores the original source
|
||||
position and deliberately applies the matrix a second time for the stored
|
||||
transformed position (`src/game/validity.cpp:54-57`).
|
||||
The selection notes link passing the orientation/validity gate with visible
|
||||
skeleton rendering (`game-internals.md:28-29,43-46`).
|
||||
|
||||
## Handedness, cursor reach, and limits
|
||||
|
||||
The shim swaps left/right joint indices with
|
||||
`{0,1,2,3,8,9,10,11,4,5,6,7,16,17,18,19,12,13,14,15}`,
|
||||
then applies calibrated arm amplification
|
||||
(`/home/athapa/kinect/fallback/windows-nui/src/sensor.cpp:934-946`).
|
||||
The notes attribute these corrections to mirrored tracker input and compressed
|
||||
arm reach, and say the hip/center-of-mass stays unchanged
|
||||
(`game-internals.md:69-85`).
|
||||
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
|
||||
(`/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
|
||||
[the validity and cursor section](./04-validity-cursor.md)
|
||||
(`game-internals.md:60-66`).
|
||||
|
||||
Six ABI skeleton slots do not establish six tracked players: the shim
|
||||
declares at most two tracked skeletons, and the documented tracker is
|
||||
single-person. The optional second-slot probe duplicates a pose rather than
|
||||
tracking a second person (`/home/athapa/kinect/fallback/windows-nui/include/nui_abi.h:34-36`;
|
||||
`game-internals.md:89-113`).
|
||||
|
||||
## Verification and remaining unknowns
|
||||
|
||||
The reproducible replay command is
|
||||
`source ~/.nix-profile/etc/profile.d/nix.sh && source ./activate.sh && python3 tests/golden/golden_harness.py`.
|
||||
It checks projection, validity, and a recorded hip midpoint against committed
|
||||
fixtures. Projection expectations are derived from reconstruction math;
|
||||
passing them does not independently establish fidelity to physical Kinect
|
||||
hardware (`tests/golden/golden_harness.py:1-23`;
|
||||
`tests/golden/gen_fixtures.py:7-18`; `tests/golden/README.md:20-24`).
|
||||
|
||||
The named routine mappings can be checked without decompilation: inspect
|
||||
the function and data-symbol records listed above in `re/rvadb.json`, then
|
||||
disassemble the three string-load addresses with `objdump -d` against
|
||||
`/mnt/f/Users/Aaron Thapa/Downloads/KDM-2016021900/contents/gamekdm.dll`.
|
||||
The flat import block is separately inspectable with `objdump -p` against
|
||||
that same absolute game-binary path.
|
||||
|
||||
**UNVERIFIED:** complete synchronization and ownership rules, fixed update
|
||||
frequency, the optional copy transform's full semantics, a later
|
||||
depth-resolution change, and whether gamekdm calls
|
||||
`NuiSkeletonCalculateBoneOrientations`.
|
||||
The evidence above establishes specific branches and data transfers,
|
||||
a captured stream size, or an available export rather than those stronger
|
||||
claims (VAs `0x1000ef50`, `0x1000f0a0`, `0x100103d0`;
|
||||
`/home/athapa/kinect/.re/shim_log_init.txt:7`;
|
||||
`re/importlibs/Kinect10.def:32`).
|
||||
@@ -0,0 +1,311 @@
|
||||
# 04 - Player Validity Gate and Menu Hand Cursor
|
||||
|
||||
This section covers the two gates `gamekdm.dll` applies to whatever skeleton
|
||||
the NUI stack hands it: the **validity/selection gate** that decides whether a
|
||||
tracked body is allowed to render and drive gameplay, and the separate
|
||||
**Flash/`afp` hand cursor** that drives menu navigation. The two are unrelated
|
||||
code paths with unrelated math, and the reconstruction treats them as such
|
||||
(`src/game/validity.{h,cpp}`, `src/game/box_distance.cpp`). All RVAs are
|
||||
against image base `0x10000000` (confirmed by `re/rvadb.json`
|
||||
`image_base = "0x10000000"`, [00-overview.md](./00-overview.md)). Background
|
||||
on how both gates were discovered — in-process live-memory introspection
|
||||
against the running game, reimplemented in Python from a dump rather than
|
||||
guessed — is in [game-internals.md](../../game-internals.md) §5.
|
||||
|
||||
## 1. The three functions
|
||||
|
||||
| Function | RVA | Role |
|
||||
|---|---|---|
|
||||
| `FUN_10018570` | `0x10018570` | Builds the gravity/floor-relative transform `M` used to project a candidate skeleton's hip position into validity-box space. |
|
||||
| `FUN_100e4140` | `0x100e4140` | Per-skeleton-slot driver: for each of the 6 NUI skeleton slots, transforms the candidate position and calls the box-distance metric to decide `valid`/`not valid`. |
|
||||
| `FUN_101ab6d0` | `0x101ab6d0` | The box-distance metric itself: squared distance from a point to an axis-aligned box, after clamping to the box's extent. |
|
||||
|
||||
`FUN_100e4140` and `FUN_101ab6d0` are both named explicitly in the task's
|
||||
scope, and both are confirmed live: `metric.out` (Ghidra `dump_metric.py`
|
||||
output against the once-analyzed `gkproj` project) decompiles `FUN_101ab6d0`
|
||||
at `101ab6d0`, and `filter.out` (`dump_filter.py`) decompiles `FUN_100e4140`
|
||||
at `100e4140` and shows it calling `FUN_101ab6d0` directly
|
||||
(`ghidra/filter.out:291`: `fVar9 = (float10)FUN_101ab6d0();`). `FUN_10018570`
|
||||
is documented in [game-internals.md](../../game-internals.md) §2 and
|
||||
§6 (`game-internals.md:31,141`) but was not re-dumped for this section; its
|
||||
listing there is taken as given per the task's reading list.
|
||||
|
||||
## 2. `FUN_101ab6d0` — box-distance metric
|
||||
|
||||
The raw decompile (`ghidra/metric.out:195-206`):
|
||||
|
||||
```c
|
||||
float10 FUN_101ab6d0(void)
|
||||
{
|
||||
float *pfVar1;
|
||||
float *unaff_EDI;
|
||||
|
||||
FUN_101ab640();
|
||||
pfVar1 = (float *)FUN_101ab5b0();
|
||||
return (float10)((unaff_EDI[2] - pfVar1[2]) * (unaff_EDI[2] - pfVar1[2]) +
|
||||
(*unaff_EDI - *pfVar1) * (*unaff_EDI - *pfVar1) +
|
||||
(unaff_EDI[1] - pfVar1[1]) * (unaff_EDI[1] - pfVar1[1]));
|
||||
}
|
||||
```
|
||||
|
||||
`EDI` (`unaff_EDI`) carries the transformed point, and the return value of
|
||||
`FUN_101ab5b0` carries a clamped point (`ghidra/metric.out:201-202`). The
|
||||
Ghidra decompiler surfaces `FUN_101ab6d0` as having no visible parameters
|
||||
because the x86 cdecl register/stack args were optimized into caller-set
|
||||
`EAX`/`EDI`, matching the header comment in the reconstruction
|
||||
(`src/game/validity.h:17`: `// original inputs EAX=box, EDI=point`). The two
|
||||
helpers it calls are per-axis `min`/`max`:
|
||||
|
||||
- `FUN_101ab640` (`ghidra/metric.out:212-240`) is a 3-wide **max** (NaN-aware,
|
||||
per-axis `if (a < b != (NAN(a)||NAN(b))) a = b;`).
|
||||
- `FUN_101ab5b0` (`ghidra/metric.out:246-...`) is a 3-wide **min**
|
||||
(`if (*param_2 < fVar1) fVar1 = *param_2;`).
|
||||
|
||||
Together these clamp the point into `[center-extent, center+extent]` per axis
|
||||
before squaring the per-axis delta and summing — a standard point-to-AABB
|
||||
squared-distance routine, just with Ghidra's register allocation obscuring
|
||||
which operand is "box" and which is "point" at the call site. The
|
||||
reconstruction (`src/game/box_distance.cpp:6-26`) makes this explicit and
|
||||
documents the surprising field-naming inversion it found during RE:
|
||||
|
||||
```cpp
|
||||
// T7's field names are misleading: the instructions use center +/- extent,
|
||||
// not minimum/maximum corners. Preserve its verified binary layout.
|
||||
const float center[] = {box.minimum.x, box.minimum.y, box.minimum.z};
|
||||
const float extent[] = {box.maximum.x, box.maximum.y, box.maximum.z};
|
||||
```
|
||||
|
||||
i.e. the struct fields named `minimum`/`maximum` in `ValidityState::box`
|
||||
(`src/game/validity.h:10`, `ValidityBox box; // DAT_103d3230`) actually hold
|
||||
center and half-extent, not corners — `BoxDistanceSquared` reconstructs the
|
||||
corners (`lower = center - extent`, `upper = center + extent`) on every call
|
||||
rather than storing them pre-computed, matching the original's live
|
||||
clamp-then-subtract sequence. The `volatile` qualifiers on `lower`/`upper`/
|
||||
`difference` in `box_distance.cpp:15-20` mark DWORD spill points the original
|
||||
x87/SSE code forced through memory — kept to pin FP rounding behavior exactly,
|
||||
not for correctness of the algorithm.
|
||||
|
||||
## 3. `FUN_100e4140` — the per-slot validity filter
|
||||
|
||||
`ghidra/filter.out:193-306` is the full decompile. The function walks the 6
|
||||
NUI skeleton slots (`do { ... uVar5 = uVar5 + 1; ... } while (uVar5 < 6);`,
|
||||
`filter.out:296-301`), and per slot:
|
||||
|
||||
1. Takes `DAT_103d4a80` as the 4x4 transform `M` (`filter.out:236`:
|
||||
`pfVar6 = (float *)&DAT_103d4a80;` copied into 16 locals — this is the
|
||||
transform `FUN_10018570` builds, per `src/game/validity.h:9`: `Matrix4x4
|
||||
transform; // DAT_103d4a80`).
|
||||
2. Picks the source position: either the slot's own tracked position, or
|
||||
`DAT_103d32c4` (the "missing" sentinel position) if the slot is not
|
||||
tracked (`filter.out:247-256`, `src/game/validity.h:11`: `Vec3
|
||||
missing_position; // DAT_103d32c4`).
|
||||
3. Transforms that position through `M` with no perspective divide
|
||||
(`filter.out:257-260`: three dot-products against `M`'s rows plus
|
||||
translation — this is `TransformPosition` in `src/game/validity.cpp:8-18`).
|
||||
4. If the source position differs from the sentinel (the tracking-state
|
||||
check), computes `BoxDistanceSquared` against the box and compares it to a
|
||||
**squared tolerance**: `DAT_10299294` if the slot was not already valid,
|
||||
`DAT_10299298` if it was (hysteresis — `filter.out:282,284`: `local_80 =
|
||||
DAT_10299294; if (*pcVar7 != '\0') { local_80 = DAT_10299298; }`). These
|
||||
map directly to `src/game/validity.h:12-13`: `float entry_tolerance; //
|
||||
DAT_10299294` / `float retained_tolerance; // DAT_10299298`.
|
||||
5. On a pass, re-applies `M` a **second time** to the already-transformed
|
||||
point and stores that as the "transformed" candidate position
|
||||
(`filter.out:297-302`; `src/game/validity.cpp:56-57`: "The original
|
||||
deliberately applies the matrix a second time"). This double-apply is
|
||||
preserved deliberately in the reconstruction rather than treated as a bug,
|
||||
because the original binary clearly re-invokes the same transform rather
|
||||
than caching the first result.
|
||||
|
||||
The reconstruction's `UpdateValidityCandidates` (`src/game/validity.cpp:23-63`)
|
||||
mirrors this slot loop 1:1, including the integer-vs-float tracking-ID
|
||||
reinterpretation the original performs (`validity.cpp:33-36`, matching the
|
||||
T7-style struct where a tracking ID is stored in a field declared `float` but
|
||||
read/written as raw `uint32_t` bits) and the "entry" vs "retained" tolerance
|
||||
split (`validity.cpp:48-49`).
|
||||
|
||||
## 4. The validity box and tolerance
|
||||
|
||||
Per [game-internals.md](../../game-internals.md) §2 and §6
|
||||
(`game-internals.md:38-42,142`), the box global `DAT_103d3230` holds:
|
||||
|
||||
- `A = (0, 1, 0)` — box center.
|
||||
- `B = (1.22, 1, 0.675)` — half-extent, giving bounds
|
||||
`x ∈ [-1.22, 1.22]`, `y ∈ [0, 2]`, `z ∈ [-0.675, 0.675]` in the
|
||||
transform's output space.
|
||||
|
||||
The candidate point fed into the check is
|
||||
`P1 = (-px, py + m13, -pz + m14)` with **no perspective divide**, where
|
||||
`m14 = 2.5` (a constant inside the transform matrix, chosen in the shim to
|
||||
match the published `z0`) and `m13` is taken straight from the skeleton
|
||||
frame's `vFloorClipPlane.w` (`game-internals.md:38-41`). The tolerance is
|
||||
`0.05` (compared as `tolerance²` against `BoxDistanceSquared`'s output, per
|
||||
§3 above and `validity.cpp:50-53`) — this is one `entry_tolerance`/
|
||||
`retained_tolerance` pair (`DAT_10299294`/`DAT_10299298`), and
|
||||
`game-internals.md` records the combined entry behavior as "within 0.05 of
|
||||
the box" without the sourced values distinguishing the two constants at the
|
||||
byte level; the reconstruction keeps them as two distinct fields
|
||||
(`validity.h:12-13`) so a divergence between entry and retained tolerance, if
|
||||
one exists in the binary, is representable without re-deriving the whole
|
||||
struct.
|
||||
|
||||
**Floor-clip rule.** Because `P1.y = py + m13` and the box is centered at
|
||||
`y = 1` with half-extent `1` (so `y ∈ [0, 2]` is a very loose band but `z` and
|
||||
`x` are tight), the floor-clip term `m13 = vFloorClipPlane.w` is what anchors
|
||||
a player's vertical position into the box regardless of absolute camera
|
||||
height. The shim's fix sets `vFloorClipPlane = {0, 1, 0, 1.0 - hip.y}` every
|
||||
frame, which forces `P1.y = hip.y + (1.0 - hip.y) = 1.0` — the exact box
|
||||
center on the y-axis — so the gate's y-component is unconditionally satisfied
|
||||
every frame regardless of where the hip tracks (`game-internals.md:43-46`,
|
||||
commit `36035cc`, `sensor.cpp BuildSkeletonFrame`). This, combined with
|
||||
`vNormalToGravity = (0,1,0,0)` steering `FUN_10018570` onto its simpler
|
||||
"gravity sentinel" branch instead of deriving gravity from tracked-joint
|
||||
geometry (`game-internals.md:31-36`), is the entire mechanism by which the
|
||||
shim's synthetic skeleton reliably clears the validity gate.
|
||||
|
||||
## 5. The afp/Flash PhIZ menu hand cursor
|
||||
|
||||
The menu cursor is architecturally separate from the validity gate above: it
|
||||
is not computed by `gamekdm.dll` native code at all. Per
|
||||
[game-internals.md](../../game-internals.md) §3:
|
||||
|
||||
- `afp` is the Flash/ActionScript runtime (`libafp-win32.dll`, exporting
|
||||
`flash.display.InteractiveObject`, `flash.ui.MouseCursor`, `useHandCursor`
|
||||
— `game-internals.md:52-53`). Menu UI, including the cursor sprite, is
|
||||
compiled Flash packed into `.ifs` archives under
|
||||
`GAME-DIR/data/bm2d/*.ifs` (`game-internals.md:55`).
|
||||
- The live cursor-controller object pointer is the global `DAT_103d2bb8`
|
||||
(`game-internals.md:57`, `game-internals.md:139`). The reconstruction's
|
||||
scope list names this the `cursor controller global`.
|
||||
- 1P cursor coordinates live at `(*DAT_103d2bb8)+0x108` / `+0x10c`; 2P at
|
||||
`+0x110` / `+0x114`, in screen pixels (1280x720)
|
||||
(`game-internals.md:57-58`). This is independently confirmed by the
|
||||
decompile of the cursor-hit-test function: `ghidra/cursor.out:222-224`
|
||||
writes `*(float*)(iVar1+0x108)` / `+0x10c` for the 1P branch
|
||||
(`param_1 == 0`), and `ghidra/cursor.out:315-317` writes
|
||||
`*(float*)(iVar1+0x110)` / `+0x114` for the 2P branch (the trailing `else`
|
||||
of the same function, gated on `*(int*)(iVar1+0x30)` and
|
||||
`*(int*)(iVar1+0x44)` both being non-zero).
|
||||
- That function is `FUN_1007fbf0` (`ghidra/cursor.out:193-320`, confirmed by
|
||||
the `==== FUN_1007fbf0 @ 1007fbf0 ====` header in the dump). It reads the
|
||||
live cursor position via `FUN_101d84c0`, called in pairs
|
||||
(`ghidra/cursor.out:217-218`: `FUN_101d84c0(&local_4,&local_c);
|
||||
FUN_101d84c0(¶m_1,&local_8);`) — one call for the cursor, one for a
|
||||
button's reference position — and snaps to an OK button when the squared
|
||||
distance is under the threshold. For the 1P/2P "not yet near a button"
|
||||
branches the comparison is `0x1fa3 < dist_sq` (reject above `0x1fa3` =
|
||||
8099, i.e. accept at `dist_sq <= 8099`,
|
||||
`ghidra/cursor.out:219-221,283-285,312-314`); for the "already locked to a
|
||||
specific OK button" branches it is `dist_sq < 0x1fa4` (accept strictly
|
||||
below `0x1fa4` = 8100, `ghidra/cursor.out:236-238,251-253,269-270`). Both
|
||||
thresholds bracket the same value — `game-internals.md:59-60` rounds this
|
||||
to "`dist² < 0x1fa4` (~90 UI units)", consistent with `sqrt(8100) = 90`
|
||||
exactly.
|
||||
- `FUN_101d71e0("_but_ok_1p_usr")` / `"_but_ok_2p_usr"`
|
||||
(`ghidra/cursor.out:266,280`) resolve the OK-button objects by name before
|
||||
`FUN_101d78e0` reads their position and `FUN_101d84c0` compares again
|
||||
(`ghidra/cursor.out:264-290`) — these are the OK-button icons, not the
|
||||
cursor itself, matching `game-internals.md:61`'s note that `_icon_1p/2p/
|
||||
only_usr` strings are button icons.
|
||||
- **No gamekdm code writes the cursor position from a hand joint.**
|
||||
`game-internals.md:63-64` states this was checked by searching for any
|
||||
`afp_mc_set_param` call with the `0x1008` parameter ID across 53
|
||||
decompiled menu ActionScript scripts, finding none. `FUN_1007fbf0` and
|
||||
`FUN_101d84c0` only *read* the cursor (`afp_mc_get_param(ctrl+8, 0x1008)`
|
||||
per `game-internals.md:59`); they never set it. The hand -> cursor mapping
|
||||
(the "PhIZ", body-relative and reach-normalized) is internal to the
|
||||
Flash/Natal runtime inside `libafp-win32.dll`, which gamekdm does not
|
||||
control (`game-internals.md:65-66`). This is why the fix for cursor
|
||||
behavior lives entirely on the shim side (skeleton joint positions handed
|
||||
to the NUI layer), not in any gamekdm patch.
|
||||
|
||||
### Shim-side cursor fixes
|
||||
|
||||
Because the mapping from hand position to cursor position cannot be patched
|
||||
in `gamekdm.dll` or `libafp-win32.dll`, the only lever is the skeleton data
|
||||
the shim publishes (`game-internals.md:67`, all changes land in
|
||||
`sensor.cpp BuildSkeletonFrame`):
|
||||
|
||||
1. **Handedness.** The tracker mirrors the camera (selfie view, matching a
|
||||
real Kinect's mirrored depth image), which swaps MediaPipe's left/right
|
||||
joint labels; the shim swaps them back via a `kSwap[]` table so the
|
||||
player's right hand lands in `HAND_RIGHT` with the sign convention real
|
||||
Kinect recordings show (`game-internals.md:69-77`).
|
||||
2. **Reach compression.** MediaPipe reports the hand roughly 1.6x (x) / 1.3x
|
||||
(y) closer to the shoulder than a real Kinect does, measured against
|
||||
UTKinect/MSR-Action3D reference recordings; the shim amplifies each arm
|
||||
outward from its shoulder by `kArmGainX`/`kArmGainY` (tuned to 3.2/2.6)
|
||||
without touching the hip/center-of-mass, so the validity box (§4 above)
|
||||
stays centered while the cursor gets full screen coverage
|
||||
(`game-internals.md:78-85`).
|
||||
|
||||
## 6. Two-player handling
|
||||
|
||||
Both gates are structurally two-player-capable in the shipped binary, but the
|
||||
emulator side is single-person end to end:
|
||||
|
||||
- **Validity gate:** `FUN_100e4140`'s slot loop iterates all 6 NUI skeleton
|
||||
slots unconditionally (§3 above, `filter.out:296-301`), so a second tracked
|
||||
skeleton in slot 1 is evaluated by the exact same box/tolerance logic as
|
||||
slot 0 — there is no special-cased "player 2" branch in the validity math
|
||||
itself; slot index is the only distinguishing input.
|
||||
- **Cursor:** `FUN_1007fbf0`'s `param_1 == 0` vs `param_1 != 0` /
|
||||
`*(int*)(iVar1+0x30)`/`+0x44` branches (`ghidra/cursor.out:215,226,309`)
|
||||
are the 1P/2P split, writing to the independent `+0x108/+0x10c` (1P) and
|
||||
`+0x110/+0x114` (2P) cursor fields identified in §5. `game-internals.md:89`
|
||||
also cites `NuiSkeletonSetTrackedSkeletons([id0, id1])` and NUI's 6-slot
|
||||
skeleton array as evidence the game expects real dual tracking.
|
||||
- **Emulator limitation:** the contract carries a single `SkeletonFrame`, and
|
||||
the shim only fills `SkeletonData[0]`; the tracker itself runs
|
||||
single-person BlazePose (`game-internals.md:91-93`). The reproducible
|
||||
evidence for this is `tracker-native/build/two_person_probe`, which
|
||||
composes a 24-frame two-person synthetic sequence from the committed
|
||||
`testdata/sample_rgb.bin` and drives the shipping `PoseEstimator::acquire`/
|
||||
`run` selection policy; the 2026-11-27 run it records tracked exactly one
|
||||
skeleton in all 24 frames, with the selected region-of-interest switching
|
||||
identity twice (frame 14, frame 22) rather than tracking two people at once
|
||||
(`game-internals.md:93-99`).
|
||||
- **Experimental `CUR2` probe.** Setting `KINECT_SHIM_2P=1` makes
|
||||
`BuildSkeletonFrame` copy slot 0 into `SkeletonData[1]`, horizontally
|
||||
offset, with a distinct tracking ID, purely to exercise whether DEA lights
|
||||
its `CUR2` UI state — explicitly not a real second-player claim, since both
|
||||
slots share the same pose and depth mask. The gating logic lives in one
|
||||
shared `PopulateSecondSkeletonFromEnv` function called by both the
|
||||
production path and a `two_person_shim_probe` unit test, which asserts the
|
||||
real environment-variable gate (unset/`0`/empty/`2` -> off, `1` -> on, the
|
||||
on-to-off transition, and that slot 0's bytes are unchanged) rather than a
|
||||
re-implementation of it (`game-internals.md:100-112`). Real two-player
|
||||
support would need a multi-person pose stage and a two-skeleton tracker
|
||||
contract, neither of which exists yet.
|
||||
|
||||
## 7. Reconstruction mapping
|
||||
|
||||
| Original | Reconstruction |
|
||||
|---|---|
|
||||
| `FUN_101ab6d0` (`0x101ab6d0`) | `gk::game::BoxDistanceSquared` (`src/game/box_distance.cpp:6`) |
|
||||
| `FUN_100e4140` (`0x100e4140`) | `gk::game::UpdateValidityCandidates` (`src/game/validity.cpp:23`) |
|
||||
| `FUN_10018570` (`0x10018570`) | not yet reconstructed into `src/game/validity.*`; `ValidityState::transform` (`validity.h:9`) is the slot it will populate. |
|
||||
| `DAT_103d3230` | `ValidityState::box` (`validity.h:10`) |
|
||||
| `DAT_103d4a80` | `ValidityState::transform` (`validity.h:9`) |
|
||||
| `DAT_103d32c4` | `ValidityState::missing_position` (`validity.h:11`) |
|
||||
| `DAT_10299294` | `ValidityState::entry_tolerance` (`validity.h:12`) |
|
||||
| `DAT_10299298` | `ValidityState::retained_tolerance` (`validity.h:13`) |
|
||||
| `DAT_103e29b0` | `ValidityState::candidates[kSkeletonCount]` (`validity.h:14`) |
|
||||
|
||||
No reconstruction currently exists for `FUN_1007fbf0`/`FUN_101d84c0`/
|
||||
`DAT_103d2bb8` (the cursor path): §5 documents the live mechanism from the
|
||||
decompile and `game-internals.md`, but the fix for cursor behavior is
|
||||
entirely shim-side (§5, "Shim-side cursor fixes"), so no gamekdm cursor code
|
||||
needs reimplementing for the emulator to work correctly.
|
||||
|
||||
## See also
|
||||
|
||||
- [00-overview.md](./00-overview.md) — module stack and image base.
|
||||
- [08-abi-conventions.md](./08-abi-conventions.md) — calling-convention and
|
||||
struct-layout conventions referenced by `src/game/validity.h`'s `GK_CDECL`
|
||||
annotations.
|
||||
- [09-reconstruction-codebase.md](./09-reconstruction-codebase.md) — how
|
||||
`src/game/*` fits into the overall reconstruction build.
|
||||
- [game-internals.md](../../game-internals.md) — the primary RE notes this
|
||||
section draws from (§2 validity, §3 cursor, §4 two-player, §5 tooling,
|
||||
§6 jump-start references for Ghidra and bemaniutils).
|
||||
@@ -0,0 +1,388 @@
|
||||
# 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
|
||||
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).
|
||||
|
||||
## 1. Top-level game-dir layout
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
Verified directory listings (`find GAME-DIR/{data,arkdata,prop,modules,api,dev} -maxdepth 2`):
|
||||
|
||||
- `data/arc/`, `data/arc/2d/`, `data/bm2d/`, `data/dal/`, `data/dal/2d/`,
|
||||
`data/data/`, `data/font/`, `data/sound/`, `data/bgmov/` — asset trees.
|
||||
- `arkdata/ark/{font,testmode,xml}` and
|
||||
`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.
|
||||
|
||||
## 2. `prop/` configuration XML — structure
|
||||
|
||||
All `prop/*.xml` files use a flat, typed-attribute XML dialect: every leaf
|
||||
element carries no namespace and, where the value is not implicitly a UTF-8
|
||||
string, an `__type` attribute (`str`, `u8`, `u16`, `u32`, `s32`, `bool`)
|
||||
giving its decoded scalar type. This is the textual (`format=binary`-adjacent
|
||||
but XML-serialized) form of the AVS2 **property tree** (§3) — the same typed
|
||||
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
|
||||
|
||||
Root `<ea3>`. Verified structure (`prop/ea3-config.xml`, line numbers from a
|
||||
direct `grep`):
|
||||
|
||||
```xml
|
||||
<ea3>
|
||||
<id>
|
||||
<pcbid __type="str">00000000000000000000</pcbid> <!-- ea3-config.xml:4 -->
|
||||
<softid __type="str">00000000000000000000</softid> <!-- ea3-config.xml:5 -->
|
||||
</id>
|
||||
<soft>
|
||||
<model __type="str">KDM</model> <!-- ea3-config.xml:9 -->
|
||||
<dest __type="str">A</dest>
|
||||
<spec __type="str">A</spec>
|
||||
<rev __type="str">A</rev>
|
||||
<ext __type="str">2016021900</ext> <!-- ea3-config.xml:13: matches install dir name KDM-2016021900 -->
|
||||
</soft>
|
||||
<timezone __type="s32">32400</timezone> <!-- ea3-config.xml:16: +9:00 (JST) -->
|
||||
<encoding>SHIFT_JIS</encoding> <!-- ea3-config.xml:18 -->
|
||||
<format>binary</format> <!-- ea3-config.xml:19: wire encoding for ea3 RPC -->
|
||||
<network>
|
||||
<sz_xrpc_buf __type="u32">102400</sz_xrpc_buf>
|
||||
<ssl __type="bool">0</ssl>
|
||||
<services __type="str">http://localhost:8080/</services> <!-- ea3-config.xml:23 -->
|
||||
<url_slash __type="bool">1</url_slash>
|
||||
</network>
|
||||
<eacoin> ... </eacoin> <!-- ea3-config.xml:28-37: PASELI/eacoin service params -->
|
||||
<pos>
|
||||
<coin>
|
||||
<slot1> ... <event __type="str">coin.i</event> ... </slot1> <!-- ea3-config.xml:56-69 -->
|
||||
<service> ... <event __type="str">service.p</event> ... </service> <!-- ea3-config.xml:71-80 -->
|
||||
<p1s01a1> ... <event __type="str">game.s</event> ... </p1s01a1> <!-- ea3-config.xml:87-98, article/credit mapping -->
|
||||
<!-- p1s02a1..p1s16a1: one <article>/<event>/<credit_ref> block per
|
||||
coin-pool article slot, mapping coin events to credit refs such as
|
||||
/coin/start, /coin/continue, /coin/join, /coin/item1..12
|
||||
(ea3-config.xml:99-203) -->
|
||||
</coin>
|
||||
</pos>
|
||||
</ea3>
|
||||
```
|
||||
|
||||
`<model>KDM</model>` (ea3-config.xml:9) is the e-amusement model code for
|
||||
DanceEvolution Arcade; `<ext>2016021900</ext>` (ea3-config.xml:13) is the data
|
||||
version stamp, matching the install directory name `KDM-2016021900` in
|
||||
GAME-DIR's parent path. The `<pos><coin>` 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.
|
||||
|
||||
### 2.2 `avs-config.xml` — AVS2 runtime config
|
||||
|
||||
Root `<config>`. Verified structure (`prop/avs-config.xml`):
|
||||
|
||||
```xml
|
||||
<config>
|
||||
<fs>
|
||||
<root><device __type="str">.</device></root> <!-- avs-config.xml:5 -->
|
||||
<nvram>
|
||||
<fstype __type="str">fs</fstype> <!-- avs-config.xml:8 -->
|
||||
<device __type="str">dev\nvram</device> <!-- avs-config.xml:9 -->
|
||||
<option __type="str">sz_block=768,nr_block=128,nr_mirror=4</option> <!-- avs-config.xml:11 -->
|
||||
</nvram>
|
||||
<raw><device __type="str">dev\raw</device></raw> <!-- avs-config.xml:14 -->
|
||||
<nr_mountpoint __type="u16">256</nr_mountpoint>
|
||||
<nr_filedesc __type="u16">256</nr_filedesc>
|
||||
</fs>
|
||||
<time><gmt_offset __type="s32">32400</gmt_offset></time>
|
||||
<log>
|
||||
<level>all</level>
|
||||
<sz_buf __type="u32">8192</sz_buf>
|
||||
<enable_console __type="bool">1</enable_console>
|
||||
<enable_file __type="bool">1</enable_file>
|
||||
<rotate __type="bool">1</rotate>
|
||||
<gen __type="u16">10</gen> <!-- avs-config.xml:33: keep 10 rotated log generations -->
|
||||
</log>
|
||||
<net>
|
||||
<nr_protocol __type="u16">8</nr_protocol>
|
||||
<nr_socket __type="u16">16</nr_socket>
|
||||
<lz77sock><enable __type="bool">1</enable></lz77sock> <!-- avs-config.xml:39-41: compressed-socket transport -->
|
||||
<multisock><enable __type="bool">1</enable></multisock>
|
||||
</net>
|
||||
<thread>
|
||||
<nr_thread __type="u16">100</nr_thread>
|
||||
<nr_semaphore __type="u16">50</nr_semaphore>
|
||||
<nr_mutex __type="u16">512</nr_mutex>
|
||||
<nr_event __type="u16">64</nr_event>
|
||||
</thread>
|
||||
<sntp><ea_on __type="bool">0</ea_on></sntp>
|
||||
</config>
|
||||
```
|
||||
|
||||
`<fs>` declares the AVS2 virtual filesystem's mount table: a `root` device
|
||||
mapped to `.` (GAME-DIR itself), an `nvram` device backed by `dev\nvram`
|
||||
mounted with filesystem type `fs` and block options
|
||||
(`sz_block=768,nr_block=128,nr_mirror=4` — 768-byte blocks, 128 blocks, 4
|
||||
mirrored copies, matching the small XML snapshot files actually present
|
||||
under `dev/nvram/`), and a `raw` device backed by `dev\raw` (matching the
|
||||
`bookkeeping/`, `fscache/`, `log/`, `ranking/`, `settings/` subdirectories
|
||||
observed there). `nr_mountpoint`/`nr_filedesc` size the AVS2 VFS table and
|
||||
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 (`<tag __type="...">value</tag>`),
|
||||
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`.
|
||||
|
||||
## 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)).
|
||||
|
||||
- **Virtual filesystem.** AVS2 multiplexes named *devices* under mount
|
||||
points declared in `avs-config.xml`'s `<fs>` 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.
|
||||
- **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.
|
||||
`<player_ref __type="str">/coin/player1/ref_slotid</player_ref>`,
|
||||
ea3-config.xml:64). 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`),
|
||||
and `re/avs/recon_avs_harness.cpp` / `re/avs/prove_t14.py` are a
|
||||
differential-test harness proving a MinGW reconstruction of
|
||||
`property_node_datasize` against the real `libavs-win32.dll`
|
||||
(`re/avs/recon_avs_harness.cpp:1`, `re/avs/prove_t14.py:1`). This confirms
|
||||
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 `<pos><coin>`
|
||||
article table (§2.1) is a concrete example of gamekdm-level data stored and
|
||||
resolved as property-tree paths (`credit_ref`, `player_ref`).
|
||||
- `prop/avs-config.xml:1` — root tag is `<config>`, not `<ea3>` or `<avs>`:
|
||||
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.
|
||||
|
||||
## 4. Archive / container formats (by inspection)
|
||||
|
||||
### 4.1 `.arc` — the dominant asset archive (2,214 files under `data/`)
|
||||
|
||||
Twelve sampled `.arc` files across `data/arc/*.arc` and `data/arc/2d/*.arc`
|
||||
(`2d_font_ark_system.arc`, `2d_font_lang_han.arc`, `2d_font_lang_kan.arc`,
|
||||
`2d_font_system.arc`, `2d_font_ui.arc`, `animtest.arc`, two `ani_back000_*`
|
||||
files, `2d_mask_128data.arc`, `2d_sys.arc`, `2d_sys_ja.arc`,
|
||||
`2d_sys_sys_list.arc`) **all** begin with the same little-endian 32-bit word:
|
||||
|
||||
```
|
||||
offset 0x00: 20 11 75 19 -> u32 LE = 0x19751120 (constant across all 12 samples)
|
||||
offset 0x04: 01 00 00 00 -> u32 LE = 1
|
||||
offset 0x08: 34 00 00 00 -> u32 LE = 0x34 (52)
|
||||
offset 0x0c: 02 00 00 00 -> u32 LE = 2
|
||||
```
|
||||
|
||||
(verified by direct Python `struct.unpack_from('<I', data, 0)` over all 12
|
||||
files; see also the raw `xxd -l 64` dump of
|
||||
`data/arc/2d/2d_mask_128data.arc`, which shows the same leading
|
||||
`20 11 75 19 01 00 00 00` bytes). `0x19751120` is treated here as the `.arc`
|
||||
container's magic/version constant; its field-level meaning (beyond "first
|
||||
header word, constant across every sampled file") is UNVERIFIED — no `.arc`
|
||||
parser or on-disk format description was found elsewhere in this repository.
|
||||
`file(1)` classifies all sampled `.arc` files as generic `data` (no libmagic
|
||||
signature). `data/arc/2d/2d_sys.arc` (1,320,128 bytes) contains the ASCII
|
||||
substrings `lob` at file offset `0x370` and `afp` at offset `0x707`, i.e. the
|
||||
packed payload embeds path fragments ending in `.lob`/`.afp` — the same
|
||||
component extensions a `.dal` manifest for the same 2D package lists (§4.3),
|
||||
which is consistent with `.arc` being a packed-archive container whose
|
||||
entries are the `.lob`/`.lp`/`.afp`/texture/font components a `.dal`
|
||||
manifest names, though the entry table layout itself was not reverse
|
||||
engineered for this section (UNVERIFIED beyond "contains an embedded,
|
||||
multi-u32 header and readable path-like substrings at non-zero offsets").
|
||||
|
||||
### 4.2 `.ifs` — Flash/UI archive (326 files, concentrated in `data/bm2d/`)
|
||||
|
||||
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`
|
||||
(pure-Python) successfully extracts `data/bm2d/*.ifs` into an `afp/<name>`
|
||||
Flash-asset tree, and `game-internals.md:54-55` 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`,
|
||||
`"value": "%s_%s_v0.ifs"` at `re/rvadb.json:219441`, and about 30 concrete
|
||||
UI-screen `.ifs` names such as `title_v0.ifs`, `game_hud_v0.ifs`,
|
||||
`calibration_v0.ifs`, `license_v0.ifs` around `re/rvadb.json:206500-207100`),
|
||||
confirming gamekdm opens `.ifs` files by printf-style name pattern per UI
|
||||
screen/locale. The internal entry-table layout was not reverse engineered
|
||||
here; `ifstools`' published format description (not reproduced in this repo)
|
||||
is the only known decoder. This repository's own format knowledge for `.ifs`
|
||||
is therefore UNVERIFIED beyond "Konami IFS container, Flash payload,
|
||||
externally decodable via `ifstools`."
|
||||
|
||||
### 4.3 `.dal` — 2D package manifest (3,167 files, the most numerous extension)
|
||||
|
||||
Plain text, not a binary container. Sampled
|
||||
`data/dal/2d/2d_calibration.dal` in full:
|
||||
|
||||
```
|
||||
# this file was created by mk2Ddal.py
|
||||
|
||||
# .lob
|
||||
data/2d/calibration/calibpic1_layout.lob
|
||||
...
|
||||
# .lp
|
||||
data/2d/calibration/bgcalib1_pack.lp
|
||||
...
|
||||
# .afp
|
||||
data/2d/calibration/bgcalib.afp
|
||||
...
|
||||
```
|
||||
|
||||
Each `.dal` file is a `#`-comment-sectioned plain list of relative component
|
||||
paths grouped by extension (`.lob` layout files, `.lp` pack files, `.afp`
|
||||
Flash/vector assets observed in this sample; other `.dal` files under
|
||||
`data/dal/` may list additional component extensions). The header comment
|
||||
names the authoring tool, `mk2Ddal.py` — a Konami build-pipeline script, not
|
||||
present in GAME-DIR. `.dal` is therefore a build-time manifest of which
|
||||
`.lob`/`.lp`/`.afp` component files compose one named 2D UI package (here,
|
||||
the calibration screen), analogous in role to the `.arc` archives' packed
|
||||
contents (§4.1) but shipped as loose files plus a manifest rather than a
|
||||
single packed blob in this directory. `.inc` files (166 under `data/`, e.g.
|
||||
`data/dal/em_clnm01.inc`) are the same family: UTF-8-with-BOM, CRLF text
|
||||
created by a sibling tool (`MahoroMagic`, per the file's own header comment),
|
||||
listing includable sub-resources.
|
||||
|
||||
### 4.4 Audio containers
|
||||
|
||||
- `.xwb` (115 files, e.g. `data/sound/afpr.xwb`): magic `WBND` at offset 0
|
||||
(`57 42 4e 44` = `"WBND"`), the Microsoft XACT **Wave Bank** container
|
||||
format — `file(1)` does not classify it, but the ASCII magic is
|
||||
unambiguous.
|
||||
- `.xsb` (115 files, e.g. `data/sound/afpr.xsb`): magic `SDBK` at offset 0
|
||||
(`53 44 42 4b` = `"SDBK"`), the Microsoft XACT **Sound Bank** format (paired
|
||||
1:1 with `.xwb` by base name — both samples here are `afpr.{xwb,xsb}`).
|
||||
- `.xgs` (1 file, `data/sound/dmas.xgs`): the XACT **global settings** file
|
||||
that normally accompanies a wave/sound-bank pair; present as a single
|
||||
shared file rather than per-package. Header bytes not decoded for this
|
||||
section (UNVERIFIED beyond file presence/naming).
|
||||
- `.ttc` (3 files) — likely TrueType Collection font containers (standard
|
||||
`ttcf` magic was not independently re-verified here; name/extension
|
||||
evidence only — UNVERIFIED).
|
||||
|
||||
### 4.5 Texture / font containers
|
||||
|
||||
- `.dds` (16 files, e.g. `data/font/2d_font_ark_system.0.dds`,
|
||||
`arkdata/arkkdm/ea3license/license1.dds`): standard Microsoft DirectDraw
|
||||
Surface magic `44 44 53 20` (`"DDS "`) at offset 0; `file(1)` decodes the
|
||||
sample as `2048 x 1136, 8-bit color, luminance` — an 8-bit single-channel
|
||||
(luminance/alpha-style) atlas texture, consistent with a font glyph sheet.
|
||||
- `.kbf` (6 files, e.g. `data/font/2d_font_ark_system.kbf`): magic
|
||||
`6b 62 66 00` = ASCII `"kbf\0"` at offset 0, followed by an ASCII version
|
||||
string `"00"` at offset 4 — a Konami-proprietary font-metrics/glyph-layout
|
||||
companion to the `.dds` atlas of the same base name
|
||||
(`2d_font_ark_system.{kbf,0.dds}`). Internal field layout beyond the magic
|
||||
and version bytes was not decoded (UNVERIFIED).
|
||||
|
||||
### 4.6 Video container
|
||||
|
||||
- `.wmv` (25 files, e.g. `data/bgmov/brav.wmv`): standard ASF/WMV GUID magic
|
||||
`30 26 b2 75 8e 66 cf 11 a6 d9 00 aa 00 62 ce 6c` at offset 0 (the
|
||||
canonical Microsoft ASF header object GUID); `file(1)` confirms
|
||||
`Microsoft ASF`. These are background/attract-mode movies
|
||||
(`data/bgmov/`), standard WMV, no custom wrapper.
|
||||
|
||||
### 4.7 Miscellaneous
|
||||
|
||||
- `data/data/texture.db` and `data/data/dam_en_us.cfg`: present as single
|
||||
named files rather than per-asset extensions; contents not decoded for
|
||||
this section (UNVERIFIED — plausibly a texture index and a locale-specific
|
||||
config/string table respectively, based on naming only).
|
||||
- `prop/card_allow.bin`, `arkdata/arkkdm/qc/zero.bin` (2 `.bin` files
|
||||
total under the sampled scope): opaque binary, not decoded.
|
||||
- `arkdata/arkkdm/sound/{seteq.def,setvolume.def}` (2 `.def` files): not
|
||||
decoded; likely plain key=value EQ/volume preset text based on naming
|
||||
(UNVERIFIED).
|
||||
|
||||
## 5. Summary table — extensions observed under `data/` + `arkdata/`
|
||||
|
||||
| ext | count | format (verified) |
|
||||
|---|---|---|
|
||||
| `.dal` | 3,167 | plain-text component manifest (§4.3) |
|
||||
| `.arc` | 2,214 | packed archive, magic `0x19751120` (§4.1) |
|
||||
| `.ifs` | 326 | Flash/UI container, opaque header, decodable via external `ifstools` (§4.2) |
|
||||
| `.inc` | 166 | plain-text include list, `mk2Ddal.py`/`MahoroMagic`-family tooling (§4.3) |
|
||||
| `.xwb` | 115 | Microsoft XACT Wave Bank, magic `WBND` (§4.4) |
|
||||
| `.xsb` | 115 | Microsoft XACT Sound Bank, magic `SDBK` (§4.4) |
|
||||
| `.wmv` | 25 | Microsoft ASF/WMV, standard GUID magic (§4.6) |
|
||||
| `.dds` | 16 | Microsoft DirectDraw Surface, magic `"DDS "` (§4.5) |
|
||||
| `.kbf` | 6 | Konami font companion, magic `"kbf\0"` (§4.5) |
|
||||
| `.xml` | 5 (under `data/`) | typed property-tree XML, same dialect as §2 |
|
||||
| `.ttc` | 3 | likely TrueType Collection (unverified magic) |
|
||||
| `.def` | 2 | plain text preset (unverified) |
|
||||
| `.bin` | 2 | opaque binary (unverified) |
|
||||
| `.xgs` | 1 | XACT global settings (unverified header) |
|
||||
| `.db` | 1 | `texture.db`, unverified internal format |
|
||||
| `.cfg` | 1 | `dam_en_us.cfg`, unverified internal format |
|
||||
|
||||
Counts from `find GAME-DIR/data GAME-DIR/arkdata -type f | sed -E 's/.*\./ /' |
|
||||
tr A-Z a-z | sort | uniq -c`, run directly against the live install.
|
||||
@@ -0,0 +1,210 @@
|
||||
# gamekdm.dll Subsystem Map
|
||||
|
||||
An RVA-anchored partition of `gamekdm.dll` into functional subsystems. All
|
||||
addresses are RVAs relative to image base `0x10000000` (`re/rvadb.json:
|
||||
image_base`); absolute VA = RVA + base. The module holds `function_count` =
|
||||
**9728** functions (`re/rvadb.json`). This is a *representative* map: each
|
||||
subsystem lists 8-15 functions chosen as entry points or distinctive workers,
|
||||
not an exhaustive per-function catalog. Citations are RVAs verified present in
|
||||
`re/rvadb.json`; semantics come from the committed Ghidra dumps under
|
||||
`/home/athapa/ghidra/*.out`, the recovered source paths and class names in the
|
||||
DLL's string table, and `game-internals.md`.
|
||||
|
||||
## Method and confidence
|
||||
|
||||
The DLL ships almost fully stripped: of 9728 functions only ~364 carry a real
|
||||
name, and `owning_module_guess` is `unknown` for 9711 (the rest are CRT/EH
|
||||
thunks and four `D3DX9_43.DLL` imports). Subsystems were therefore seeded from
|
||||
three evidence sources, strongest first: (1) `strref`/`StatusCB` labels in the
|
||||
Ghidra dumps and the game's own recovered source paths embedded as strings
|
||||
(`..\Game_DaM\...`, `..\Renderer\...`, `..\src\mm\...`, `Source\BM2D\...`) and
|
||||
C++ class names (`NuiThread::`, `mm::Emitter`, `CAudioWrap::`, `BM2D::`); (2)
|
||||
the retained `ark*` export-name string table; (3) call-graph adjacency plus
|
||||
shared writes to the same mutable globals. A function was assigned only when a
|
||||
name/string anchor matched, or when >=2 of its graph neighbours already belong
|
||||
to one subsystem *and* it writes a global that subsystem owns. Everything else
|
||||
is left unclassified rather than guessed (see coverage note).
|
||||
|
||||
## Game-state manager — the live manager at `*(gamekdm+0x3cf1b4)`
|
||||
|
||||
The central per-frame object. `DAT_103cf1b4` holds its pointer and is read by 53
|
||||
functions; it carries the NUI thread handle, the skeleton frame at `+0x1a0`, the
|
||||
requested/selected tracking IDs at `+0x15f0`/`+0x1684`, and the synthetic-mode
|
||||
flag at `+0x17f4` (layout in `include/gk/structs/manager.h`, `gk::LiveManager`).
|
||||
`FUN_1000fa20` (0x0000fa20) is the frame-commit path: it drains the NUI worker,
|
||||
copies tracking IDs into the manager, and signals the frame event;
|
||||
`FUN_10010030` (0x00010030) diffs the committed vs requested subsystem mask at
|
||||
`+0xc`/`+0x10` and starts/stops skeleton tracking. State-query helpers
|
||||
`FUN_10013220` (0x00013220), `FUN_10013290` (0x00013290), `FUN_100132d0`
|
||||
(0x000132d0), `FUN_10013310` (0x00013310) and `FUN_10013330` (0x00013330) read
|
||||
manager fields for callers; `FUN_10019850` (0x00019850) and `FUN_100198f0`
|
||||
(0x000198f0) are its update drivers. Key global: `DAT_103cf1b4`. See
|
||||
[./03-kinect-skeleton.md](./03-kinect-skeleton.md).
|
||||
|
||||
## Kinect / skeleton — NuiThread and hid::Natal
|
||||
|
||||
The NUI consumer thread and skeleton ingest. `FUN_1000f0a0` (0x0000f0a0,
|
||||
`NuiThread::updateFrame`), `FUN_1000f300` (0x0000f300, `NuiThread::updateSkeleton`)
|
||||
and `FUN_1000f400` (0x0000f400, `NuiThread::updateStream`) are the three
|
||||
per-frame NUI pumps; `FUN_1000ebd0` (0x0000ebd0, `StatusCB`) and `FUN_1000ecc0`
|
||||
(0x0000ecc0, `CreateSensor`) own sensor lifecycle; `FUN_100103d0` (0x000103d0,
|
||||
`hid::Natal::copySkeleton`) and `FUN_100122d0` (0x000122d0,
|
||||
`HidNatalNuiThread_win32.cpp`) move skeleton data into the manager.
|
||||
`FUN_100100d0` (0x000100d0, `TransformSmooth`) smooths joints and `FUN_10019c30`
|
||||
(0x00019c30, `ColorCoord`) maps depth to colour space. `FUN_10004e40`
|
||||
(0x00004e40, `[$CameraImage]`) and `FUN_100076f0` (0x000076f0, `noCamera`) handle
|
||||
the camera-image/no-camera cases; `FUN_1000ef50` (0x0000ef50) is a worker in the
|
||||
same cluster. Globals: `DAT_103cf1b4`, `DAT_103d2d90`. Full treatment in
|
||||
[./03-kinect-skeleton.md](./03-kinect-skeleton.md).
|
||||
|
||||
## Validity gate — candidate filter and gravity transform
|
||||
|
||||
Decides whether a candidate skeleton renders. `FUN_10018570` (0x00018570) builds
|
||||
the gravity/floor-relative matrix `DAT_103d4a80` (reading gravity at
|
||||
`manager+0x2c`); `FUN_101799b0` (0x001799b0) is its 16-float matrix multiply.
|
||||
`FUN_100e4140` (0x000e4140) is the per-slot validity filter, calling
|
||||
`FUN_101ab6d0` (0x001ab6d0) for the box-distance metric, itself built from the
|
||||
clamp `FUN_101ab640` (0x001ab640) and `FUN_101ab5b0` (0x001ab5b0). `DAT_103d3230`
|
||||
holds the box's center point plus a separate half-extent value (not box
|
||||
corners — `src/game/box_distance.cpp:7-16`, `game-internals.md:37-42`) and is
|
||||
initialised by `FUN_100e4a80` (0x000e4a80); nearest-candidate selection runs
|
||||
in `FUN_100e46d0` (0x000e46d0) and
|
||||
`FUN_100e47d0` (0x000e47d0), feeding slot assignment `FUN_100e4540` (0x000e4540);
|
||||
`FUN_100182a0` (0x000182a0) is a sibling transform helper. Globals:
|
||||
`DAT_103d3230`, `DAT_103d4a80`, `DAT_103e29b0`, `DAT_103d18e8`. This is the
|
||||
subject of [./04-validity-cursor.md](./04-validity-cursor.md).
|
||||
|
||||
## Menu cursor — afp hand cursor and OK-button snapping
|
||||
|
||||
The Flash/afp menu cursor state machine. `FUN_1007e330` (0x0007e330) is the
|
||||
cursor/selection state machine; `FUN_1007fbf0` (0x0007fbf0) does OK-button
|
||||
hit-testing (`_but_ok_1p_usr`, threshold `dist² < 0x1fa4`); `FUN_10080360`
|
||||
(0x00080360) reads the `_icon_1p_usr` button icons; `FUN_1007f0a0` (0x0007f0a0)
|
||||
and `FUN_100800e0` (0x000800e0) are helper branches. The cursor coordinate is
|
||||
read through `afp_mc_get_param(_,0x1008)` in `FUN_101d84c0` (0x001d84c0) and
|
||||
`FUN_101d78e0` (0x001d78e0); `FUN_101d71e0` (0x001d71e0) resolves a movie-clip by
|
||||
name. BM2D ownership is bracketed by `FUN_10084750` (0x00084750,
|
||||
`BM2DWrapper:AcquireOwnership`) and `FUN_100847e0` (0x000847e0,
|
||||
`BM2DWrapper:ReleaseOwnership`). Global: cursor-controller `DAT_103d2bb8` (read
|
||||
by 55 functions). See [./04-validity-cursor.md](./04-validity-cursor.md).
|
||||
|
||||
## Scoring — judge counts, combo, and HUD numerals
|
||||
|
||||
`FUN_10072a30` (0x00072a30) formats the `SCORE` / `JUDGE(PE,GR,GO,BO)` debug
|
||||
line and owns the per-player judge tallies; `FUN_10073be0` (0x00073be0) drives
|
||||
the `score_00000001_usr`..`score_10000000_usr` / `hi_score_usr` numeral sprites,
|
||||
with `FUN_100741e0` (0x000741e0) and `FUN_10074d30` (0x00074d30) its HUD
|
||||
siblings. `FUN_10088740` (0x00088740) loads `data/arc/combo_1p.arc`;
|
||||
`FUN_100a93a0` (0x000a93a0) animates the `combo_01_usr` digits and `FUN_100a6d50`
|
||||
(0x000a6d50) the `wipe_usr` transition. `FUN_100bc8a0` (0x000bc8a0) reads the
|
||||
shop-area network option feeding result upload. Globals: `DAT_103d28c0`,
|
||||
`DAT_102f2258`.
|
||||
|
||||
## Song / chart flow — selection, resources, and DanceStream
|
||||
|
||||
Song/chart lifecycle. `FUN_10023b40` (0x00023b40) loads `song_resources.rlist` /
|
||||
`song_character_params.plist`; `FUN_1002adb0` (0x0002adb0) parses
|
||||
`song_params.plist` and reports `Unknown song`. `FUN_1001b740` (0x0001b740) and
|
||||
`FUN_1001fad0` (0x0001fad0) build the `song_` catalogue; `FUN_1001c070`
|
||||
(0x0001c070) resolves `data/song/` paths and `FUN_1001fc40` (0x0001fc40) applies
|
||||
`songpatch_` overrides. The playfield stream generator is `FUN_100b69e0`
|
||||
(0x000b69e0, `DanceStreamManager_Generator.cpp`) and the procedural note model is
|
||||
`FUN_100d31a0` (0x000d31a0, `p_ds_Model.cpp`). The `ark*Sequence*` export strings
|
||||
(`arkSetSequenceNumber`, `arkGetSequenceNoteCount`) are the chart-playback API
|
||||
surface. See [./05-data-formats.md](./05-data-formats.md) for the on-disk
|
||||
`.rlist`/`.plist` formats.
|
||||
|
||||
## D3D9 render — Renderer_dx9 and the Gs scene graph
|
||||
|
||||
The DirectX 9 renderer (`..\Renderer\Renderer_dx9.cpp`) plus the `Gs` scene-graph
|
||||
layer. Post-process filters each have their own function: `FUN_100fd140`
|
||||
(0x000fd140, `ColorFilter_dx9`), `FUN_10100c30` (0x00100c30, `GodRay`),
|
||||
`FUN_100fc980`/`FUN_100fd4c0`/`FUN_10101680` (0x000fc980 / 0x000fd4c0 /
|
||||
0x00101680, `render_color` targets) and the `sys_copy` blit chain
|
||||
`FUN_100ff880`/`FUN_10100240`/`FUN_10102c20`. `FUN_100e9450` (0x000e9450) sets
|
||||
`audience_color`; `FUN_100292a0` (0x000292a0) sets the
|
||||
`primary_directional_light_direction`; `FUN_100f4590` (0x000f4590) and
|
||||
`FUN_100f77e0` (0x000f77e0) are scene-graph node workers. External edges confirm
|
||||
`D3D9.DLL` (7 call sites) and `D3DX9_43.DLL`. Globals: `DAT_103d2d0c`,
|
||||
`DAT_103d2d14`, `DAT_103d24e0`.
|
||||
|
||||
## Movie — DirectShow demo/tutorial playback
|
||||
|
||||
Full-motion video via DirectShow. `FUN_1003e330` (0x0003e330) loads
|
||||
`data/movie/demo_movie` (`AC_movie`); `FUN_10041b30` (0x00041b30) plays
|
||||
`data/movie/_demo_tuto.wmv` (`TutoMovie`, from `HowToDemoSequence.cpp`);
|
||||
`FUN_10057890` (0x00057890) is the `DEMO MOVIE` attract hook. The DirectShow
|
||||
graph builder `FUN_101c26f0` (0x001c26f0) instantiates the `MPEG-2 Splitter`
|
||||
filter, guarded by `FUN_101c2380` (0x001c2380). RTTI names confirm the C++
|
||||
namespace `me::movie::impl::DShow`/`DShowPlayer`/`MemRenderer`. `OLE32.DLL`
|
||||
(`CoCreateInstance`, 43 edges) is the COM backing. Global: `DAT_103d1d48`.
|
||||
|
||||
## Particle — mm (MahoroMagic) effect engine
|
||||
|
||||
The `mm::` effect/particle engine (`..\src\mm\MahoroMagic.cpp`,
|
||||
`mmEmitterGroup.cpp`, `mmModel.cpp`), the largest classified cluster.
|
||||
`FUN_100862d0`..`FUN_10086790` (0x000862d0, 0x000863f0, 0x00086510, 0x00086650,
|
||||
0x00086790) are the `mm::stl::allocator` / handle-table constructors for
|
||||
`Emitter`/`Particle`/`PresetInfo`; `FUN_101682c0`..`FUN_10168820` (0x001682c0,
|
||||
0x00168630, 0x00168820) and `FUN_10167800`/`FUN_10167a60` (0x00167800 /
|
||||
0x00167a60) are preset-bin readers and model-instancing workers (`FailedTexture`).
|
||||
`FUN_1008ace0` (0x0008ace0) and `FUN_100c4ba0` (0x000c4ba0) are update/display
|
||||
drivers (`EMITTER_UPDATE` / `EMITTER_DISPLAY`, `Cloth Update Particle`). Globals:
|
||||
`DAT_103e5f34`, `DAT_103e5f88`.
|
||||
|
||||
## Sound / mm — CAudioWrap over XACT3/XAudio2
|
||||
|
||||
Audio built on XACT3/XAudio2 (`CSd::`, `CKsd::`, `CAudioWrap::`,
|
||||
`SoundHeapManager::`, `CCtrlBlk::`, `CWorkMan::`). `FUN_100d9e50` (0x000d9e50,
|
||||
`CKsd::Init`) and `FUN_100db340` (0x000db340, `SoundHeapManager` /
|
||||
`FileManager`) own init and the sound heap; `FUN_100dae20` (0x000dae20) creates
|
||||
the request-queue mutex; `FUN_100dcae0`/`FUN_100dcb80`/`FUN_100dcbe0` (0x000dcae0
|
||||
/ 0x000dcb80 / 0x000dcbe0) are `CCtrlBlk::RequestPlay/RequestPrepare/PreparedPlay`;
|
||||
`FUN_100dce20` (0x000dce20) calls `XAudio2Create`; `FUN_100dbee0` (0x000dbee0)
|
||||
wraps `CMutex::UnLock`. `FUN_1005e840` (0x0005e840) triggers `se_kuma_elev_up`
|
||||
SE. The retained `ark*Sound*` exports (`createSound`, `playSoundBGM`,
|
||||
`setSoundVolume`) are the public API. `WINMM.DLL` provides 32 edges. Globals:
|
||||
`DAT_103d1840`, `DAT_103e2764`.
|
||||
|
||||
## UI — BM2D 2D layer system and bitmap fonts
|
||||
|
||||
The BM2D 2D compositor (`Source\BM2D\*.cpp`) and bitmap-font text.
|
||||
`FUN_101d8330` (0x001d8330, `BM2D_LayerBase.cpp`) manages layers;
|
||||
`FUN_101d8de0` (0x001d8de0, `BM2D_LinePrim.cpp`) emits line primitives;
|
||||
`FUN_101d9180`/`FUN_101d91e0`/`FUN_101d9250` (0x001d9180 / 0x001d91e0 /
|
||||
0x001d9250, `BM2D_Utility.cpp`) build user shapes. Text rendering is
|
||||
`FUN_10135880` (0x00135880, `BmpfontSimpleString::render`) with line parsing in
|
||||
`FUN_1013ca00`/`FUN_1013cad0` (0x0013ca00 / 0x0013cad0,
|
||||
`BmpfontSimpleString::parseLines`). `FUN_101d9e80` (0x001d9e80) bridges to
|
||||
`afputils`. `LIBAFP-WIN32.DLL` (96 edges) backs the Flash layer. See
|
||||
[./07-companion-apis.md](./07-companion-apis.md).
|
||||
|
||||
## Boot / entry — gameMain and CRT startup
|
||||
|
||||
Module and game entry. `entry` (0x001dd76b) -> `___DllMainCRTStartup`
|
||||
(0x001dd675) with `___security_init_cookie` (0x001e4f5b) is the PE/CRT bring-up.
|
||||
The single game export is `gameMain` (0x00009e20, confirmed by `objdump -p` and
|
||||
`re/rvadb.json`, absolute VA `0x10009e20`); it runs `FUN_100029a0` (0x000029a0),
|
||||
which binds the `arkKDMInitialize`/`arkKDMUpdate` entry points via
|
||||
`GetProcAddress`, and `FUN_10009b40` (0x00009b40) / `FUN_10009a00` (0x00009a00),
|
||||
the subsystem bring-up fan-out (`arkHeapBoot`, `arkNetworkTCPInitialize`). AVS2
|
||||
is reached through `LIBAVS-WIN32.DLL` (595 edges). See
|
||||
[./01-runtime-boot.md](./01-runtime-boot.md) and
|
||||
[./02-dll-architecture.md](./02-dll-architecture.md).
|
||||
|
||||
## Coverage note
|
||||
|
||||
This map assigns **261 of 9728** functions (~2.7%) to a named subsystem: 226
|
||||
seed functions anchored by a name, string, source-path, or the known
|
||||
hand-verified RVAs from `game-internals.md`, plus 35 added by conservative
|
||||
call-graph + shared-global expansion. The remaining **9467** functions (~97.3%)
|
||||
are left **unclassified** — this is expected for a near-fully-stripped 3.3 MB
|
||||
DLL where only ~364 functions retain any symbol and 9711 report an `unknown`
|
||||
owning module. The unclassified bulk is dominated by compiler/EH boilerplate
|
||||
(2123 `Unwind@*`, 169 `Catch_All@*` thunks) and un-anchored leaf helpers that
|
||||
carry no string, name, or distinctive global to attribute them safely. The
|
||||
classified set deliberately favours precision over recall: a function is mapped
|
||||
only on positive evidence, so the per-subsystem RVAs above are reliable entry
|
||||
points even though the long tail stays open. Deepening coverage requires
|
||||
targeted decompilation (the `/home/athapa/ghidra` project, `game-internals.md`
|
||||
§6), not further name/string inference.
|
||||
@@ -0,0 +1,529 @@
|
||||
# 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.
|
||||
|
||||
Cross-links: [`./00-overview.md`](./00-overview.md),
|
||||
[`./08-abi-conventions.md`](./08-abi-conventions.md),
|
||||
[`./09-reconstruction-codebase.md`](./09-reconstruction-codebase.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.
|
||||
|
||||
**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`.
|
||||
|
||||
## 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.
|
||||
|
||||
**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.
|
||||
|
||||
## 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).
|
||||
|
||||
**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 families and roles, grouped by prefix (every function below is a
|
||||
literal export name from `re/importlibs/arkkdm.def`):
|
||||
|
||||
- **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.
|
||||
|
||||
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`).
|
||||
|
||||
`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).
|
||||
|
||||
## libafp-win32.dll + libafputils-win32.dll — AFP Flash-like player
|
||||
|
||||
**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 (`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`).
|
||||
|
||||
**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.
|
||||
|
||||
**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.
|
||||
|
||||
## ess.dll — Enterprise Shop/Server (e-amusement middleware)
|
||||
|
||||
**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`.
|
||||
|
||||
**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.
|
||||
|
||||
## libacio.dll + libacio_mbr.dll — ACIO arcade I/O
|
||||
|
||||
**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.
|
||||
|
||||
**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.
|
||||
|
||||
**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.
|
||||
|
||||
**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.
|
||||
|
||||
## 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.
|
||||
@@ -0,0 +1,241 @@
|
||||
# 08 - ABI, Calling Conventions, and Struct Layouts
|
||||
|
||||
This section pins the binary-level contract the reconstruction has to honor: the
|
||||
compiler and ABI the original `gamekdm.dll` was built with, the calling
|
||||
convention at every module boundary, and the struct layouts recovered from the
|
||||
image. Everything here is grounded in the reconstruction's own convention docs
|
||||
(`docs/conventions.md`, `docs/companion-conventions.md`) and the reconstructed
|
||||
headers under `include/gk/`, with offsets pinned by the `static_assert` set in
|
||||
`include/gk/offsets_assert.h`.
|
||||
|
||||
Related sections: [06 - gamekdm subsystems](./06-gamekdm-subsystems.md),
|
||||
[07 - companion DLLs](./07-companion-dlls.md).
|
||||
|
||||
## Compiler and image facts
|
||||
|
||||
The original binary is a 32-bit (x86) Windows DLL built with MSVC (`cl.exe`),
|
||||
the VS2010 SP1 x86 toolchain, linked against the static CRT (`/MT`). The default
|
||||
free-function convention is `__cdecl`, while many internal entry points and
|
||||
vtables use `__stdcall` or `__thiscall`
|
||||
(`include/gk/types.h:4-8`). The image base is `0x10000000`, which is why Ghidra
|
||||
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").
|
||||
|
||||
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;
|
||||
SSE scalar opcodes (`movss`, `mulss`, `addss`, `cvtsi2ss`, ...) mean SSE and a
|
||||
`-mfpmath=sse -msse2` build. The default is `-mfpmath=387` unless the disasm
|
||||
shows SSE, and every FP build adds `-ffp-contract=off -fno-fast-math` so the
|
||||
compiler never fuses or reorders FP ops away from the original's rounding
|
||||
(`docs/conventions.md`, "Floating point model").
|
||||
|
||||
MinGW/GCC on i686 is ABI-compatible with these MSVC calling conventions, so the
|
||||
reconstruction names the convention explicitly at each declaration rather than
|
||||
copying bytes (`include/gk/types.h:5-11`).
|
||||
|
||||
## Calling-convention macros
|
||||
|
||||
`include/gk/types.h` defines three convention macros. Under GCC they expand to
|
||||
the matching `__attribute__`, under MSVC to the keyword, and any other compiler
|
||||
is a hard `#error` (`include/gk/types.h:15-25`):
|
||||
|
||||
| Macro | GCC expansion | MSVC expansion | Cleanup / `this` |
|
||||
|---|---|---|---|
|
||||
| `GK_CDECL` | `__attribute__((cdecl))` | `__cdecl` | caller-cleaned |
|
||||
| `GK_STDCALL` | `__attribute__((stdcall))` | `__stdcall` | callee-cleaned |
|
||||
| `GK_THISCALL` | `__attribute__((thiscall))` | `__thiscall` | `this` in `ecx`, callee-cleaned |
|
||||
|
||||
Apply them by origin (`docs/conventions.md`, "Calling convention macros"):
|
||||
|
||||
- `GK_CDECL`: caller-cleaned C convention. Used for avs and afp interop (the
|
||||
game's `avs2` / `avfs` imports and callbacks) and anything the original
|
||||
declared `__cdecl`, which is MSVC's default for free functions.
|
||||
- `GK_STDCALL`: callee-cleaned stdcall. Used for the Win32-style boundaries:
|
||||
Kinect10 (`Kinect10.dll`) and Direct3D 9 (`d3d9.dll`) entry points and any
|
||||
`WINAPI`/`CALLBACK` path.
|
||||
- `GK_THISCALL`: MSVC thiscall. Used for internal non-virtual member functions
|
||||
reconstructed as free functions, and any method whose disasm passes `this` in
|
||||
`ecx` and cleans its own stack.
|
||||
|
||||
When the convention can't be read off the import table, it's read from the
|
||||
disasm: `ret N` (nonzero) is callee cleanup (stdcall/thiscall); a bare `ret`
|
||||
with the caller fixing `esp` is cdecl; `this` arriving in `ecx` marks thiscall
|
||||
(`docs/conventions.md`, "Calling convention macros").
|
||||
|
||||
## Calling convention per companion module
|
||||
|
||||
Each companion's convention and binding mode were derived by disassembling
|
||||
`gamekdm.dll`'s own call sites against its Import Address Table: a
|
||||
`call DWORD PTR ds:0x<iat>` followed by the caller popping arguments (`add
|
||||
esp,N`) is cdecl; a callee returning `ret N` with no caller fixup is stdcall
|
||||
(`docs/companion-conventions.md`, intro).
|
||||
|
||||
| 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-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 |
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
||||
All companions bind by name except Kinect10, which 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
|
||||
name; it's needed for `arkkdm.dll` and `Kinect10.dll` (whose export tables hold
|
||||
undecorated names) and is a no-op for the six cdecl companions, whose `.def`
|
||||
files carry no `@N` for dlltool to strip
|
||||
(`docs/companion-conventions.md`, "`--kill-at` scope"). The generated import
|
||||
libraries are link-proven by `tests/importlibs/companion_link_test.c`, with a
|
||||
negative control that removes one `.def` entry and confirms the link then fails
|
||||
(`docs/companion-conventions.md`, "Link proof").
|
||||
|
||||
## Struct packing rules
|
||||
|
||||
MSVC built the original with its default packing (natural alignment, equivalent
|
||||
to `#pragma pack(8)` on x86) unless a translation unit set a tighter pack. A
|
||||
reconstructed struct either relies on natural alignment (already correct for
|
||||
int/float/pointer-only structs on x86) or brackets itself with the pack macros
|
||||
to reproduce the exact MSVC pack state (`docs/conventions.md`, "Struct
|
||||
packing"). The macros are in `include/gk/types.h:54-56`:
|
||||
|
||||
- `GK_PRAGMA(x)` stringizes `x` and emits it as a `_Pragma`.
|
||||
- `GK_PACK_PUSH(n)` emits `#pragma pack(push, n)`.
|
||||
- `GK_PACK_POP` emits `#pragma pack(pop)`.
|
||||
|
||||
GCC/MinGW honor `#pragma pack` identically to MSVC, so no byte copying is needed.
|
||||
Every reconstructed struct header brackets its layout with `GK_PACK_PUSH(8)` /
|
||||
`GK_PACK_POP` (for example `include/gk/structs/math.h`,
|
||||
`include/gk/structs/manager.h`), matching MSVC's default pack(8).
|
||||
|
||||
## Reconstructed struct layouts
|
||||
|
||||
The layouts below are the recovered binary structures under
|
||||
`include/gk/structs/`, with every offset pinned by a `static_assert` in
|
||||
`include/gk/offsets_assert.h`. Unrecovered regions are kept as byte-storage
|
||||
arrays (`storage_XXXX`) rather than invented fields
|
||||
(`include/gk/structs/manager.h`).
|
||||
|
||||
### Math types (`include/gk/structs/math.h`)
|
||||
|
||||
Natural x86 layout confirmed by float-indexed accesses in `FUN_101799b0`,
|
||||
`FUN_101ab5b0`, `FUN_101ab640`.
|
||||
|
||||
- `gk::Vec3`: `float x,y,z` at `+0x00/+0x04/+0x08`, size `0x0c`.
|
||||
- `gk::Vec4`: `float x,y,z,w` at `+0x00/+0x04/+0x08/+0x0c`, size `0x10`.
|
||||
- `gk::Matrix4x4`: 16 row-major floats `m00..m33` at `+0x00` through `+0x3c`,
|
||||
size `0x40`. `FUN_101799b0` reads all sixteen contiguous floats;
|
||||
`FUN_100e4140` applies rows 0..2 to candidate positions.
|
||||
|
||||
(All asserts: `include/gk/offsets_assert.h:11-40`.)
|
||||
|
||||
### Skeleton types (`include/gk/structs/skeleton.h`)
|
||||
|
||||
Kinect NUI v1 wire layout. `kSkeletonCount = 6`, `kSkeletonJointCount = 20`.
|
||||
`SkeletonTrackingState` / `JointTrackingState` are `uint32_t` enums
|
||||
(`not_tracked=0`, `inferred/position_only=1`, `tracked=2`).
|
||||
|
||||
`gk::SkeletonData` (size `0x1b4`, the stride `FUN_100e4140` advances through
|
||||
candidates by):
|
||||
|
||||
| Field | Offset |
|
||||
|---|---|
|
||||
| `tracking_state` | `0x000` |
|
||||
| `tracking_id` | `0x004` |
|
||||
| `enrollment_index` | `0x008` |
|
||||
| `user_index` | `0x00c` |
|
||||
| `position` (`Vec4`) | `0x010` |
|
||||
| `joint_positions[20]` (`Vec4`) | `0x020` |
|
||||
| `joint_tracking_states[20]` | `0x160` |
|
||||
| `quality_flags` | `0x1b0` |
|
||||
|
||||
`gk::SkeletonFrame` (size `0xa68`), the `NUI_SKELETON_FRAME` copied into the live
|
||||
manager at `+0x1a0`: `timestamp` (`int64`) `0x000`, `frame_number` `0x008`,
|
||||
`flags` `0x00c`, `floor_clip_plane` (`Vec4`) `0x010`, `normal_to_gravity`
|
||||
(`Vec4`) `0x020`, `skeletons[6]` `0x030`
|
||||
(`include/gk/offsets_assert.h:42-57`).
|
||||
|
||||
### Live manager (`include/gk/structs/manager.h`)
|
||||
|
||||
`gk::LiveManager` is the live object addressed by `*(gamekdm.dll+0x3cf1b4)`.
|
||||
Selected pinned offsets (`include/gk/offsets_assert.h:75-87`):
|
||||
|
||||
| Field | Offset |
|
||||
|---|---|
|
||||
| `nui_thread_address` | `0x0000` |
|
||||
| `committed_subsystems` | `0x000c` |
|
||||
| `subsystem_mask` | `0x0010` |
|
||||
| `flags` | `0x0014` |
|
||||
| `reference_direction` (`Vec3`) | `0x0020` |
|
||||
| `gravity` (`Vec4`) | `0x002c` |
|
||||
| `skeleton_frame` | `0x01a0` |
|
||||
| `requested_tracking_ids[2]` | `0x15f0` |
|
||||
| `skeleton_tracking_enabled` | `0x15f8` |
|
||||
| `nui_sensor_address` | `0x15fc` |
|
||||
| `selected_tracking_ids[2]` | `0x1684` |
|
||||
| `synthetic_tracking_mode` | `0x17f4` |
|
||||
|
||||
`gk::CursorControllerState` is reached through `DAT_103d2bb8`. The pointer at
|
||||
`+0x000` (`inner_address`) is an opaque target address; no MSVC vtable/RTTI bytes
|
||||
are reproduced. Cursor fields: `player1_x` `+0x108`, `player1_y` `+0x10c`,
|
||||
`player2_x` `+0x110`, `player2_y` `+0x114`
|
||||
(`include/gk/offsets_assert.h:89-93`).
|
||||
|
||||
### Validity types (`include/gk/structs/validity.h`)
|
||||
|
||||
- `gk::ValidityBox` (`DAT_103d3230`, size `0x18`): `minimum` (`Vec3`) `+0x00`,
|
||||
`maximum` (`Vec3`) `+0x0c`. Consumed as six consecutive floats by
|
||||
`FUN_101ab6d0`'s clamp-and-distance check.
|
||||
- `gk::ValidityCandidate` (`DAT_103e29b0`..., stride `0x20` for six candidates,
|
||||
size `0x20`): `source_position` (`Vec3`) `+0x00`, `transformed_position`
|
||||
(`Vec3`) `+0x0c`, `tracking_id` (`float`) `+0x18`, `valid` (`uint8`) `+0x1c`,
|
||||
`reserved[3]` `+0x1d`. `FUN_100e4140` writes these fields
|
||||
(`include/gk/offsets_assert.h:59-73`).
|
||||
|
||||
## vtable and RTTI reconstruction
|
||||
|
||||
C++ classes are declared and MinGW regenerates the vtable and RTTI under the
|
||||
Itanium ABI. MSVC vtable or RTTI bytes are never memcpy'd, because MSVC and
|
||||
Itanium disagree on layout: MSVC stores the Complete Object Locator at
|
||||
`vtable[-1]`, Itanium stores the `type_info` pointer at `vtable[-1]`, so copied
|
||||
bytes are wrong under MinGW (`docs/conventions.md`, "vtable and RTTI
|
||||
reconstruction"). The procedure:
|
||||
|
||||
1. Reconstruct the class hierarchy and virtual-function signatures from the
|
||||
Ghidra-recovered vtables.
|
||||
2. Verify slot order with `g++ -fdump-lang-class` and compare the emitted vtable
|
||||
slot order against Ghidra's; they must agree slot for slot.
|
||||
3. Let the toolchain emit RTTI; never hand-build `type_info`.
|
||||
|
||||
## Function naming and forwarding
|
||||
|
||||
Each undecompiled routine is named `FUN_<rva>` by Ghidra (lowercase hex RVA,
|
||||
image base excluded). Reconstruction renames it to a semantic name in the
|
||||
module namespace (e.g. `gk::audio::MixSample`) and pins the origin in a comment
|
||||
the differ reads back: `// rva=0x10023af0 (orig FUN_10023af0)`. One RVA maps to
|
||||
exactly one semantic name, recorded in the function's claim entry so the mapping
|
||||
stays reversible; an existing import/export symbol is kept as the semantic name
|
||||
(`docs/conventions.md`, "Function naming").
|
||||
|
||||
A function may be forwarded (left as a call into the original image) only if
|
||||
neither it nor any callee writes a global that non-forwarded code reads. If a
|
||||
forwarded routine and a reconstructed routine both touch the same global, state
|
||||
drifts, so the function must be reconstructed instead (`docs/conventions.md`,
|
||||
"Global ownership").
|
||||
|
||||
## Macro cross-check
|
||||
|
||||
The `GK_` macro names in `docs/conventions.md` and `include/gk/types.h` must
|
||||
match exactly. The macros in scope are `GK_CDECL`, `GK_STDCALL`, `GK_THISCALL`,
|
||||
`GK_PRAGMA`, `GK_PACK_PUSH`, and `GK_PACK_POP`, cross-checked with:
|
||||
|
||||
```
|
||||
grep -o 'GK[_][A-Z_]*' docs/conventions.md include/gk/types.h | sort -u
|
||||
```
|
||||
|
||||
(`docs/conventions.md`, "Macro cross-check").
|
||||
@@ -0,0 +1,285 @@
|
||||
# 09 - The kdm-re reconstruction codebase
|
||||
|
||||
This section documents the `kdm-re` repository itself: the layout, the no-sudo
|
||||
cross-build, the verification harnesses, the three cutover build modes, and the
|
||||
per-function loop that turns one shipping `FUN_<rva>` into a proven MinGW C++
|
||||
reconstruction. It is the engineering counterpart to the subsystem analysis in
|
||||
[./06-gamekdm-subsystems.md](./06-gamekdm-subsystems.md); the companion-DLL and
|
||||
AVS detail it leans on lives in [./07-companion-dlls.md](./07-companion-dlls.md)
|
||||
and [./08-libavs.md](./08-libavs.md).
|
||||
|
||||
Everything below is grounded in the tree at `/home/athapa/kdm-re` as it stands.
|
||||
Scope note: the reconstruction is early. The canonical RVA database carries
|
||||
`9728` function records and, at this writing, exactly one is `verified` and
|
||||
`9727` are still `orig` (unclaimed), confirmed by reading `re/rvadb.json`
|
||||
(`function_count` = 9728; status histogram `Counter({'orig': 9727,
|
||||
'verified': 1})`). The three-function proven slice is tracked through a separate
|
||||
evidence overlay (`re/pure-slice-status.json`), not the canonical statuses.
|
||||
|
||||
## 1. Repository layout
|
||||
|
||||
Top level of the checkout (`ls` of `/home/athapa/kdm-re`):
|
||||
|
||||
| Path | Purpose |
|
||||
| --- | --- |
|
||||
| `CMakeLists.txt` | Build driver for all three modes (hybrid proxy, PURE full, PURE slice). |
|
||||
| `activate.sh` | Sources Nix and puts the pinned i686 cross toolchain + wine on `PATH`. |
|
||||
| `toolchain.lock` | Pins nixpkgs rev, GCC/mingw/wine versions, mcfgthread store path. |
|
||||
| `cmake/` | `toolchain-mingw-i686.cmake` (cross toolchain file) and `check_pure_coverage.py` (the coverage gate). |
|
||||
| `include/gk/` | Reconstructed-source headers: `types.h` (ABI macros), `manager.h`, `offsets_assert.h`, and `structs/` (`math.h`, `validity.h`, `skeleton.h`, `manager.h`). |
|
||||
| `src/` | Reconstruction source, sharded by module: `entry/`, `game/`, `hybrid/`, `pure/`, plus still-empty module dirs (`gs/`, `mm/`, `movie/`, `particle/`, `platform/`, `render/`, `ui/`, `util/`). |
|
||||
| `re/` | The RE data lock: `rvadb.json` (canonical function DB), `importlibs/` (companion `.def` + generated `.dll.a`), `avs/` (companion proofs), `pure-slice-status.json`. |
|
||||
| `tools/` | `ghidra/` (DB export/validate), `unicorn_diff/` (differential harness), `gen_importlibs.sh`. |
|
||||
| `tests/golden/` | Standalone golden-I/O replay harness and fixtures. |
|
||||
| `docs/` | `pipeline.md`, `cutover.md`, `reconstruction-loop.md`, `conventions.md`, and this `spec/`. |
|
||||
| `orig/`, `export/`, `bin/` | Gitignored originals drop zone, the hand-authored `gamekdm.def`, and the `activate.sh`-generated tool aliases. |
|
||||
|
||||
Source modules carry one reconstructed function per concern. The three that
|
||||
actually compile today are `src/game/box_distance.cpp`
|
||||
(`gk::game::BoxDistanceSquared`, rva `0x001ab6d0`), `src/game/validity.cpp`
|
||||
(`UpdateValidityCandidates`, rva `0x000e4140`), and `src/game/nui_elevation.cpp`
|
||||
(`UpdateCameraElevation`, rva `0x0000f510`), as named in
|
||||
`docs/reconstruction-loop.md` and wired into `CMakeLists.txt:46-50`.
|
||||
|
||||
## 2. Build system
|
||||
|
||||
### No-sudo cross toolchain
|
||||
|
||||
The build targets a 32-bit Windows DLL and never touches system packages. Every
|
||||
tool comes from a user-space Nix profile pinned in `toolchain.lock` (nixpkgs rev
|
||||
`619c39f6eac5d1ed6b8f073a9414baf7034b2356`, GCC 16.2.0 / mingw-w64 14.0.0, wine
|
||||
11.0, per `docs/pipeline.md` section 0). `activate.sh` sources
|
||||
`~/.nix-profile/etc/profile.d/nix.sh`, prepends `~/.nix-profile/bin` plus a
|
||||
worktree-local `bin/`, and symlinks the bare `dlltool`, `gendef`, and `objdump`
|
||||
names onto their `i686-w64-mingw32-` prefixed binaries (`activate.sh:17-33`). It
|
||||
must be sourced, not executed, and returns non-zero with recovery guidance when
|
||||
a tool is missing (`activate.sh:5-8`) so a broken toolchain never looks clean.
|
||||
|
||||
### CMake toolchain file
|
||||
|
||||
`cmake/toolchain-mingw-i686.cmake` sets `CMAKE_SYSTEM_NAME Windows`,
|
||||
`CMAKE_SYSTEM_PROCESSOR x86`, and the `i686-w64-mingw32-` compiler/windres/
|
||||
dlltool prefix (lines 15-24). The decisive choice is static linking: the
|
||||
original `gamekdm.dll` was built by MSVC with a statically linked CRT and
|
||||
imports zero C/C++ runtime DLLs, so the rebuild must match that import shape or
|
||||
it is not a drop-in replacement. The file seeds
|
||||
`CMAKE_{EXE,SHARED,MODULE}_LINKER_FLAGS_INIT` with
|
||||
`-static-libgcc -static-libstdc++ -static` and a `-L` onto the pinned
|
||||
`mcfgthread` lib dir (toolchain file final three `set()` lines). Plain `-static`
|
||||
forces even `-lmcfgthread`, pulled in by GCC 16.2.0's default link spec, to
|
||||
resolve against its `.a` instead of its import library, so no
|
||||
`libgcc_s_dw2-1.dll` / `libstdc++-6.dll` / `libmcfgthread-*.dll` import leaks in.
|
||||
|
||||
### The default hybrid build
|
||||
|
||||
With no options, `CMakeLists.txt` builds `gamekdm` as a SHARED library from the
|
||||
single TU `src/entry/gamemain.cpp` (`CMakeLists.txt:88`), links the hand-written
|
||||
`export/gamekdm.def` so only `gameMain` is exported at ordinal 1
|
||||
(`CMakeLists.txt:100-106`), and also builds the T12 detour static library
|
||||
`gamekdm_detours` (from `src/hybrid/detours.cpp` + `src/game/box_distance.cpp`)
|
||||
and its `gamekdm_detour_test` host. The detour TU compiles with
|
||||
`-mfpmath=387 -ffp-contract=off -fno-fast-math -fno-exceptions -fno-rtti`
|
||||
(`CMakeLists.txt:120-121`) to match the original's float model. Build and
|
||||
confirm the export table with:
|
||||
|
||||
```bash
|
||||
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 (`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<name>.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.
|
||||
|
||||
### PURE build modes and the coverage gate
|
||||
|
||||
Two options switch the build away from the hybrid proxy
|
||||
(`CMakeLists.txt:4-5`):
|
||||
|
||||
- `BUILD_PURE=ON` excludes the proxy and detour targets entirely and never links
|
||||
an original DLL or its import libs.
|
||||
- `PURE_SLICE=ON` (only meaningful with `BUILD_PURE`) builds the three-function
|
||||
verified slice plus explicit remainder stubs.
|
||||
|
||||
Both run `cmake/check_pure_coverage.py` against `re/rvadb.json` at configure time
|
||||
and as an `ALL` custom target before each build (`CMakeLists.txt:17-42`). The
|
||||
gate is fail-closed:
|
||||
|
||||
- **Full mode** treats every recorded function as a root, traverses the `callees`
|
||||
graph, and fails unless the whole DB is `status=verified` (`verified ==
|
||||
len(records)`, no rounding). Today that is `1/9728`, so full mode fails with
|
||||
`not yet at coverage` by design (`check_pure_coverage.py`, `main()` final
|
||||
check). Even once metadata hits 100%, `CMakeLists.txt:45-48` still aborts full
|
||||
mode with a `FATAL_ERROR`, because the complete reconstructed source graph and
|
||||
entry point are not integrated. That refusal is deliberate and must not be
|
||||
swapped for the proxy.
|
||||
- **Slice mode** roots only `0x0000f510`, `0x000e4140`, `0x001ab6d0`
|
||||
(`SLICE_ROOTS` in `check_pure_coverage.py`), accepts the three
|
||||
`status=verified` claims from the evidence overlay `re/pure-slice-status.json`,
|
||||
and skips three substitution RVAs during traversal: the two clamp helpers
|
||||
`0x001ab5b0` / `0x001ab640` (reconstructed inline) and `0x001db674` (the MSVC
|
||||
security cookie supplied by the new toolchain), per `SLICE_SUBSTITUTIONS`.
|
||||
These substitutions never apply to the full gate.
|
||||
|
||||
`PURE_REQUIRE_RVA` adds extra mandatory roots but cannot relax coverage; passing
|
||||
`-DPURE_REQUIRE_RVA=0x00009e20` forces a `not yet at coverage` failure naming
|
||||
`gameMain`, which is how `docs/cutover.md` proves a new internal dependency can't
|
||||
silently enter the slice.
|
||||
|
||||
## 3. The proxy, the detour carve-out, and the pure slice
|
||||
|
||||
**Proxy (`src/entry/gamemain.cpp`).** The Phase-0 export is a forwarding proxy.
|
||||
`gameMain` only `LoadLibraryA("gamekdm_orig.dll")` at call time, resolves the
|
||||
original `gameMain` by name then ordinal 1, forwards `hInstance`, and returns the
|
||||
original's result (`src/entry/gamemain.cpp:37-73`). It is declared `GK_CDECL`
|
||||
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
|
||||
(`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
|
||||
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).
|
||||
|
||||
**Detour carve-out (`src/hybrid/`).** The T12 installer hot-patches a
|
||||
reconstruction into the loaded original image, but only for an immutable
|
||||
allowlist. `src/hybrid/detours.h` hardcodes three `Entry` rows with an
|
||||
`Ownership` verdict each: `BoxDistanceSquared` (`0x1ab6d0`) is `pod_only`
|
||||
(allowed), `UpdateValidityCandidates` (`0x0e4140`) is `shared_mutable_globals`
|
||||
(blocked), and `UpdateCameraElevation` (`0x00f510`) is `foreign_object_abi`
|
||||
(blocked). `set_enabled` returns `ownership_blocked` for anything but
|
||||
`pod_only`, and unknown RVAs can't be hooked at all. The handwritten x86
|
||||
trampoline supports only `0x1ab6d0`: its first six bytes are three whole
|
||||
instructions with no relative operands, checked before patching, copied to an
|
||||
executable trampoline, then followed by a jump back; an ABI adapter maps the
|
||||
original EAX/EDI args to the cdecl POD reconstruction and returns ST0
|
||||
(`src/hybrid/README.md`). Original data is addressed in its owning image via
|
||||
`at_rva` (`slide = base - 0x10000000`), never copied into the CRT. The tested
|
||||
input DLL SHA-256 is pinned in the README as
|
||||
`0595cb1dd98e4c02e2700f22f29d6504a9a74b401238ba5ec539d666ee8f0804`.
|
||||
|
||||
**Pure slice (`src/pure/`).** `src/pure/slice.cpp` exports a slice-only
|
||||
`gameMain` that is an explicit unsupported stub returning `-17`, plus a
|
||||
`pure_slice_self_test` that drives all three reconstructed routines against known
|
||||
inputs and returns 0 on success. The camera interface terminates at a `MockSensor`
|
||||
implementing `ICameraElevation` (`GetAngle` returns 7, `SetAngle` records the
|
||||
applied value), never a Kinect or original binary. `src/pure/mock_host.cpp`
|
||||
`LoadLibraryA`s the slice DLL, asserts `pure_slice_self_test() == 0` and
|
||||
`gameMain(nullptr) == -17`, and prints `PURE_SLICE_LOAD_PASS`. The slice DLL is
|
||||
named `gamekdm_pure_slice.dll`, deliberately different from the shipping name.
|
||||
|
||||
## 4. Verification system
|
||||
|
||||
Three independent gates, all reproducible on Linux with no network and no game
|
||||
binary beyond the owner's legally-possessed originals.
|
||||
|
||||
### Unicorn per-function differential (`tools/unicorn_diff/`)
|
||||
|
||||
This is the universal gate. For each reconstructed function it emulates the real
|
||||
routine inside the shipping `gamekdm.dll` under Unicorn (original-as-oracle) and
|
||||
runs the compiled C++ reconstruction under wine on the same inputs, then asserts
|
||||
behavioural equality; it also injects a known bug to prove the comparison can
|
||||
fail (non-vacuity). The oracle binary path is pinned in
|
||||
`tools/unicorn_diff/prove_t11.py` (`DLL = Path("/home/athapa/ghidra/gamekdm.dll")`).
|
||||
The `udiff` package carries the pieces: `runner.py` (Unicorn register/stack
|
||||
setup, `CallSpec`/`ReturnKind` from `abi.py`), `image.py` (PE mapping and scratch
|
||||
layout), `result.py` (global deltas), and `metadata.py` (calling convention from
|
||||
the DB).
|
||||
|
||||
Float fidelity is where this harness earns its keep. `udiff/fp.py`'s
|
||||
`capture_st0` reads the physical x87 register `FP[TOP]` including the exponent,
|
||||
because `UC_X86_REG_ST0` omits it, and raises if a float return is declared but
|
||||
`ST(0)` is empty. `detect_fp` classifies a bounded disassembly into x87 vs SSE
|
||||
scalar sites and derives the exact compiler flags (`-mfpmath=387` for x87,
|
||||
`-mfpmath=sse -msse2` for SSE, always `-ffp-contract=off -fno-fast-math`), and
|
||||
refuses to guess on a mixed function. Those are the same flags the harness build
|
||||
command uses (`docs/pipeline.md` section 5a). Expect `ALL DIFFERENTIALS PASS`,
|
||||
exit 0.
|
||||
|
||||
### Golden I/O harness (`tests/golden/`)
|
||||
|
||||
A stdlib-only supplement (T9) that replays committed `(input -> expected-output)`
|
||||
tuples recorded from existing introspection dumps against an independent
|
||||
reconstruction, within a float tolerance, with no binary, wine, or network
|
||||
(`tests/golden/README.md`). It covers three subsystems with committed fixtures
|
||||
(`depth_projection.json`, `validity_gate.json`, `pose_ref.json` + `ref.txt`).
|
||||
Non-vacuity is built in: `--perturb FIELD` nudges one constant so the assertions
|
||||
fail on purpose, and `run.sh` reports `VACUITY VIOLATION` if any perturbed run
|
||||
still passes. Expect `GOLDEN HARNESS OK: clean run passed and every perturbation
|
||||
failed.`, exit 0.
|
||||
|
||||
### Wine load-smoke
|
||||
|
||||
A tiny `LoadLibraryA` loader built under the cross toolchain confirms the rebuilt
|
||||
`gamekdm.dll` loads under wine and still exports `gameMain`
|
||||
(`docs/pipeline.md` section 5c). Because the proxy resolves the original lazily,
|
||||
this needs no original present.
|
||||
|
||||
## 5. The per-function reconstruction loop
|
||||
|
||||
`docs/reconstruction-loop.md` is the repeatable procedure for turning one
|
||||
`FUN_<rva>` into a verified reconstruction. The status field in `re/rvadb.json`
|
||||
is both the progress marker and the inter-worker lock, with four values enforced
|
||||
by `tools/ghidra/validate_rvadb.py`: `orig` (unclaimed), `reimpl` (owned, in
|
||||
progress), `stub`, and `verified` (terminal).
|
||||
|
||||
1. **Claim (`orig -> reimpl`).** Flip the status and commit the DB alone before
|
||||
working, so the lock is visible on the next pull. One RVA, one owner.
|
||||
2. **Decompile** the claimed function headless from the already-analyzed Ghidra
|
||||
project (`gkproj` for `gamekdm.dll`, per-companion projects otherwise) with
|
||||
`-noanalysis -readOnly`, and read the raw disasm for calling convention, FP
|
||||
model, and struct field accesses.
|
||||
3. **Clean to MinGW C++** in the right `src/` module per `docs/conventions.md`:
|
||||
pin the origin (`// rva=...`), state the convention with `GK_CDECL` /
|
||||
`GK_STDCALL` / `GK_THISCALL` from `include/gk/types.h`, match MSVC struct
|
||||
layout (natural alignment or `GK_PACK_PUSH/POP`), and match the FP model.
|
||||
4. **Verify** with the Unicorn differential (and the golden harness where a
|
||||
fixture exists), adding the function's `CallSpec` to the proof.
|
||||
5. **Register the detour** only if the function is a POD-in/POD-out stateless
|
||||
leaf (the `pod_only` ownership rule); blocked functions are still
|
||||
reconstructed and verified, just not hot-patched.
|
||||
6. **Mark verified (`reimpl -> verified`)** once the differential passes, then
|
||||
re-run `validate_rvadb.py` before committing.
|
||||
|
||||
Two standing gates sit over the loop. The **globals-first gate** forbids marking
|
||||
a function `verified` until every global it reads and every callee it depends on
|
||||
is already verified (each row carries `globals_touched` and `callees`). The
|
||||
**Track-B modding seam** rule keeps song/content/chart boundaries as named,
|
||||
non-inlined functions with stable signatures so the later modding toolkit can
|
||||
hook or replace them, overriding the usual "no helper for a hypothetical need"
|
||||
instinct for those planned hook points. Parallel workers shard by RTTI/namespace
|
||||
cluster and coordinate shared struct layouts through single-owner headers in
|
||||
`include/gk/structs`.
|
||||
|
||||
## 6. Cutover status
|
||||
|
||||
`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
|
||||
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
|
||||
as a fallback.
|
||||
|
||||
See also [./06-gamekdm-subsystems.md](./06-gamekdm-subsystems.md) for what these
|
||||
reconstructed functions actually do inside the game, and
|
||||
[./07-companion-dlls.md](./07-companion-dlls.md) for the companion DLLs whose
|
||||
import libraries `gen_importlibs.sh` produces.
|
||||
@@ -0,0 +1,162 @@
|
||||
# DanceEvolution Arcade (KDM) — Technical Specification
|
||||
|
||||
This is the master index for the full technical specification of
|
||||
**DanceEvolution Arcade** (DEA), a Konami arcade Kinect dance game shipped
|
||||
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
|
||||
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
|
||||
creative asset (song audio, video, lyrics, or art) is reproduced anywhere in
|
||||
this spec; only file formats, code structure, and behavior are described.
|
||||
|
||||
## Table of contents
|
||||
|
||||
| # | 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. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 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.
|
||||
|
||||
## The three dimensions
|
||||
|
||||
Every section above is organized along one (or more) of three axes, following
|
||||
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 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
|
||||
GAME-dimension with an ORIGINAL-dimension RVA/evidence layer underneath (04 in
|
||||
particular straddles GAME and ORIGINAL, since the validity gate and cursor are
|
||||
both observable game behavior *and* disassembled binary routines); 02, 06, 07
|
||||
are ORIGINAL; 08 bridges ORIGINAL (the facts being matched) and RECONSTRUCTION
|
||||
(the macros/headers that encode them); 09 is pure 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 `<model>KDM</model>` in `ea3-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
|
||||
(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
|
||||
`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).
|
||||
- **AVS2** — "Application/Audio-Visual System v2," Konami's core middleware
|
||||
runtime (`libavs-win32.dll`): property-tree config store, virtual
|
||||
filesystem, and thread/mutex/event primitives underlying every other
|
||||
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)).
|
||||
- **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)).
|
||||
- **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
|
||||
[04](./04-validity-cursor.md) §5).
|
||||
- **RVA DB / `re/rvadb.json`** — the canonical per-function database for
|
||||
`gamekdm.dll`: 9,728 records (`function_count = 9728`), each with `rva`,
|
||||
`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)).
|
||||
- **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++
|
||||
reconstruction under wine on the same inputs, asserting behavioral
|
||||
equality, with an injected-bug non-vacuity check (see
|
||||
[09](./09-reconstruction-codebase.md) §4).
|
||||
- **Detour** — a hot-patch of a reconstructed function into the loaded
|
||||
*original* image at runtime, restricted by an ownership allowlist
|
||||
(`pod_only` functions only; `shared_mutable_globals` and
|
||||
`foreign_object_abi` functions are blocked from detouring even though they
|
||||
are reconstructed and verified) (see [09](./09-reconstruction-codebase.md) §3).
|
||||
- **PURE build** — the reconstruction build mode that excludes the proxy and
|
||||
detour targets and never links an original DLL; gated by a fail-closed
|
||||
coverage check (`cmake/check_pure_coverage.py`) that, in full mode, demands
|
||||
100% `verified` status across the whole call graph before it will build at
|
||||
all (see [09](./09-reconstruction-codebase.md) §2).
|
||||
|
||||
## Grounding and scope
|
||||
|
||||
- **Behavioral, not byte-identical.** The reconstruction's goal is to
|
||||
reproduce `gamekdm.dll`'s observable behavior (given the same inputs, the
|
||||
same outputs and global-state effects), proven function-by-function via the
|
||||
Unicorn differential and golden-I/O harnesses. It does not aim to byte-match
|
||||
the original compiled machine code; the toolchain (MinGW/GCC targeting x86)
|
||||
differs from the original's MSVC/VS2010 SP1 toolchain by construction, and
|
||||
the ABI/FP-model conventions in [08](./08-abi-conventions.md) exist
|
||||
precisely to keep that different toolchain producing matching behavior
|
||||
(register-level calling convention, x87 vs. SSE float model, MSVC struct
|
||||
packing, Itanium-vs-MSVC vtable/RTTI layout handled explicitly rather than
|
||||
memcpy'd).
|
||||
- **Copyrighted creative assets are out of scope for reproduction.** No song
|
||||
audio, video, lyrics, or art is reproduced anywhere in this spec or the
|
||||
reconstruction codebase; [05](./05-data-formats.md) describes container
|
||||
*formats* and directory *structure* only, never asset content.
|
||||
- **Coverage is early and explicitly tracked, not implied.** As of this
|
||||
writing, `re/rvadb.json` records exactly 1 of 9,728 functions as
|
||||
`verified` (confirmed via `re/pure-slice-status.json` and the status
|
||||
histogram in [09](./09-reconstruction-codebase.md) §1); the subsystem map
|
||||
in [06](./06-gamekdm-subsystems.md) classifies only ~2.7% of functions into
|
||||
a named subsystem by design (positive-evidence-only attribution, not a
|
||||
claim about the unclassified 97.3%). Any claim about "what a function does"
|
||||
beyond a function explicitly reconstructed, decompiled, or cited to a
|
||||
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
|
||||
`.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
|
||||
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
|
||||
this spec as a defect rather than treating it as established fact.
|
||||
Reference in new issue
Block a user