How thephrozenkeep/d2moo works
Purpose and execution model
D2MOO is a Windows C++ reimplementation of Diablo II DLL functionality, primarily version 1.10f, coupled to Detours-based runtime patching for modding. It requires original game binaries/assets; it is not a standalone game. The executable-side entry point is source/Game/src/Main.cpp; rebuilt subsystem DLLs expose original-style ordinals, while patch DLLs intercept selected functions in the original process.
Build, deployment, and patch boundary
CMake composes the DLL projects, launcher/debug setup, external dependencies, and patch targets: CMakeLists.txt, source/CMakeLists.txt, D2.Detours.patches/CMakeLists.txt. external/D2.Detours is the central runtime-hooking dependency. Patch definitions are version-specific and map hooks to game modules, notably D2.Detours.patches/1.10f/D2Common.patch.cpp and D2.Detours.patches/1.10f/D2Game.patch.cpp. Direct replacement is intended only provisionally for D2Common; other rebuilt DLLs are generally consumed through patches.
Shared ABI and platform foundation
source/D2CommonDefinitions/include establishes cross-module primitive types, constants, DLL/import metadata, build configuration, packets, and reconstructed layouts. source/Fog supplies shared runtime services—memory, errors/logging, strings, queues/sockets, file-format support, and system abstractions—used as the lower-level compatibility layer. Key paths: source/D2CommonDefinitions/include/D2Dll.h, source/Fog/src/Fog.cpp, source/Fog/src/Mem/Mem.cpp.
Core game simulation: D2Common
D2Common is the largest reusable gameplay/data layer and the most mature replacement target. It owns data-table loading and lookup, unit/item/stat state, collision and dungeon generation, random seeds, paths, quests, and text. Its flow is data tables and world state → unit/path/dungeon operations → D2Game orchestration. Key paths: source/D2Common/src/DataTbls/DataTbls.cpp, source/D2Common/src/Drlg/DrlgDrlg.cpp, source/D2Common/src/Path/AStar.cpp.
Game orchestration: D2Game
D2Game implements server/gameplay-side lifecycle and updates: game/client/task/event control, unit creation and messaging, player progression/save/trade, monster spawning/AI, items, missiles, skills, objects, and per-act quests. It consumes D2Common structures/tables and emits gameplay state and packet-oriented behavior. Key paths: source/D2Game/src/GAME/Game.cpp, source/D2Game/src/UNIT/SUnit.cpp, source/D2Game/src/AI/AiThink.cpp.
Client-facing compatibility modules
Several reconstructed DLLs represent game-facing boundaries rather than a single application UI: rendering and tile/textures (source/D2Gfx/src/D2Gfx.cpp, source/D2CMP/src/D2CMP.cpp); interface controls/resources (source/D2Win/src/D2WinMain.cpp); localization/string tables (source/D2Lang/src/D2StrTable.cpp); archive/file access (source/D2Hell/src/Archive.cpp, source/Storm/src/Storm.cpp); and network client/server packet surfaces (source/D2Net/src/Client.cpp, source/D2Net/src/Server.cpp). These preserve DLL APIs around original assets and game process behavior.
Debugging and observability
An optional injected debugger is enabled by -debug or D2_DEBUGGER=1. It is a D3D9/ImGui overlay integrated through patch hooks, not a separate service. Key paths: source/D2Debugger/src/D2Debugger.cpp, source/D2Debugger/src/D2Debugger.imgui.d3d9.cpp, D2.Detours.patches/1.10f/D2Debugger.patch.cpp. External UI dependencies include external/imgui; no cloud infrastructure or hosted service is present.
Main entry points: D2Game.patch.cpp 1.10f patch DLLs · DrlgDrlg.cpp World, paths & dungeons · CMakeLists.txt CMake build · Game.cpp Game lifecycle
Components 16
Build & Injection
- CMake build · Builds replacement DLLs, patch targets, and launcher setup.
CMakeLists.txt - Detours runtime · Runtime interception layer used by patch DLLs.
external/D2.Detours - 1.10f patch DLLs · Maps replacement hooks into original game modules.
D2.Detours.patches/1.10f/D2Game.patch.cpp - Original game process · Supplies required original binaries and assets.
- Injected debug overlay · Optional -debug or D2_DEBUGGER=1 observability overlay.
source/D2Debugger/src/D2Debugger.cpp
Shared Foundation
- Shared DLL ABI · Defines cross-module types, packets, layouts, and import metadata.
source/D2CommonDefinitions/include/D2Dll.h - Fog runtime services · Provides memory, logging, strings, queues, sockets, and system abstractions.
source/Fog/src/Fog.cpp
Game Simulation
- Data tables · Loads and looks up game tables and text data.
source/D2Common/src/DataTbls/DataTbls.cpp - World, paths & dungeons · Maintains units, stats, collision, RNG, paths, and dungeon generation.
source/D2Common/src/Drlg/DrlgDrlg.cpp - Game lifecycle · Coordinates games, clients, tasks, events, units, and messaging.
source/D2Game/src/GAME/Game.cpp - Gameplay systems · Implements progression, items, skills, monsters, AI, missiles, and quests.
source/D2Game/src/AI/AiThink.cpp
Compatibility DLLs
- Rendering & assets · Provides rendering, tiles, textures, and compositing APIs.
source/D2Gfx/src/D2Gfx.cpp - Game interface · Provides interface controls and resources.
source/D2Win/src/D2WinMain.cpp - Localization · Exposes localized string-table APIs.
source/D2Lang/src/D2StrTable.cpp - Archive & file access · Reads game archives and file resources.
source/D2Hell/src/Archive.cpp - Network packet surface · Provides client/server packet compatibility APIs.
source/D2Net/src/Client.cpp
Connections 26
- CMake build → Detours runtime: builds with
- CMake build → 1.10f patch DLLs: builds
- CMake build → Fog runtime services: builds
- CMake build → World, paths & dungeons: builds replacement
- CMake build → Game lifecycle: builds replacement
- 1.10f patch DLLs → Detours runtime: uses
- 1.10f patch DLLs → Original game process: injects into
- 1.10f patch DLLs → World, paths & dungeons: hooks D2Common
- 1.10f patch DLLs → Game lifecycle: hooks D2Game
- Shared DLL ABI → Fog runtime services: shared ABI
- Shared DLL ABI → World, paths & dungeons: shared ABI
- Shared DLL ABI → Game lifecycle: shared ABI
- Fog runtime services → Data tables: runtime services
- Fog runtime services → World, paths & dungeons: runtime services
- Data tables → World, paths & dungeons: data and text
- World, paths & dungeons → Game lifecycle: world state
- Game lifecycle → Gameplay systems: updates
- Gameplay systems → Network packet surface: packet-oriented state
- Archive & file access → Data tables: game resources
- Archive & file access → Rendering & assets: assets
- Localization → Game interface: strings
- Rendering & assets → Original game process: game-facing API
- Game interface → Original game process: game-facing API
- Network packet surface → Original game process: game-facing API
- Injected debug overlay → 1.10f patch DLLs: overlay hook
- Injected debug overlay → Original game process: renders in process