# rei-2/amalgam architecture

> Architecture diagram of the GitHub repository rei-2/amalgam, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rei-2/amalgam
- Repository: https://github.com/rei-2/amalgam

## Overview

##### Project type and purpose
- Amalgam is a native C++ “game-cheat” DLL designed to be injected into a Windows game process (Team Fortress 2) via a VAC bypass or Xenos injector.
- Its purpose is to hook into the game’s engine functions, read or modify game data, and render overlays (ESP, Aimbot, Visuals) using ImGui and FreeType.

##### File structure
- Top-level solution (Amalgam.sln) builds one DLL project (Amalgam.vcxproj).
- “include/” brings in third-party libraries:
- ImGui (UI rendering)
- MinHook (runtime function hooking)
- FreeType (font rasterization)
- “src/” is subdivided into:
- Core (initialization, module loader)
- DllMain (entry point)
- Hooks (one file per engine function hook)
- SDK (game engine definitions & interfaces)
- Features (Aimbot, Visuals, Networking, etc.)
- Utils (common helpers: memory scanning, hooking glue, timers, crash logging)
- BytePatches (patching bytes in memory)
- Configuration and build scripts under “.github/” and “packages.config.”

##### README for insights
- Describes downloadable artifacts (AVX2, FreeType variants).
- Mentions dependencies (VAC bypass, Xenos).
- Confirms primary use-case: injected DLL cheat with UI overlay.

##### Main components & their relationships
a. External Injector
- Runs outside the game, loads the Amalgam DLL into the target process.
b. Core Module
- DllMain initializes the system, reads configs, sets up MinHook.
- Orchestrates the order: apply byte patches, install hooks, initialize UI.
c. Hooking Layer
- Uses MinHook to detour game engine functions (found in “src/Hooks”).
- All engine calls funnel through these hooks before/after original logic.
d. SDK Interfaces
- C++ wrappers around game engine classes and functions.
- Hooks invoke SDK to read game state (players, world, commands).
e. Feature Modules
- Organized under “src/Features” (Aimbot, Visuals, Backtrack, etc.).
- Subscribe to hook callbacks, inspect/modify game data, issue game commands.
f. UI Layer
- ImGui + FreeType provide a menu overlay drawn on top of the game scene.
- Features register menus, controls, font assets under “src/Features/ImGui.”
g. Utility Modules
- Helpers for memory operations, signature scanning, convars, crash reporting.
- Invoked by Core and Features to simplify low-level tasks.

##### Architectural patterns & design principles
- Layered architecture: Injector → Core → Hooking → SDK → Features → UI.
- Modular plugin pattern: each Feature is isolated in its own folder, implements a common interface.
- Dependency inversion: Features depend on SDK interfaces, not on engine internals directly.
- Single responsibility: Core only handles bootstrap; each module has one focus (hooks vs visuals vs input).

- Layer separation: group “Hooks,” “SDK,” “Features,” “UI,” and “Utils” inside the “Amalgam DLL” boundary.
- From Game Engine into Hooks (detour) → back to Game Engine
- From Features down to SDK → Engine state
- From Core to Hooks & Features (initialization)
- From UI to rendering libraries → GPU/framebuffer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Injector
    Injector["External Injector"]:::external

    %% Amalgam DLL boundary
    subgraph "Amalgam DLL"
        %% Bootstrap & Core Services
        DllMainCore["DllMain / Core"]:::bootstrap
        BytePatches["BytePatches Layer"]:::bootstrap
        MinHookLib["MinHook"]:::hook
        Hooks["Hooks"]:::hook
        SDKInterfaces["SDK Interfaces"]:::hook
        SDKCore["SDK Core & Helpers"]:::hook
        Features["Feature Modules"]:::feature
        UILayer["UI Layer"]:::ui
        Utils["Utility Modules"]:::util
        ImGuiLib["ImGui Lib"]:::lib
        FreeTypeLib["FreeType Lib"]:::lib
    end

    %% Connections
    Injector -->|"loads DLL"| DllMainCore
    DllMainCore -->|"apply patches"| BytePatches
    DllMainCore -->|"init hooks"| MinHookLib
    MinHookLib -->|"detours installed"| Hooks
    Hooks <-->|"invoke engine interfaces"| SDKInterfaces
    SDKInterfaces -->|"state & calls"| SDKCore
    Features <-->|"use interfaces"| SDKInterfaces
    Features -->|"register menus / draw"| UILayer
    UILayer -->|"render calls"| ImGuiLib
    UILayer -->|"font rasterization"| FreeTypeLib
    DllMainCore -->|"use utils"| Utils
    Features -->|"use utils"| Utils
    Hooks -->|"use utils"| Utils
    SDKCore -->|"use utils"| Utils

    %% Click Events
    click DllMainCore "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/DllMain.cpp"
    click DllMainCore "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/Core/Core.cpp"
    click DllMainCore "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/Core/Core.h"
    click BytePatches "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/BytePatches/BytePatches.cpp"
    click BytePatches "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/BytePatches/BytePatches.h"
    click Hooks "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Hooks/"
    click SDKInterfaces "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/SDK/Definitions/"
    click SDKCore "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/SDK/SDK.cpp"
    click SDKCore "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/SDK/SDK.h"
    click SDKCore "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/SDK/Globals.h"
    click SDKCore "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/SDK/Events/Events.cpp"
    click SDKCore "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/SDK/Events/Events.h"
    click Features "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Features/"
    click UILayer "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/Features/ImGui/Menu/Menu.cpp"
    click UILayer "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/Features/ImGui/Menu/Menu.h"
    click UILayer "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/Features/ImGui/Render.cpp"
    click UILayer "https://github.com/rei-2/amalgam/blob/master/Amalgam/src/Features/ImGui/Render.h"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/Assert"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/ConVars"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/CrashLog"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/Feature"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/Hash"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/Hooks"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/Interfaces"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/KeyHandler"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/Math"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/Memory"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/NetVars"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/Signatures"
    click Utils "https://github.com/rei-2/amalgam/tree/master/Amalgam/src/Utils/Timer"
    click MinHookLib "https://github.com/rei-2/amalgam/tree/master/Amalgam/include/MinHook/"
    click ImGuiLib "https://github.com/rei-2/amalgam/tree/master/Amalgam/include/ImGui/"
    click FreeTypeLib "https://github.com/rei-2/amalgam/tree/master/Amalgam/include/freetype/"

    %% Styles
    classDef external fill:#FFFFFF,stroke:#000000;
    classDef bootstrap fill:#ADD8E6,stroke:#000000;
    classDef hook fill:#90EE90,stroke:#000000;
    classDef feature fill:#FFA500,stroke:#000000;
    classDef ui fill:#DDA0DD,stroke:#000000;
    classDef util fill:#D3D3D3,stroke:#000000;
    classDef lib fill:#E6E6FA,stroke:#000000;
```
