Savedata Structure on 2.0+ Games

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
shell
Posts: 7
Joined: Tue Apr 03, 2007 6:11 am
Location: NYC
Contact:

Savedata Structure on 2.0+ Games

Post by shell »

Put simply, I want to make a program which can modify various traits and attributes of the Syphon Filter savedata. Before you flame me I have read up at jimparis's thread and plan to borrow some code from that sample (with credit). However, I have also read at some other thread that this code does not function on 3.0+. Is this true? What if the program is run on 3.03 OE-C with the 1.50 kernel option for homebrew? Also, how would I be able to extract the gamekey from the game ISO?

Thanks,
Shell
shell
Posts: 7
Joined: Tue Apr 03, 2007 6:11 am
Location: NYC
Contact:

Post by shell »

I have made a rough, unchecked, uncompiled draft. First I consolidated encrypt.c, decrypt.c, hash.c and psf.c into one large file called cryptfuncs.h. I know that this does not delete the temporary DEC.BIN in the memory stick root but I want to keep it like that until release so I can do debugging in the meanwhile after I get the things like the gamekey that I need to get this off the ground.

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>

#include "cryptfuncs.h"

PSP_MODULE_INFO&#40;"SyphonFilter Savegame Tweaker", 0, 1, 1&#41;;

#define printf pspDebugScreenPrintf

int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;

	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegiste\rExitCallback&#40;cbid&#41;;

	sceKernelSleepThreadCB&#40;&#41;;

	return 0;
&#125;

int SetupCallbacks&#40;void&#41;
&#123;
	int thid = 0;

	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41; &#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;

	return thid;
&#125;

const char *temp_bin = "ms0&#58;/DEC.BIN";
const char *prefix = "ms0&#58;/PSP/SAVEDATA/UCUS98641"; // append save number &#40;ex. 0000&#41;
const unsigned char gamekey&#91;&#93; = &#123; 0x00 &#125;; // need to wait on this one.

int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	bool satisfied = false;
	int i = 0;
	char *savename = &#40;char *&#41;calloc&#40;strlen&#40;prefix&#41; + 4 + strlen&#40;"/DATA.BIN"&#41; + 1, sizeof&#40;char&#41;&#41;;
	char *sfoname = &#40;char *&#41;calloc&#40;strlen&#40;prefix&#41; + 4 + strlen&#40;"/PARAM.SFO"&#41; + 1, sizeof&#40;char&#41;&#41;;

	pspDebugScreenInit&#40;&#41;;
	SetupCallbacks&#40;&#41;;

	SceCtrlData pad;

	while&#40;satisfied == false&#41;
	&#123;
		printf&#40;"SyphonFilter Savegame Tweaker\n\nSavegame #&#58; %d\nPress Triangle to increase and X to decrease\nPress O when ready.\n", num&#41;;
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
		if&#40;pad.Buttons & PSP_CTRL_TRIANGLE&#41;
		&#123;
			if&#40;i < 9999&#41;
			++i;
		else if&#40;pad.Buttons & PSP_CTRL_CROSS&#41;
		&#123;
			if&#40;i > 0&#41;
				--i;
		&#125;
		else if&#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;
			satisfied = true;
	&#125;

	pspDebugScreenClear&#40;&#41;;

	sprintf&#40;savename, "%s%.4d/DATA.BIN%c", prefix, i, NULL&#41;;
	sprintf&#40;sfoname, "%s%.4d/PARAM.SFO%c", prefix, i, NULL&#41;;

	i = decrypt_file&#40;temp_bin, savename, gamekey&#41;;
	
	if&#40;i < 0&#41;
	&#123;
		printf&#40;"There was an error in decoding, &#40;code %d&#41;\n", i&#41;;
		pspDebugScreenClear&#40;&#41;;
		sceKernelSleepThread&#40;&#41;;
		return 0;
	&#125;

	// do tweaking/editing of DEC.BIN here

	i = encrypt_file&#40;temp_bin, savename, "DATA.BIN", sfoname, gamekey&#41;;

	if&#40;i < 0&#41;
	&#123;
		printf&#40;"There was an error in encoding, &#40;code %d&#41;\n", i&#41;;
		pspDebugScreenClear&#40;&#41;;
		sceKernelSleepThread&#40;&#41;;
		return 0;
	&#125;

	printf&#40;"Done.\n"

	pspDebugScreenClear&#40;&#41;;

	sceKernelSleepThread&#40;&#41;;

	return 0;
&#125;
shell
Posts: 7
Joined: Tue Apr 03, 2007 6:11 am
Location: NYC
Contact:

Post by shell »

Come on people! It's been hours! Does anyone know how to get the gamekey from a ISO to use for decrypting saves?!?!
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Decrypting saves it not something we support and surely it is up to you to find the key it isn't very difficult :)
shell
Posts: 7
Joined: Tue Apr 03, 2007 6:11 am
Location: NYC
Contact:

Post by shell »

I tried this PRX which hooks a savedata function to get the key but the call that it hooks is broken in 3.0+. Could you key it for me?
Post Reply