Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save vittorioromeo/8985f5c538deccf19e9a8c84fed64aea to your computer and use it in GitHub Desktop.

Select an option

Save vittorioromeo/8985f5c538deccf19e9a8c84fed64aea to your computer and use it in GitHub Desktop.
prey_claude_reverse_engineering_notes.md

Prey (2017) internals - notes from three Chairloader DLL mods

Written for the PreyVR / motion-controls effort by Vittorio "Vee" Romeo, September 2026. Everything below was learned while building three DLL mods on the Chairloader framework and is offered freely (the mods are MIT):

Each repository has a DEVNOTES.md with more detail and the source is small enough to read in one sitting. This document collects the parts most likely to matter for a VR conversion and the traps that cost us crashes. It is written to be pasted into an LLM's context as well as read by a human; sections are self-contained.

Build targeted: Steam Prey 1.0.1.0 as patched by Chairloader to the EGS 2021-08-18 PreyDll.dll (the only build Chairloader supports; Chairloader replaces the Steam DLL with it). All RVAs are into that PreyDll.dll unless stated. PreyDll.dll is monolithic: CryEngine (system, renderer, entity system, action, audio ATL) and the game code are one module; Prey.exe is a thin launcher.


1. Tooling and workflow

Chairloader

  • https://github.com/thelivingdiamond/Chairloader - mod loader with a PDB-derived SDK (Common/Prey/**/*.h), hooking (PreyFunction<Sig>(rva).MakeHook() + SetHookFunc, InvokeOrig), ImGui overlay (F1), cvar persistence (REGISTER_CVAR2 with VF_DUMPTOCHAIR -> Mods/config/Chairloader_CVars.xml), a hot-reload cycle, and ChairManager/PreyFiles/ = the game's paks extracted (XML data, localization, levels). Mods are Prey/Mods/<Name>/{ModInfo.xml, <Name>.dll}.
  • The SDK headers are generated from Arkane's PDB, so class layouts, member offsets and static/member function RVAs are almost always right. Interface vtable orders copied from stock CryEngine are not always right (section 3).
  • Mod lifecycle hooks and where they run: UpdateBeforeSystem from a CGame::Update hook before the original; MainUpdate from a CSystem::Update hook after the original; LateUpdate from CCryAction::PostUpdate (HUD drawing goes here); Draw inside the ImGui frame.
  • Unregister your cvars in ShutdownSystem (IConsole::UnregisterVariable(name, true) for your prefix); the console keeps raw pointers to name/help/storage that vanish with your DLL and touches them at engine shutdown (crash on exit otherwise).
  • The F1 GUI shows the hardware cursor, so CHardwareMouse::m_iReferenceCounter > 0 also fires for it; check gCL->gui->IsEnabled() before treating a visible cursor as "game menu open".

Reverse engineering

  • Ghidra headless is fast enough to decompile single functions on demand: analyzeHeadless <proj> <name> -process PreyDll.dll -noanalysis -postScript <script> with a script that takes 0x18XXXXXXX Name lines, disassemble() + CreateFunctionCmd, then DecompInterface. The SDK's PreyFunction RVAs are your entry points; 0x180000000 is the preferred image base. No RTTI names survive in the binary, so find vtables via the constructor's lea rax, [rip+vtable].
  • capstone + pefile for quick disassembly around an address and for dumping vtables / strings.
  • Crash triage: Game.log prints the call stack as raw addresses. Map them to modules with the module list of the minidump (error.dmp in the Prey root, MINIDUMP module stream), symbolize your own frames with llvm-symbolizer --obj=<your.dll> --relative-address <rva> against your PDB, and disassemble the game's frame around the return address (the instruction before it is the call).
  • Cross-compiling on Linux works: clang-cl + lld-link against copied MSVC/Windows SDK headers (the official route is VS2022 + CMake + vcpkg). clang-cl matched the MSVC ABI in every case we checked, with one miscompile (section 3, Draw2dLabel).
  • Struct offsets in the SDK can be checked at compile time: template<int N> struct Probe; Probe<offsetof(T, m)> p; with -fsyntax-only prints the value in the error.

