diff --git a/common/include/globals.h b/common/include/globals.h index 549f0adae..8722a3b0f 100644 --- a/common/include/globals.h +++ b/common/include/globals.h @@ -56,7 +56,7 @@ #define ARK_MAJOR_VERSION 4 #define ARK_MINOR_VERSION 20 #define ARK_MICRO_VERSION 60 -#define ARK_REVISION 4 +#define ARK_REVISION 5 #define MAX_FLASH0_SIZE 0x32000 /* diff --git a/common/include/rebootconfig.h b/common/include/rebootconfig.h index f5aecca9b..eaa06c215 100644 --- a/common/include/rebootconfig.h +++ b/common/include/rebootconfig.h @@ -58,6 +58,7 @@ typedef struct RebootConfigARK { u32 size; u32 flags; } rtm_mod; + char game_id[10]; } RebootConfigARK; #define IS_ARK_CONFIG(config) (*((u32*)config) == ARK_CONFIG_MAGIC) diff --git a/core/compat/pentazemin/Makefile b/core/compat/pentazemin/Makefile index 122cbc483..cd160fae1 100644 --- a/core/compat/pentazemin/Makefile +++ b/core/compat/pentazemin/Makefile @@ -16,7 +16,6 @@ C_OBJS = \ $(ARKROOT)/core/compat/vita/vlf.o \ $(ARKROOT)/common/utils/patches.o \ $(ARKROOT)/core/systemctrl/src/dummy.o \ - $(ARKROOT)/core/systemctrl/src/gameinfo.o \ OBJS = \ $(C_OBJS) imports.o diff --git a/core/compat/psp/Makefile b/core/compat/psp/Makefile index 36ecafdaf..f4e7de49b 100644 --- a/core/compat/psp/Makefile +++ b/core/compat/psp/Makefile @@ -8,7 +8,6 @@ C_OBJS = \ libertas.o \ usb_charge.o \ region_free.o \ - $(ARKROOT)/core/systemctrl/src/gameinfo.o \ OBJS = \ $(C_OBJS) imports.o diff --git a/core/systemctrl/exports.exp b/core/systemctrl/exports.exp index a53471e61..ea4090eae 100644 --- a/core/systemctrl/exports.exp +++ b/core/systemctrl/exports.exp @@ -201,7 +201,7 @@ PSP_EXPORT_FUNC_NID(strncasecmp, 0xAC7554DF) PSP_EXPORT_FUNC_NID(sctrlHENSetArkConfig, 0x6EAFC03D) PSP_EXPORT_FUNC(sctrlHENSetPluginHandler) PSP_EXPORT_FUNC(sctrlHENSetRebootexConfig) -PSP_EXPORT_FUNC(readGameIdFromDisc) +PSP_EXPORT_FUNC(getGameId) PSP_EXPORT_END PSP_EXPORT_START(ARKdebug, 0, 0x4001) diff --git a/core/systemctrl/src/gameinfo.c b/core/systemctrl/src/gameinfo.c index 2dc26aa6b..5ad1ac193 100644 --- a/core/systemctrl/src/gameinfo.c +++ b/core/systemctrl/src/gameinfo.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "globals.h" #include "macros.h" @@ -20,11 +21,9 @@ struct LbaParams { }; static const char* HOME_ID = "HOME00000"; +extern RebootConfigARK rebootex_config; -/* -int readGameIdFromUmd(char* gameid){ - int (*UmdActivate)(int, char*) = sctrlHENFindFunction("sceUmd_driver", "sceUmd", 0xC6183D47); - if (UmdActivate) UmdActivate(1, "disc0:"); +int readGameIdFromDisc(char* gameid){ // Open Disc Identifier int disc = sceIoOpen("disc0:/UMD_DATA.BIN", PSP_O_RDONLY, 0777); // Opened Disc Identifier @@ -45,77 +44,74 @@ int readGameIdFromUmd(char* gameid){ } return 0; } -*/ -int readGameIdFromDisc(char* gameid){ - static char game_id[10] = {0}; - int apitype = sceKernelInitApitype(); +int readGameIdFromPBP(char* gameid){ + int n = 9; + int res = sctrlGetInitPARAM("DISC_ID", NULL, &n, rebootex_config.game_id); + if (res < 0) return 0; + return 1; +} - if (game_id[0] == 0){ - if (apitype == 0x144 || apitype == 0x155){ // PS1: read from PBP - int n = 9; - int res = sctrlGetInitPARAM("DISC_ID", NULL, &n, game_id); - if (res < 0) return 0; - } - else { //if (sceKernelFindModuleByName("PRO_Inferno_Driver")){ // Inferno Driver: use IoDevctl - struct LbaParams param; - memset(¶m, 0, sizeof(param)); - - param.cmd = 0x01E380C0; - param.lba_top = 16; - param.byte_size_total = 10; - param.byte_size_start = 883; - - int res = sceIoDevctl("umd:", 0x01E380C0, ¶m, sizeof(param), game_id, sizeof(game_id)); - - if (res < 0) return 0; - - // remove the dash in the middle: ULUS-01234 -> ULUS01234 - game_id[4] = game_id[5]; - game_id[5] = game_id[6]; - game_id[6] = game_id[7]; - game_id[7] = game_id[8]; - game_id[8] = game_id[9]; - game_id[9] = 0; - } - /* - else { // UMD: use regular IO - readGameIdFromUmd(game_id); - int fd = sceIoOpen("ms0:/gameid.bin", PSP_O_WRONLY|PSP_O_CREAT|PSP_O_TRUNC, 0777); - sceIoWrite(fd, game_id, strlen(game_id)); - sceIoClose(fd); - } - */ - } +int readGameIdFromUmd(char* gameid){ + struct LbaParams param; + memset(¶m, 0, sizeof(param)); + + param.cmd = 0x01E380C0; + param.lba_top = 16; + param.byte_size_total = 10; + param.byte_size_start = 883; + + int res = sceIoDevctl("umd:", 0x01E380C0, ¶m, sizeof(param), rebootex_config.game_id, sizeof(rebootex_config.game_id)); + + if (res < 0) return 0; + + // remove the dash in the middle: ULUS-01234 -> ULUS01234 + rebootex_config.game_id[4] = rebootex_config.game_id[5]; + rebootex_config.game_id[5] = rebootex_config.game_id[6]; + rebootex_config.game_id[6] = rebootex_config.game_id[7]; + rebootex_config.game_id[7] = rebootex_config.game_id[8]; + rebootex_config.game_id[8] = rebootex_config.game_id[9]; + rebootex_config.game_id[9] = 0; - if (gameid) memcpy(gameid, game_id, 9); return 1; } int getGameId(char* gameid){ + int res = 1; + int apitype = sceKernelInitApitype(); if (apitype == 0x141 || apitype == 0x152 || apitype >= 0x200){ strcpy(gameid, HOME_ID); - return; + return res; } - // Find Function - void * (* SysMemForKernel_EF29061C)(void) = (void *)sctrlHENFindFunction("sceSystemMemoryManager", "SysMemForKernel", 0xEF29061C); - - // Function unavailable (how?!) - if(SysMemForKernel_EF29061C == NULL) return 0; - - // Get Game Info Structure - void * gameinfo = SysMemForKernel_EF29061C(); - - // Structure unavailable - if(gameinfo == NULL) return 0; - memcpy(gameid, gameinfo+0x44, 9); + if (rebootex_config.game_id[0] == 0){ - if (gameid[0] == 0 || strncmp(gameid, HOME_ID, 9) == 0){ - return readGameIdFromDisc(gameid); + // Find Function + void * (* SysMemForKernel_EF29061C)(void) = (void *)sctrlHENFindFunction("sceSystemMemoryManager", "SysMemForKernel", 0xEF29061C); + + // Function unavailable (how?!) + if(SysMemForKernel_EF29061C == NULL) return 0; + + // Get Game Info Structure + void * gameinfo = SysMemForKernel_EF29061C(); + + // Structure unavailable + if(gameinfo == NULL) return 0; + memcpy(gameid, gameinfo+0x44, 9); + + if (rebootex_config.game_id[0] == 0 || strncmp(rebootex_config.game_id, HOME_ID, 9) == 0){ + if (apitype == 0x144 || apitype == 0x155){ // PS1: read from PBP + res = readGameIdFromPBP(rebootex_config.game_id); + } + else { + res = readGameIdFromUmd(rebootex_config.game_id); + } + } } - return 1; + if (gameid) memcpy(gameid, rebootex_config.game_id, 9); + + return res; } diff --git a/core/systemctrl/src/loadercore.c b/core/systemctrl/src/loadercore.c index 8cf41f6d4..9b49dd479 100644 --- a/core/systemctrl/src/loadercore.c +++ b/core/systemctrl/src/loadercore.c @@ -205,12 +205,13 @@ static void checkArkPath(){ else{ sceIoDclose(res); } + extern RebootConfigARK rebootex_config; + if (sceKernelInitApitype() > PSP_INIT_APITYPE_DISC) rebootex_config.game_id[0] = 0; } // Init Start Module Hook int InitKernelStartModule(int modid, SceSize argsize, void * argp, int * modstatus, SceKernelSMOption * opt) { - extern u8 rebootex_config[]; SceModule2* mod = (SceModule2*) sceKernelFindModuleByUID(modid); int result = -1; diff --git a/core/systemctrl/src/plugin.c b/core/systemctrl/src/plugin.c index 6d97846ce..b02e7db7a 100644 --- a/core/systemctrl/src/plugin.c +++ b/core/systemctrl/src/plugin.c @@ -111,7 +111,8 @@ static int matchingRunlevel(char * runlevel) } else { // check if plugin loads on specific game char gameid[10]; memset(gameid, 0, sizeof(gameid)); - return (getGameId(gameid) && strstr(runlevel, gameid) != NULL); + getGameId(gameid); + return (gameid[0] && strstr(runlevel, gameid) != NULL); } // Unsupported Runlevel (we don't touch those to keep stability up) diff --git a/core/systemctrl/src/sctrl.c b/core/systemctrl/src/sctrl.c index 4c8efecf5..3cb7e1a81 100644 --- a/core/systemctrl/src/sctrl.c +++ b/core/systemctrl/src/sctrl.c @@ -77,6 +77,9 @@ int sctrlKernelLoadExecVSHMs4(const char *file, struct SceKernelLoadExecVSHParam } int sctrlKernelLoadExecVSHDisc(const char *file, struct SceKernelLoadExecVSHParam *param) { + int k1 = pspSdkSetK1(0); + readGameIdFromDisc(rebootex_config.game_id); + pspSdkSetK1(k1); return sctrlKernelLoadExecVSHWithApitype(PSP_INIT_APITYPE_DISC, file, param); } diff --git a/core/vshctrl/vshpatch.c b/core/vshctrl/vshpatch.c index e9418cb9d..e7c0fedea 100644 --- a/core/vshctrl/vshpatch.c +++ b/core/vshctrl/vshpatch.c @@ -367,7 +367,7 @@ int umdLoadExec(char * file, struct SceKernelLoadExecVSHParam * param) } else { sctrlSESetBootConfFileIndex(MODE_UMD); sctrlSESetUmdFile(""); - ret = sceKernelLoadExecVSHDisc(file, param); + ret = sctrlKernelLoadExecVSHDisc(file, param); } return ret; diff --git a/libs/SystemCtrlForKernel/SystemCtrlForKernel.S b/libs/SystemCtrlForKernel/SystemCtrlForKernel.S index fbbd9033b..b23cdbfae 100644 --- a/libs/SystemCtrlForKernel/SystemCtrlForKernel.S +++ b/libs/SystemCtrlForKernel/SystemCtrlForKernel.S @@ -207,7 +207,7 @@ IMPORT_FUNC "SystemCtrlForKernel",0xDCDC3891,sctrlHENSetRebootexOverride #endif #ifdef F_SystemCtrlForKernel_0067 - IMPORT_FUNC "SystemCtrlForUser",0x577AF198,sctrlKernelLoadExecVSHDisc + IMPORT_FUNC "SystemCtrlForKernel",0x577AF198,sctrlKernelLoadExecVSHDisc #endif #ifdef F_SystemCtrlForKernel_0068 IMPORT_FUNC "SystemCtrlForKernel",0x94FE5E4B,sctrlKernelLoadExecVSHDiscUpdater diff --git a/loader/live/kernel/kernel_loader/main.c b/loader/live/kernel/kernel_loader/main.c index e51440d15..405dc624e 100644 --- a/loader/live/kernel/kernel_loader/main.c +++ b/loader/live/kernel/kernel_loader/main.c @@ -192,9 +192,6 @@ void kernelContentFunction(void){ g_tbl->prtstr = KERNELIFY(g_tbl->prtstr); kxf->repairInstruction = KERNELIFY(kxf->repairInstruction); - PRTSTR("Testing Priviledges"); - u32 test = *(u32*)SYSMEM_TEXT; - PRTSTR("Scanning kernel functions"); // get kernel functions scanKernelFunctions(k_tbl);