saints row iv · for modders

Saints Row IV: how the game works

Our reverse-engineering notes on SR4's engine, in plain English. Pick a tab, search anything.

start here

These notes explain the game's code in plain English. It was produced by statically reverse-engineering SaintsRowIV.exe (v1.0.6.1, Steam, 2017 build): all 99,724 functions were decompiled, and the important ones were read and named. Addresses are fixed (the exe has no ASLR), so an address here is the same every time the game runs. Nothing here was tested while the game was running.

99,724functions decompiled
23,423functions with a name
1,928lua commands
282data tables (.xtbl)
67object types

How to read it

  • Address = where the function or value lives in the exe (hex). Use it in Ghidra, x64dbg or Cheat Engine.
  • Names in the Name column are ours, except Lua command names and C++ class names, which are Volition's own.
  • Offsets like +0x1E20 are positions inside an object in memory (e.g. player + 0x1E20 = health).
  • Every tab has a search box: type a name, an address or a word to narrow it down.

The tabs

How the Game WorksThe game's life cycle in order: start-up, menus, loading, and what happens every frame.SystemsEvery major system in one line each: what it does, how it works, where it lives.AIHow enemies and allies decide what to do: 20 goals checked in priority order, 112 actions tried until one succeeds.Game StatesThe 10 'screens/modes' the game can be in (menu, loading, in game, pause...).ThreadsThe parallel workers the game runs (rendering, loading, audio, network...).Object TypesEvery kind of thing that exists in the world (player, NPC, car, weapon, door...) and what it inherits from.Player & Object DataWhere specific values live in memory (health, cash, current car, super power...).SuperpowersThe 8 powers and 21 elements and how unlocking/selecting works.CheatsHow cheats are loaded, activated, and when a save gets flagged.Weapon UpgradesHow weapon upgrade levels patch weapon stats (replace / add / multiply / remove).Memory BudgetsThe fixed memory pools the game reserves at start-up.Files & ModsHow files are found: mods folder, packfiles, streaming.RenderingHow a frame is drawn: lighting technique, shadows, post-effects.In-Game FrameThe ~170 updates the game runs every frame while you play, in order.Missions & ScriptsHow missions are defined, how mission scripts run, and what happens when a mission ends.Weapons FiringHow a shot becomes a hit and damage.CustomizationPlayer, gang and vehicle customization data.AudioSound engine, banks, voices, radio and interactive music.Key Functions~600 hand-picked and auto-named functions with a plain-English description.Hook PointsBest places to hook for mods and tools.Lua CommandsAll 1,931 commands mission/UI scripts can call into the engine.Data TablesAll 282 .xtbl data tables, the code that loads each one, and the fields it reads.All Named FunctionsEvery one of the ~23,000 named functions with its address and subsystem - use the filter to search.
FAQ

Saints Row IV modding questions

How do I install Saints Row IV mods?

Drop the modded file, named exactly like the file it replaces, into a folder called mods next to SaintsRowIV.exe (no sub-folders). When the game opens a file it checks the mods folder first, then the packfiles in packfiles\pc\cache\*.vpp_pc, so your copy wins. Details on the files & mods page.

What Lua commands can Saints Row IV scripts use?

Mission and UI scripts can call 1,928 engine commands. The Lua commands page lists every one with its native address and group.

Where is the player's health and cash in memory?

Read the player object's pointer, then add an offset: +0x1E20 is current health (float), +0x1E10 max health and +0x1E08 cash in cents. More on the player & object data page.

Why does using a cheat mark my save as cheated?

Each cheat in cheats.xtbl has a Dont_Flag_As_Cheating flag. If it's off, activating the cheat marks the save as cheated and tells your co-op partner. See how cheats work.

Which version of Saints Row IV are these addresses for?

SaintsRowIV.exe v1.0.6.1, the 2017 Steam build. The exe has no ASLR, so every address is the same each time the game runs. Other builds will differ.

Built from SR4_Game_Explained.xlsx (650 KB), if you'd rather filter it in Excel. SaintsRowIV.exe v1.0.6.1 (Steam). Names are ours unless they're Volition's own Lua or C++ class names.