Most recent Grand Theft Auto IV reverse-engineering projects focus on Xbox 360 static recompilation or Rust rewrites. I wanted to share gta4-reversed, an early-stage open-source C++20 project that tackles the PC GTAIV.exe 1.0.7.0 (x86) binary directly through runtime ASI injection.
Today, the project just crossed its first milestone: 1% (462 / 43,740 functions implemented, ~1.06%).
- GitHub Repository: https://github.com/master4824/gta4-reversed
-
License: MIT (Source code only — no copyrighted game files, dumps, or compiled binaries are included. Requires a legitimate copy of GTA IV
1.0.7.0.)
Why Runtime ASI Injection Instead of a Standalone .exe?
Inspired by how gta-reversed approaches GTA: San Andreas, gta4-reversed compiles into a single plugin (gta4_reversed.asi, zero external dependencies, CMake + Ninja + MSVC x86) that injects into a real running copy of GTAIV.exe:
- Incremental Verification: Every single hooked function can be tested immediately inside the live game without breaking the rest of the 43,740 functions.
-
Eliminating
Hook::CallOver Time: Initially, unreversed callees bridge back to original game addresses viaCore::Hook::Call(...). As lower-level systems are rewritten, those hex calls are replaced by direct C++20 calls until a module hits 0 fallbacks (100% Pure C++). - Clean Scope: Original game files on disk are never modified, and DRM/anti-tamper/launcher code is completely out of scope.
Interesting Technical Challenges So Far
Reimplementing a 2008 32-bit MSVC Link-Time Code Generation (LTCG) binary comes with plenty of surprises:
-
Non-Standard Register Calling (
__usercall& HiddenECX/EDXAssumptions): LTCG routinely omits frame rules and passes arguments inESIorEAX, or assumes small leaf functions preserveECX/EDXacross calls. Even decompilers sometimes hidemov ecx, ...before a__thiscall(which recently caused a real crash at spawn until checked directly in x86 disassembly). Where needed, small__declspec(naked)register-preserving bridges keep callers safe. -
Sharing RAGE's Allocator via TLS:
Calling standard
malloc/newfor engine objects corrupts RAGE's internal memory pools. For classes likeCPool,CDummyObject, andCIplStore, allocations go directly through the game'ssysMemAllocatorfetched from Windows x86 TLS (__readfsdword(0x2C)). -
Strict Struct Layout Verification:
Classes like
CPed(0xF00bytes) andCPad(0x3A84bytes) are locked down withVALIDATE_SIZEandVALIDATE_OFFSET(static_assert) checks against1.0.7.0disassembly. -
Built-in VEH Crash Diagnostics:
A Vectored Exception Handler (
gta4_reversed.log) catches runtime crashes and subtracts the ASLR delta to log the exactGTAIV.exeIDA virtual address and stack trace.
Current Status (462 / 43,740 Functions — ~1.06%)
-
11 Modules at 100% Pure C++ (
0original game fallbacks):-
Core:Matrix,Pool,Vector -
Game:LoadingScreens,Pad -
Rage(Physics):phBound,phBoundComposite,phInst,phArticulatedCollider,phConstraint,phLevelNew
-
-
Core Subsystems Implemented & Hooked:
CPlayerInfo,CWanted,CBuilding,CDummyObject,CModelInfo,CTxdStore,CStreaming,CCamera,CCam,rage::fiStream,CFileMgr,CIplStore,CFont,CEntity,CDynamicEntity,CPhysical,CPed,CVehicle,CWeaponInfo,CTimer,CClock,CWeather,CStats,CCheat,CWorld,phArchetype,phBoundBVH,phCollider,phSimulator. - CI: Automated MSVC x86 CMake + Ninja build check via GitHub Actions.
Looking for Contributors
43,740 functions is a massive undertaking, and even small contributions help—whether it's converting remaining Core::Hook::Call wrappers to pure C++, verifying struct fields/sizes, or helping debug physics/entity subsystems.
If you're interested in C++20, RAGE engine internals, or GTA IV modding, check out the repo, open issues, or CONTRIBUTING.md!
Top comments (0)