Skip to content

Commit

Permalink
fix plugins on vita
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAaronLopezGarcia committed Jul 23, 2023
1 parent ad317ed commit 89c759c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 40 deletions.
29 changes: 0 additions & 29 deletions core/compat/psp/syspatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ int isSystemBooted(void)
return 0;
}

static u32 fakeDevkitVersion(){
return FW_660; // Popsloader V3 will check for 6.60, it fails on 6.61 so let's make it think it's on 6.60
}

static unsigned int fakeFindFunction(char * szMod, char * szLib, unsigned int nid){
if (nid == 0x221400A6 && strcmp(szMod, "SystemControl") == 0)
return 0; // Popsloader V4 looks for this function to check for ME, let's pretend ARK doesn't have it ;)
return sctrlHENFindFunction(szMod, szLib, nid);
}

static int _sceKernelBootFromForUmdMan(void)
{
return 0x20;
Expand Down Expand Up @@ -289,25 +279,6 @@ void PSPOnModuleStart(SceModule2 * mod){
goto flush;
}

if (strcmp(mod->modname, "popsloader") == 0 || strcmp(mod->modname, "popscore") == 0){
// fix for 6.60 check on 6.61
hookImportByNID(mod, "SysMemForKernel", 0x3FC9AE6A, &fakeDevkitVersion);
// fix to prevent ME detection
hookImportByNID(mod, "SystemCtrlForKernel", 0x159AF5CC, &fakeFindFunction);
goto flush;
}

if (strcmp(mod->modname, "DayViewer_User") == 0){
// fix scePaf imports in DayViewer
static u32 nids[] = {
0x2BE8DDBB, 0xE8CCC611, 0xCDDCFFB3, 0x48BB05D5, 0x22FB4177, 0xBC8DC92B, 0xE3D530AE
};
for (int i=0; i<NELEMS(nids); i++){
hookImportByNID(mod, "scePaf", nids[i], sctrlHENFindFunction("scePaf_Module", "scePaf", nids[i]));
}
goto flush;
}

if (strcmp(mod->modname, "vsh_module") == 0){
if (se_config->umdregion){
patch_vsh_region_check(mod);
Expand Down
17 changes: 8 additions & 9 deletions core/systemctrl/src/loadercore.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,6 @@ int InitKernelStartModule(int modid, SceSize argsize, void * argp, int * modstat
SceModule2* mod = (SceModule2*) sceKernelFindModuleByUID(modid);

int result = -1;

// Custom Handler registered
if(customStartModule != NULL)
{
// Forward to Handler
result = customStartModule(modid, argsize, argp, modstatus, opt);
if (result >= 0) return result;
}

// VSH replacement
if (strcmp(mod->modname, "vsh_module") == 0){
Expand All @@ -248,8 +240,15 @@ int InitKernelStartModule(int modid, SceSize argsize, void * argp, int * modstat
// Remember it
pluginLoaded = 1;
}

// Custom Handler registered
if(customStartModule != NULL)
{
// Forward to Handler
result = customStartModule(modid, argsize, argp, modstatus, opt);
}

// start module
// Default start module
if (result < 0) result = sceKernelStartModule(modid, argsize, argp, modstatus, opt);

return result;
Expand Down
4 changes: 2 additions & 2 deletions core/systemctrl/src/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ static void startPlugins()
char* path = plugins->paths[i];
// Load Module
int uid = sceKernelLoadModule(path, 0, NULL);
if (uid >= 0){
if (uid > 0){
// Call handler
if (plugin_handler){
res = plugin_handler(path, uid);
// Unload Module on Error
if (res < 0){
sceKernelUnloadModule(uid);
return;
continue;
}
}
// Start Module
Expand Down
25 changes: 25 additions & 0 deletions core/systemctrl/src/syspatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ static int isSystemBooted(void)
return 0;
}

static unsigned int fakeFindFunction(char * szMod, char * szLib, unsigned int nid){
if (nid == 0x221400A6 && strcmp(szMod, "SystemControl") == 0)
return 0; // Popsloader V4 looks for this function to check for ME, let's pretend ARK doesn't have it ;)
return sctrlHENFindFunction(szMod, szLib, nid);
}

// Module Start Handler
static void ARKSyspatchOnModuleStart(SceModule2 * mod)
{
Expand Down Expand Up @@ -152,6 +158,25 @@ static void ARKSyspatchOnModuleStart(SceModule2 * mod)
goto flush;
}

if (strcmp(mod->modname, "popsloader") == 0 || strcmp(mod->modname, "popscore") == 0){
// fix for 6.60 check on 6.61
hookImportByNID(mod, "SysMemForKernel", 0x3FC9AE6A, &sctrlHENFakeDevkitVersion);
// fix to prevent ME detection
hookImportByNID(mod, "SystemCtrlForKernel", 0x159AF5CC, &fakeFindFunction);
goto flush;
}

if (strcmp(mod->modname, "DayViewer_User") == 0){
// fix scePaf imports in DayViewer
static u32 nids[] = {
0x2BE8DDBB, 0xE8CCC611, 0xCDDCFFB3, 0x48BB05D5, 0x22FB4177, 0xBC8DC92B, 0xE3D530AE
};
for (int i=0; i<NELEMS(nids); i++){
hookImportByNID(mod, "scePaf", nids[i], sctrlHENFindFunction("scePaf_Module", "scePaf", nids[i]));
}
goto flush;
}

// Boot Complete Action not done yet
if(booted == 0)
{
Expand Down

0 comments on commit 89c759c

Please sign in to comment.