Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Game-Hacking-Framework

A modular C++ framework that provides the common functionality required to build a game hack.

Overview

Building an external or internal hack for a new game usually involves rewriting the same core logic: hooking a graphics API, installing a WndProc, projecting world coordinates to screen space, and orchestrating per-frame tick/draw passes against a thread-safe data model.

Game-Hacking-Framework factors that core logic out as a C++ library. To port the framework to a new game, an integrator only implements the functions declared in bridge.hpp. Everything else - feature modules, menu, synchronization, and rendering backends, is reused as is.

Features

  • Modular feature system - each feature (Aimbot, ESP, HUD) is a self-contained singleton that implements a uniform Tick / Draw / DrawMenu lifecycle.
  • ImGui-based overlay - feature menus are composed automatically into a single tabbed window toggleable at runtime
  • Rendering backends - graphics-API hooking via Microsoft Detours
  • Thread-safe data model - each feature owns a std::recursive_mutex; tick and draw data are explicitly invalidated between phases to prevent the use of stale frame data.
  • Bring-your-own engine adapter - a small bridge.hpp surface keeps engine-specific code isolated from the framework core.
  • Extensible - register custom ITickableAndDrawable modules to add game-specific features without modifying the framework.

Architecture

Per-frame lifecycle

The integrator drives the framework from the game's render or main thread:

  1. game_hacking_framework::Tick() acquires the global lock, calls TickImpl() on every feature and on every registered custom tickable, then calls Globals::Invalidate() to clear shared per-frame state.
  2. game_hacking_framework::Draw() acquires the global lock, calls DrawImpl() on every feature, and renders the menu when it is open.

Each feature derives from TickableAndDrawableBase<T> (a CRTP wrapper around Singleton<T>) which:

  • Resets the feature's Data struct before TickImpl.
  • Clears the feature's TickData after TickImpl, so draw code cannot accidentally read tick-only state.
  • Clears the feature's Data after DrawImpl, so the next tick starts from a known state.
  • Holds a std::recursive_mutex guarding the feature's state for the full duration of each phase.

Bridge layer

bridge.hpp declares the seam between the framework and the host game. The framework calls into the bridge for game-specific operations (projection, line of sight check, aim actuation); the integrator implements them in a bridge.cpp against the game's reverse-engineered types.

Usage

1. Implement the bridge

Provide a bridge.cpp in your DLL implementing every function declared in bridge.hpp, and implement the Player, MyPlayer, and Weapon constructors against your game's types.

// bridge.cpp (integrator-owned)
#include <Game-Hacking-Framework/bridge.hpp>
#include <Game-Hacking-Framework/globals.hpp>
#include <Game-Hacking-Framework/aimbot.hpp>

namespace game_hacking_framework
{
    void SetupConfigurations(void)
    {
        // Tune per-game defaults, e.g. compensate for client-side prediction.
        auto& aimbot = Aimbot::GetInstance().config_;
        aimbot.use_custom_ping_ = true;
        aimbot.custom_ping_     = 0.0f;
    }

    void SetupCustomTickableAndDrawables(void) { /* register custom features */ }

    void CustomWndProcHandler(HWND, UINT, WPARAM, LPARAM) {}

    void InternalTick(void)
    {
        // Populate Globals::my_player_ and Globals::players_ from engine state,
        // then call game_hacking_framework::Tick().
    }

    std::optional<Vector2D> Project(const Vector3D& world)        { /* ... */ }
    bool                    LineOfSight(const Player& target)     { /* ... */ }
    void                    AimAtDirection(const Vector3D& dir)   { /* ... */ }
}

2. Hook the graphics API

Call the appropriate backend's hook function once during DLL load. The backend installs and initializes ImGui, and invokes the supplied callbacks each frame.

// dllmain.cpp (integrator-owned)
#include <Game-Hacking-Framework/game_hacking_framework.hpp>
#include <Game-Hacking-Framework/backends/dx11.hpp>

