Hacking Grand Theft Auto IV

A week ago Grand Theft Auto IV came out for the PC, since then I’ve been trying to poke about at things, the first thing I saw that I wanted to try was to edit the save files.

I found the save files nestled in C:\Users\Rick\AppData\Local\Rockstar Games\GTAIV\savegames. You’ll likely find several subdirectories there, following the format of user_<16 byte Live user ID>. Under one of these directories you find files following the scheme of SGTA4<index>.

Taking a look at these saves, the data is unencrypted and in a very obvious format. Unfortunately you cannot directly edit them, GTAIV makes use of some hashing features built into xlive.dll (Games for Windows – Live).

There is a 360 (coincidence?) byte footer to each GTAIV save file — this makes up two blocks. A 296 byte block, and a 64 byte block. I’m not sure about the 296 byte block, but the 64 bit block is likely a hash of the save data.

I set an obvious way to try and edit the save data: change the amount of money you have.

Looking at the structure of the save data, the amount of cash you have is in the second block of data in the save (PlayerInfo), there appear to be two values for money — one is probably total cash while the other is current cash. They are 0x1EA and 0x1F2 bytes from the start of the save file (due to the structure of the file, these offsets are unlikely to change).

Out of all the attempts I made in trying to edit a save file — the one I ended up with was pretty much a massive hack. xlive.dll has some protections enabled that make tampering with a running game a bad idea (crashing, not functioning properly, among other things). I dug deep enough to discover that I could essentially break a part of xlive.dll to make it possible to modify GTAIV code. When GTAIV calls xlive.dll to do something (in this instance, hash a save file), xlive.dll does a check on the calling process to make sure it hasn’t been modified. The offending function is called XLivepVerifyAddress (xlive.dll+0xA6354, according to xlive.pdb ;-).

I broke this function (by making it always return 0), hooked the function that hashes save data (GTAIV.exe+0x18C180), a pointer to the save data being the first argument.

Starting the game with my changes (done at runtime, no modification to files of course, via loader + injected DLL), I load my game, something crashes (another thread, perhaps), the game continues to run fine. I save.

The end result?

A save file with its cash altered to $10,000,000, with a valid hash.

(shortly after purchasing a fancy hat with my new money in a relatively new game)

Tags: ,

