# stevenklar/age-of-empires-ii-2013 architecture

> Architecture diagram of the GitHub repository stevenklar/age-of-empires-ii-2013, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stevenklar/age-of-empires-ii-2013
- Repository: https://github.com/stevenklar/age-of-empires-ii-2013

## Overview

##### Project type and purpose
- This is a native C++ “game‐hack” DLL that injects into the Age of Empires II (2013) process.
- Its goal is to hook into the game’s functions (via DetourHook), read memory structures (Offsets, Classes), and overlay debugging/ESP/map‑hack information through ImGui + DirectX9.

##### File structure
- Top‐level solution and project files: AoE_IMGUI.sln, AoE_IMGUI.vcxproj ⇒ MSVC C++ DLL project.
- AoE_IMGUI/ directory contains all core C++ code:
- Core.cpp/.h and dllmain.cpp – entry point and module initialization.
- DetourHook.* – wrapper around Microsoft Detours for function hooking.
- Engine.*, FeatureManager.*, Feature.* – abstraction layers for feature registration and update loops.
- Maphack.*, ResourceInformation.*, UnitCollisions.* – individual feature modules.
- Renderer.* – rendering logic, bridges memory data into ImGui calls.
- Offsets.h, Classes.h, Sdk.h – memory layouts and signature definitions.
- ImGui/ directory: the entire Dear ImGui library with Win32 + DirectX9 back ends.
- README.md describes features (ESP, resource display, maphack, extensibility).

##### Key insights from README
- Hooks into game to read player resources, unit counts, fog‑of‑war data.
- Uses pattern scanning + reverse‑engineered offsets.
- Extensible by adding new “Feature” modules.
- Relies on DirectX9 overlay via ImGui.

a. Main components to include
- External System: Age of Empires II (2013) Game Process
- Injection Layer: dllmain → DetourHook Module
- Memory Access Layer: Offsets & Classes definitions + pattern scanning
- Core Engine: Core/Engine classes that schedule “tick” updates
- Feature Manager: FeatureManager registers and updates Feature modules
- Feature Modules: Maphack, ResourceInformation, UnitCollisions, ESP, etc.
- Rendering Layer: Renderer module + ImGui back ends (Win32 + Dx9)
- ImGui Library: UI widgets and internal renderer
b. Relationships and interactions
- dllmain loads on process attach → initializes DetourHook
- DetourHook hooks target game functions (e.g., main loop, rendering)
- On each frame or game tick, Core triggers Engine → FeatureManager → each Feature
- Features read game memory via Offsets/Classes, possibly call hooked game functions
- ImGui core renders UI overlays on top of the game window
c. Architectural patterns/design principles
- Modular plugin pattern: each Feature is self‑contained, registered at runtime
- Hook‐and‐proxy pattern: DetourHook intercepts game functions without modifying original binary
- Layered architecture: clear separation between memory access, business logic (features), and presentation (UI)
d. Key technologies/frameworks
- Microsoft Detours (for hooking)
- Dear ImGui (for overlay UI) with DirectX9 + Win32 back ends
- C++17 (or similar) project in MSVC
- Pattern scanning for dynamic offset resolution

##### Detail without over‑splitting
- Third‑party or OS components (Detours, DirectX9, Win32 API) to show external dependencies.
- Module’s role is clear: data source, controller, renderer, or external dependency.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Systems
    subgraph "External Systems"
        GP["Age of Empires II (2013) Game Process"]:::external
        GW["Game Window"]:::external
    end

    %% Injection & Hooking Layer
    subgraph "Injection & Hooking" 
        IL["Injection Layer\n(dllmain)"]:::infrastructure
        HM["Hooking Module\n(DetourHook)"]:::infrastructure
    end

    %% Memory Access Layer
    subgraph "Memory Access Layer"
        MA["Offsets & Classes\n(Sdk)"]:::infrastructure
    end

    %% Core & Engine
    subgraph "Core & Engine"
        CE["Core Engine"]:::infrastructure
        ES["Engine Scheduler"]:::infrastructure
    end

    %% Feature Modules
    subgraph "Features"
        FM["Feature Manager"]:::infrastructure
        MH["Map-Hack Feature"]:::feature
        RI["Resource Information"]:::feature
        UC["Unit Collisions"]:::feature
    end

    %% Rendering & UI
    subgraph "Rendering & UI"
        RL["Rendering Layer"]:::ui
        IM["ImGui Library\n(Win32 + DirectX9)"]:::ui
    end

    %% Solution & Documentation
    SP["Solution & Project Files"]:::external
    RD["README.md"]:::external

    %% Connections
    GP -->|"Inject DLL"| IL
    IL -->|"Install Hooks"| HM
    IL -->|"Init Memory Access"| MA
    IL -->|"Init Core"| CE

    HM -->|"Hook Game Functions"| ES
    CE -->|"Start Scheduler"| ES
    ES -->|"Update() Call"| FM

    FM -->|"Register/Invoke"| MH
    FM -->|"Register/Invoke"| RI
    FM -->|"Register/Invoke"| UC

    MH -->|"Read Memory"| MA
    RI -->|"Read Memory"| MA
    UC -->|"Read Memory"| MA

    MH -->|"Feature Data"| RL
    RI -->|"Feature Data"| RL
    UC -->|"Feature Data"| RL

    RL -->|"DrawUI() Calls"| IM
    IM -->|"Render Overlay"| GW

    %% Click Events
    click IL "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/dllmain.cpp"
    click HM "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/DetourHook.cpp"
    click HM "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/DetourHook.h"
    click MA "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Offsets.h"
    click MA "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Classes.h"
    click MA "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Sdk.h"
    click CE "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Core.cpp"
    click CE "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Core.h"
    click ES "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Engine.cpp"
    click ES "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Engine.h"
    click FM "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/FeatureManager.cpp"
    click FM "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/FeatureManager.h"
    click FM "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Feature.cpp"
    click FM "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Feature.h"
    click MH "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Maphack.cpp"
    click MH "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Maphack.h"
    click RI "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/RessourceInformation.cpp"
    click RI "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/RessourceInformation.h"
    click UC "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/UnitCollisions.cpp"
    click UC "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/UnitCollisions.h"
    click RL "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Renderer.cpp"
    click RL "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/Renderer.h"
    click IM "https://github.com/stevenklar/age-of-empires-ii-2013/tree/master/ImGui/"
    click SP "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI.sln"
    click SP "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/AoE_IMGUI.vcxproj"
    click SP "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/AoE_IMGUI.filters"
    click SP "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/AoE_IMGUI/AoE_IMGUI.vcxproj.filters"
    click RD "https://github.com/stevenklar/age-of-empires-ii-2013/blob/master/README.md"

    %% Styles
    classDef infrastructure fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef feature fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef ui fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