A patch worth knowing about

  • Random EXCEPTION_STACK_OVERFLOW in JobSystem_Worker threads in CParticleContainer::UpdateParticles (a large alloca for particle sorting). Worker threads inherit Prey.exe's default stack size (SizeOfStackReserve = 1 MB). Patching the PE header to 8 MB (and zeroing the checksum) removed the crashes. A VR build that pushes more particles per frame may hit this sooner.

2. Calling-convention and layout traps (each cost a crash)

  1. Struct returns > 8 bytes (QuatT, std::vector, std::pair, ...): for member functions the hidden return pointer comes after this: R* fn(T* _this, R* _ret, args...). Several SDK headers declare these as returning the struct directly (ArkItemSystem::GiveArchetype, IEntity::CreateProxy, ...); declare your own PreyFunction with the real layout.
  2. 8-byte structs with a user-declared constructor (ArkBinkPlayerHandle) are returned through a hidden pointer (MSVC rule: no user-defined ctor/dtor/copy for register return) but passed by value in a register (they are still trivially copyable). Handle both when calling through raw function pointers.
  3. PreyFunction objects are rebased at DLL init. A function-local static PreyFunction is constructed too late and calls the raw RVA. Keep them at file/class scope.
  4. The SDK's physinterface.h is stock CryEngine; Prey's physics structs are bigger. pe_status_living is 152 bytes in Prey (an extra Vec3 after velGround, groundSurfaceIdx at +0x64 not +0x58) vs. 136 in the header. GetStatus() into a header-sized stack local silently overwrote the caller's saved xmm6 (our frame dt), producing wrong smoothing with no crash. Rule: every struct the game fills in (pe_status_*, ray_hit, SLocalizedInfoGame, ...) gets Prey's layout when known and a generous pad after it regardless.
  5. Prey added parameters to some engine functions. ILocalizationManager::LocalizeString(const char*, wstring&, bool bEnglish, void** pOutHolder) has a 5th out-pointer the header lacks; leaving it to the stack garbage made the game write through it. IEntityAudioProxy::ExecuteTrigger(trigger, ELipSyncMethod, proxyId, callbacks) likewise has the CE 3.8 lip-sync parameter.
  6. IRenderAuxGeom::Draw2dLabel(..., fmt, ...) (inline variadic wrapper in the header) was miscompiled by clang-cl at one call site: the va_list pointed at the argument's bytes instead of its slot. Call RenderText(Vec3, SDrawTextInfo&, "%s", va_list) yourself with const char* p = text; (va_list)&p.

3. SDK vtable order vs. the binary

Verified by decompiling the game's own callers. Where the header is wrong, call by byte offset (((R(**)(void*, Args...))*(void**)obj)[off/8](obj, args...)).

