Skip to content

Commit

Permalink
detect FinalSpeed installs
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAaronLopezGarcia committed Apr 16, 2024
1 parent 96f8e1a commit 3734900
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 56 deletions.
7 changes: 7 additions & 0 deletions loader/live/kernel/kernel_loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "core/compat/vitapops/rebootex/payload.h"
#include "core/compat/pentazemin/rebootex/payload.h"

extern char* kbin_path;

static int isVitaFile(char* filename){
return (strstr(filename, "psv")!=NULL // PS Vita btcnf replacement, not used on PSP
|| strstr(filename, "660")!=NULL // PSP 6.60 modules can be used on Vita, not needed for PSP
Expand Down Expand Up @@ -41,6 +43,11 @@ void flashPatch(){
k_tbl->KernelStartThread(kthreadID, sizeof(void*)*3, &args);
k_tbl->waitThreadEnd(kthreadID, NULL);
k_tbl->KernelDeleteThread(kthreadID);
// delete archive on FinalSpeed installs
if (kbin_path && strstr(kbin_path, "/PSP/APP/")){
PRTSTR("FinalSpeed Live Install detected, deleting FLASH0.ARK");
k_tbl->KernelIORemove(archive);
}
}
}
else{ // Patching flash0 on Vita
Expand Down
4 changes: 3 additions & 1 deletion loader/live/kernel/kernel_loader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ extern void copyPSPVram(u32*);

// K.BIN entry point
void (* kEntryPoint)() = (void*)KXPLOIT_LOADADDR;
char* kbin_path = NULL;

int autoDetectDevice(ARKConfig* config);
int initKxploitFile();
int initKxploitFile(char*);
void kernelContentFunction(void);

// Entry Point
Expand Down Expand Up @@ -166,6 +167,7 @@ int initKxploitFile(char* kxploit_file){
kxploit_file = k_path;
}
PRTSTR1("Loading Kxploit at %s", kxploit_file);
kbin_path = kxploit_file;
memset((void *)KXPLOIT_LOADADDR, 0, 0x4000);
g_tbl->IoRead(fd, (void *)KXPLOIT_LOADADDR, 0x4000);
g_tbl->IoClose(fd);
Expand Down
92 changes: 37 additions & 55 deletions loader/perma/cipl/installer/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,36 +80,6 @@ void ErrorExit(int milisecs, char *fmt, ...)
sceKernelDelayThread(milisecs*1000);
sceKernelExitGame();
}
////////////////////////////////////////
void flash_ipl(int size, u16 key)
{

printf("Flashing IPL...");

// if(ReadFile("ipl_block.bin", 0 , ipl_block_large , 0x4000) < 0)
// ErrorExit(5000,"Failed to load custom ipl!\n");

if(pspIplUpdateClearIpl() < 0)
ErrorExit(5000,"Failed to clear ipl!\n");

if (pspIplUpdateSetIpl(ipl_block , size, key ) < 0)
ErrorExit(5000,"Failed to write ipl!\n");

printf("Done.\n");

}

void flash_kbooti(int size)
{

printf("Flashing KBOOTI...");

if (pspKbootiUpdateKbooti(kbooti_ipl_block_01g, (sizeof(kbooti_ipl_block_01g))) < 0)
ErrorExit(5000,"Failed to write kbooti!\n");

printf("Done.\n");

}

void loadIplUpdateModule(){
SceUID mod;
Expand Down Expand Up @@ -152,7 +122,6 @@ void classicipl_menu(){

printf("Classic cIPL installation.\n");

ipl_block = ipl_block_large;
if( model == 0 ) {
memcpy( ipl_block_large , ipl_block_01g, 0x4000);
}
Expand Down Expand Up @@ -203,7 +172,15 @@ void classicipl_menu(){
sceCtrlReadBufferPositive(&pad, 1);

if (pad.Buttons & PSP_CTRL_CROSS) {
flash_ipl( size+0x4000, 0 );
printf("Flashing IPL...");

if(pspIplUpdateClearIpl() < 0)
ErrorExit(5000,"Failed to clear ipl!\n");

if (pspIplUpdateSetIpl(ipl_block_large, size+0x4000, 0 ) < 0)
ErrorExit(5000,"Failed to write ipl!\n");

printf("Done.\n");
break;
} else if ( (pad.Buttons & PSP_CTRL_CIRCLE) && ipl_type ) {
printf("Flashing IPL...");
Expand Down Expand Up @@ -293,7 +270,11 @@ void devtoolipl_menu(){
sceCtrlReadBufferPositive(&pad, 1);

if (pad.Buttons & PSP_CTRL_CROSS) {
flash_kbooti( size );
printf("Flashing KBOOTI...");
if (pspKbootiUpdateKbooti(kbooti_ipl_block_01g, (sizeof(kbooti_ipl_block_01g))) < 0)
ErrorExit(5000,"Failed to write kbooti!\n");

printf("Done.\n");
break;
} else if ( (pad.Buttons & PSP_CTRL_CIRCLE) && ipl_type ) {
printf("Flashing KBOOTI...");
Expand All @@ -316,24 +297,22 @@ void devtoolipl_menu(){


void newipl_menu(){
int size, ipl_type;
int size = 184320;
int ipl_type = 0;
u16 ipl_key = 0;

struct {
unsigned char* buf;
size_t size;
} ipl_table[] = {
{(unsigned char*)cipl_01G, size_cipl_01G},
{(unsigned char*)cipl_02G, size_cipl_02G},
{(unsigned char*)cipl_03G, size_cipl_03G},
{(unsigned char*)cipl_04G, size_cipl_04G},
{(unsigned char*)cipl_05G, size_cipl_05G},
{(unsigned char*)NULL, 0}, // 6g
{(unsigned char*)cipl_07G, size_cipl_07G},
{(unsigned char*)NULL, 0}, // 8g
{(unsigned char*)cipl_09G, size_cipl_09G},
{(unsigned char*)NULL, 0}, // 10g
{(unsigned char*)cipl_11G, size_cipl_11G},
static unsigned char* ipl_table[] = {
(unsigned char*)cipl_01G,
(unsigned char*)cipl_02G,
(unsigned char*)cipl_03G,
(unsigned char*)cipl_04G,
(unsigned char*)cipl_05G,
(unsigned char*)NULL, // 6g
(unsigned char*)cipl_07G,
(unsigned char*)NULL, // 8g
(unsigned char*)cipl_09G,
(unsigned char*)NULL, // 10g
(unsigned char*)cipl_11G,
};

int supported_models = sizeof(ipl_table)/sizeof(ipl_table[0]);
Expand All @@ -345,19 +324,17 @@ void newipl_menu(){
ErrorExit(5000,"6.61 FW SUPPORTED ONLY!\n");
}

if(model >= supported_models || ipl_table[model].buf == NULL) {
if(model >= supported_models || ipl_table[model] == NULL) {
ErrorExit(5000,"This installer does not support this model.\n");
}

ipl_block = ipl_table[model].buf;
u8* ipl_block = ipl_table[model];
if (model > 2){
ipl_key = (model==4)?2:1;
}

loadIplUpdateModule();

size = ipl_table[model].size;

printf("\nCustom ipl Flasher for 6.61.\n\n\n");

printf(" Press X to ");
Expand All @@ -366,7 +343,7 @@ void newipl_menu(){
printf("Re");
}

printf("install CIPL\n");
printf("install CIPL on %dg\n", model);

if( ipl_type ) {
printf(" Press O to Erase CIPL and Restore Raw IPL\n");
Expand All @@ -379,7 +356,12 @@ void newipl_menu(){
sceCtrlReadBufferPositive(&pad, 1);

if (pad.Buttons & PSP_CTRL_CROSS) {
flash_ipl( size, ipl_key );
printf("Flashing cIPL...");
if(pspIplUpdateClearIpl() < 0)
ErrorExit(5000,"Failed to clear ipl!\n");

if (pspIplUpdateSetIpl(ipl_block, size, ipl_key ) < 0)
ErrorExit(5000,"Failed to write cipl!\n");
break;
} else if ( (pad.Buttons & PSP_CTRL_CIRCLE) && ipl_type ) {
printf("Flashing IPL...");
Expand Down

0 comments on commit 3734900

Please sign in to comment.