apocalyptech / animalwellsave

Python-Based CLI Animal Well Savegame Editor
GNU General Public License v3.0
4 stars 1 forks source link

Animal Well sav file signature? #4

Closed milw closed 4 months ago

milw commented 4 months ago

I'm attempting to recover a deleted save file using photorec, and examination of my (outdated) save file shows a potential signature at the beginning of the file 0x09000000BE9F0F0091080000

Are you aware of any other 'fixed' data in the save files that could be used as a signature? For PhotoRec, you can simply create a signature file 'photorec.sig' that contains the line 'sav 0 0x09000000BE9F0F0091080000' (at least, it will detect my old save file!)

Lost 1 month of progress due to Steam Cloud being out of sync!

apocalyptech commented 4 months ago

Hello! I always recommend having Steam Cloud disabled so you're not bitten by that kind of thing. :) Anyway, in re: signatures, most of the data in the save files probably can't be counted on especially well. The first four bytes of the file should always be 0x09000000 (we think that's the savefile version), but that's not much for a signature. The next four bytes are achievement data (just for achievements unlocked for that savefile) -- your specific unlocked achievements would probably be relatively unchanging, but it could vary by person. I think a save with full achievements would show as 0xFEFF1F00 for those bytes. Then the next four bytes are an effectively random number which is used for a few things by the game -- you definitely wouldn't be able to count on that for savefiles in general.

I suspect that the game's revealed-minimap data section might be the most consistent across games, assuming that you haven't used tools like this one to reveal all (which would result in different data patterns than the "legitimately" unlocked minimap in-game). There's areas of the minimap which are almost certainly revealed identically for any valid save, such as the first few "intro" rooms. I wouldn't say these would be 100% usable, but I'd expect 'em to get maybe 99%. A couple of patterns that seem to match for all the savefiles that I've collected are these two:

  1. At 0x844C: 0xF00F00E007
  2. At 0x8574: 0xFFFFFF07F0FF1FFC07

... that's for minimap data that's unlocked in slot 1. The offsets for slot 2 would be 0x2F45C and 0x2F584, and the offsets for slot 3 would be 0x5646C and 0x56594. If you match on those with the first four bytes of the file being 0x09000000, I'd call that a pretty strong match.

apocalyptech commented 4 months ago

Oh, and I guess I'll probably close this out just to keep the issue list clean; I think the above is probably my best guess on a globally-usable signature. If you've got any other insights or ideas, though, feel free to leave more comments. Cheers!

apocalyptech commented 4 months ago

Oh oh, right, though the other thing I'd wanted to mention but then forgot: the data at the very end of the file, starting at position 0x75048, is where the game stores its options (fullscreen, scanlines, language, volumes, etc). That'll obviously vary per player, but I suspect it's unlikely to change once set. So that could work as well for your own saves, at least.