Created
July 24, 2017 21:48
-
-
Save st4rk/9cc05894a4bd46b795d2eeeca0497200 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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