35 Responses to “Hacking Grand Theft Auto IV”

  1. Andrew D says:

    This is unfortunately negated by the fact that GTAIV on the PC is quite god awful.

  2. Rick says:

    I disagree strongly. There may be small performance issues, but the game itself is fine (but I can only go by my experience).

  3. Andrew D says:

    The game itself is quite awesome, the port is unfortunately from what I’ve heard, and these problems range from bad, average, and top-end computers.

    I’m not going to mention SecuROM either, as that’s another case in point.

  4. Rick says:

    This blog isn’t about debating bad ports or SecuROM, but I still disagree that it’s a bad port.

  5. zerox says:

    Hi,

    I have problem with my savegames. I lost my Xlive account which is needed to load my savegames and the savegames don’t work with the new accounts. I just get error “Load failed, please check hdd.” or something like that. I was wondering that how did you edit the savefiles, with what program? Also, could you know fix for this problem?

  6. Andrew D says:

    Zerox, if your talking about the Xbox 360, there is NOTHING you can do, apart from recovering your gamertag possibly.

  7. zerox says:

    Its PC version.

  8. Rick says:

    I am currently working on disabling the save validation in a user friendly way.

  9. David says:

    I really dont get any of this -_-‘ what program did u use to open the SGTA400 file ? cuz all i get when i open with notepad is jibberish.

  10. Alexis says:

    Hello can you help me installed a complete backup of GTA4 I can not biin and I spoke directly with someone who speaks english and mexplique! I translate my sentences better than you understand thank you Alexis

  11. Robin Moonen says:

    Dear Rick,

    I found this 100 percent save game file on the internet, but I can not find the map in the GTA IV folders where savegames are located. Do you know where to find it?

    Please answer me into an e-mail, I would gladly appreciate it.

    All the best,
    Robin.

  12. Niko says:

    PC

  13. ANDREJ says:

    hey rick,

    i copy xlive but the game wont start.. i have windows vista ultimate. please help…i follow the instructions but didnt work.. when i delete xlive.dll the game start but i couldn t load save games……it shows something like unable to load savegames…….PLEASE HELP

  14. Ariel says:

    i have the same problem as ANDREJ… . pls HELP!

  15. Tyler says:

    Can you hack gta 4 on the ps3 one guy did it before but how

  16. rockmadhavan says:

    Dear Rick,

    im really needing your help now,im using windows 7 rc 7100,i just reformatted the computer,i backup the rockstargames folder which is located in C:\Users\Somasundram\AppData\Local before formating,after formating,i reinstalled gta4 and just replace the new folder with my old folder,i dint backup the xlive folder,when i open the game,my old settings are working but the saved files are gone,i mean there are no saved games detected,can you please help me how to make the saved game detected.are there any ways of recovering it
    if sao,please explain me step by step because im very beginner in computing
    Please,i finished over 50% of the game d,i dont want to start the game all over again

  17. kaycee says:

    dear Rick……heard stuff bout ur prowess so i decided to check u out…..i hav a problem….i purchased GTA IV with its crack from a non-authentic source…..but right now, though i can play the game offline, i cant save except i’m online!!!. When i try to log on with my Windows Live account, i’m asked for a serial which i do not possess. Its really frustrating playin a game such as GTA IV whilst knowing you cant save!!……..can u help me out with some kind of crack dat will enable me save my game offline without requesting for any serials……just like it was done in GTA III? thanks

  18. shahid says:

    gta iv fatal error :rmn20 help me b4 it sed it can not excert xlive file then i deleted it now it sat gta iv fatal error :rmn20

  19. Matt says:

    Dear Rick,

    im having a problem with my gta 4. i’ve used your xlive.dll offline file correctly and i’ve saved the game succesfully. the problem is,why does my screen goes ‘shaking’ while im playing the game in just a few minutes? please help me. i’ve installed the game so many times and i don’t wanna repeat it again and again. or there was another problem that i didn’t realized? im really hope that you can help me Rick.
    i wanna finish the game by myself. Please help me…

  20. tokugagua says:

    matt. you have to start the game with LaunchGTAIV.exe that showld fix it…

  21. joe says:

    you put this up over a year ago so you’re probably not interested in working on it any more, plus there’s spam in the comments here so you probably don’t still read them but i’ll try anyway

    i’ve been playing for 30+ hours and my autosave game file became corrupted on its own (i was just playing normally). i read that your wrapper will get the game to load it without checking the hash so i tried it but now when i start the game (Rockstar Games Social Club dialog, i hit the PLAY button), the GTA4 process starts running at 100% on one core but no windows appear and nothing visibly happens to the PC.

    any idea how i can get this working? thanks 🙁

  22. FreddyLuxe says:

    I tried the Xlive wrapper and the game wont start.

    I copied Xlive.dll to GTA4 directory.
    Copied and ran the CopyXLiveResources.exe and I deleted it.

    I ran the game and a window poped up saying Windows found problem with this program and cannot run it.

    Please, what can I do?

    Thank you!

  23. Have you ever considered adding more videos to your blog posts to keep the readers more entertained? I mean I just read through the entire article of yours and it was quite good but since I’m more of a visual learner

  24. emerald says:

    i wanna know how to use xlive to play episodes of liberty city of GTA4, i am having problem loading the level momma’s boy. i get a freezed loading screen anytime i try to play that level. is there anyway you can help me. i have searched everywhere and i believe i have come to the final place of solution

  25. Ryan says:

    GTA 4 v. 1.0.1.0 didnot start after hacking what need i do ?!

  26. Ryan says:

    My System writes c/windows/system32/xlive.dll and
    c/windows/system32/xlive.cat will be copied to
    c/users/apdata/local/rockstargames/gtaiv/ylive.dll
    c/users/apdata/local/rockstargames/gtaiv/ylive.cat
    Is this ok?
    No will cause the game exit

  27. Ryan says:

    Windows Vista is used

  28. Pretom says:

    Dear Rick,
    Currently i am playing GTA4:Episodes from Liberty City. Everything is ok,but after the “Mori” mission “No.3″(after completing it successfully, there is just a screen says “loading” and then the game freezes,the loading goes continuously,but nothing happens,it just continue loading.Please brother,can you help me about this matter(this matter was also happened where it freezes before starting No.3 mission).please……….. help me,i am crazy about the game,please.

  29. Tommy says:

    Hello! i tried the savegame, but when i replace the savegame and the xlive.dll, the game would not lauch! do you know what the problem is? plz respond me asap 🙂

  30. Matt says:

    Hey Rick,
    I’m Just trying to replace my savegame with your savegame and im having a problem with the CopyXLiveResources.exe file… is the location of this file
    C://Program Files/ Rockstar Games/ GTA IV OR
    C:// User/ Matt/ Appdata/ Local/ Rockstar Games/ savegame
    Cause im a little confused right there. i understand just aboutneverything else? could you help me out here?

    Thanks, Matt

  31. Amin says:

    hello.man haw can i install the save of gta iv that i download

  32. Vlad says:

    man can you help me ? with savegame ? you found me at quickly_indungi@yahoo.com

  33. Have you ever thought about writing an e-book or guest authoring on other websites?
    I have a blog centered on the same topics you discuss
    and would love to have you share some stories/information. I
    know my audience would enjoy your work. If you’re even remotely interested, feel free
    to send me an e mail.

    Here is my site :: dui lawyers in San Diego