Navigation
Browse the developer docs

FH2 Modding Guide · Chapter 12

Online play and FH2MP

Your mod might run online, or you work on multiplayer.

By Trinculo54 · from the FH2 Modding Guide · CC BY 4.0 · copied 4 Dec 2026 · read the original, which may be newer

On this page

This chapter is about Forza Horizon 2 played online on PC through FH2MP, and what that means for your mod. It starts with the parts every mod author needs: how a mod knows the game is online, and how to decide whether it should run there. The rest is a reference for people working on online features: how FH2's networking works, what FH2MP's client changes and why, how remote cars are moved and ghosted, and how online UI was added.

All addresses are for forza_durango_release_final.exe of 24 Nov 2015 (TimeDateStamp 0x565501ED, SizeOfImage 0x3A18000), image base 0x140000000; see chapter 1. Tables give each game address in both forms, game+0xRVA and the full address. Addresses inside other modules (Azimuth, the Xbox Live DLL) are given as module+0xOffset and change with that module's version.

12.1 What FH2MP is

FH2MP is Charelene's project that brings FH2's own online modes back on PC: online Free Roam, Road Trips, Rivals, car meets and races, with each player's real car and the game's own network code. Under Azimuth, every online service answers "offline"; FH2MP undoes that at the narrowest points it can and points the game's Xbox Live calls at its own servers.

It has four parts:

PartWhat it is
The client "shim", fh2-mods\FH2MP.dllAn FH2 Mod Platform mod written in plain C with no C runtime. Every game change goes through the platform: patch_bytes, hook_function, hook_call, hook_instruction.
Web services (Go)Answer the game's Xbox Live web calls: sessions, leaderboards, storage.
Game server (Go)A UDP server that relays the game's own network traffic and FH2MP's side channels (12.6).
Encore LauncherStarts the game with FH2MP's options, keeps the shim up to date and carries the in-game Guide overlay.

The supported set-up for FH2MP 1.5.1 is Azimuth 1.0.4, Extra Options 0.6.1, FH2 Mod Platform 2.9.1, plus two community mods: a horn mod and an in-game menu mod, which FH2MP now requires. FH2MP's launcher also installs the platform and Achievements, so a platform change reaches every FH2MP player.

What Azimuth does to online calls

Azimuth runs the Xbox One build on Windows and answers each online service as if the console were offline:

  • Winsock: the game's socket imports are offline stubs.
  • Xbox Live tokens: the token request (GetTokenAndSignature) fails with 0x800704CF (network unreachable), so the game never sends the web request that would follow.
  • Web requests: creating an IXMLHTTPRequest2 is refused with 0x80500010.
  • Sessions: CreateAssociationAsync (secure device association) throws and stops the process; QoS measurement answers 0x800704CF.
  • Identity: every player gets the same XboxUserId, 0x0009000000000000.
  • Sockets: the game never calls bind(), because the console OS did that for it. Windows refuses a receive on an unbound UDP socket with WSAEINVAL.
  • Launch arguments: stock Azimuth passes an empty argument list, so the game's own command-line options never arrive.

Habits worth copying from FH2MP

FH2MP makes well over a hundred changes to the game, and a few habits keep that manageable:

  • Byte-check against the exe on disk, not memory. Another mod may already have hooked the bytes in memory; the platform chains hooks. A mismatch turns off that one feature with a log line, never the whole mod. See chapter 5.
  • One kill switch per change. Each change has an environment variable FH2MP_NO_<NAME>. The server can set the same switches remotely through a signed document, but it only accepts NO_ names, so it can only turn things off.
  • Wait for every executable section. The shim waits until every executable section of the exe is mapped and readable before it patches. An earlier version gave up waiting after 10 s and then crashed on slow starts.
  • Know your log filter. The release shim keeps only log lines whose prefix it knows. A new feature's lines vanish until their prefix is added, so a missing line proves nothing.
  • Test builds carry the current release's version. The launcher replaces any shim whose version marker differs from the one it wants (it leaves "-debug" alone). A test shim with an older version is overwritten at the next start.

12.2 How a mod knows it is online

The FH2 Mod Platform answers this for you from API 9 (platform 2.8.0). The rules below are for platform 2.9.0 and later; see chapter 2 for the API in general.

What counts as online

The platform calls the game online when all of these hold:

  • FH2MP is present and turned on (fh2-mods\FH2MP.dll, or a DLL that registered as FH2MP before);
  • there is a session: FH2MP's session file exists (in data\bin if that folder exists, else next to azimuth.exe) and is less than 30 minutes old. The platform only checks that the file is there; it never reads it.

This is decided before any mod loads, and on the safe side: when in doubt, the game counts as online.

offline_only: the one-line answer for most mods

If your mod should never run online, say so when you register. Older platforms ignore the field, so set it anyway.

FH2ModInfo info{sizeof info, "Nitro", "1.2.0", "Me/Nitro", FH2MOD_PLATFORM_VERSION, 1};
info.description  = "Fast & Furious style nitro.";
info.offline_only = 1;   // the boost would be a cheat online
g_mod = api->register_mod(&info);
if (!g_mod) return 0;    // online (or a bad info): nothing to do

