Files
kdm-re/include/gk/types.h
T

46 lines
2.0 KiB
C++

#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").