SUNRISE

Client hooks

A client hook is a change Sunrise makes to the game’s code at run time. Sunrise keeps these to a minimum. The tables below list every hook Sunrise installs. They follow the install calls in the code. A hook that is never installed is not listed.

The rule

A hook may do four things: redirect traffic, serve the Sunrise tools and menu, draw, or log.

A hook that changes game behavior is a stand-in for server behavior not yet understood. The live game needed no such hook, so a correct server needs none. When the server behavior lands, the hook is deleted in the same change.

The Activity Host never reads the client to make up events or state. It works only from the activity messages.

Every hook finds its target by byte pattern, export name or a probe object, never by a fixed address. It fails cleanly when the target is missing. Every hook except the egress guard can detach.

These behaviors come from the server. No hook is needed for them:

behaviorhow the server delivers it
hold the spawn until the fadethe message 5 roster holds the client’s own spawn gate
fix the solo fireteam checkthe matchmaking config carries the fireteam threshold
skip the profile setup screensthe account object publishes a completion marker
drop an empty queue updatethe subscribe answer carries the family snapshot
force the join statethe host waits for the client’s join

Install order

Hooks use Microsoft Detours (src/client/hooking/detour.cpp). A group attaches in one transaction: all or none.

whenwherewhat
DLL load, Steam initsrc/dllmain.cpp, src/steam/runtime/steam_lifecycle.cppegress guard, package trust, boot textures
Steam networking loadssrc/client/runtime/client_platform_hook_activation.cpptwo Steam networking hooks
first framesrc/client/runtime/client_hook_activation.cppDXGI, cursor, keys; test input only in a test process
game image scannedsrc/client/runtime/client_hook_activation.cppnetwork group, all game hooks; the co-op hooks only with co-op on; noclip and infinite ammo only when client.cheats is on
Studio link startssrc/client/diagnostics/studio/pose and CUI observers, only when core.studio_attach is on
on a triggersrc/client/hooks/retail_log/, src/steam/runtime/callbacks/callback_dispatch.cpptwo data fixes, one feature flag, and the co-op machine id write, applied again from the callback pump

In the tables below, “detour” hooks a function found by byte pattern or through a probe object, “export” hooks a Windows export by name, and “data” writes a game value that is restored on detach. A number is how many hooks.

Transport

hookwhat it doeskind
egress guardsockets and DNS: blocks outbound traffic, sends connects to Sunrise, answers the discovery queryexport (31)
HTTP executoranswers HTTP in process; unserved requests get 503detour
transport kinduses direct sockets instead of the Steam relay; the kind getter and the session selectordetour (2)
Steam certificatereports a local certificate as valid; in steamnetworkingsockets.dlldetour (2)
content configanswers the content manifest request; skips its signature checkdetour (2), data
config URL and tokensupply the values the content fetch asks fordetour (2)
external serverexternal-server mode only: turns off TLS peer checks and points every request URL at that serverdetour

The egress guard never detaches. The certificate and manifest hooks stay until Sunrise can sign these itself.

Tools and menu

Most of these attach at start, so a tool can be turned on without a restart. The noclip step and the ammo setters attach only when client.cheats is on at startup.

hookwhat it doeskind
game windowstake mouse and keys while the menu is openwindow subclass (2)
SetCursorPos, ClipCursorfree the pointer while the menu is openexport (2)
GetKeyState, GetAsyncKeyStatehide keys from the game; hold the teleport keyexport (2)
camera and physics syncteleport; also ticks fly, sword skate and the Sunrise Studio linkdetour (2)
physics stepnoclip and flydetour
ammo settersinfinite ammodetour (3)
inactivity timeoutsanti-AFKdata
placed-object create, destroyfeed the world-object browser and the Studio link; read onlydetour (7)
skinned pose producercopies finished bone palettes for the Studio link; read only; only with core.studio_attachdetour
UI framecopies the open CUI screens for the Studio link; read only; only with core.studio_attachdetour
mission launcherstarts an activity through the game’s own entry pointscall

Rendering

hookwhat it doeskind
Present, ResizeBuffers, SetFullscreenStatedraw the menu on the game’s swap chain, only when the menu is ondetour (3)
boot texture dispatcherswap a few boot-screen textures for ones built into Sunrisedetour

Co-op

These install only when co-op is on: multiplayer_enabled is true, and the role is host or the install has an upstream host. A failed install of the first two stops the image-scan step.

hookwhat it doeskind
account registrationreports when the game has registered the local Steam id and its friends manager exists; Sunrise raises the friends callback only after both; changes nothingdetour
machine idwrites machine_id over the game’s cached machine id, and restores it at shutdown; does nothing while the value is 0data
single-instance guardreleases the game’s single-instance mutexes once, so a second game starts on the same PC; only with a nonzero machine_idimport slot

The machine id and the guard serve two games on one PC. Co-op across two PCs needs neither.

Hooks that change game behavior

hookwhat it doeskindretired by
bubble authoritylets message 5 set authority on every bubbledetour (2)nothing yet; no server field reaches the gate
package trustloads installed packages the trust check refusesdetour, patch (2)unknown; the refusal is not understood
mod package pathopens the package files a mod serves from the Sunrise folder: the path builder and the file opener; writes kept live updates into a tag when it loads; attached only when a mod serves a filedetour (3)nothing; the game only opens packages from packages, and registers them once (Mods)
async I/O guardstops a native reload from racing a teardownpatcha fix for the native race
lore booksclears display gates on lore books; on by defaultdataa data fix for the gates
Arrivals leg modsmoves four leg mods into the leg plug set; off by defaultdataremoval; the retail game has the same gap
ownerless channelsets one client feature flag; off by defaultcallserver behavior that keeps the channel owned

Diagnostics

These only read and log, with three exceptions: the assert handler, the retail log’s verbosity setting, and the test input guards.

hookwhat it logskind
retail logthe game’s own log, into the Sunrise log; with the client channel at debug, it also sets the game’s 26 log categories to full verbosity every 2 secondsdetour
assert handlerthe assert; the game keeps running unless the device was losthandler swap
hitch watchdogthe watchdog snapshot and the stuck thread’s stackdetour
stall watcherevery thread’s stack when the frame pump stopsthread
exception probeC++ throws from Sunrise, faults in Sunrise code, and access violations in game code, with return addresses; every exception goes on to the next handlervectored handler
test inputonly when the process starts with SUNRISE_TEST_INPUT=1: takes keys, mouse, raw input and pad state from a test harness, reports the window as in front, and saves screenshotsexport
cinematic readinessthe readiness stages of boot cinematicsdetour (16)
lifetime gatethe spawn gate inputs and each message 5 roster applydetour (2)
network tickone byte of the network guard, each framecall
entity create, purge, policyentity ids and purge masks; 3 of the 7 object hooks abovedetour