When the game is online, register_mod returns NULL. Return at once, and return 0: any other value shows the red "Not working" row on YOUR MODS for every other case, so make 0 a habit. On the next online launch the platform does not load your DLL at all.

The player's "Load when playing online" switch

When FH2MP is installed, every mod's page on the MODS tab gets a Load when playing online row. The player's choice there wins over your offline_only in both directions, and it is kept in fh2-mods\platform-online.txt. Write your readme so a player who turns an offline-only mod on knows what they are risking.

For loaders that host several mods (scripts or .NET mods, such as Platform.NET), each hosted mod's own offline_only decides.

Online found later: mods are stopped

Sometimes the platform only learns the game is online after mods have started, for example when FH2MP's own init finishes. Since 2.9.0 it checks again when a DLL registers as FH2MP, when FH2MP's init returns, and when FH2MP asks through going_online (below). Offline-only mods that already started are then stopped until the game restarts:

StoppedNot stopped
Hooks and patches removed; enable_hooks refusedYour own threads
Your strings, SQL and files removedMODS tab callbacks
Pop-ups, tips and sounds droppedHUD layer on_status
Hotkeys, commands, pad layers and title entries do nothingInterfaces you published
Your HUD layer hidden

The MODS tab shows the mod as "Off online". So if you keep a thread running, have it check playing_online() before it touches the game.

Two kinds of change can't be stopped: DLLs without fh2mod_init (mods from before the platform, which start from DllMain), and files a player copied into mediaoverride by hand. Files you add with set_file can be removed.

playing_online(): turning off one feature

If most of your mod is harmless online and only one feature isn't, don't set offline_only. Check playing_online() where that feature runs. It can change from 0 to 1 during a session, never back, so ask each time it matters rather than once at start.

static bool online_now(const FH2ModApi* api) {
    return api->api_version >= 9 && api->playing_online();
}

void on_boost_pressed() {
    if (online_now(g_api)) {
        g_api->log(g_mod, "boost: the game is online, so the boost stays off.");
        return;
    }
    start_boost();
}

Guard every API 9 call with api->api_version >= 9, so a player on an older platform gets a log line, not a crash.

FH2Platform.Online: the platform's side of the handshake

The platform publishes FH2Platform.Online (version 1) for FH2MP itself:

typedef struct FH2PlatformOnline {
    uint32_t size;
    int (*playing_online)(void);
    int (*going_online)(char* names, size_t size);
} FH2PlatformOnline;

going_online returns how many not-online-safe mods have already run (hooks or patches in, or text, SQL or files written for the game; loaded pre-platform mods count) and writes their names into names ("Nitro, Other").

  • 0: the game now counts as online, and offline-only mods that haven't run yet are stopped.
  • More than 0: nothing changes. The game stays offline and FH2MP asks the player to start from its launcher.

Ordinary mods have no reason to call it. It never rewrites string tables or the database.

FH2MP.Online: FH2MP's side, for car and tuning mods

FH2MP publishes FH2MP.Online (header fh2mp_online.h) so a mod with custom cars or parts can grey them out in its own menus before the server refuses them. The struct starts with its size, like every interface:

MemberMeaning
size, versionSize and interface version. Version 2 added online_held.
is_online()In a session and not held offline.
keeps_own_cars()Online, but the game kept its own database (no server database in place).
car_allowed_in_events(car_id)Checked against the server's base part list. 1, 0, or -1 if not known.
part_allowed_in_events(table, part_id)The same check for one part.
online_held(names, size)Which mods kept this game offline, and how many.

Read it from your own thread, after wait_for_mods (which returns 0 inside fh2mod_init):

if (api->wait_for_mods(30000)) {
    auto* mp = static_cast<const FH2MPOnline*>(api->get_interface("FH2MP.Online", 1));
    if (mp && mp->is_online())
        api->log(g_mod, "FH2MP is online, so modded cars are marked as offline only.");
}

The game server enforces the car and part rules either way; the interface only lets your menu say so first.

Extra Options plugins

Extra Options plugins have none of this: no offline_only, no stopping. If your plugin should not run online, say so in its readme, or make it a platform mod. See chapter 3.

12.3 Should my mod run online?

Ask one question first: does anything my mod changes reach, or depend on, another player's game? FH2's online code sends car states, not the inputs behind them, so most local changes don't break the connection. They break fairness, or they make two players see two different worlds.

Your mod...OnlineWhy
Changes physics, grip, power, boost, damage or the clock to your advantageoffline_only = 1It is a cheat in races and leaderboards, however small.
Changes the game database (add_sql) for cars, parts, events or rewardsoffline_only = 1, or keep it to Free Roam with playing_online()The server uses its own database and refuses a client whose database differs (below).
Turns collision off or ghosts your car locallyDon'tCollision requests are not replicated. Your car stays solid on other screens, and theirs hit an invisible wall (12.6).
Changes traffic, AI or world objects (trees, poles)Think hardEach client simulates its own traffic and world props; others won't see your change, and a car that hits something only you have will jump.
Changes the time of day or weatherOnly if it keeps the game's syncThe clock is kept in sync between players; a frozen clock fights the server.
Changes only what you hear or see: radio, HUD text, menus, camerasUsually fineNothing leaves your PC. Check it still works with FH2MP's own pages (12.7).
Reads stats or events only (achievements, logging)FineFH2MP's launcher installs Achievements for every player.

