Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/angelballay/pes6_game_physics_mod/llms.txt

Use this file to discover all available pages before exploring further.

KitserverOverlay provides optional on-screen feedback by integrating with Kitserver’s rendering pipeline. All Kitserver APIs are resolved at runtime via GetProcAddress — the mod compiles and runs without Kitserver being present. If kload.dll is not loaded when InstallKitserverOverlay is called, the overlay is silently disabled and all other mod functionality continues normally.

Dynamic Loading Strategy

At install time, GetModuleHandleA("kload.dll") is called to check whether Kitserver is present in the process. If the handle is NULL, the overlay is skipped entirely. If the module is found, four exports are resolved by name:

Kitserver Function Pointer Typedefs

typedef void(__cdecl* HookFunctionFn)(int hookId, DWORD functionAddress);
typedef void(__cdecl* UnhookFunctionFn)(int hookId, DWORD functionAddress);
typedef void(__cdecl* KDrawTextFn)(float x, float y, DWORD color, DWORD fontSize, char* text, bool absolute);
typedef void(__cdecl* KGetTextExtentFn)(char* text, DWORD fontSize, SIZE* size);
Export namePurpose
HookFunctionRegisters a callback for a Kitserver hook point
UnhookFunctionRemoves a previously registered callback
KDrawTextDraws text on screen at (x, y) with the given color and font size
KGetTextExtentMeasures the pixel dimensions of a string for a given font size
If any of the four exports fails to resolve, all four pointers are set to nullptr and the overlay is disabled. No partial state is left behind.

Hook IDs

The overlay uses the KitserverHookId enum to identify the D3D callback slot:
enum KitserverHookId
{
    hk_D3D_Create       = 0,
    hk_D3D_GetDeviceCaps = 1,
    hk_D3D_CreateDevice = 2,
    hk_D3D_Present      = 3
};
The mod registers only hk_D3D_Present = 3, which fires on every Direct3D Present call — once per rendered frame.

Public API

InstallKitserverOverlay

bool InstallKitserverOverlay();
Initializes the CRITICAL_SECTION used to protect g_lastEnabled, loads the four Kitserver exports, and calls g_hookFunction(hk_D3D_Present, (DWORD)ABPhysicsPresent) to register the per-frame callback. Returns false if kload.dll is absent or any export is missing. Called from MainThread in dllmain.cpp after the game hooks are installed.

UninstallKitserverOverlay

void UninstallKitserverOverlay();
Calls g_unhookFunction(hk_D3D_Present, (DWORD)ABPhysicsPresent) to deregister the callback, then calls DeleteCriticalSection to release the overlay lock. Called from the DLL_PROCESS_DETACH branch of DllMain.

ShowPhysicsModOverlayMessage

void ShowPhysicsModOverlayMessage(bool enabled);
Stores enabled in g_lastEnabled (under the critical section), sets g_messageUntilTick = GetTickCount() + 2200, and sets g_drawMessage = 1 via InterlockedExchange. The message will be visible for 2.2 seconds from the moment this function is called. Called by HotkeyToggle immediately after each toggle.

IsKitserverOverlayAvailable

bool IsKitserverOverlayAvailable();
Returns g_overlayInstalled. Used by MainThread to decide whether to log a warning about the overlay not being available.

Rendering

ABPhysicsPresent is the D3D Present callback registered with Kitserver. Its signature matches the hk_D3D_Present prototype:
void STDMETHODCALLTYPE ABPhysicsPresent(
    void* self,
    const RECT* src,
    const RECT* dest,
    HWND hWnd,
    void* unused
);
All parameters are unused by the mod — the callback only calls DrawPhysicsMessage() and increments a frame counter. DrawPhysicsMessage runs every frame and checks whether a message is active:
  1. If g_drawMessage == 0, returns immediately (nothing to draw).
  2. Compares GetTickCount() against g_messageUntilTick. If the timer has expired, clears g_drawMessage and returns.
  3. Reads g_lastEnabled under the critical section to determine the message text and color.
  4. Calls g_kGetTextExtent(text, 16, &size) to measure the string width.
  5. Centers horizontally against a 640-pixel base width: x = (640.0f - size.cx) / 2.0f.
  6. Draws at y = 26.0f with absolute = true.
StateTextColor
EnabledFISICAS ACTIVADAS0xff40ff40 (green)
DisabledFISICAS DESACTIVADAS0xffff4040 (red)
A drop shadow is drawn first at (x + 2, y + 2) in solid black (0xff000000), then the colored text is drawn on top.
Even when Kitserver is not present and the overlay is unavailable, the toggle still functions fully. HotkeyToggle logs the new state via LogFormat("[HOTKEY] Mod de fisicas %s", ...) whenever ENABLED = true in Logger.cpp, and MainThread logs "[WARN] Overlay Kitserver no disponible. El toggle funcionara igual por log." at startup to confirm the degraded-but-functional state.

Build docs developers (and LLMs) love