Interface Header Real slots (byte offsets)
IGameFramework two virtuals short in places +0x120 GetISubtitleManager, +0x1D8 GetArkSaveLoadSystem (then +0x08 GetCampaignSlot), +0x298 SaveGame(path, quick, immediate, reason, ignoreDelay, checkpoint), +0x2A0 LoadGame(path, quick, ignoreDelay). IsGameStarted/IsGamePaused/GetLevelName via the header are fine.
IEntity two spurious virtuals at the front (SetLocalSeg/IsLocalSeg); GetId is really slot 1 +0x08 GetId, +0xE8 GetWorldTM, +0x210 CreateProxy(type) -> shared_ptr via hidden ptr. Prefer CEntity::FGetProxy (0x904D50) / FCreateProxy (0x903540) statics from CryEntitySystem/Entity.h (that class header is PDB-derived and correct).
ILocalizationManager two slots low +0x80 LocalizeString(const char*, wstring&, bool, void**), +0x98 GetLocalizedInfoByKey(key, SLocalizedInfoGame&). ISystem::GetLocalizationManager (+0x4A0) via header is fine.
IRenderer two slots high at the tail +0x898 GetIArkBinkManager(). Everything we used before that (GetWidth/GetHeight, SetState, Draw2dImage, GetWhiteTextureId, GetIRenderAuxGeom) matched.
IEntityAudioProxy (CEntityAudioProxy vtable @ 0x181d28e08) order differs +0xA8 CreateAuxAudioProxy(bool) -> id, +0xB0 RemoveAuxAudioProxy(id), +0xD8 ExecuteTrigger(trigger, lipSync, proxyId, const SAudioCallBackInfos&), +0xF8 SetEnvironmentAmount(env, amount, proxyId), +0x120 SetObstructionCalcType(type, proxyId). Entity audio proxies wrap IAudioProxy objects from IAudioSystem::GetFreeAudioProxy() (+0x98).
IAudioSystem, ISystem, IArkBinkManager, IArkDialogAudioManager, IRenderAuxGeom, ISubtitleManager, IAnimationOperatorQueue, ISkeletonPose, IDefaultSkeleton, IAttachmentManager, IAttachment match (slots we relied on are listed where used below)

4. Camera, first-person arms and the weapon - the pipeline VR has to bend

Prey kept Crysis 3's first-person setup. The order of operations per frame matters for anything that wants to put the camera or the weapon somewhere else:

  1. ArkPlayerCamera::PrePhysicsUpdate updates m_rotation (view Ang3: pitch = x, yaw = z) from input and smooths m_leanAmount (10/s).
  2. The first-person arms character is animated (mannequin). CProceduralWeaponAnimationContext::Update (0x17D4D50) calls CProceduralWeaponAnimation::Update(dt) (0x17D31E0), which blends the weapon's authored pose offsets, look/strafe sway, recoil, bumps and zoom into two view-space QuatTs: m_rightOffset (this+0x2D8, weapon hand) and m_leftOffset (this+0x2F4, support hand). The context rotates them into the aim frame (Quat::CreateRotationVDir(aimDir)) and pushes them additively onto the hand IK joints through an IAnimationOperatorQueue pose modifier (joint index at ctx+0x18; queue slots 8/9 = push position / orientation with eOp_Override=?/eOp_Additive=3). Some mannequin fragments (jump/land) have no weapon procedural clip; the context early-outs on m_instanceCount < 1 and nothing is applied (the weapon snaps back) - we hook that function and force the count to 1.
  3. The camera is built from the skeleton, not the other way round. ArkPlayerCamera::UpdateView (0x145ED50) -> GetDesiredPositionAndRotation (0x145C530) reads the #camera attachment of the arms character (IAttachmentManager::GetInterfaceByName = vtable +0x38, IAttachment::GetAttModelRelative = +0x68), rotates it by the entity rotation, and combines view angles with lean roll (m_leanAngle * m_leanAmount). The position is returned relative to the entity because the arms render in camera space (ENTITY_SLOT_RENDER_NEAREST; CView::Update adds the entity position). Nothing touches the skeleton between this call and rendering -> post-hooking GetDesiredPositionAndRotation is the last moment to override camera and/or weapon transforms consistently. For VR: this is where an HMD pose can replace the game's camera while the arms still follow.
  4. The weapon is not rendered from its own entity. CArkWeapon::AttachToHand binds the weapon's character as a skeleton attachment (CSKELAttachment) of the arms and clears the weapon entity's render flag; it is drawn at armsWorldMatrix * CAttachmentBONE::m_AttModelRelative (a QuatT at attachment+0x130; GetAttModelRelative() returns a reference to it, so it can be written directly). CArkWeapon::m_pAttachment is at +0x2B0. Muzzle flash / projectile origin are attached to the weapon bone, so moving the weapon moves the shot origin too.
  5. Hand joints follow via the final absolute pose buffer ISkeletonPose::GetAbsJointByID (slot 24) returns by reference - the skinning reads it at render time, so you can rigidly move the weapon-hand subtree (and the support hand when it is near the weapon) after step 3. Hierarchy: IDefaultSkeleton GetJointCount slot 1, GetJointParentIDByID 2, GetJointNameByID 6, GetJointIDByName 7; the weapon hangs off r_handProp_jnt (child of the right hand joint).

