Skip to content

Instantly share code, notes, and snippets.

@st4rk
Created Jul 24, 2017
Embed
What would you like to do?
/*
The Sims 3 save game checksum fix
*/
#include <stdio.h>
#include <stdlib.h>
// the sims 3 code: sub_20935D0
unsigned int checksum(unsigned char *savegame, size_t size)
{
unsigned int i = 0; // r4@1
unsigned int v3; // r2@2
for (i = 19; size; --size )
{
v3 = *savegame++;
i = (i + (v3 * size & 0xFFFF)) & 0xFFFF;
}
return i;
}
int main(int argc, char **argv) {
unsigned char *saveFile = NULL;
FILE *save = fopen(argv[1], "rb");
if (save != NULL) {
unsigned int saveSize = 0;
fseek(save, 0L, SEEK_END);
saveSize = ftell(save);
rewind(save);
saveFile = (unsigned char*) malloc (sizeof(unsigned char) * saveSize);
fread(saveFile, sizeof(unsigned char), saveSize, save);
printf("value: 0x%X\n", *(unsigned int*)(saveFile+0x28));
unsigned short data = checksum((saveFile+0x28), 0x6C);
printf("value: 0x%X\n", data);
fclose(save);
free(saveFile);
saveFile = NULL;
} else {
printf("Failed to open save game file");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment