Code: Select all
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspsysmem_kernel.h>
#include <psploadexec_kernel.h>
#include <pspreg.h>
#include <pspctrl.h>
#include <psprtc.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <psppower.h>
#include <pspnet.h>
#include <pspdisplay.h>
#include <psputility.h>
#include <systemctrl.h>
#include <systemctrl_se.h>
#include <stdio.h>
#include <string.h>
PSP_MODULE_INFO("rdriver", 0x1007, 1, 0);
u32 orig_funcs[7];
int sceNetInitPatched(int unk1,int unk2,int unk3,int unk4,int unk5){
SceUID FileToWrite,res;
int k1 = pspSdkSetK1(0);
FileToWrite = sceIoOpen("ms0:/log.txt", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777);
sceIoWrite(FileToWrite,"[*] sceNetInit hooked!\n",23);
sceIoClose(FileToWrite);
sctrlHENPatchSyscall((u32)sceNetInitPatched,(void *)orig_funcs[6]);
res=sceNetInit(unk1,unk2,unk3,unk4,unk5);
sctrlHENPatchSyscall(orig_funcs[6], sceNetInit);
pspSdkSetK1(k1);
return res;
}
SceUID sceKernelLoadModulePatched(const char *path, int flags, SceKernelLMOption *option){
SceUID FileToWrite,res;
char stringa[32];
int k1 = pspSdkSetK1(0);
FileToWrite = sceIoOpen("ms0:/log.txt", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777);
sceIoWrite(FileToWrite,"[*] System is loading ",22);
sceIoWrite(FileToWrite,path,strlen(path));
sceIoWrite(FileToWrite,"\n",1);
sceIoClose(FileToWrite);
if(strcmp(path,"flash0:/kd/pspnet.prx")){
sctrlHENPatchSyscall((u32)sceKernelLoadModulePatched,(void *)orig_funcs[2]);
res=sceKernelLoadModule(path,flags,option);
sctrlHENPatchSyscall(orig_funcs[2], sceKernelLoadModulePatched);
}else res=66061197;
FileToWrite = sceIoOpen("ms0:/log.txt", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777);
sprintf(stringa,"%d",res);
sceIoWrite(FileToWrite,stringa,strlen(stringa));
sceIoWrite(FileToWrite,"\n",1);
sceIoClose(FileToWrite);
pspSdkSetK1(k1);
return res;
}
int sceKernelStartModulePatched(SceUID modid, SceSize argsize, void *argp, int *status, SceKernelSMOption *option){
int res,FileToWrite;
int k1 = pspSdkSetK1(0);
char stringa[32];
FileToWrite = sceIoOpen("ms0:/log.txt", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777);
sceIoWrite(FileToWrite,"[*] Starting a module\n",22);
sceIoClose(FileToWrite);
if(modid!=66061197){
sctrlHENPatchSyscall((u32)sceKernelStartModulePatched,(void *)orig_funcs[5]);
res=sceKernelStartModule(modid,argsize,argp,status,option);
sctrlHENPatchSyscall(orig_funcs[5], sceKernelStartModulePatched);
} else res=66061197;
FileToWrite = sceIoOpen("ms0:/log.txt", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777);
sprintf(stringa,"%d",res);
sceIoWrite(FileToWrite,stringa,strlen(stringa));
sceIoWrite(FileToWrite,"\n",1);
sceIoClose(FileToWrite);
pspSdkSetK1(k1);
return res;
}
int RestoreExitGame()
{
int k1 = pspSdkSetK1(0);
sctrlHENPatchSyscall((u32)sceKernelLoadModulePatched,(void *)orig_funcs[2]);
sctrlHENPatchSyscall((u32)sceKernelStartModulePatched,(void *)orig_funcs[5]);
pspSdkSetK1(k1);
return 0;
}
void SetConfFile(int n)
{
int k1 = pspSdkSetK1(0);
sctrlSESetBootConfFileIndex(n);
pspSdkSetK1(k1);
}
void SetUmdFile(char *umdfile)
{
int k1 = pspSdkSetK1(0);
sctrlSESetUmdFile(umdfile);
pspSdkSetK1(k1);
}
int module_start(SceSize args, void *argp){
SceUID fd = sceIoOpen("ms0:/PSP/GAME4XX/bootload/rdriver.prx", PSP_O_RDONLY, 0);
if (fd < 0)
{
return 0;
}
int size = sceIoLseek(fd, 0, PSP_SEEK_END);
sceIoLseek(fd, 0, PSP_SEEK_SET);
SceUID pid = sceKernelAllocPartitionMemory(PSP_MEMORY_PARTITION_KERNEL, "", PSP_SMEM_Low, size, NULL);
if (pid < 0) return 0;
sceIoRead(fd, sceKernelGetBlockHeadAddr(pid), size);
sctrlHENLoadModuleOnReboot("/kd/usersystemlib.prx", sceKernelGetBlockHeadAddr(pid), size, BOOTLOAD_GAME | BOOTLOAD_POPS | BOOTLOAD_UMDEMU);
sceUtilityLoadModule(256);
orig_funcs[2] = sctrlHENFindFunction("sceModuleManager", "ModuleMgrForUser", 0x977DE386); //sceKernelLoadModule
orig_funcs[5] = sctrlHENFindFunction("sceModuleManager", "ModuleMgrForUser", 0x50F0C1EC); //sceKernelStartModule
orig_funcs[6] = sctrlHENFindFunction("sceNet_Library", "sceNet", 0x39AF39A6); //sceNetInit
sctrlHENPatchSyscall(orig_funcs[2], sceKernelLoadModulePatched); // sceKernelLoadModulePatched
sctrlHENPatchSyscall(orig_funcs[5], sceKernelStartModulePatched); //sceKernelStartModulePatched
sctrlHENPatchSyscall(orig_funcs[6], sceNetInitPatched); //sceNetInitPatched
sceKernelDcacheWritebackAll();
sceKernelIcacheClearAll();
return 0;
}