Fix save file checksum / hash for Rune Factory 4

Reading, editing and everything related to the files created by games to contain savegames and configurations
HenryEx
Posts: 27
Joined: Wed Aug 13, 2014 6:43 pm

Fix save file checksum / hash for Rune Factory 4

Post by HenryEx »

I had this for a long time and never put it out there, but with the recent re-release of Rune Factory 4 for the Switch, maybe someone else could find it useful. In any case, it's here for posterity.
This should work for both normal and special version of the game, and works on both the save slot files as well as the "save selection" file a.k.a the system save, which governs unlocks across saves and character names.

The save has a simple CRC32 error check that prevents modification, so a simple script is enough to fix it.

https://pastebin.com/fRvqRduA
HenryEx
Posts: 27
Joined: Wed Aug 13, 2014 6:43 pm

Re: Fix save file checksum / hash for Rune Factory 4

Post by HenryEx »

Script in full:

Code: Select all

# Rune Factory 4 (Special)
# Script to fix save checksum after modification
#
# Works on save files and "system saves" / save select file
#
# Written by HenryEx
#
# script for QuickBMS http://quickbms.aluigi.org
# See also: http://aluigi.altervista.org/bms/quickbms_crc_engine.txt

get NAME filename
get FILESIZE asize
get MAGIC long
set PAD long 0xE0

if MAGIC == 1144276562  # string 'RF4D'
  get FILECRC long
  set PAD long 0
else
  set FILECRC long MAGIC
  set PAD long 0xE0
endif

SavePos OFFSET
xmath SIZE "FILESIZE - OFFSET - PAD"

# print "File CRC: %FILECRC|x%, data pos: %OFFSET%, pad by %PAD%, data size: %SIZE%"

encryption CRC 0xEDB88320 "32 -1 -1 0 0 1"
log MEMORY_FILE OFFSET SIZE
set NEWCRC long QUICKBMS_CRC

if FILECRC == NEWCRC
  print "Save CRC seems to be intact! No modification necessary."
  CleanExit
endif

encryption "" ""
log MEMORY_FILE 0 FILESIZE

math OFFSET - 4
goto OFFSET MEMORY_FILE
put NEWCRC long MEMORY_FILE
print "Checksum fixed! New CRC: %NEWCRC|x%"

log NAME 0 FILESIZE MEMORY_FILE
CleanExit