What the Ironsights mod does with this (directly reusable for motion controls, replacing "aim pose" with "controller pose"):

  • Skeleton side, after the context pushed its operators: push eOp_Additive position/orientation for the weapon-hand IK joint so the hand lands on camera(model) * pose * (weapon relative to IK joint)^-1. Uses the previous frame's camera + this frame's mouse delta (the camera is not final yet). Using eOp_Override instead kills the authored fire/reload hand animation; additive keeps it, and the game's own frame-old additive is subtracted back out to recover the pure animation (used to extract the recoil kick).
  • Render side, in the GetDesiredPositionAndRotation post-hook: write m_AttModelRelative = camera(model) * pose and move the hand joint subtree by the same rigid delta. Deterministic, no filtering -> no jitter. Everything read from the game is checked for finiteness / near-unit quaternions; accumulated state is reset on bad numbers (Ang3(Quat) in CryMath uses an unclamped asin).
  • Per-weapon poses keyed by IEntityClass::GetName() of the equipped CArkWeapon.

Other pieces around the pipeline:

  • Near FOV. The arms/weapon render in the "nearest" pass with their own FOV in r_DrawNearFoV (EFQ_Set/GetDrawNearFov). ArkPlayerZoomManager::Reset() / SetNearFOVUnlocked() hard-code 55 deg and ArkPlayerZoomManager::Update() rescales it while zooming - a game.cfg value never sticks; re-apply per frame after the game's update. Camera FOV: ArkPlayerZoomManager::SetDesiredHFOV(hfov, time, false, high) / ClearDesiredHFOV; cl_hfov is the base.
  • Player state useful for gating: ArkPlayer::GetInstancePtr(), m_stance (STANCE_SNEAK = crouch), m_bInTrackview (scripted sequence / cutscene), ArkPlayerMovementFSM::IsSprinting() (0x1570580) / IsInZeroG() (0x1570370), ArkPlayer::IsInCombat() (0x15514A0: list of NPCs fighting the player is non-empty), ArkPlayerAwarenessComponent::m_awarenessStates (VectorMap<EntityId, {m_level: EArkAttentionLevel unknown/noticed/curious/interested/known}>), velocity from pe_status_living::vel (see the size trap).
  • Weapon state (CArkWeapon): m_bIsReadyToAttack @ +0x48B (cleared for select, reload and every shot), m_bIsReloading @ +0x48C, m_bIsUnequipping @ +0x48D, m_condition (0..100), CArkWeapon::FireWeapon (0x16659B0) is the shot event for every weapon. ArkPlayerWeaponComponent: m_equippedWeaponId, m_toBeEquippedWeaponId @ +0x64, m_bIsUnequipping @ +0x78. The draw animation has a window where the arms are not yet valid for overrides - we gate on ready + a minimum delay after the equipped id changed (0.75 s worked for all weapons).
  • Procedural offsets you may want to keep or kill: CRecoilOffset/CBumpOffset/CLookOffset/CStrafeOffset::Compute can be hooked to capture (and scale) what the game adds.
  • Time: gEnv->pTimer->GetRealFrameTime() for real time; GetAsyncTime() as int64 ticks for a clock that does not freeze in menus. ITimer::GetFrameTime() is scaled/paused game time.

