Date: February 8, 2026
Scope: GeneralsMD and Generals source directories
Focus: Windows-specific functions and Linux port compatibility risks
This audit identifies 10 search patterns across the codebase. 5 are Windows-only (high risk for Linux), 3 are math utilities (platform-independent), and 2 patterns were not found. Total findings: 260+ matches, with most concentrated in debug/exception handling code.
Windows-specific debug function for outputting call stack traces via callback mechanism.
- Total matches: 31 (13 unique in GeneralsMD/Generals, 18 in references)
- Type: Declaration + Implementation + Empty stub (conditional)
| File | Lines | Usage Context |
|---|---|---|
| GeneralsMD/Code/GameEngine/Include/Common/StackDump.h | 34, 53 | Function declaration + empty inline stub |
| GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp | 60 | Function implementation |
| Generals/Code/GameEngine/Include/Common/StackDump.h | 34, 53 | Function declaration + empty inline stub |
| Generals/Code/GameEngine/Source/Common/System/StackDump.cpp | 60 | Function implementation |
- Code Type: Debug-only (guarded by
#if defined(RTS_DEBUG) || defined(IG_DEBUG_STACKTRACE)) - Linux Impact: BLOCKING - Requires complete reimplementation for Linux
- Dependencies:
- Uses
DbgHelpLoaderfor Windows symbol resolution - Uses Windows APIs directly (no POSIX equivalent in existing code)
- Currently has empty stub implementations for non-Windows builds
- Uses
- Backcompat: Windows builds unaffected (original code preserved behind
#ifdef)
- Empty inline stubs already exist for non-debug builds:
__inline void StackDump(...) {} - Reference implementations (fighter19) use
libunwindorbacktrace()for Linux - Linux stub is acceptable for MVP Phase 1 (graphics-first)
Converts pre-filled stack address array into human-readable stack trace with symbol information.
- Total matches: 28 (8 unique in GeneralsMD/Generals)
- Type: Declaration + Implementation + Empty stub
| File | Lines | Usage Context |
|---|---|---|
| GeneralsMD/Code/GameEngine/Include/Common/StackDump.h | 44, 59 | Declaration + empty stub |
| GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp | 439 | Implementation |
| Generals/Code/GameEngine/Include/Common/StackDump.h | 44, 59 | Declaration + empty stub |
| Generals/Code/GameEngine/Source/Common/System/StackDump.cpp | 439 | Implementation |
- Code Type: Debug-only (guarded preprocessor blocks)
- Linux Impact: BLOCKING - No Linux implementation
- Called By:
Debug.cpplines 314, 713, 808 (in references)GameMemory.cpplines 311, 1007 (address conversion)
- Implementation Strategy:
- Wraps result of
FillStackAddresses()with symbol details - Should use
addr2lineorlibunwindon Linux - Reference: fighter19 DXVK port has implementation
- Wraps result of
Captures raw return addresses from call stack into array.
- Total matches: 30 (10 unique in GeneralsMD/Generals)
- Type: Declaration + Implementation + Empty stub
| File | Lines | Usage Context |
|---|---|---|
| GeneralsMD/Code/GameEngine/Include/Common/StackDump.h | 41, 56 | Declaration + empty inline stub |
| GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp | 317 | Implementation |
| Generals/Code/GameEngine/Include/Common/StackDump.h | 41, 56 | Declaration + empty inline stub |
| Generals/Code/GameEngine/Source/Common/System/StackDump.cpp | 317 | Implementation |
- Code Type: Debug-only infrastructure
- Linux Impact: BLOCKING - Requires system-specific implementation
- Called By:
GameMemory.cppline 857, 1421 (memory debug tracking)Debug.cpp(exception handlers)
- Implementation Strategy:
- Currently uses Windows stack walking via
DbgHelpLoader - Linux alternatives:
backtrace()(glibc),libunwind, or GCC intrinsics - Empty stub acceptable for Phase 1
- Currently uses Windows stack walking via
Converts a single code address to function name, filename, and line number.
- Total matches: 34 (10 unique in GeneralsMD/Generals)
- Type: Declaration + Implementation + Empty stub + Usage
| File | Lines | Usage Context |
|---|---|---|
| GeneralsMD/Code/GameEngine/Include/Common/StackDump.h | 46, 61 | Declaration + empty stub |
| GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp | 248, 468 | Implementation + usage |
| GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp | 269 | Used in exception handler |
| Generals/Code/GameEngine/Include/Common/StackDump.h | 46, 61 | Declaration + empty stub |
| Generals/Code/GameEngine/Source/Common/System/StackDump.cpp | 248, 468 | Implementation + usage |
| Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp | 267 | Used in exception handler |
- Code Type: Debug-only symbol resolution
- Linux Impact: BLOCKING - Depends on
DbgHelpLoader - Usage Pattern:
- Called once per stack frame in
StackDumpFromAddresses() - Populates output: function name (256 chars), filename (256 chars), line number, address
- Called once per stack frame in
- Linux Strategy:
- Use
addr2line,dladdr(), or libunwind for symbol lookup - fighter19 reference has implementation
- Use
Windows-specific exception handler that outputs exception context and stack trace.
- Total matches: 28 (10 unique in GeneralsMD/Generals)
- Type: Declaration + Implementation (Windows-only) + Empty stub + Usage
| File | Lines | Usage Context |
|---|---|---|
| GeneralsMD/Code/GameEngine/Include/Common/StackDump.h | 49, 64 | Declaration + empty inline stub |
| GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp | 480, 645 | Implementation + empty stub |
| GeneralsMD/Code/Main/WinMain.cpp | 777 | CRITICAL - Structured Exception Handler (SEH) callback |
| GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp | 269 | Tool exception handler |
| Generals/Code/GameEngine/Include/Common/StackDump.h | 49, 64 | Declaration + empty inline stub |
| Generals/Code/GameEngine/Source/Common/System/StackDump.cpp | 480, 645 | Implementation + empty stub |
| Generals/Code/Main/WinMain.cpp | 755 | CRITICAL - Structured Exception Handler (SEH) callback |
| Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp | 267 | Tool exception handler |
- Code Type: Exception handling (runtime-critical on Windows)
- Linux Impact: BLOCKING - Depends on EXCEPTION_POINTERS (Windows-only type)
- Call Sites:
- WinMain.cpp line 777/755:
DumpExceptionInfo(e_info->ExceptionRecord->ExceptionCode, e_info);- This is in the top-level SEH handler for unhandled exceptions
- Windows-specific:
__try / __exceptblock
- WinMain.cpp line 777/755:
- Parameters:
- Takes
EXCEPTION_POINTERS*(platform-specific Windows type) - No cross-platform equivalent exists
- Takes
- Linux Strategy:
- Replace with POSIX signal handler (SIGSEGV, SIGABRT, etc.)
- Use
sigaction()instead of SEH - Can reuse
DumpExceptionInfologic but change parameter type - stub is acceptable (silent exception handling)
Static class for dynamic loading/unloading of Windows debug symbol library (dbghelp.dll).
- Total matches: 100+ (reduced scope, ~50 in GeneralsMD/Generals)
- Type: Static method calls (thread-safe, singleton)
| Method | Files | Count | Purpose |
|---|---|---|---|
DbgHelpLoader::isLoaded() |
StackDump.cpp | 2 | Check if dll loaded |
DbgHelpLoader::isFailed() |
StackDump.cpp | 2 | Check if load failed |
DbgHelpLoader::load() |
StackDump.cpp | 2 | Load dbghelp.dll |
DbgHelpLoader::unload() |
StackDump.cpp | 4 | Unload dbghelp.dll |
DbgHelpLoader::symSetOptions() |
StackDump.cpp | 2 | Configure symbol options |
DbgHelpLoader::symInitialize() |
StackDump.cpp | 2 | Init symbol engine |
DbgHelpLoader::symLoadModule() |
StackDump.cpp | 2 | Load module symbols |
DbgHelpLoader::stackWalk() |
StackDump.cpp | ~6 | Walk stack frames |
DbgHelpLoader::symGetSymFromAddr() |
StackDump.cpp | 2 | Get symbol from address |
DbgHelpLoader::symGetLineFromAddr() |
StackDump.cpp | 2 | Get source line info |
DbgHelpLoader::symFunctionTableAccess |
StackDump.cpp | ~4 | Function table callback |
DbgHelpLoader::symGetModuleBase |
StackDump.cpp | ~4 | Get module base address |
| File | Lines | Usage |
|---|---|---|
| GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp | 34 | Include |
| GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp | 123-407 | 40+ usages within StackDump functions |
| Generals/Code/GameEngine/Source/Common/System/StackDump.cpp | 34 | Include |
| Generals/Code/GameEngine/Source/Common/System/StackDump.cpp | 123-407 | 40+ usages within StackDump functions |
- Code Type: Windows-only system library (dbghelp.dll)
- Linux Impact: BLOCKING - No direct Linux equivalent for dbghelp
- Scope: All concentrated in
StackDump.cpp(debug initialization and symbol resolution) - Linux Strategy:
- Replace with libunwind + addr2line combination
- Or use backtrace()/backtrace_symbols() for basic stack traces
- Empty stub acceptable for Phase 1 (defer detailed symbol info)
Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.h
Key Features:
- Thread-safe singleton pattern (CriticalSection)
- Loads dbghelp.dll dynamically (not linked at compile time)
- Currently 223 lines of Windows-only code
- Already wrapped in
#ifdef _WIN32
RAII class to temporarily manage dbghelp.dll loading/unloading to prevent conflicts with AMD/ATI drivers.
- Total matches: 10 (4 unique in GeneralsMD/Generals primary code)
- Type: Stack-allocated RAII guard object (activate/deactivate)
| File | Lines | Usage |
|---|---|---|
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | 86 | Include directive |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | 341 | DbgHelpGuard dbgHelpGuard; instantiation |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | 599 | DbgHelpGuard dbgHelpGuard; instantiation |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | 645 | dbgHelpGuard.deactivate(); call |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | 83 | Include directive |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | 330 | Instantiation |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | 575 | Instantiation |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | 592 | deactivate() call |
- Code Type: Graphics initialization code (runtime)
- Linux Impact: NOT BLOCKING - Can be safely removed
- Context: Used in DirectX 8 device creation (dx8wrapper.cpp)
- Line 341: Inside
GetDeviceCaps()or similar DirectX init - Line 599: Inside graphics mode change sequence
- Line 341: Inside
- Linux Strategy:
- DbgHelpGuard becomes no-op class (empty implementation)
- Or: Remove entirely with conditional compilation
- No functional impact on graphics output
Core/Libraries/Source/WWVegas/WWLib/DbgHelpGuard.h (44 lines)
Purpose: Prevents AMD/ATI drivers from loading old dbghelp.dll version during game initialization.
Inline conversion function from game math matrices (Matrix3D or Matrix4x4) to DirectX D3DMATRIX.
- Total matches: 42 (21 unique in GeneralsMD/Generals)
- Type: Inline function calls (no definition found in matches, likely macro)
| File | Count | Lines |
|---|---|---|
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h | 8 | 1201, 1240, 1245, 1251, 1259, 1269, 1274, 1280 |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp | 3 | 1354, 1468, 1623 |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h | 8 | 1184, 1189, 1195, 1203, 1213, 1218, 1224 |
| Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp | 3 | 1248, 1362, 1517 |
- Code Type: Graphics rendering transformation matrix conversion
- Linux Impact: MANAGEABLE - Needs DXVK equivalent
- Usage Pattern:
- Called during graphics rendering setup
- Always converts game-internal matrices to DirectX matrices
- Lines primarily in
dx8wrapper.h(graphics abstraction) - Some in shadow volume rendering code
- Linux Strategy:
- DXVK handles D3DMATRIX internally
- May need adapter layer to convert to Vulkan matrix format
- Not code-blocking (just needs graphics layer replacement)
- Appears to be
#define To_D3DMATRIX(m) ...or inline function - 21 of 42 matches are in primary GeneralsMD/Generals
- Remaining are in references or duplicated declarations
- Total matches: 0 (PATTERN NOT FOUND)
This function/macro does not exist in the codebase. Only To_D3DMATRIX() exists.
Core game math classes for 3D and 4x4 matrix operations. These are platform-independent game logic utilities.
- Total matches: 100+ (representative sample)
- Type: Class instantiation, method calls, type conversions
| Category | File | Approx Lines |
|---|---|---|
| Declarations | Core/Libraries/Source/WWVegas/WW3D2/matrix3d.h | N/A (not searched) |
| Game Logic | GeneralsMD/Code/GameEngine/Source/.../*.cpp | 20+ usages |
| Graphics | GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/.../*.cpp | 30+ usages |
| Camera/View | GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp | 10+ usages |
| Shadows | GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/*.cpp | 15+ usages |
| Game Locomotion | GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp | 10+ usages |
- Code Type: Math utility classes (no platform dependencies)
- Linux Impact: NO IMPACT - Fully portable C++ code
- Implementation: Pure C++ math operations (no Win32/DirectX/Linux-specific code)
- Note: Matrix3D/Matrix4x4 can be directly used in DXVK Vulkan rendering path
Matrix3D: 3x4 affine transformation matrix (position + 3D rotation/scale)Matrix4x4: Full 4x4 matrix (used for projection matrices, 3D transformations)- Static methods:
Transform_Vector(),Rotate_Vector(),Inverse(), etc. - Used extensively: transforms, projections, shadows, camera math
| Header | Location | Primary Uses |
|---|---|---|
DbgHelpLoader.h |
Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.h | StackDump.cpp (debug symbol resolution) |
DbgHelpGuard.h |
Core/Libraries/Source/WWVegas/WWLib/DbgHelpGuard.h | dx8wrapper.cpp (graphics init) |
StackDump.h |
GeneralsMD/Code/GameEngine/Include/Common/ | Exception handlers, memory tracking |
All debug functions wrapped in:
#if defined(RTS_DEBUG) || defined(IG_DEBUG_STACKTRACE)
// Full implementation
#else
// Empty inline stubs
#endif- StackDump() - No Linux stack dumping
- StackDumpFromAddresses() - Depends on above
- FillStackAddresses() - Windows stack walk
- GetFunctionDetails() - Symbol resolution
- DumpExceptionInfo() - EXCEPTION_POINTERS (Windows-only type)
- DbgHelpLoader:: - dbghelp.dll dependency
- To_D3DMATRIX() - Needs DXVK equivalent
- DbgHelpGuard - Can be no-op class
- Matrix3D / Matrix4x4 - Pure C++ math
- To_D3DXMATRIX() - Pattern not found
β No changes needed for:
- Matrix3D / Matrix4x4 (use as-is)
β Leave stubbed:
- StackDump() β empty inline (already exists)
- StackDumpFromAddresses() β empty inline (already exists)
- FillStackAddresses() β empty inline (already exists)
- GetFunctionDetails() β empty inline (already exists)
- DumpExceptionInfo() β empty inline (already exists)
- DbgHelpGuard β empty RAII class (no-op constructor/destructor)
π§ Replace for graphics:
- To_D3DMATRIX() β Add DXVK matrix conversion layer
β No changes needed - no graphics/debugging dependencies
When Linux exception handling is complete:
- Implement POSIX signal handlers (SIGSEGV, SIGABRT)
- Add libunwind or backtrace() for stack capturing
- Create Linux equiv of DumpExceptionInfo()
All changes are contained in conditional compilation blocks:
#if defined(RTS_DEBUG) || defined(IG_DEBUG_STACKTRACE)
// Windows implementation
#else
// Empty inline stubs (Linux will use these)
#endif
#ifdef _WIN32
// Windows-only: dx8wrapper.cpp DbgHelpGuard usage
#endifWindows VC6/Win32 builds: β ZERO IMPACT - Original code preserved
| Function | Header | Implementation | Debug-only? | Empty Stub? | Linux Risk |
|---|---|---|---|---|---|
| StackDump() | StackDump.h#L34 | StackDump.cpp#L60 | Yes | Yes | π΄ HIGH |
| StackDumpFromAddresses() | StackDump.h#L44 | StackDump.cpp#L439 | Yes | Yes | π΄ HIGH |
| FillStackAddresses() | StackDump.h#L41 | StackDump.cpp#L317 | Yes | Yes | π΄ HIGH |
| GetFunctionDetails() | StackDump.h#L46 | StackDump.cpp#L248 | Yes | Yes | π΄ HIGH |
| DumpExceptionInfo() | StackDump.h#L49 | StackDump.cpp#L480 | Yes | Yes | π΄ CRITICAL |
| Function | Header | Usage | Linux Risk |
|---|---|---|---|
| To_D3DMATRIX() | dx8wrapper.h#L1201+ | Matrix conversion | π‘ MEDIUM (graphics layer) |
| Class | Header | Usage | Linux Strategy |
|---|---|---|---|
| DbgHelpLoader | DbgHelpLoader.h | Symbol resolution | Replace with libunwind |
| DbgHelpGuard | DbgHelpGuard.h | Graphics init guard | Empty RAII no-op |
| Class | Usages | Scope | Linux Risk |
|---|---|---|---|
| Matrix3D | 100+ | Game logic + graphics | π’ NONE |
| Matrix4x4 | 50+ | Graphics projections | π’ NONE |
- Document Linux signal handler strategy (replace SEH)
- Design POSIX exception handling layer
- Plan libunwind or backtrace() integration
- Design DXVK matrix conversion layer
- Document To_D3DMATRIX() macro definition location
- Create conditional compilation test for Linux builds