DWORD WINAPI MainThread(LPVOID)
{
	static const auto window_name{"Midair2  "};
    if (!game_hacking_framework::Setup(window_name))
        return 1;

    HookDirectX(
        window_name,
        /* pre_render_callback  = */ game_hacking_framework::InternalTick; },
        /* post_render_callback = */ nullptr);
    return 0;
}

BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID)
{
    if (reason == DLL_PROCESS_ATTACH)
    {
        DisableThreadLibraryCalls(module);
        CreateThread(nullptr, 0, MainThread, module, 0, nullptr);
    }
    return TRUE;
}

3. Drive the framework

Tick() is typically run on the thread that owns the game/world state (though it may be able to run on the render thread depending on the game); Draw() must run on the render thread after Tick and before the backend submits the frame. The example above wires InternalTick into the DX11 backend's pre-render callback which then calls Tick(); this is useful for engines that expose a single tick site.

4. Inject

Inject the resulting DLL into the target process using any standard loader (manual map, LoadLibrary via remote thread, etc.).

API Overview

All public symbols live in namespace game_hacking_framework.

Top-level entry points - game_hacking_framework.hpp

Function Description
bool Setup(std::string window_name) Locates the game window by title, installs the WndProc hook, and invokes SetupConfigurations / SetupCustomTickableAndDrawables. Returns false if the window cannot be found. Call once during DLL initialization.
void Tick(void) Runs TickImpl on every feature and registered custom tickable, then invalidates shared per-frame state. Must be called once per frame before Draw.
void Draw(void) Runs DrawImpl on every feature and renders the menu. Must be called on the render thread, after Tick and within the active ImGui frame established by the rendering backend.

Core functionality - game_hacking_framework_core.hpp

template <typename T> class Singleton;                // T& Singleton<T>::GetInstance()
class ITickableAndDrawable;                           // Tick() / Draw() / DrawMenu()
template <typename T> class TickableAndDrawableBase;  // CRTP + mutex + data lifecycle

TickableAndDrawableBase<T> requires T to define three nested types - Data, TickData, Config - and to implement TickImpl(), DrawImpl(), and DrawMenuImpl(). It guarantees that:

  • mutex_ is held for the duration of each phase.
  • data_ is zero-initialized before TickImpl and cleared after DrawImpl.
  • tick_data_ is cleared after TickImpl so it cannot leak into draw code.

Bridge - bridge.hpp

The integrator implements every function below.

Function Responsibility
void SetupConfigurations(void) Override default feature configs for the target game.
void SetupCustomTickableAndDrawables(void) Register custom ITickableAndDrawable* instances into Globals::custom_tickable_and_drawables.
void CustomWndProcHandler(HWND, UINT, WPARAM, LPARAM) Receive raw window messages for game-specific keybinds.
void InternalTick(void) Optional helper for engines whose tick can be driven from a single hooked function.
std::optional<Vector2D> Project(const Vector3D&) World to screen projection; return std::nullopt when behind the camera.
bool LineOfSight(const Player&) Trace from MyPlayer to the target.
void AimAtDirection(const Vector3D&) Apply a yaw/pitch change so the camera faces the supplied unit vector.

Examples

A minimal integrator DLL is shown in the Usage section. A typical custom feature looks like:

#include <Game-Hacking-Framework/game_hacking_framework_core.hpp>

class Radar : public game_hacking_framework::TickableAndDrawableBase<Radar>
{
    friend class game_hacking_framework::Singleton<Radar>;
protected:
    Radar() = default;
public:
    struct Config   { bool enabled_{true}; float range_{5000.f}; } config_;
    struct Data     { /* per-frame draw data */ }                  data_;
    struct TickData { /* per-frame intermediate state */ }         tick_data_;

    void TickImpl();
    void DrawImpl();
    void DrawMenuImpl();
};

// In SetupCustomTickableAndDrawables():
game_hacking_framework::Globals::GetInstance()
    .custom_tickable_and_drawables.push_back(&Radar::GetInstance());

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages