 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Ruj89
Joined: 12 Jun 2007 Posts: 12
|
Posted: Mon Sep 29, 2008 2:21 am Post subject: sceNet functions hook |
|
|
I modified rdriver.prx source from D_A sdk to hook the sceNetInit function, but it's not working... This is my source:
| Code: |
#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;
}
|
The program loads the pspnet.prx module, patches the net syscall and the loadmodule (so the target homebrew won't load the pspnet prx again). Where's the error?
Last edited by Ruj89 on Mon Sep 29, 2008 7:20 am; edited 2 times in total |
|
| Back to top |
|
 |
Ruj89
Joined: 12 Jun 2007 Posts: 12
|
Posted: Mon Sep 29, 2008 2:29 am Post subject: Re: sceNet functions hook |
|
|
| [DELETED] |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Mon Sep 29, 2008 6:41 am Post subject: |
|
|
| There is a problem: net api is not kernel mode, so, they are no syscalls, they are pure jumps from user to user. |
|
| Back to top |
|
 |
Ruj89
Joined: 12 Jun 2007 Posts: 12
|
Posted: Mon Sep 29, 2008 7:00 am Post subject: |
|
|
| Thank you moonlight! So I have to develop a parallel module and, hooking the loadmodules functions, replace the prx... is there a faster way to change a function user2user? |
|
| Back to top |
|
 |
Ruj89
Joined: 12 Jun 2007 Posts: 12
|
Posted: Tue Sep 30, 2008 2:39 am Post subject: |
|
|
| If it exists, could you indicate me an example on how to hook the functions of a user module? Or just tell me if there is a source of a program that do that. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|