Desync risks to know about

  • The game database is checked. FH2MP sends a SHA-256 of the game database with its requests, so the server can refuse a client whose database differs. While the server's database is in use, FH2MP moves another mod's database aside and puts it back afterwards. Platform 2.9.0 and later leave the database alone entirely while online.
  • Traffic is local. FH2MP keeps every client on its own offline traffic manager, so traffic cars differ between players. A mod that changes traffic changes it only for you.
  • Contacts are not forces. When two cars touch, the other side only gets visual damage (message MsgCarCollision, id 21). A mod that makes collisions harder or softer changes your car's reaction only.
  • The Free Roam lobby and its events look alike. The event context reads 3 for both, so a client can't tell them apart by itself; FH2MP asks the server. Don't base an "is this a race?" rule on that value alone.
  • Pausing doesn't pause online. The world keeps running while a player is in the pause menu (12.7).

12.4 How FH2's networking works

On the Xbox One, FH2 used three layers. Knowing them tells you where to look when something online fails.

  1. Xbox Live web services, through the Xbox Services API (XSAPI) DLL that ships with the game. Every call first asks for a token, then sends an HTTP request through IXMLHTTPRequest2. The game's HTTP wrapper is Xls::HttpRequest. Sessions, matchmaking tickets, leaderboards and cloud storage all go this way.
  2. Session set-up: multiplayer session documents, secure device association between consoles, and QoS measurements to every peer.
  3. The game's own UDP traffic, "NetV2" over a NerdLib packet layer, read and written with a BitStream class. Car states, starting grids, car meets and the rest travel here.

The lobby object, CLobby, ties it together. Useful globals:

GlobalAddressWhat
[game+0x34D6348][0x1434D6348]CLobby. +0xF0 "connected to Xbox Live" (always 0 under Azimuth; forcing it to 1 crashed the game). In a session: +0xD0 != 0 and +0xA8 == 0. +0xB0 GameOptionsSynced; +0x30 mode (2 = race starting from a lobby); +0xB8 event options.
[[game+0x34ABA60]+0x48][[0x1434ABA60]+0x48]CGameManager. +0x28 paused; +0x29 "a pause stops the simulation" (0 online, 1 offline).
game+0x34AF7D00x1434AF7D0Options singleton with the developer network switches (12.5).
game+0x36E29600x1436E2960MatchRequester / network manager pointer.
[game+0x34D6AC8][0x1434D6AC8]Road Trip manager.
[game+0x34C0F40], +0x60[0x1434C0F40], +0x60Event context, reached through game+0x2129A0 (0x1402129A0): 2 solo Free Roam, 3 online Free Roam lobby (and its events).

Every car carries its kind at car+0x598 and car+0x4D08: 0 local human, 1 Drivatar, 2 traffic, and 3, 4, 5 the same three as copies in another player's game. See chapter 11 for more structures.

Helpers worth knowing if you decode packets: BitStream::ReadString game+0x17676B0 (0x1417676B0), and the BitReader helpers game+0x1767100 (0x141767100) and game+0x1767940 (0x141767940).

12.5 What FH2MP's client changes, and why

The tables below list FH2MP's client changes by topic, from its develop branch. "Kind" is the platform API used: function (hook_function), call (hook_call), instruction (hook_instruction), patch (patch_bytes), pointer (an import or vtable slot). Each one is byte-checked and can be turned off with FH2MP_NO_<TAG>. If your mod touches any of these sites, expect to share them: chain through the platform and pass the original on.

Sign-in and tokens

TagWhereKindWhat and why
GetCmdArgumentsazimuth.exe (found by a hash of its first 9 bytes, since it moves every release)functionHands the game FH2MP's launch options, which stock Azimuth drops.
identityazimuth.exe: the XboxUserId getter and the save-folder renamefunction + patchGives each player their own Xbox user id. Scoped to FH2 only, so FH3, FM5 and FM6 saves keep their own ids.
xstokenMicrosoft.Xbox.Services.dll (the game's XSAPI): GetTokenAndSignature and its ForAllUsers twinfunctionReturns a token result at once instead of a network failure, so the game goes on to send its web request. The real session credential travels in FH2MP's own HTTP header. Waits for XSAPI's imports to be bound before hooking.
stsgame+0xEF88B0 / 0x140EF88B0, StsAuthTokenManager::GetAuthTokenfunction (replacement)The game's second token path: completes the ready callback (vtable slot 2) synchronously.
online-setupgame+0x183ABD0 / 0x14183ABD0, sign-in listener (the test at game+0x183ACD7)functionLets the sign-in event reach the multiplayer services.
xhrthe game's CoCreateInstance importpointerWhen the game asks for CLSID_FreeThreadedXMLHTTP60, returns FH2MP's own in-process IXMLHTTPRequest2 built on WinHTTP. Azimuth refuses the real one, so without this no web call happens.

The game also asks for a session template every 30 s and gets "not found". That is expected and harmless.

Sockets and addresses

TagWhereKindWhat and why
winsockWS2_32 import table at game+0x1DD0D80 / 0x141DD0D80 (23 slots)pointerPoints the imports at the real ws2_32.dll instead of Azimuth's stubs.
implicit bindinside the WSARecvFrom/recvfrom wrappers(in the wrapper)Binds a never-bound socket to the wildcard address, port 0, before the first receive. The console OS did this; Windows refuses with WSAEINVAL.
UDP ticketinside the WSASendTo wrapper(in the wrapper)Before a datagram that opens a connection, sends an 84-byte signed ticket (magic FH2MPTK1) so the server admits only signed-in players.
serverportthe literal "5000" at game+0x1E9B0F4 / 0x141E9B0F4patchThe service port in the game's endpoint string; replaceable by an environment variable.
net_string_guardBitStream::ReadString, game+0x17676B0 / 0x1417676B0functionBounds-checks strings read from the network. Readers include OpenConnection game+0x176D570, CarMeet game+0x17F7440 and BucketList game+0x181F630.
net_watchDispatch game+0x1761D60, Disconnect game+0x1761C40, ProcessReceivedPackets game+0x1766100, Close game+0x1768690function (passive)Logs connection life.

Sessions, invites and matchmaking

FH2 kept its developer network switches in the options singleton at game+0x34AF7D0 (0x1434AF7D0). FH2MP sets these:

OffsetOption
+0x2FF1BypassMatchmaking
+0x30F4NetSessionEnableSinglePlayerFreeRoamEvents
+0x3013DirectIp for Road Trip (char[0x20])
+0x3033DirectIp for Free Roam (char[0x20])
+0x321ALocalLobbyHopper
+0x321BEnableDebugIpList

The direct-connect helpers are BuildRequest game+0x1763490 (0x141763490) and BeginJoin game+0x17A99E0 (0x1417A99E0).

TagWhereKindWhat and why
matchmaking tablethe lea at game+0x80E868 / 0x14080E868 (Road Trip: game+0x80E801 / 0x14080E801)patch (rip-relative displacement)Points the matchmaking config from network_matchmaking_freeroam.xml to a direct-IP variant. The new string sits in a page allocated within 2 GB of the code so the displacement reaches it.
mmallowgame+0x80F6D3 / 0x14080F6D3, in IsMatchMakingAllowed game+0x80F6B0patch (NOP 6)Matchmaking was skipped when CLobby+0xF0 was 0, which is always so under Azimuth. Patch the gate, not the byte.
qosokQoS lambda game+0x17940F0: game+0x17941DB / 0x1417941DB and game+0x1794216 / 0x141794216; private-game lambda game+0x1794840: game+0x1794907 and game+0x179493FpatchMarks the secure association / QoS step as succeeded. Both changes of one lambda go in, or neither.
secureipSecureIPResolver game+0x17A0FF0 / 0x1417A0FF0function (replacement)Calls OnSecureIPResolved game+0x17AEC90 at once with success and no endpoint list; the handler then builds the endpoint from the server's host name.
sdastrSecureDeviceAddress::ToString game+0x17A5B00 / 0x1417A5B00functionReturns a placeholder Base64 string. Without it, XSAPI fails with E_INVALIDARG and the player sees "Unable to join session".
invitetypeMatchRequester::SetSession game+0x17B8C50 / 0x1417B8C50function (replacement)Sets the lobby type at MatchRequester+0x160 (Road Trip 1, Free Roam 2) from the synced Car Meet invite. Without it a joiner asks for type 3.
samesessiongame+0x17B07C0 / 0x1417B07C0patch (jnz to jmp)A join into the session you are already in is no longer an error.
matchpollgame+0x183AFF2 / 0x14183AFF2, game+0x183FC3F, game+0x183AFCDpatchPolls the match ticket every 0.5 s instead of 5 s.
mmtimeoutgame+0x17B3361 / 0x1417B3361, game+0x17B33B1; QoS wait game+0x17B1B58patchShorter waits for steps that can never really succeed here.
qosresultMeasureQosToSessionPeers game+0x179B030 / 0x14179B030functionAnswers success.
mmtoastgame+0x80C10F / 0x14080C10F, game+0x80C285patch (jne to jmp)Hides the "lost connection to Xbox Live" toast after a match attempt.
livegategame+0xC86AA2 / 0x140C86AA2, game+0xE687A4 / 0x140E687A4, game+0xE0D75D / 0x140E0D75Dpatch (jne to jmp)Menu gates that hid online entries when not on Xbox Live.
onlinemeetgame+0x830B8E / 0x140830B8Epatch (NOP 2)Lets the online Car Meet tick run.
rivalgategame+0x666F52 / 0x140666F52patchRivals gate.
Rivals leavestateflow global.xmlfile (set_file)Disconnects first, so a Rivals event can start from the menu online.

The pattern is the same throughout: never fake the global "connected" state, which crashes the game; find each gate that reads it and change that branch.

Traffic, events and game rules

TagWhereKindWhat and why
trafficgame+0x3B94F3 / 0x1403B94F3 (a mov byte [rcx+0x20],0; ret, the 0 becomes 1); game+0x728C10 / 0x140728C10patchKeeps the OfflineTrafficManager, and sends SyncTrafficModule's "go online" to its "go offline" path. Every client runs its own traffic.
trafficowngame+0x717445 / 0x140717445, in RequestOwnership game+0x717410patch (NOP 2)Every collision requests ownership of the traffic car, not just the first. The game's own 2 s limit stays.
mpdiffgame+0xF58A5E / 0x140F58A5Epatch (displacement)Points a vaddss from the Medium to the Insane entry of the AI difficulty table (game+0x354F9A0, entries 0x28 apart), so online counts as top difficulty for rewards.
hometilegame+0xDDB49B / 0x140DDB49Bpatch (jnz to jmp)Shows the pause menu's Home tile online. Setting the byte it tests (page+0x537) broke the Social tab and LB/RB; change the jump, not the data.
bucket-list carsEnableBucketListCarLoading game+0x43EF60 / 0x14043EF60function (opt-in)Loads bucket-list cars online.
event_fix, event_stock, autodrive, tune_gategame+0x140C3F0, game+0xF58A90, game+0x8A4880; vtable slot 59 at game+0x28D9A0; game+0xF79F10; call at game+0xDBFDD6 / 0x140DBFDD6function / pointer / callKeep events stock online: the server's event set, no autodrive, no tuning where the server forbids it.
speed_pbcall game+0x5B0B9D / 0x1405B0B9DcallPersonal bests on speed traps and zones online.
eo_routesSetFeature game+0x899010 / 0x140899010functionExtra Options' "Show All Events" gates broke online routes; this keeps them working.
eo_timelockclock game+0x197AEC0 / 0x14197AEC0functionExtra Options' weather control froze the clock online by clearing the network-sync flag (+0x361); this keeps the time of day in sync.
gamedb_keep(files)set_fileMoves another mod's game database aside while the server's is in use, and puts it back afterwards.

The festival grid

At the end of a Road Trip, FH2MP builds the finishing grid at the festival hub (about 6154.6, 118.6, -5935.6) for every player.

TagWhereKindWhat
festivalgridgame+0x8131A0 / 0x1408131A0, where BuildEndEventGrid game+0x813080 calls game+0x627C20callSupplies the hub grid. Related: Road Trip manager [game+0x34D6AC8], RoadTripSynced game+0x14A8620 (vtable +0xC0 = EventRaceId), race data game+0x1762870 (+0x2A8 slot, +0x2B0 position, +0x2C0 forward).

Event options: a real extra row in race set-up

This is in FH2MP's develop branch, not yet in a release. It shows how to add a working row to a stock set-up screen, which other mods may want too (a "modded cars" host option uses the same technique).

PieceAddressNotes
Row buildergame+0xD78E50 / 0x140D78E50Builds the screen's rows; called once, from game+0xD8200D. Extra Options hooks that call site, so hook the function instead.
Row classvtable game+0x2E0C898 / 0x142E0C898, 0xA8 bytesTitle +0x70, SelectedIndex +0x78, Data +0x80, a std::function at +0x88.
Make a rowgame+0xD709F0 / 0x140D709F0
Add a rowgame+0xD6E650 / 0x140D6E650The collection is at page+0x410. The function wrapper's vtable is game+0x2E105C0.
On Startgame+0xD6F470 / 0x140D6F470Calls every row's function.
Settergame+0xD91C40 / 0x140D91C40

Every injected row needs a real function. An empty std::function stops the game with bad_function_call when the player presses Start. The host's choice reaches everyone over a side channel (12.6).

12.6 Multiplayer cars

Side channels: your own data beside the game's

FH2MP sends its own data as signed UDP datagrams on the same port as the game's traffic. The trick that makes this safe is the header: the datagram starts with an 11-byte NerdLib header that carries no messages, and the game itself throws such a datagram away. So the game never sees side-channel data, and FH2MP's server can still relay it.

Layout, in order:

  1. the empty NerdLib header, ff ff fe ff 00 00 00 00 00 00 00;
  2. an 8-byte magic;
  3. type;
  4. sender's Xbox user id;
  5. sequence number;
  6. a 16-byte ticket epoch;
  7. data;
  8. an HMAC-SHA256 under the player's ticket key.
MagicCarries
FH2MPLT1Lights: headlights, brake lights, indicators; version 2 adds open parts such as the bonnet.
FH2MPHN1The horn (with a community horn mod).
FH2MPPN1Probe / ping.
FH2MPCS1, CS2Car-select hold: everyone waits until every car has loaded.
FH2MPMD1Mod state: NOS and underglow.
FH2MPQC1Quick chat (12.7).
FH2MPEO1Event options (12.5).
FH2MPEL1An elimination mode (in progress).

Rules that came out of building these:

  • Send state, not events. A lost datagram then heals with the next one. Give each state a lease (lights 2 s, horn 0.5 s) and fall back to "off" when it runs out.
  • Don't touch car memory from the network thread. Copy what you need on the game thread, then hand it over.
  • Find the game's own hook points for showing the state. Light sync uses the local prediction sample game+0x1808170, the remote prediction identity game+0x9C7300, light material publication game+0xF5C900, the headlight animation game+0xF7BCC0, and car animation events through game+0xF5D300(car, "hood:open"). Remote underglow uses the LightManager: CreateLight game+0x10C7E00, SetIntensity game+0x10F0550, SetPosition game+0x10F1C30, SetDirection game+0x10F0DA0.
  • Hold the start until every car has loaded. The car-select hold hooks NetworkWaitForCarsLoaded's update game+0x8E0990 (0x1408E0990) and NetworkWaitForCountdown game+0x8E0B90 (0x1408E0B90), and relabels the "Setting Up Event" and "Waiting for Players" texts (game+0x5E68C0, game+0x5E6950).

The car pool and party limits

Stock FH2 can't show more than 11 remote cars, and a 12-player party is its limit:

  • Car pool. CarCacheModule (vfunc 2 at game+0x47A570 / 0x14047A570) has 11 slots for remote cars and clamps at 12, so the 12th remote car of a world never exists.
  • Car ids. FindOrQueue game+0xFD08B0 uses stand-in ids 0 to 11 for players and 12 to 29 for AI. AI controller arrays hold 12 entries, and an id past 11 crashed the game.
  • Name tags. CarLabelCacheModule game+0x47A830 holds 12 labels.
  • Party list. 12 rows; a 13th member crashed the whole lobby.

FH2MP grows them together: the slot count and clamp, the view allocation (game+0x1302160), the LOD table, the allocator budget (game+0x125DE50), the name-tag pool, shared stand-in ids when they run out (game+0xFCEEE0), no AI controller for remote cars (game+0xF73E10), and up to 75 party rows (the row writer call at game+0x78BE88 / 0x14078BE88, the mini-leaderboard call at game+0x78BEB0, and the per-frame update game+0x78BBD0).

One lesson from this: the AI count follows the slot count. A 75-slot profile once made solo events stick at "Synchronizing Drivatars 10/11", so solo AI counts must stay unchanged when the pool grows.

How the game moves a remote car

PieceAddress
RemoteCarPrediction vtablegame+0x2D3B360 / 0x142D3B360
Blend helpergame+0x9EFFA0 / 0x1409EFFA0
ApplyUnpackedStategame+0x9EBC20 / 0x1409EBC20
AddPositionOffsetgame+0x9ECF80 / 0x1409ECF80
LocalCarPrediction look-ahead (about 1/3 s)game+0x9B9350 / 0x1409B9350
LimitLocalRemoteCollisionsgame+0x9C6900 / 0x1409C6900
CPhysicsWorld::StepWorldgame+0x12EB450 / 0x1412EB450
Simulation::Updategame+0xFB33D0 / 0x140FB33D0

Each frame, Simulation::Update runs input (slot 0x170), the car's slot 0x78, the physics step, ForzaCar::Update (game+0x2A9400, slot 0x80), then slot 0x88. Remote cars are placed from received states and blended towards them.

Two things follow for anyone trying to improve contact between players:

  • The look-ahead never runs the physics step, so a prediction can't see a collision coming.
  • Contacts are not replicated as forces (12.3). Each side solves the contact with its own copy of the other car.

FH2MP has experimental changes to both the copy path and a contact forecast, behind a switch; they are not on by default.

Collision groups and replicated bits

Each car's collidable request sets are at car+0x4C58. Groups 2 and 3 are cars, 4 and 5 ghosts; the collision matrix is at game+0x367AAD0 (0x14367AAD0). The functions are: request set update game+0xF7B770, hide game+0xF649F0, show game+0xF79330, alpha game+0x28C590; Car::GetDynamics is game+0xF605D0.

Requests are never replicated. If either car has collision off, there is no contact on that PC. So ghosting your own car the offline way leaves it solid on everyone else's screen: one side ghosts, the other doesn't, and the result looks like a wall.

What does travel, inside the car prediction state:

  • a 2-bit teleport counter;
  • a 1-bit griefing flag (body bit 394 of the full prediction state);
  • a 5-bit "universe". Cars in different universes ignore each other (the universe component's vtable is game+0x2C884B8).

The anti-griefing bit: the game's own online ghost

FH2 already ghosts a griefing car online, and that state is replicated. That makes it the right carrier for any ghosting feature.

FunctionAddressNotes
ShouldStartGriefinggame+0x28D350 / 0x14028D350bool(car, float abs_dt); one call, at game+0x2A949F. Byte check: 48 8B C4 57 48 81 EC 90 00 00 00 48. Named FH2_GAME_FORZACAR_SHOULD_START_GRIEFING in fh2game.h.
StartGriefinggame+0x2A5F00 / 0x1402A5F00
ShouldStopGriefinggame+0x28CCB0 / 0x14028CCB0
StopGriefinggame+0x28D6D0 / 0x14028D6D0

All four are called from ForzaCar::Update. The flag is ICarDynamics+0x4EE5, set through vtable slot 0x950 and read through slot 0x958.

  • Only the local human car (kind 0) is judged. Remote copies (kind 3) mirror the replicated flag.
  • Stock triggers: under 5 mph after 20 s, and driving the wrong way.
  • Effect: the "griefing" preset turns collision off and sets alpha 0.5, with a 5.5 to 7.5 s cooldown.
  • The whole rule is gated by GameOptions UseOnlineAntiGriefing (GameOptions+0x4830, slot 0x310), which is off by default.

A ghosting feature that every player sees the same way therefore hooks ShouldStartGriefing on every client: for the local car, return the stock answer OR your own triggers (a speed zone, a ram, a hard hit); for remote copies, return the replicated bit. Nothing like this is in a FH2MP release yet; it is the approach that fits how the game works.

A side note for speed-zone ideas: every random traffic draw uses the C runtime's per-thread rand(), and nothing in the traffic code reseeds it. The only srand in the exe is the dialogue picker at game+0x506C75. So "the same traffic for everyone" needs your own reseed.

12.7 UI online

Quick chat through an existing menu

The first attempt at quick chat used a controller chord (hold LB plus the d-pad) through the platform's pad layer. It was dropped, and the reasons apply to any driving-time input:

  • Every d-pad direction is already used while driving. Extra Options binds DPadLeft/Right to indicators (a tap also replays the radio), DPadUp to hazards and photo mode, and DPadDown to autodrive; the radio reads the d-pad as one control.
  • The game's value query ignores the "taken" mask, so a pad layer has to clear the buttons from the reading as well.

The version that shipped adds a "Quick Chat" list to a community in-game menu mod, through the interface that menu publishes. It has 16 fixed phrases whose numbers never change meaning, so a phrase travels as a number. A quick-chat mod shows it with the game's HUD notification (with the Car Meet icon) and publishes a small bridge interface; FH2MP sends the number over FH2MPQC1 and hands received ones back. Scope is the same world and the same event; messages older than 5 s are dropped, and there is a 1.5 s cooldown.

The lesson: if a menu mod already exists, add an entry to it rather than claiming buttons.

A message box over the name tag, with no hooks

FH2's name tag is Scenes/Anthem/AR_OpponentLabel.xaml, one page object per opponent (12 in all, made at start-up). It has no spare text property. Platform API 11 (2.9.1) added add_page_text(mod, name, get, user) and page_text_changed: a game page binds {Binding FH2Mod_Text_<name>}, and the getter is handed the page object that reads it, so each tag can show its own text. See chapter 2.

The page itself is read from media/UI.zip at start, the box is added to the XAML text, and the result goes back with set_file. Points that mattered:

  • Collapse the box when its text is empty, or an empty box floats over every car.
  • Show the text longer than the pop animation (6 s against a 0.63 s pop), because a car that comes into view late misses the start.
  • One owner per page. FH2MP owns AR_OpponentLabel.xaml and puts both its developer badge and the chat box in one replace; the quick-chat mod only supplies a page text when FH2MP is loaded.

Photo mode online (in progress)

FH2MP has photo mode working online on a branch that is not yet in a release. It is a good example of opening a feature the game hides online.

  • The photo button is read in States::WaitForPause's update, game+0x964810 (0x140964810): control 15, then a "may open" test.
  • The test is game+0x9636C0 (0x1409636C0). Its last check is the online block: a CLobby test at game+0x963739, then a je at game+0x963740 (0x140963740, bytes 74 0F).
  • Online, the world keeps running in a pause: network.xml runs update_simulation_when_paused, and CGameManager+0x29 is 0. The set-paused function is vtable slot 0xC8, game+0x2EF310 (0x1402EF310).

The change NOPs the je, hooks the test so that in Free Roam with no Road Trip it sets +0x29 = 1 for the photo session, and hooks set-paused to clear it after the unpause:

static const uint8_t kJe[2]  = {0x74, 0x0F};
static const uint8_t kNop[2] = {0x90, 0x90};
api->patch_bytes(g_mod, "photo online gate", base + 0x963740, kJe, kNop, 2);

Extra Options 0.6.1 hooks the same code: it replaces the readiness call at game+0x963703 with a cave and hooks the button read at game+0x964C00, and its own check says no when online. So FH2MP asks the remaining conditions itself and opens after a 1 s hold. What other players see of a frozen car is not yet known.

Pause menu tiles

The pause page set-up, game+0xDDAC80 (0x140DDAC80), switches on the event context and hides or disables tiles per mode. Hide is game+0xDD8FD0(page, name, visibility); "disable with a reason" is game+0xDC2A00. In the online lobby case (3, at game+0xDDAF7A) it hides PART_Button_Photomode.

  • Change the branch, not the data: the Home tile lesson in 12.5 applies to every tile.
  • Don't hook the platform's pause sites (the Marketplace handlers and the Achievements tile calls, listed in chapter 5). For a tile of your own, use the platform's pages API (API 8 and up).

Page edits instead of hooks

Much of FH2MP's online UI has no hooks at all: it reads the game's own XAML from media/UI.zip, edits the text, and set_files the result. Pages it edits include the name tag, NotificationPopupControl.xaml, PlayerListControl.xaml, the A_*Leaderboard.xaml pages and HUDMiniLeaderboardControl.xaml.

  • DataTrigger, MultiDataTrigger and template triggers with storyboards work, including a Setter on Text.
  • FZGeometry polygons draw a logo with no texture; FH2MP's developer badge is drawn that way. The game's gamertag text carries club marks as characters (U+222B leader, U+2229 and U+222A marks), so a DataTrigger keyed on one can show a badge with no hook.
  • The XAML reader decodes only named entities and lowercase-x hex references (&#xNN;). A decimal &#NNN; becomes a space, and a file without a BOM is read as Latin-1.
  • Keep the game file's CRLF line endings in raw XAML strings.
  • Extra Options rewrites some stock pages by their exact x:Class text. Write x:Class =, with a space, on your own pages.
  • On Azimuth 1.0 or later without Extra Options, files go to the platform's own layer; use set_file and override_root(), never a hard-coded mediaoverride.

More on pages in chapter 4 and chapter 8.

"Xbox Live" text

Online, the game still says "Xbox Live" in about 12 visible strings (Lobby 0xCD5B, 0xCC5C, 0x355C; Main 0x8102, 0x4387, 0x923B, 0xD69C; LiveStrings 0x6446, 0xF85B, 0x2CBF, 0x4AA1, 0x5BDD, 0x2505). Changing them cleanly needs a per-language substring replace, which the platform doesn't have yet: set_string writes one text to every language, and replace_string matches whole strings only. German, French, Spanish, Italian and Brazilian Portuguese keep "Xbox Live" verbatim; Polish and Japanese don't.

12.8 Performance lessons

A mod that runs every frame for every car costs far more online, with up to a dozen cars on screen. FH2MP's measurements are the best data we have; the details are in chapter 13.

  • VirtualQuery is slow on FH2's heap. Its cost grows with the size of the committed block that holds the address, and the game's heap is one huge block:

    BlockVirtualQuery
    16 MB36 µs
    256 MB680 µs
    1 GB11.3 ms
    3 GB13.7 ms
    ReadProcessMemory, any0.46 µs

    A "safe read" that queried before each read, called per car per frame, took free roam from about 93 fps to about 25 fps as players joined. Read with ReadProcessMemory alone; it fails cleanly on unmapped memory. Keep a query path only under Wine (ntdll exports wine_get_version).

  • Don't check "is this still mapped?" every frame. A per-frame guard that queried one game address cost 0.5 ms a frame, with worst calls of 15 to 41 ms. Check rarely, or cache the answer.

  • Sample before you guess. A stall sampler that suspends threads once a second and records RIP and return addresses found the VirtualQuery cost in minutes. A frame-stall log on the frame step game+0xFA78A0 (render side: see 16.2) later showed that most long frames were waiting in the game's gamma routine, game+0x10EF300 (0x1410EF300), which costs about 28 µs a call. That is where the frame waits, not the cause; the long frames' real cause is still unknown.

  • Measure A against B in one session, in alternating turns, and count calls as well as time.

  • Quit the launcher fully between A/B runs. An environment kill switch set in a shell lived on in the launcher process, so runs that were meant to test a feature had it turned off.

12.9 Crashes online

Online play exposed a long list of game crashes: remote cars loading and unloading, party lists outgrowing their arrays, modded cars with bad physics data, Azimuth refusing some texture formats, and more. FH2MP guards each one at a named address. The full table, with addresses, causes and guards, is in chapter 13, alongside the platform's crash reports.

12.10 Other games

Azimuth runs more than FH2: Forza Horizon 3, Forza Motorsport 5 and Forza Motorsport 6, each mapped at 0x140000000. That matters to online code and to the platform:

  • FH2 Mod Platform 2.8.0 and later leave other Forza games alone. game_base returns NULL for anything but FH2, so check it for NULL before using it.
  • Earlier tests ran the platform in FM5 and FM6 with a new offset: replacing files through mediaoverride worked; the Mods page did not.
  • The FH3 Mod Platform is a community fork of FH2 Mod Platform 2.8.0 for Forza Horizon 3. Its API versions 10 to 15 are FH3-only additions, its mods go in fh3-mods, and it targets the FH3 exe of 5 Jun 2018 (TimeDateStamp 0x5B16ECCA). An FH2 mod does not run there unchanged.
  • Identity is per game. FH2MP's identity change is scoped to FH2, so FH3, FM5 and FM6 saves keep their own ids. Anything you hook in azimuth.exe should be scoped the same way.
  • Whether the FH2 platform itself will support other games is undecided.

Content from other games can still be useful as reference: FH5's UI.zip is a plain zip, and its quick-chat XAML was read as a guide for the name-tag box above, though none of it is shipped.

12.11 In short

  1. Set offline_only = 1 if your mod gives an advantage, changes the database or ghosts cars; otherwise check playing_online() where one feature matters. Always return 0 from fh2mod_init.
  2. Assume your mod can be stopped mid-session, and let your threads check before they touch the game.
  3. Under Azimuth, undo each "offline" answer at its narrowest point. Never fake the global "connected to Xbox Live" byte.
  4. If Extra Options hooks a call site you need, hook the function instead, and do the check it refuses yourself.
  5. Change branches, not the UI data bytes they test.
  6. Grow car slots, labels, party rows and ids together, and keep solo AI counts as they were.
  7. Ghost through the replicated anti-griefing bit, never through local collision requests.
  8. Send state with a lease over side channels, and copy car data on the game thread.
  9. One owner per page; others add through the owner.
  10. Measure per-frame costs with many cars, and never VirtualQuery in a hot path.

“The FH2 Modding Guide” by Trinculo54 is licensed under CC BY 4.0; its code samples are under the MIT licence. This page is an unchanged copy (links point to this site) of 12-online.md at commit bb10508; corrections belong in the original repository.