Having trouble decrypting the GD save files

Hi,

I am very new to modding for Grim Dawn and am writing a parser for the transfer.gst file. I am following the examples at this URL: http://www.lost.org.uk/grimdawn.html, but am running into an issue.

I think it’s a lack of understanding in how the file has to be decrypted. In the code, I don’t know what the “key” variable refers to, what the “mod” variable refers to, and what the “version” refers to.

Looking at http://www.lost.org.uk/grimdawn/decryptstash.java, I also have no idea how the author knows where the different values are within the byte sequence of the file, but he does.

Does anyone know where I can find out more information on how to properly decrypt the grim dawn save files?

1 Like

Welcome to the forum. :slightly_smiling_face:

Have you looked at the guides here to see if they have anything that might help? Grim Dawn's Modding Tools + User-Generated Tutorials to Get Started

Nothing there is likely to assist him with decrypting save files. Someone like @mamba (or anyone else that has made tools that manipulate/read save files) might be better able to guide him in that area.

I need to learn that to. I’d like to have something for easier / automatic Tributes increasing so that I don’t have to use GDStash for that / minimize the game. Hacking game’s memory (without using Cheat Engine) would be best but that’s too difficult for me.
@recursive thanks for the links

In the end any route you choose is going to require tabbing out of the game to do anything that modifies your saves. Well, I suppose if you figure it out you could always write a script and global hotkey it to call it from within game - hard to say if it would work with your character loaded into the world/crucible tho.

Main Menu is enough for GDStash Character changes. That’s what I was thinking.
Yes, hotkey or even file monitor if possible that would do that automatically
(you go to main menu and back to Crucible with full Tributes)

yes, guides won’t help, but the links he provided do, that is the same code I used as a baseline for GD Stash, translated it from C++ to Java :wink:

that seems to be more a problem of understanding the program. It reads the key from the file, see

void stash_file::read(const char *filename)

as to what key stands for in a decryption, I am not sure that needs answering :wink:

mod is the name of the mod the stash is for, empty for vanilla

version refers to the version of the stash format

they too are read from the file, so it ultimately should not even matter what they stand for, as long as you replicate the logic correctly it should work, whether you know what each field is or not (there are some fields in the char save I still don’t know how they are used by GD but I read them and write them back…)

because they are always in the same position… if your question is how did he learn that position, no idea, how did he learn any of this ? decompiler / reverse engineering I guess, doesn’t matter either way

2 Likes

Thanks for all the replies. I did end up getting it working. The decrypt code provided at the links I posted will not work for the latest version of the game. This is because the save game files are version 5 while the the decrypt code was written for version 4, and the byte order of the values within transfer.gst have changed.

I fixed my code by looking at the source code of Item Assistant. Located here: https://github.com/marius00/iagd.

Specifically this file: https://github.com/marius00/iagd/blob/master/Parser/Stash/Stash.cs

The code in that file showed that version 5 of transfer.gst has an additional byte that needs to be read, which is why I wasn’t getting the correct values before.

I am still not sure how the Item Assistant author was able to find out the order of the bytes in the file, which is what I would like to find out because I may be able to use the same method for other games.

1 Like

As I said, chances are a decompiler was used for that initially. See e.g https://derevenets.com/

I assume all tools that read/write the GD formats started from that C++ code. I assume IA did, i am pretty sure Defiler did, I know GD Stash did… once you had that initial format, finding where it breaks when a new file version is released is not that hard. You find the position where it breaks immediately, figuring out what got inserted there is a bit harder - but then Crate does help with that if you ask them :wink:

1 Like

@mamba That helps, thanks for your reply. I’m writing an app for the JVM as well. Is the GD Stash code available on GitHub?

No, the code is not available. If you are interested in reading / writing the stash file I can send you those files however. Have made that available to people before.

Do you know by any chance if the decryptsave.cc (for player.gdc) is not up-to-date as well? I got an error.

Error reading file: player.gdc

@tqFan It probably isn’t up to date. I haven’t gotten to reading in the character yet.

Probably not useful to you but I’ll describe my slow progress in reading the character file (decrypted already by GDStash, probably doesn’t matter).

I’ve started correcting decryptsave.cc slowly as I’m not skilled in this and so far

  • changed one of initial checks from 1 to 2 (not sure what it does, left if for now)

  • later header is read fine I think because I read level and hardcore status from it

  • now there’s version read which is 8 instead of 7 like in the original but to read it correctly
    I needed to read an additional byte after the author reads an int

  • and now I have some error in character info which I’ll try to fix later

I’m very close to Tributes which I’m interested in so I guess I won’t need to correct the whole thing, only decrypt and change Tribute number.

Sounds like item 3 is the same thing I ran into with moving from version 4 to version 5 of the decryptstash.java file. I still haven’t had a chance to dive in since my last reply. I spoke with mamba and he brought to my attention that my first idea for a tool wasn’t exactly feasible. Which was a concern I had.

Since then I’ve thought of a similar tool without as much in-depth functionality. So I’ll be jumping in again soon. By the way, mamba mentioned earlier in the thread that he has provided his decryption code to some people. If you ask him directly he may provide it for you.

1 Like