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
Savedata Structure on 2.0+ Games
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("SyphonFilter Savegame Tweaker", 0, 1, 1);
#define printf pspDebugScreenPrintf
int exit_callback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegiste\rExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
const char *temp_bin = "ms0:/DEC.BIN";
const char *prefix = "ms0:/PSP/SAVEDATA/UCUS98641"; // append save number (ex. 0000)
const unsigned char gamekey[] = { 0x00 }; // need to wait on this one.
int main(int argc, char *argv[])
{
bool satisfied = false;
int i = 0;
char *savename = (char *)calloc(strlen(prefix) + 4 + strlen("/DATA.BIN") + 1, sizeof(char));
char *sfoname = (char *)calloc(strlen(prefix) + 4 + strlen("/PARAM.SFO") + 1, sizeof(char));
pspDebugScreenInit();
SetupCallbacks();
SceCtrlData pad;
while(satisfied == false)
{
printf("SyphonFilter Savegame Tweaker\n\nSavegame #: %d\nPress Triangle to increase and X to decrease\nPress O when ready.\n", num);
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_TRIANGLE)
{
if(i < 9999)
++i;
else if(pad.Buttons & PSP_CTRL_CROSS)
{
if(i > 0)
--i;
}
else if(pad.Buttons & PSP_CTRL_CIRCLE)
satisfied = true;
}
pspDebugScreenClear();
sprintf(savename, "%s%.4d/DATA.BIN%c", prefix, i, NULL);
sprintf(sfoname, "%s%.4d/PARAM.SFO%c", prefix, i, NULL);
i = decrypt_file(temp_bin, savename, gamekey);
if(i < 0)
{
printf("There was an error in decoding, (code %d)\n", i);
pspDebugScreenClear();
sceKernelSleepThread();
return 0;
}
// do tweaking/editing of DEC.BIN here
i = encrypt_file(temp_bin, savename, "DATA.BIN", sfoname, gamekey);
if(i < 0)
{
printf("There was an error in encoding, (code %d)\n", i);
pspDebugScreenClear();
sceKernelSleepThread();
return 0;
}
printf("Done.\n"
pspDebugScreenClear();
sceKernelSleepThread();
return 0;
}