5. Input, reticle, in-world screens

  • Mod key bindings: an IInputEventListener registered with gEnv->pInput receives raw events; events are not delivered while a cursor is on screen, which is the behaviour you want for gameplay binds.
  • Action maps: the UI enables/disables the "UIInput" action map through CUIManager (the Ark:BinkMovie flow node calls GetActionMap("UIInput") then Enable(true) after a movie).
  • Reticle: hud_reticleSetting (SCVars+0x930; 0 off, 1 default, 2 dot) is what the options menu writes; its only readers are 4 sites in CArkUIHUD; at 0 the HUD gets reticleDisplay("none") and interactIconDisplay("none").
  • In-world screens use the HUD reticle as the cursor: ArkExaminationMode::UpdateReticlePos (0x157EBA0) moves m_reticlePos (+0x60) and sends reticlePosition to the HUD. State: ArkPlayer::m_examinationMode.m_examinationState != inactive with m_examinationType == worldUI. For a VR laser pointer this is the hook: feed your own screen position into that path.
  • The HUD is Scaleform Flash (IUIElement, events like reticlePosition, subtitleUpdate, audioLogUpdate), reached through CGame::m_pUIManager (CUIManager::GetUIEventSystem("<TypeName>") returns the game-side event system object, e.g. "ArkSubtitleHandler").

