Created
December 24, 2012 18:49
-
-
Save danielkza/4370329 to your computer and use it in GitHub Desktop.
Rocksmith save game transfer tool
This file contains hidden or 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
// Author: pcsmith | |
// Modifications: danielkza ([email protected]) | |
// License: GPLv3 https://www.gnu.org/licenses/gpl.html | |
// More info: http://rsmods.oakey-dev.eu/index.php?title=Savegame_Transfer | |
// | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdint.h> | |
#include <inttypes.h> | |
uint32_t get_id(FILE* handle) | |
{ | |
uint32_t id = 0; | |
if(fseek(handle, 8, SEEK_SET) != 0) | |
return 0; | |
if(fread(&id, sizeof(id), 1, handle) != 1 || ferror(handle)) | |
return 0; | |
return id; | |
} | |
int main(int argc, char* argv[]) | |
{ | |
FILE* handle; | |
uint32_t id; | |
if(argc<2) | |
{ | |
printf("Rocksmith Profiles ID Changer v0.2.1 by pcsmith\n"); | |
printf("------------------------------------------------\n"); | |
printf("Rocksmith only loads profiles with certain IDs.\n"); | |
printf("This tool can show and modify them.\n\n"); | |
printf("syntax: get profile ID: rsprofiles file\n"); | |
printf(" set profile ID: rsprofiles profileID file_1 [file_2] ... [file_n]\n"); | |
printf("More info:\n"); | |
printf(" http://rsmods.oakey-dev.eu/index.php?title=Savegame_Transfer\n\n"); | |
return 1; | |
} | |
if(argc == 2) // read mode | |
{ | |
handle = fopen(argv[1], "rb"); | |
if(handle == NULL) { | |
fprintf(stderr, "ERROR: Can't open file %s:", argv[1]); | |
perror(NULL); | |
return 1; | |
} | |
id = get_id(handle); | |
if(id == 0) { | |
fprintf(stderr, "ERROR: failed to retrieve ID\n"); | |
return 1; | |
} | |
fclose(handle); | |
printf("%" PRIx32, id); | |
return 0; | |
} | |
else // write mode | |
{ | |
int i; | |
// scan the new id | |
if(strlen(argv[1]) != 8 || sscanf(argv[1], "%" SCNx32, &id) != 1) { | |
fprintf(stderr, "ERROR: input id must be a 4 byte hex number in the form 'abcdef01'!\n"); | |
return 1; | |
} | |
// write it to all files | |
for(i = 2; i < argc; i++) | |
{ | |
uint32_t old_id; | |
handle = fopen(argv[i], "r+b"); | |
if(handle == NULL) { | |
fprintf(stderr, "WARNING: Can't open file %s, skipping:", argv[i]); | |
perror(NULL); | |
continue; | |
} | |
old_id = get_id(handle); | |
if(fseek(handle, 8, SEEK_SET) != 0 || fwrite(&id, sizeof(uint32_t), 1, handle) != 1) { | |
fprintf(stderr, "ERROR: failed to write ID to file %s", argv[i]); | |
} else { | |
fprintf(stderr, "OK: Changed profile ID from %" PRIx32 " to %" PRIx32 " (file %s)\n", old_id, id, argv[i]); | |
} | |
fclose(handle); | |
} | |
return 0; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment