# loof-sys/examplehook architecture

> Architecture diagram of the GitHub repository loof-sys/examplehook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/loof-sys/examplehook
- Repository: https://github.com/loof-sys/examplehook

## Overview

##### Project Type & Purpose
- A Windows-focused injection/hooking toolkit for “Discord voice hooks.”
- Multi‐stage chain: installer → kernel driver → injector → in‐process hook DLL → Discord voice pipeline → overlay UI.

##### Top-Level Components (from file tree)
- Setup/ Installer
– Setup/Setup.vcxproj, SystemMask.inf
- Kernel Driver
– SystemMask/systemmask.sys (source.cpp)
- Injector Layer
– Injector/Injector.exe (CreateRemoteThread + LoadLibrary)
– HiddenInjector/HiddenInjector.exe (manualmapper.cpp → stealth injection)
- Hook DLL
– ExampleHook/ExampleHook.dll
· dllmain.cpp, exceptions.cpp/​.hpp
· Hook libraries: minhook/, hde/, trampoline.c/.h
· Audio codec: opus/ (celt & silk subfolders, include/, src/)
· UI: imgui/, implot/
· Scheduler: scheduler.cpp/​.hpp/​.asm
· Utilities: ini.hpp, offsets.cpp/​.hpp, utils.cpp, window.cpp
- AntiScan DLL
– AntiScan/AntiScan.dll (minhook + ntdll API detours)

##### Interactions & Data-Flow
a. Installation Phase
- User runs Setup.exe → installs SystemMask.sys via SystemMask.inf.
- On boot, SystemMask.sys masks kernel handles to enable stealth.
b. Injection Phase
- User launches Injector.exe (standard) or HiddenInjector.exe (manual map).
- Injector locates Discord.exe → injects ExampleHook.dll + AntiScan.dll.
c. In-Process Hooking
- DllMain calls AntiScan to hook low-level APIs (hide modules).
- ExampleHook uses MinHook/HDE & trampolines to detour Discord voice functions in ntdll.
- Voice data path: intercepted calls → Opus engine (encode/decode) → Scheduler → original Discord logic.
- Config loader (ini.hpp) reads config.ini/boot.ini for offsets and settings.

##### Architectural Patterns & Key Libraries
– Multi-stage injection (user-mode + kernel stealth + manual map)
– Kernel-mode driver for concealment (masking objects)
– Function detouring via MinHook + HDE disassembler + trampolines
– Modular in-process plugin (ExampleHook.dll)
– Third-party libs: Opus (celt/silk), ImGui/ImPlot, manualmapper, scheduler

