chore(repo): layered source tree + CMake mingw toolchain + gamekdm.def

This commit is contained in:
ulw-execute committed 2026-11-28 03:42:33 -05:00
1 parent 111bb3371b
commit 091dd18d9e
22 files changed
+170 -1

No files matched your search

+6 -1
View File
@@ -1,10 +1,15 @@
.omo/ .omo/
build/ build/
orig/ orig/*
!orig/.gitkeep
*.dll *.dll
*.a *.a
*.o *.o
*.exe *.exe
*.i64
*.idb
*.asm.txt
decompiled/
.venv/ .venv/
venv/ venv/
__pycache__/ __pycache__/
+31
View File
@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 3.16)
project(gamekdm LANGUAGES C CXX)
# 32-bit Windows DLL, built with the pinned i686-w64-mingw32 cross toolchain
# (see cmake/toolchain-mingw-i686.cmake, toolchain.lock). The real shipping
# gamekdm.dll's reconstructed source lands in src/* over subsequent tasks;
# today's target is a minimal stub so the layered tree + build + export
# table shape is proven before any real logic is reconstructed.
add_library(gamekdm SHARED
src/entry/gamemain.cpp
)
target_include_directories(gamekdm PRIVATE
${CMAKE_SOURCE_DIR}/include
)
set_target_properties(gamekdm PROPERTIES
OUTPUT_NAME "gamekdm"
PREFIX ""
SUFFIX ".dll"
)
# Link with the hand-authored .def so ONLY gameMain is exported, at ordinal 1,
# matching the original DLL's export table (no CRT/C++ name-mangled exports).
target_link_options(gamekdm PRIVATE
"${CMAKE_SOURCE_DIR}/export/gamekdm.def"
)
set_target_properties(gamekdm PROPERTIES
LINK_DEPENDS "${CMAKE_SOURCE_DIR}/export/gamekdm.def"
)
+14
View File
@@ -0,0 +1,14 @@
All Rights Reserved (placeholder, unlicensed)
Copyright (c) 2026, the repository owner. All rights reserved.
This repository's reconstructed source is PRIVATE and UNLICENSED for the
time being. No license to use, copy, modify, merge, publish, distribute,
sublicense, or sell any part of this repository is granted. The final
license for this project (if any) has not yet been decided by the owner.
No third-party license text is incorporated into this file or this
repository by virtue of this placeholder.
See docs/provenance.md for the origin of the reconstructed source and the
handling of original game binaries.
+38
View File
@@ -0,0 +1,38 @@
# CMake cross-compilation toolchain file for the Windows (32-bit) build of
# gamekdm.dll, targeting i686-w64-mingw32 with the pinned no-sudo Nix toolchain
# recorded in ../toolchain.lock (GCC 16.2.0, mingw-w64 14.0.0 headers/CRT).
#
# Usage (after `source ./activate.sh` to put the cross toolchain on PATH):
# cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw-i686.cmake
# cmake --build build
#
# Pattern reused/adapted from ~/kinect/cmake/mingw-w64.cmake, fixed to the
# i686 (32-bit) target that matches the shipping gamekdm.dll's bitness
# (confirmed PE32 by `objdump -f` on the stub build; see task-2.log).
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86)
set(_gk_mingw_prefix i686-w64-mingw32)
set(CMAKE_C_COMPILER ${_gk_mingw_prefix}-gcc)
set(CMAKE_CXX_COMPILER ${_gk_mingw_prefix}-g++)
set(CMAKE_RC_COMPILER ${_gk_mingw_prefix}-windres)
set(CMAKE_RC_COMPILER_INIT ${_gk_mingw_prefix}-windres)
find_program(CMAKE_DLLTOOL NAMES ${_gk_mingw_prefix}-dlltool dlltool)
set(CMAKE_FIND_ROOT_PATH /usr/${_gk_mingw_prefix})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# GCC 16.2.0's i686-w64-mingw32 default link spec needs -lmcfgthread, which
# ships as its own Nix package (pkgsCross.mingw32.windows.mcfgthreads) rather
# than bundled with the gcc derivation itself; point the linker at its lib
# dir explicitly for every link (shared libs/DLLs and any executables alike).
# Store path pinned in ../toolchain.lock; keep in sync if the pin moves.
set(_gk_mcfgthread_lib "/nix/store/g72bh3mrbh6gkh59axd2199js9kccxfs-mcfgthread-i686-w64-mingw32-2.5.1/lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${_gk_mcfgthread_lib}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${_gk_mcfgthread_lib}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L${_gk_mcfgthread_lib}")
+21
View File
@@ -0,0 +1,21 @@
# Provenance
This repository reconstructs source for `gamekdm.dll` as part of a
game-preservation / reverse-engineering effort. The reconstructed C/C++
source under `src/` and `include/` is derived from static and dynamic
analysis (disassembly, decompiler output, runtime tracing) of a binary the
repository owner legally possesses.
- `orig/` is where the original game binary (and any other original game
files needed as reconstruction input) is placed locally. It is gitignored
(except for its `.gitkeep` placeholder) and is never committed.
- Decompiler-generated intermediate dumps (disassembly listings, decompiler
project databases, raw pseudocode dumps) are working inputs only; they are
kept out of git (see `.gitignore`) and are not treated as the
authoritative source. The hand-reviewed, hand-named reconstruction checked
into `src/`/`include/` is authoritative.
- No original game binary, asset, or third-party copyrighted material is
ever committed to this repository.
- Licensing for this project's own reconstructed source is **TBD**: see
`LICENSE` for the current private/all-rights-reserved placeholder. The
owner has not yet decided on a final license.
+3
View File
@@ -0,0 +1,3 @@
LIBRARY "gamekdm.dll"
EXPORTS
gameMain @1
View File
Whitespace-only changes.
+6
View File
@@ -0,0 +1,6 @@
#pragma once
// TODO(T7): the live manager struct (the central game-state/subsystem
// registry gamekdm.dll's entry point builds up and hands to subsystems) is
// reconstructed from static/dynamic analysis of orig/gamekdm.dll in task T7.
// This header is a placeholder so later tasks have a stable include path
// (include/gk/manager.h) to populate without reshuffling src/ includes.
View File
Whitespace-only changes.
+45
View File
@@ -0,0 +1,45 @@
#pragma once
// gamekdm reconstructed-source types: fixed-width integer includes and
// MSVC-matching calling-convention / layout macros. The original gamekdm.dll
// was built with MSVC (cl.exe) for 32-bit Windows (__cdecl default, but many
// internal entry points/vtables use __stdcall or __thiscall); GCC/MinGW is
// ABI-compatible with these calling conventions on i686, so the macros below
// just name the convention explicitly at each declaration site so a reader
// (and a future llvm-mingw/clang-cl cross-check) can see which ABI a given
// function uses without guessing.
#include <cstdint>
#include <cstddef>
#if defined(__GNUC__)
# define GK_CDECL __attribute__((cdecl))
# define GK_STDCALL __attribute__((stdcall))
# define GK_THISCALL __attribute__((thiscall))
#elif defined(_MSC_VER)
# define GK_CDECL __cdecl
# define GK_STDCALL __stdcall
# define GK_THISCALL __thiscall
#else
# error "gk/types.h: unsupported compiler for calling-convention macros"
#endif
// MSVC-matching struct packing guidance:
//
// The original binary was compiled by MSVC with its default struct packing
// (natural alignment, i.e. #pragma pack(8) equivalent on x86 unless the
// source explicitly set a tighter pack). Any reconstructed struct in
// include/gk/structs/ that must match the original's binary layout (parsed
// from the binary via static/dynamic analysis in later tasks) MUST either:
// 1. rely on natural alignment matching MSVC's default (true for most
// int/float/pointer-only structs on x86), or
// 2. bracket itself with an explicit pack pragma reproducing MSVC's pack
// state at that point in the original translation unit, e.g.:
//
// #pragma pack(push, 1)
// struct SomePackedThing { /* ... */ };
// #pragma pack(pop)
//
// GCC/Clang both honor `#pragma pack` identically to MSVC, so no GK_PACK_*
// macro is introduced here; use the pragma directly at each struct that
// needs it, and comment the source of the packing evidence (e.g. "offsets
// confirmed via Ghidra struct editor on orig/gamekdm.dll").
View File
Whitespace-only changes.
+6
View File
@@ -0,0 +1,6 @@
#include "gk/types.h"
extern "C" int gameMain(void* hInstance) {
(void)hInstance;
return 0;
}
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.