Files
kdm-re/docs/companion-conventions.md
ulw-execute 3910630c25 docs: mark release-difference facts verified; fix doc inconsistencies
Owner confirmed the differing sizes/export counts/RVAs are just a different
release of the same official game. Remove the "pending re-check against
clean-release binary" / "contaminated install" caveats throughout and state
those numbers (module sizes, export counts, gameMain RVA 0x9e20) as verified
facts. Drop the stale 3,369,104-byte gamekdm figure in favor of the
consistent 3.19 MB. Genuine format/behavior UNVERIFIED markers (undecoded
.arc/.ifs/.ttc/etc. formats, Kinect dispatch/sync) are preserved.
2026-11-28 21:01:37 -05:00

5.2 KiB

Companion DLL calling conventions

Regenerated by tools/gen_importlibs.sh into re/importlibs/. Convention and binding mode for each companion, derived by disassembling gamekdm.dll's own call sites against its Import Address Table (IAT): a call DWORD PTR ds:0x<iat> followed by the caller popping the arguments itself (add esp,N, or the callee returning with a plain ret while the caller already stacked a compensating pop) is cdecl; a callee that returns with ret N and the caller performs no stack fixup is stdcall. Full objdump excerpts and the gendef/dlltool transcript are in .omo/evidence/gamekdm-decomp-linux/task-3.log.

The official release contains exactly nine Konami modules under contents/modules/: libavs-win32.dll, libavs-win32-ea3.dll, libafp-win32.dll, libafputils-win32.dll, ess.dll, libacio.dll, arkkdm.dll, arkkdmtest.dll, and gamekdm.dll. Kinect10.dll is an external Microsoft NUI runtime dependency of gamekdm.dll, not a shipped companion.

DLL Convention Evidence Binding --kill-at
libavs-win32.dll cdecl IAT 0x102183cc etc.: callers emit add esp,N after the call by name (vendor exports via synthetic hashed names, e.g. XCd229cc0000fb, not ordinal-only — confirmed in the DLL's own export name table, not just gendef's fallback) no
libavs-win32-ea3.dll cdecl same vendor build as libavs-win32.dll, same export-naming scheme (XE592acd...) by name no
libafp-win32.dll cdecl IAT 0x10218304 (afp_display_layer) etc.: caller pops its own argument after the call by name no
libafputils-win32.dll cdecl (logger entry points are cdecl-varargs) IAT 0x10218394/0x10218398/0x1021839c: caller issues one push per call and never relies on a callee ret N by name no
ess.dll cdecl not called directly through gamekdm's IAT (no ess.dll import block in gamekdm.dll); follows the plain, undecorated C export convention shared by every other Konami companion in this build and never emits @N-decorated symbols by name no
arkkdm.dll stdcall export ordinal 2, arkAFPBoot, RVA 0x52790: objdump -d on that RVA shows ret 0x4 at file offset 0x100527ca -- the callee pops its own stack frame, which only a stdcall (or fastcall) function does; gendef's arkAFPBoot@4 guess in the .def matches this disassembly exactly by name (the DLL's own export name table, objdump -p, stores arkAFPBoot undecorated, no @N; dlltool's decorated .def guess must have the @N stripped back off to bind to it) yes
libacio.dll cdecl not called directly through gamekdm's IAT; undecorated plain-C export names, same convention family as ess.dll by name no

arkkdmtest.dll and gamekdm.dll both export gameMain; the official arkkdm.dll entry path resolves that cdecl entry by name. They are not import libraries consumed by the reconstructed gamekdm.dll.

The external Microsoft Kinect10.dll uses stdcall. Its import-library binding details remain external-platform integration, not part of the shipped nine-module companion set.

--kill-at scope

Per i686-w64-mingw32-dlltool --help, -k/--kill-at "Kill @ from exported names": it strips (removes) the @N stdcall decoration dlltool would otherwise carry into the generated import name -- it does not add an @N suffix, and it has no effect on calling convention at the ABI level (it never retags a cdecl import as stdcall or vice versa). It is passed for arkkdm.dll, the one shipped module in this set that is stdcall, because its export table holds the plain, undecorated name arkAFPBoot rather than a Name@N form -- gendef annotates every stdcall export it detects in the .def with a guessed @N (correctly, in arkAFPBoot's case: @4), and without --kill-at dlltool would emit an import-by-name entry like arkAFPBoot@4 that does not exist in the DLL's real, undecorated export table, so the import would fail to bind at load time. (The external Kinect10.dll NUI runtime dependency gets the same --kill-at treatment for the same reason, but it is not one of the nine shipped modules.) It is not passed for the six cdecl companions (AVS, AVS-EA3, AFP, AFPUtils, ESS, ACIO): their .def files carry no @N decoration for dlltool to strip in the first place (gendef only annotates stdcall exports), so --kill-at would be a no-op for them -- passing it was never the risk; the reason to omit it is that cdecl imports have nothing for it to act on, and AVS's logger entry points being cdecl-varargs rules out a fixed @N byte count for them regardless.

tests/importlibs/companion_link_test.c references one function from each generated import library with its correct calling convention, cross-compiled and linked into companion_link_test.dll. objdump -p on that DLL confirms every import resolves to its real companion name (or Kinect10 ordinal), with no unresolved symbols. A negative control removed one entry from libafp-win32.def before rebuilding its import lib and relinking: the link failed with an undefined reference to the removed symbol, proving the test actually exercises the generated libraries rather than passing vacuously. Transcript: .omo/evidence/gamekdm-decomp-linux/task-3.log.