<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: master48</title>
    <description>The latest articles on DEV Community by master48 (@master4824).</description>
    <link>https://dev.to/master4824</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4250662%2F0dbe7b6d-6738-468d-8715-76f6602244ea.png</url>
      <title>DEV Community: master48</title>
      <link>https://dev.to/master4824</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/master4824"/>
    <language>en</language>
    <item>
      <title>gta4-reversed: Starting a C++20 Runtime Reimplementation of GTA IV (1.0.7.0) — Crossing 1%</title>
      <dc:creator>master48</dc:creator>
      <pubDate>Tue, 17 Nov 2026 23:00:59 +0000</pubDate>
      <link>https://dev.to/master4824/gta4-reversed-starting-a-c20-runtime-reimplementation-of-gta-iv-1070-crossing-1-e5</link>
      <guid>https://dev.to/master4824/gta4-reversed-starting-a-c20-runtime-reimplementation-of-gta-iv-1070-crossing-1-e5</guid>
      <description>&lt;p&gt;Most recent Grand Theft Auto IV reverse-engineering projects focus on Xbox 360 static recompilation or Rust rewrites. I wanted to share &lt;strong&gt;gta4-reversed&lt;/strong&gt;, an early-stage open-source &lt;strong&gt;C++20&lt;/strong&gt; project that tackles the &lt;strong&gt;PC &lt;code&gt;GTAIV.exe 1.0.7.0&lt;/code&gt; (x86)&lt;/strong&gt; binary directly through runtime ASI injection.&lt;/p&gt;

&lt;p&gt;Today, the project just crossed its first milestone: &lt;strong&gt;1% (&lt;code&gt;462 / 43,740&lt;/code&gt; functions implemented, &lt;code&gt;~1.06%&lt;/code&gt;)&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/master4824/gta4-reversed" rel="noopener noreferrer"&gt;https://github.com/master4824/gta4-reversed&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;License:&lt;/strong&gt; MIT &lt;em&gt;(Source code only — no copyrighted game files, dumps, or compiled binaries are included. Requires a legitimate copy of GTA IV &lt;code&gt;1.0.7.0&lt;/code&gt;.)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Why Runtime ASI Injection Instead of a Standalone &lt;code&gt;.exe&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;Inspired by how &lt;strong&gt;gta-reversed&lt;/strong&gt; approaches &lt;em&gt;GTA: San Andreas&lt;/em&gt;, &lt;code&gt;gta4-reversed&lt;/code&gt; compiles into a single plugin (&lt;code&gt;gta4_reversed.asi&lt;/code&gt;, zero external dependencies, CMake + Ninja + MSVC x86) that injects into a real running copy of &lt;code&gt;GTAIV.exe&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Incremental Verification:&lt;/strong&gt; Every single hooked function can be tested immediately inside the live game without breaking the rest of the 43,740 functions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Eliminating &lt;code&gt;Hook::Call&lt;/code&gt; Over Time:&lt;/strong&gt; Initially, unreversed callees bridge back to original game addresses via &lt;code&gt;Core::Hook::Call(...)&lt;/code&gt;. As lower-level systems are rewritten, those hex calls are replaced by direct C++20 calls until a module hits &lt;strong&gt;0 fallbacks (100% Pure C++)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean Scope:&lt;/strong&gt; Original game files on disk are never modified, and DRM/anti-tamper/launcher code is completely out of scope.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Interesting Technical Challenges So Far
&lt;/h3&gt;

&lt;p&gt;Reimplementing a 2008 32-bit MSVC &lt;strong&gt;Link-Time Code Generation (LTCG)&lt;/strong&gt; binary comes with plenty of surprises:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Non-Standard Register Calling (&lt;code&gt;__usercall&lt;/code&gt; &amp;amp; Hidden &lt;code&gt;ECX&lt;/code&gt;/&lt;code&gt;EDX&lt;/code&gt; Assumptions):&lt;/strong&gt;
LTCG routinely omits frame rules and passes arguments in &lt;code&gt;ESI&lt;/code&gt; or &lt;code&gt;EAX&lt;/code&gt;, or assumes small leaf functions preserve &lt;code&gt;ECX&lt;/code&gt;/&lt;code&gt;EDX&lt;/code&gt; across calls. Even decompilers sometimes hide &lt;code&gt;mov ecx, ...&lt;/code&gt; before a &lt;code&gt;__thiscall&lt;/code&gt; (which recently caused a real crash at spawn until checked directly in x86 disassembly). Where needed, small &lt;code&gt;__declspec(naked)&lt;/code&gt; register-preserving bridges keep callers safe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sharing RAGE's Allocator via TLS:&lt;/strong&gt;
Calling standard &lt;code&gt;malloc&lt;/code&gt;/&lt;code&gt;new&lt;/code&gt; for engine objects corrupts RAGE's internal memory pools. For classes like &lt;code&gt;CPool&lt;/code&gt;, &lt;code&gt;CDummyObject&lt;/code&gt;, and &lt;code&gt;CIplStore&lt;/code&gt;, allocations go directly through the game's &lt;code&gt;sysMemAllocator&lt;/code&gt; fetched from Windows x86 TLS (&lt;code&gt;__readfsdword(0x2C)&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strict Struct Layout Verification:&lt;/strong&gt;
Classes like &lt;code&gt;CPed&lt;/code&gt; (&lt;code&gt;0xF00&lt;/code&gt; bytes) and &lt;code&gt;CPad&lt;/code&gt; (&lt;code&gt;0x3A84&lt;/code&gt; bytes) are locked down with &lt;code&gt;VALIDATE_SIZE&lt;/code&gt; and &lt;code&gt;VALIDATE_OFFSET&lt;/code&gt; (&lt;code&gt;static_assert&lt;/code&gt;) checks against &lt;code&gt;1.0.7.0&lt;/code&gt; disassembly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built-in VEH Crash Diagnostics:&lt;/strong&gt;
A Vectored Exception Handler (&lt;code&gt;gta4_reversed.log&lt;/code&gt;) catches runtime crashes and subtracts the ASLR delta to log the exact &lt;code&gt;GTAIV.exe&lt;/code&gt; IDA virtual address and stack trace.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Current Status (&lt;code&gt;462 / 43,740&lt;/code&gt; Functions — &lt;code&gt;~1.06%&lt;/code&gt;)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;11 Modules at 100% Pure C++ (&lt;code&gt;0&lt;/code&gt; original game fallbacks):&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Core&lt;/code&gt;: &lt;code&gt;Matrix&lt;/code&gt;, &lt;code&gt;Pool&lt;/code&gt;, &lt;code&gt;Vector&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Game&lt;/code&gt;: &lt;code&gt;LoadingScreens&lt;/code&gt;, &lt;code&gt;Pad&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Rage&lt;/code&gt; (Physics): &lt;code&gt;phBound&lt;/code&gt;, &lt;code&gt;phBoundComposite&lt;/code&gt;, &lt;code&gt;phInst&lt;/code&gt;, &lt;code&gt;phArticulatedCollider&lt;/code&gt;, &lt;code&gt;phConstraint&lt;/code&gt;, &lt;code&gt;phLevelNew&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Core Subsystems Implemented &amp;amp; Hooked:&lt;/strong&gt;
&lt;code&gt;CPlayerInfo&lt;/code&gt;, &lt;code&gt;CWanted&lt;/code&gt;, &lt;code&gt;CBuilding&lt;/code&gt;, &lt;code&gt;CDummyObject&lt;/code&gt;, &lt;code&gt;CModelInfo&lt;/code&gt;, &lt;code&gt;CTxdStore&lt;/code&gt;, &lt;code&gt;CStreaming&lt;/code&gt;, &lt;code&gt;CCamera&lt;/code&gt;, &lt;code&gt;CCam&lt;/code&gt;, &lt;code&gt;rage::fiStream&lt;/code&gt;, &lt;code&gt;CFileMgr&lt;/code&gt;, &lt;code&gt;CIplStore&lt;/code&gt;, &lt;code&gt;CFont&lt;/code&gt;, &lt;code&gt;CEntity&lt;/code&gt;, &lt;code&gt;CDynamicEntity&lt;/code&gt;, &lt;code&gt;CPhysical&lt;/code&gt;, &lt;code&gt;CPed&lt;/code&gt;, &lt;code&gt;CVehicle&lt;/code&gt;, &lt;code&gt;CWeaponInfo&lt;/code&gt;, &lt;code&gt;CTimer&lt;/code&gt;, &lt;code&gt;CClock&lt;/code&gt;, &lt;code&gt;CWeather&lt;/code&gt;, &lt;code&gt;CStats&lt;/code&gt;, &lt;code&gt;CCheat&lt;/code&gt;, &lt;code&gt;CWorld&lt;/code&gt;, &lt;code&gt;phArchetype&lt;/code&gt;, &lt;code&gt;phBoundBVH&lt;/code&gt;, &lt;code&gt;phCollider&lt;/code&gt;, &lt;code&gt;phSimulator&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CI:&lt;/strong&gt; Automated MSVC x86 CMake + Ninja build check via GitHub Actions.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Looking for Contributors
&lt;/h3&gt;

&lt;p&gt;43,740 functions is a massive undertaking, and even small contributions help—whether it's converting remaining &lt;code&gt;Core::Hook::Call&lt;/code&gt; wrappers to pure C++, verifying struct fields/sizes, or helping debug physics/entity subsystems.&lt;/p&gt;

&lt;p&gt;If you're interested in C++20, RAGE engine internals, or GTA IV modding, check out the repo, open issues, or &lt;a href="https://github.com/master4824/gta4-reversed/blob/main/CONTRIBUTING.md" rel="noopener noreferrer"&gt;CONTRIBUTING.md&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>gamedev</category>
      <category>reverseengineering</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