6. Rendering-side helpers we used

  • Full-screen quad / fades: IRenderer::SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST) then Draw2dImage(x, y, w, h, GetWhiteTextureId(), 0,0,1,1, 0, r,g,b,a, 1), coordinates in an 800x600 virtual space, from LateUpdate.
  • 2D text: IRenderAuxGeom::RenderText (see trap 6); SDrawTextInfo.flags = eDrawText_2D | eDrawText_800x600 [| eDrawText_Center] puts positions in the same virtual space; size ~12 virtual px per unit. Chairloader replaces the engine's aux geom (CAuxGeomCB), all of this goes through it.
  • Post-process parameters: I3DEngine::SetPostEffectParam(name, value, force) with names from Ark/VisualEffects/ArkPostEffectParams.xml: VisualArtifacts_Vsync/VsyncFreq/Interlacing/InterlacingTile/ Pixelation/Noise/SyncWaveFreq/SyncWavePhase/SyncWaveAmplitude, FilterArtifacts_ChromaShift/Grain, Global_User_Saturation/Contrast/Brightness, FilterBlurring_Amount, ArkPostAliens_Glitch, AlienInterference_Amount. Set every frame while active; reset afterwards. (For VR you will probably want to disable several of the game's screen-space effects; the same parameter names apply.)
  • Named game post effects: Ark/VisualEffects/ArkPostEffects.xml (64-bit ids), CGame::m_pArkPostEffectManager->EnableEffect(id) / DisableEffect(id, blendOut). E.g. Player_EndGameVRTermination = 14610450286789593543 (gamma-to-black then white-out), Player_Fatality = 12635110349617286617, Player_NearDeath = 2428940965280750461.
  • Bink movies: IRenderer::GetIArkBinkManager() (+0x898); IArkBinkManager::MT_LoadMovie(path, instanceId, type 1 Fullscreen/2 Background/3 Texture, flags 1 AutoStart|2 Looping) [slot 3, handle via hidden pointer], MT_ReleaseMovie [4], MT_StartMovie [5], MT_StopMovie [6], MT_IsMoviePlaying [8]. Fullscreen movies are composited by the renderer over the frame - relevant if you need to intercept them for a stereo view. Files in GameSDK/Videos/*.bk2 (KB2j header: frame count @+8, w/h @+20/+24, fps @+28/+32).

7. Audio: voice lines, dialogue, positioning

  • Every dialogue line is an ATL trigger Play_<voiceId><dialogId> (16 hex digits each), defined in Libs/GameAudio/GameMode/Campaign/Voice_<voiceId>.xml; text in Localization/English_xml.pak: voices/Voice_<voiceId>.xml, names in Ark/Dialog/VoiceLibrary.xml. Radio voices' banks are resident, but line media is streamed on demand: IArkDialogAudioManager::Load(triggerId, IArkDialogLoadListener&) (manager: CGame::m_pArkResponseManager->GetAudioManager()) -> OnLoad(id, ok) -> execute; Unload later. Executing without loading "plays" silence.
  • Voice events are positioned 3D sounds; executing on the global audio object (no position) is silent. Radio calls go through ArkDialogPlayerTranscribe::SetEntity (0x13F8A50): aux audio proxy on the player entity, audio environment "Transcribe" (IAudioSystem::GetAudioEnvironmentID) at 1.0 = the radio filter, occlusion ignored, ExecuteTrigger(trigger, lipSync=1, auxProxyId, callbacks).
  • ArkAudioTrigger::Load(name) / Execute(IEntity*) (Ark/ArkAudioUtil.h) is the simple path for SFX; Execute(nullptr) pushes an SAudioRequest{flags, objectId 0, ...} with data {vtable, eART_AUDIO_OBJECT_REQUEST=3, eAORT_EXECUTE_TRIGGER=0x10, triggerId, float 0, lipSync} (the SDK lacks SAudioObjectRequestData). The IAudioSystem header vtable matches the binary (PushRequest +0x18, GetAudioTriggerID +0x40, GetAudioEnvironmentID +0x68, GetFreeAudioProxy +0x98).
  • For VR: the listener is the camera; moving the camera to the HMD through the camera path above keeps audio consistent. Hand-held weapon sounds are attached to the weapon bone (moves with your override).

8. Subtitles

The game's path (ArkDialogSubtitleManager::ShowSubtitlePart, 0x11B4BF0): text from ArkDialogSubtitleManager::GetSubtitle(dialogId, voiceId, SLocalizedInfoGame&) (0x11B44B0; localization key "%llX_%llX" = dialogId_voiceId, fallback "%llX"), formatted "<font color='#FFDF80'>%ls%ls</font> %ls" (speaker, @ui_SubtitleNameSeperator, text), shown by ArkSubtitleHandler::ShowSubtitle(wstring, bMetaGameMenu) (0x1632330 -> Flash subtitleUpdate) and removed by HideSubtitle (0x1631C70). Handler: CUIManager::GetUIEventSystem("ArkSubtitleHandler") (static_cast from the returned IUIGameEventSystem*, which is at +8). Bink subtitle timings: Ark/Dialog/BinkSubtitles/<movie>.xml (frame numbers).


9. Player health, death, revive

  • Health reaching 0: ArkPlayerHealthComponent::DoDeath() (0x155E420) holsters, sets the death movement state and camera, arms m_timeRemainingBeforeDeathMenu. ArkPlayerHealthComponent::Update() (0x155F4A0) is the only place that opens the death menu; skipping the original while IsDead() keeps it shut with no side effects (m_bDeathMenuOpened says if the game got there first).
  • ArkPlayer::Revive() (0x1556B80) is the dev "Revive" button: reloads the player model, re-attaches the weapon, resets the FSM and health. ForceKill() (0x155E530) for testing. Scripted deaths have ArkPlayer::m_bInTrackview set.
  • Health changes: ArkPlayerHealthComponent::SetHealth (0x155EFE0); consumable/operator effects arrive as signals in ArkPlayerSignalReceiver::OnReceiveSignal (0x1575690); psi CArkPsiComponent::IncrementPoints (0x157FFD0); traumas ArkPlayerStatusComponent::GetTraumaForStatus(status) -> ArkTraumaBase (IsEnabled, Activate(level)), ReduceStatus(signalId, amount) (0x14631A0); suit integrity is the SuitIntegrity trauma.
  • Inventory: items are entities - ArkInventory::GetItemIDs(), ArkItemSystem::GetItem(id), CArkItem::Drop(count, const Vec3*) (0x10B0D40), RemoveFromInventory(), IArkItem::ResetCount(n), CArkItem::InitializeCount (0x10B3600) for spawn counts, ArkFabricator::SpawnItem (0x1166DE0), ArkItemSystem::GiveArchetype (returns std::vector - see trap 1).
  • Level entrances are SpawnPoint entities (Properties.destinationName = "From_<Level>"); ArkGame::OnLevelTransitionFinished() (0x116F1A0) fires after a transition placed the player; ArkGame::OnLevelToLevelTransition (0x116F190) at its start.

10. Saving and loading

  • ArkGame::SaveToSlot(const char* name, bool immediate) (0x116FE80, member, bool) is what QuickSave / ManualSave / IronmanSave end in: IGameFramework::SaveGame(name, quick=true, immediate, eSGR_QuickSave(3), false, nullptr) + appends the name to ArkGame::m_savesThisSession[campaignSlot] (this+0x50 + slot*0x18). Slot names (manual6, autosave2, anything you like) become folders under Saved Games/Arkane Studios/Prey/SaveGames/Campaign<slot>/<name>/ (save.CSF, save.meta, one <level>.level per visited level, ~2 MB).
  • CanManualSave() (0x116CB40, static) gates F5 (ArkPlayerInput::OnActionQuickSave 0x15638A0) and the pause menu Save; CanAutoSave() (0x116CA90) checks g_blockAutoSave then calls CanManualSave() - a hook on the latter must let calls from inside CanAutoSave through. A hidden "ironman" option exists (ArkDifficultyComponent::m_difficultyOptions[0]).
  • Loading: ArkGame::LoadLastSave(listener) (0x116EB30) -> IGameFramework::LoadGame(name, quick=true, ignoreDelay=false) (+0x2A0); return eLGR_NoSavesExist (7) from a hook to refuse quietly. F9 = ArkPlayerInput::OnActionLoadLastSave (0x1563460); pause menu screens = ArkPauseMenu::OpenSaveLoadMenu(bool bSave) (0x1370300). Issue loads only from UpdateBeforeSystem: LoadGame runs synchronously and tearing the level down from the post-CSystem::Update hook crashed the Chairloader GUI (null ImGui::GetIO()).
  • Load completion: the player entity survives a same-level save load, so "player gone and back" misses it. ArkGame::PostSerialize() (0x116FAE0) runs once at the end of every save load - hook it. ArkGame::OnSaveGame() (0x116F4B0) runs after any save. ArkGame::m_saveFileToLoad (string @ +0xD0) holds a pending load.
  • Play clock: ArkGame::m_campaignPlayTime (uint64 ms @ +0xE8, +1000 per accumulated second via m_campaignTimerAccumulator float @ +0xF0) counts active play only and is serialized in saves.
  • Campaign slot: IGameFramework +0x1D8 GetArkSaveLoadSystem -> +0x08 GetCampaignSlot.

11. Where the data lives (for XML-side changes)

ChairManager/PreyFiles/ (Chairloader's extraction of the paks): Ark/ (game data: Dialog/VoiceLibrary.xml, Dialog/BinkSubtitles/, VisualEffects/ArkPostEffects.xml + ArkPostEffectParams.xml, Campaign/POILibrary.xml, ...), Libs/GameAudio/ (ATL controls, preloads), Localization/English_xml/ (voices/Voice_*.xml, UI strings), Levels/. GameSDK/Videos/ for Binks. Options the menu writes are cvars (gameOptions.xml, e.g. hud_reticleSetting).


12. Quick checklist when something "does nothing" or crashes

  • A smoothed value that snaps or freezes while the code is right -> the step is garbage -> a callee wrote past a stack struct (trap 4). Look for structs the game fills in.
  • A hook that seems to run but the game ignores the result -> check the SDK vtable slot against a decompiled caller (section 3) or the struct-return convention (traps 1/2).
  • Crash with a small absolute address (0xC, 0x10) right after a call into the game -> an undeclared out parameter (trap 5).
  • Crash in vsprintf under Chairloader's aux geom -> Draw2dLabel (trap 6).
  • Audio "plays" but is silent -> not loaded (dialog manager) or executed on the unpositioned global object.
  • A per-frame value read from ITimer::GetFrameTime() is 0 in menus/pause; use real time for effects.
  • Text/quads in the wrong place -> eDrawText_800x600 / Draw2dImage virtual space vs. pixels.

Questions, corrections or requests for specific decompiles: open an issue on any of the three repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment