Skip to main content
The KYBER Module is a C++ DLL that gets injected into the Star Wars Battlefront II game client to enable private server functionality, custom modifications, and enhanced multiplayer features.

Overview

The Module serves as the core runtime component that:
  • Intercepts and modifies game network traffic
  • Implements custom multiplayer functionality
  • Loads and manages game modifications
  • Provides VoIP integration
  • Handles game state synchronization
  • Enables custom scripting via Lua
The Module can only be built on Windows with MSVC toolchain.

Tech Stack

Language

C++17/20

Build System

Bazel with Bazelisk

Compiler

MSVC (Visual Studio)

Architecture

x86-64 DLL injection

Key Dependencies

  • EASTL: Custom STL implementation for game compatibility
  • gRPC: Communication with KYBER API
  • Protocol Buffers: Serialization format
  • IXWebSocket: WebSocket client for real-time communication
  • Sentry: Crash reporting and error tracking
  • Lua: Scripting engine for mods
  • Vivox: Voice chat integration
  • SafetyHook: Safe function hooking library
  • nlohmann/json: JSON parsing
  • GLM: Math library for game calculations

Architecture

The Module is organized into distinct subsystems:
Source/
├── Core/              # Core initialization and management
│   ├── Main.cpp          # DLL entry point
│   ├── Client.cpp        # Client-side logic
│   ├── Server.cpp        # Server-side logic
│   ├── Memory.cpp        # Memory management
│   └── EventManager.cpp  # Event system
├── Network/           # Network layer
│   ├── SocketManager.cpp # Socket management
│   ├── UDPSocket.cpp     # UDP networking
│   └── WebSocket.cpp     # WebSocket client
├── ModLoader/         # Mod loading system
├── Script/            # Lua scripting engine
├── RPC/               # gRPC client implementation
├── Hook/              # Game function hooks
├── Voip/              # Voice chat integration
├── Entity/            # Game entity management
└── Utilities/         # Helper functions

Core Components

// DLL Entry Point
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
    switch (ul_reason_for_call) {
        case DLL_PROCESS_ATTACH:
            DisableThreadLibraryCalls(hModule);
            Kyber::Init(hModule);
            break;
        case DLL_PROCESS_DETACH:
            Kyber::Shutdown();
            break;
    }
    return TRUE;
}

namespace Kyber {
    void Init(HMODULE hModule) {
        // Initialize Sentry for crash reporting
        InitSentry();
        
        // Setup memory hooks
        Memory::Initialize();
        
        // Initialize event system
        EventManager::Initialize();
        
        // Start network manager
        NetworkManager::Initialize();
        
        // Load mod system
        ModLoader::Initialize();
    }
}

Building

Prerequisites

1

Install Visual Studio

Install Visual Studio 2019 or later with C++ desktop development tools
2

Install MSYS2

Download and install MSYS2 to C:\msys64
3

Install Bazelisk

Download Bazelisk and rename to bazel.exe in your PATH
4

Setup Build Directory

Create a short path for build artifacts to avoid Windows path length limitations:
mkdir C:\bz
5

Clone with Submodules

git clone --recurse-submodules https://github.com/ArmchairDevelopers/Kyber.git
# Or if already cloned:
git submodule update --init --recursive

Build Commands

cd Module
bazel --output_user_root="C:\bz" build --config=release Kyber
Always use --config=release. Debug builds will cause game crashes due to runtime library mismatches.
Output: Module/bazel-bin/Kyber.dll

Installing Built Module

Copy the built DLL to the KYBER installation directory:
copy Module\bazel-bin\Kyber.dll C:\ProgramData\Kyber\Module\Kyber.dll
The Launcher will automatically inject this DLL when starting the game.

Build Configuration

cc_binary(
    name = "Kyber",
    srcs = glob(["Source/**/*.cpp"]),
    includes = ["Public"],
    linkopts = [
        "d3d11.lib",
        "Ws2_32.lib",
        "dxgi.lib",
        "rpcrt4.lib",
        "winmm.lib",
        "version.lib",
        "Ole32.lib",
        "crypt32.lib",
        "User32.lib",
        "Shell32.lib",
    ],
    linkshared = 1,  # Build as DLL
    deps = [
        ":KyberAPIProto",
        "//ThirdParty/EASTL",
        "//ThirdParty/IXWebSocket",
        "//ThirdParty/json",
        "//ThirdParty/sentry",
        "//ThirdParty/lua",
        "//ThirdParty/safetyhook",
        "@grpc//:grpc++",
    ],
)

Development Setup

Code Completion with VSCode

1

Install clangd Extension

Install the clangd extension for VSCode
2

Generate compile_commands.json

cd Module
clangd\refresh.bat
3

Configure VSCode

Create .vscode/settings.json:
{
  "clangd.arguments": [
    "--compile-commands-dir=${workspaceFolder}/Module",
    "--header-insertion=never"
  ]
}

Key Features

Network Interception

The Module intercepts game network calls and redirects them to KYBER servers:
  • Hooks Winsock API functions (send, recv, connect)
  • Redirects EA backend calls to Maxima (custom backend)
  • Routes game traffic through KYBER proxy servers
  • Maintains compatibility with original game protocols

Mod Loading

Supports multiple mod formats:
  • FBMod: Frosty mod format (.fbmod)
  • Archive Mods: ZIP files with asset overrides
  • Script Mods: Lua scripts for gameplay modifications

VoIP Integration

Integrates Vivox SDK for proximity voice chat:
  • Positional audio based on player location
  • Team-based voice channels
  • Mute/unmute controls
  • Push-to-talk support

Common Issues

Bazel generates very long paths. Use --output_user_root="C:\bz" to shorten them:
bazel --output_user_root="C:\bz" build --config=release Kyber
Ensure you’re building with --config=release. Debug builds use different runtime libraries that cause crashes.
Update submodules:
git submodule update --init --recursive
Bazel needs to find MSVC. Set environment variable:
set BAZEL_VC=C:\Program Files\Microsoft Visual Studio\2022\Community\VC

Debugging

Debugging the Module is complex due to DLL injection and game anti-cheat considerations.
  1. Use extensive logging with Sentry
  2. Add debug prints to DebugConsole
  3. Use OutputDebugString for Windows debug output
  4. Test in isolated environment first

Logging Example

#include "Core/Console.h"

void MyFunction() {
    Logger::Info("Function called with value: %d", someValue);
    Logger::Error("Error occurred: %s", errorMsg);
}

Performance Considerations

  • Module runs in the game’s main thread
  • Keep hook functions lightweight and fast
  • Use async operations for network calls
  • Minimize allocations in hot paths
  • Profile with game’s built-in profiler
  • Launcher - Injects the Module into the game
  • Proxy - Routes game traffic
  • API - Provides server data to the Module

Build docs developers (and LLMs) love