/*
Devhook installer
Installs via SPU hack by Neo_The_User and Dark_x_cel
*/
#include "common.h"
//Firmware Installer Version
const char version[64] = "Devhook Firmware Installer v1.50";
//Devhook Path
const char devpath[] = "ext3:/dh/";
//Update PS3UPDAT path
const char updpath[] = "ext3:/PS3UPDAT.PUP";
//PUP Magic
char pupmagic[4] = {0x0,0x50,0x42,0x50}; //_PUP
char pbpid[4] = {0,0,1,0}; //Filetype ID?!
//PSF Magic
char psfmagic[4] = {0x0,0x50,0x53,0x46};
char psfid[4] = {1,1,0,0};
//buffer to store the update version from the update PS3UPDAT
char fw[8];
//converted update version number (2.42 ->2.42)
char fwpath[4];
//full installation path e.g. ext3:/dh/302/
//depends on selected update
char installpath[64];
//Get the PUP Header
int getpbpheader(PUP_HEADER *tmp)
{
int bytes_read = 0;
SceUID fd;
if(!(fd = sceIoOpen(updpath, PS3_O_RDONLY, 0777)))
{
return 0;
}
bytes_read = sceIoRead(fd, tmp, sizeof(PUP_HEADER));
if(bytes_read != sizeof(PUP_HEADER))
{
return 0;
}
sceIoClose(fd);
return validatepbp(tmp);
}
//check if PS3UPDAT is valid
int validatepbp(PUP_HEADER *src)
{
if(memcmp(src->header, pbpmagic, 4) != 0)
{
return 0;
}
else
{
//printerror("PS3UPDAT is not a valid Update");
return 1;
}
}
//gets the update version from the sfo
int getupdateversion(u128 psf)
{
PSF_HEADER header;
INDEX_TABLE index;
SceUID fd;
int i=0;
int ok=-1;
char buffer[32];
if(!(fd = sceIoOpen(updpath, PS3_O_RDONLY, 0777)))
{
//error
return ok;
}
sceIoLseek(fd, psf, SEEK_SET);
sceIoRead(fd, &header, sizeof(PSF_HEADER));
for(i=0;iNeo_The_User and Dark_x_cel\n");
ps3DebugScreenPrintf("--------------------------------------------------------------------");
}
void printok(char *src)
{
ps3DebugScreenSetTextColor(OK);
ps3DebugScreenPrintf("%s\n",src);
ps3DebugScreenSetTextColor(TXT);
}
//pretty lazy but yeah.....
int supportedfw()
{
if(!memcmp(fw, "2.20", 4))
{
return 1;
}
if(!memcmp(fw, "2.30", 4))
{
return 1;
}
if(!memcmp(fw, "2.36", 4))
{
return 1;
}
if(!memcmp(fw, "2.40", 4))
{
return 1;
}
if(!memcmp(fw, "2.41", 4))
{
return 1;
}
if(!memcmp(fw, "2.42", 4))
{
return 1;
}
return 0;
}
void makedevpath()
{
int i=0;
int y=0;
for(i=0;i<4;i++)
{
if(fw[i]!='.')
{
fwpath[y]=fw[i];
y++;
}
}
fwpath[y] = 0x00;
sprintf(installpath, "%s%s/", devpath,fwpath);
}