##### Key Details to Capture
– External cloud service to show where voice packets ultimately go.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Installer Phase
    subgraph "Installer Phase"
        SetupExe["Setup.exe"]:::user
        SysMask(("SystemMask.sys")):::kernel
        SetupExe -->|"Install Driver"| SysMask
    end

    %% Injection Phase
    subgraph "Injection Phase"
        Injector["Injector.exe"]:::user
        HiddenInjector["HiddenInjector.exe"]:::user
        Injector -->|"DLL Injection"| DiscordExe
        HiddenInjector -->|"DLL Injection"| DiscordExe
    end

    %% Kernel Masking to Process
    SysMask -->|"Kernel Masking"| DiscordExe

    %% Main Process
    DiscordExe["Discord.exe"]:::external
    DiscordExe -->|"Detour Calls"| WindowsAPIs
    DiscordExe -->|"Render Overlay"| DirectX11

    subgraph "In-Process Modules"
        ExHook["ExampleHook.dll"]:::process
        AntiScan["AntiScan.dll"]:::process
    end
    DiscordExe --> ExHook
    DiscordExe --> AntiScan

    %% ExampleHook Internals
    subgraph "ExampleHook.dll Internals"
        HookManager["Hook Manager"]:::third
        AudioEngine["Audio Engine"]:::third
        UI_ImGui["UI Engine (ImGui)"]:::third
        UI_ImPlot["UI Engine (ImPlot)"]:::third
        Scheduler["Scheduler"]:::third
        ConfigLoader["Config Loader"]:::config

        ExHook -->|"Audio Encode/Decode"| AudioEngine
        ExHook -->|"Overlay Render"| UI_ImGui
        ExHook -->|"Overlay Render"| UI_ImPlot
        ExHook -->|"Schedule Tasks"| Scheduler
        ExHook -->|"Load Config"| ConfigLoader
        ExHook -->|"Function Detours"| HookManager
    end

    %% AntiScan Internals
    subgraph "AntiScan.dll Internals"
        AS_HookManager["Stealth Hook"]:::third
        AntiScan -->|"Stealth Hook"| AS_HookManager
    end

    %% Third-Party Libraries
    MinHook[/"MinHook + HDE + Trampolines"/]:::third
    Opus[/"Opus Codec (celt & silk)"/]:::third
    ImGuiLib[/"ImGui"/]:::third
    ImPlotLib[/"ImPlot"/]:::third

    HookManager --> MinHook
    AS_HookManager --> MinHook
    AudioEngine --> Opus
    UI_ImGui --> ImGuiLib
    UI_ImPlot --> ImPlotLib

    %% Configuration Files
    subgraph "Configuration Files"
        BootIni["boot.ini"]:::config
        ConfigIni["config.ini"]:::config
    end
    ConfigLoader --> BootIni
    ConfigLoader --> ConfigIni

    %% External Cloud
    Cloud{{"Discord Voice Server"}}:::cloud
    Opus -->|"Voice Packets"| Cloud

    %% Windows APIs
    WindowsAPIs["Windows APIs (ntdll)"]:::external
    DirectX11["DirectX11 / Win32"]:::external

    %% Click Events
    click SetupExe "https://github.com/loof-sys/examplehook/blob/master/Setup/Setup.vcxproj"
    click SetupExe "https://github.com/loof-sys/examplehook/blob/master/Setup/source.cpp"
    click SysMask "https://github.com/loof-sys/examplehook/blob/master/SystemMask/source.cpp"
    click SysMask "https://github.com/loof-sys/examplehook/blob/master/SystemMask/SystemMask.inf"
    click Injector "https://github.com/loof-sys/examplehook/blob/master/Injector/Injector.cpp"
    click HiddenInjector "https://github.com/loof-sys/examplehook/blob/master/HiddenInjector/manualmapper.cpp"
    click HiddenInjector "https://github.com/loof-sys/examplehook/blob/master/HiddenInjector/exports.cpp"
    click HiddenInjector "https://github.com/loof-sys/examplehook/blob/master/HiddenInjector/dllmain.cpp"
    click ExHook "https://github.com/loof-sys/examplehook/blob/master/ExampleHook/dllmain.cpp"
    click HookManager "https://github.com/loof-sys/examplehook/tree/master/ExampleHook/minhook/"
    click AudioEngine "https://github.com/loof-sys/examplehook/tree/master/ExampleHook/opus/"
    click UI_ImGui "https://github.com/loof-sys/examplehook/tree/master/ExampleHook/imgui/"
    click UI_ImPlot "https://github.com/loof-sys/examplehook/tree/master/ExampleHook/implot/"
    click Scheduler "https://github.com/loof-sys/examplehook/blob/master/ExampleHook/scheduler.cpp"
    click ConfigLoader "https://github.com/loof-sys/examplehook/blob/master/ExampleHook/ini.hpp"
    click AntiScan "https://github.com/loof-sys/examplehook/blob/master/AntiScan/dllmain.cpp"
    click AS_HookManager "https://github.com/loof-sys/examplehook/tree/master/AntiScan/minhook/"

    %% Styles
    classDef user fill:#cce5ff,stroke:#0062cc,color:#000;
    classDef kernel fill:#f8d7da,stroke:#a71d2a,color:#000;
    classDef process fill:#d4edda,stroke:#155724,color:#000;
    classDef third fill:#fff3cd,stroke:#856404,color:#000;
    classDef config fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef cloud fill:#d1ecf1,stroke:#0c5460,color:#000;
    classDef external fill:#f0f0f0,stroke:#333,color:#000;
```
