All pastes #1389154 Raw Edit

Devhook 1.50 PS3 (common)

public c v1 · immutable
#1389154 ·published 2009-04-11 21:31 UTC
rendered paste body
/*Devhook installerInstalls via SPU hack by <b style="color:black;background-color:#ffff66">Neo_The_User</b> and Dark_x_cel*/#include "common.h"//Firmware Installer Versionconst char version[64] = "Devhook Firmware Installer v1.50";//Devhook Pathconst char devpath[] = "ext3:/dh/";//Update PS3UPDAT pathconst char updpath[] = "ext3:/PS3UPDAT.PUP";//PUP Magicchar pupmagic[4] =  {0x0,0x50,0x42,0x50};   //_PUPchar pbpid[4] =     {0,0,1,0};      //Filetype ID?!//PSF Magicchar psfmagic[4] =  {0x0,0x50,0x53,0x46};char psfid[4] =     {1,1,0,0};//buffer to store the update version from the update PS3UPDATchar fw[8];//converted update version number (2.42 ->2.42)char fwpath[4];//full installation path e.g. ext3:/dh/302///depends on selected updatechar installpath[64];//Get the PUP Headerint 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 validint 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 sfoint 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;i<header.pairs;i++)  {    memset (buffer, 0, 32);    sceIoLseek(fd, psf+sizeof(PSF_HEADER)+(sizeof(INDEX_TABLE)*i), SEEK_SET);    sceIoRead(fd, &index, sizeof(INDEX_TABLE));    sceIoLseek(fd, psf+header.keytable+index.keytable, SEEK_SET);    sceIoRead(fd, buffer, 32);    if(!(memcmp(buffer, "UPDATER_VER", 11)))    {      //ps3DebugScreenPrintf("FOUND UPDATE VERSION\n");      ok = 1;      break;    }  }  sceIoLseek(fd, psf+header.valuetable+index.valuetable, SEEK_SET);  sceIoRead(fd, fw, index.sizepadded);  sceIoClose(fd);  return ok;  }u128 filesize(char *src){  SceUID fd;  u128 filesize = 0;  if((fd = sceIoOpen(updpath, PS3_O_RDONLY, 0777)))  filesize = sceIoLseek(fd, 0, SEEK_END);  sceIoClose(fd);    return filesize;}void printright(int y, char *src){  const int chars = 67;  int len = 0;  int tmp;   int i=0;  for(i=0;i<chars;i++)  {    if(src[i]==0x00)    break;  }         len=i;  tmp = chars - len+1;    ps3DebugScreenSetXY(tmp, y);  ps3DebugScreenPrintf("%s\n",src);}void setupdebugscreen(){  ps3DebugScreenInit();  ps3DebugScreenSetBackColor(BG);  ps3DebugScreenSetTextColor(TXT);  ps3DebugScreenClear();}void printerror(char *src){  ps3DebugScreenSetTextColor(ERROR);  ps3DebugScreenPrintf("%s\n",src);  ps3DebugScreenSetTextColor(TXT);}void printerrorxy(int x, int y, char *src){  ps3DebugScreenSetTextColor(ERROR);  ps3DebugScreenSetXY(x,y);  ps3DebugScreenPrintf("%s",src);  ps3DebugScreenSetTextColor(TXT);}void printinstallheader(){  ps3DebugScreenSetXY(0,0);  ps3DebugScreenPrintf("--------------------------------------------------------------------");  ps3DebugScreenPrintf("%s                         PS3Brewery",version);  ps3DebugScreenPrintf("based on SPU hack by <b style="color:black;background-color:#ffff66">Neo_The_User</b> 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);}