Battlefield: Bad Company 2 Proxy Hook

Battlefield: Bad Company 2 Proxy Hook

Hook for Battlefield: Bad Company 2 that enables proxying game network traffic (Plasma, Theater and HTTP) to WebSocket server re-implementation


Battlefield: Bad Company 2 Hook



Hook for Battlefield: Bad Company 2 that enables proxying game network traffic (Plasma, Theater and HTTP) to either retail server or WebSocket server re-implementation (like BFBC2_MasterServer)


Table of Contents


Game Info


Battlefield: Bad Company 2 Cover


TypeValue
Developer(s)EA DICE
Publisher(s)Electronic Arts
Producer(s)Patrick Bach, Djörn Johnsson, John Hargelid, Anders Gyllenberg
SeriesBattlefield
EngineFrostbite 1.5
Platform(s)Microsoft Windows, PlayStation 3, Xbox 360, iOS, Kindle Fire
Genre(s)First-person shooter
Mode(s)Single-player, Multi-Player
Legal notes


  • The project doesn't contain

    any

    original code from the game!
  • To use this project you need to have an original copy of the game (bought from Origin), the project doesn't make piracy easier and doesn't break any of the DRM included in-game.
Build Requirements


  • Visual Studio 2022
Libraries:
  • Boost
  • detours
  • OpenSSL v1.0.2 (with SSLv2/v3 support)
Compiling


See build workflow for more detailed steps


  1. Create

    dependencies

    folder in project root
  2. Build requirements (specified in Build Requirements) to

    dependencies

    folder in project root, each library has to be installed in its own folder (look at libs folder structure for naming)
  3. Build project in Visual Studio (It has to be x86 Release build, it's the only one configuration setup, but please check before doing that)
Installing


Copy all

dll

files from either the latest build in GitHub Releases or from

Release

folder if you compiled it yourself to the game root folder (where

exe

file is located)


Configuration


You can change the default behavior of the hook by creating JSON config named

config.json

in the game root folder


KeyDescriptionAllowed ValuesDefault Value
client.forceClientTypeForce specific client typeString ("Client" or "Server")
client.plasmaClientPortPlasma port for clients (proxy will listen on that port)Unsigned short (Range 0-65535)18390
client.theaterClientPortTheater port for clients (proxy will listen on that port)Unsigned short (Range 0-65535)18395
client.plasmaServerPortPlasma port for servers (proxy will listen on that port)Unsigned short (Range 0-65535)19021
client.theaterServerPortTheater port for servers (proxy will listen on that port)Unsigned short (Range 0-65535)19026
client.blockUnknownDomainsBlock DNS resolution for unknown (not

allowed

) domains
Boolean (true/false)true
client.allowedDomainsList of domains that is allowed to be redirected to localhost (a.k.a proxy)List of strings["bfbc2-pc.fesl.ea.com","bfbc2-pc.theater.ea.com","bfbc2-pc-server.fesl.ea.com","bfbc2-pc-server.theater.ea.com","easo.ea.com","bfbc2.gos.ea.com"]
debug.showConsoleShows hook debug consoleBoolean (true/false)false
debug.createLogCreate hook log fileBoolean (true/false)false
debug.logPathPath to where save log fileAny stringbfbc2_(current date and time).log
debug.logLevelConsoleChanges how detailed console logging isInteger (Range 0-5)2
debug.logLevelFileChanges how detailed file logging isInteger (Range 0-5)1
patches.verifyGameVersionVerify whether game version is compatible with hookBoolean (true/false)true
patches.DNSPatch game DNS resolution (redirects all game requests to localhost)Boolean (true/false)true
patches.SSLPatch game SSL certificate verification (required for hook proxy to work)Boolean (true/false)true
proxy.enableEnable/Disable hook proxyBoolean (true/false)true
proxy.hostIP Address or Domain Name of custom server implementationAny stringbfbc2.grzyb.app
proxy.portPort of custom server implementationUnsigned short (Range 0-65535)443
proxy.pathEndpoint pathAny string/ws
proxy.secureUse secure connection (wss) or not encrypted connection (ws)Boolean (true/false)true
overrides.clientVersionClient version identifierAny string"ROMEPC795745"
overrides.serverVersionServer version identifierAny string"ROMEPC851434"
overrides.sslPatchRetryCountNumber of times hook will attempt to patch SSL Certificate VerificationUnsigned short (Range 0-65535)3
Example configuration

This config will make game connect to locally hosted server, with final endpoint being

ws://localhost:8000/ws


{ "debug":{ "logLevelConsole":1 }, "proxy":{ "address":"localhost", "port":8000, "secure":false } }

Credits


Special thanks to:


  • DICE (for making the game)