| View previous topic :: View next topic |
| Author |
Message |
psp.padawan
Joined: 12 Nov 2007 Posts: 10
|
Posted: Mon Jun 23, 2008 11:31 pm Post subject: |
|
|
| The patch stays in memory if you use loadmodule. It gets destroyed if you use loadexec. Thats why I used sceKernelLoadModuleForLoadExecVSHMs2 to load the homebrew. |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Mon Jun 23, 2008 11:45 pm Post subject: |
|
|
Ok, but where is declared this function?
I've copied your function with makefile but I've not found this function! :( |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Tue Jun 24, 2008 2:36 am Post subject: |
|
|
I always get a undefined referrence for that function.
I have the sdk that comes with 3.80 m33-3 and I also downloaded the one which comes with 3.71 m33 to see if the the function was renamed but nop, it's not there too. _________________
Upgrade your PSP |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Tue Jun 24, 2008 4:11 am Post subject: |
|
|
I'm trying with sceKernelLoadModuleMs2 (pspmodulemgr_kernel.h), I think is that function but the name is changed!
If it work I'll post the solution! ( :( not very good english I think) |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Tue Jun 24, 2008 4:34 am Post subject: |
|
|
Ok, I've builted the prx but I've not start it, I've a error, I've try with sceKernelLoadExec and pspSdkLoadStartModule...
( My programm is in user mode, is possible to start a prx in user mode? )
Here is the complete code:
| Code: |
#include <pspsdk.h>
#include <pspkernel.h>
#include <systemctrl.h>
#include <systemctrl_se.h>
#include <pspkerneltypes.h>
#include <pspmodulemgr_kernel.h>
#include <apihook.h>
#include <string.h>
#include <stdio.h>
PSP_MODULE_INFO("LoaderPRX", PSP_MODULE_KERNEL, 1, 0);
PSP_MAIN_THREAD_ATTR(0);
void executeEboot(char *target)
{
struct SceKernelLoadExecVSHParam param;
memset(¶m, 0, sizeof(param));
param.size = sizeof(param);
param.args = strlen(target)+1;
param.argp = target;
param.key = "game";
sctrlKernelLoadExecVSHMs2(target, ¶m);
}
void reloadMain()
{
executeEboot("ms0:/PSP/GAME/Xplora v1.0/EBOOT.PBP");
}
int main_thread(SceSize args, void *argp)
{
SceModule *mod=0;
SceUID uid = 0;
/* Unload the loader to free user memory */
while ((mod = sceKernelFindModuleByName("BootLoader")))
{
sceKernelStopModule(mod->modid, 0, NULL, NULL, NULL);
sceKernelUnloadModule(mod->modid);
}
// Hook exit game function
mod= sceKernelFindModuleByName("sceLoadExec");
if(mod) apiHookByName(mod->modid, "LoadExecForUser","sceKernelExitGame", reloadMain);
uid = sceKernelLoadModuleMs2("ms0:/PSP/GAME/CXMBTCv0.3/Eboot.pbp", 0, NULL);
uid = sceKernelStartModule(uid, 36, argp, NULL, NULL);
return sceKernelExitDeleteThread(0);
}
int module_start(SceSize args, void *argp)
{
SceUID th = sceKernelCreateThread("main_thread", main_thread, 8, 16*1024, 0, NULL);
if (th >= 0)
{
sceKernelStartThread(th, args, argp);
}
return 0;
}
int module_stop(SceSize args, void *argp)
{
return 0;
}
|
And Makefile:
| Code: |
TARGET = loadprx
OBJS = main.o apihook.o libs.o
INCDIR =
CFLAGS = -O2 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
PSP_FW_VERSION = 371
USE_KERNEL_LIBC = 1
USE_KERNEL_LIBS = 1
LIBDIR =
LIBS = -lpspmodulemgr_kernel -lpspsystemctrl_kernel
LDFLAGS = -mno-crt0 -nostartfiles
<------------------------------------ Here you ( I think) need to set env!
include $(PSPSDK)/lib/build.mak
|
|
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Tue Jun 24, 2008 5:09 am Post subject: |
|
|
I always get an error using this one:
sceKernelLoadModuleMs2
Unsupported prx type. _________________
Upgrade your PSP |
|
| Back to top |
|
 |
psp.padawan
Joined: 12 Nov 2007 Posts: 10
|
Posted: Tue Jun 24, 2008 10:59 pm Post subject: |
|
|
The 3.71 M33 sdk I use is included in the 3.71 M33-3 archive. Ive uploaded some samples.
It is a cut down version of the bootloader and loadprx code from moonlight's hense sdk.
I also used the apihook sample files that Cpasjuste has given me.
http://www.mediafire.com/?nwswgyi9yyz
Run the boot loader sample. it will load the hello world sample and when you exit the hello world sample it will go back to the boot loader |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Tue Jun 24, 2008 11:26 pm Post subject: |
|
|
Thanks, It's the same function as sceKernelLoadModuleMs2()
I will give it a try later. _________________
Upgrade your PSP |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Wed Jun 25, 2008 2:56 am Post subject: |
|
|
| Pirata Nervo, my code works, I've try to launch the prx un Irshell and works very great! |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Wed Jun 25, 2008 3:26 am Post subject: |
|
|
Cool :)
mine does not work lol.
I always get the error 8002012e.
From my patchexit.prx
but if I load the patchexit.prx from the sample it works.
I will load the bridge.elf instead of bridge.prx and load the patchexit.prx from the .elf.
Edit: the only way I found of getting it to work was:
create a bridge pbp and then read the path, written by NervOS into a file, and then pass it to patchexit.prx and then from patchexit.prx load the file path passed. lol this works _________________
Upgrade your PSP |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Thu Jun 26, 2008 2:33 am Post subject: |
|
|
Yes, I'm working on this solution!
Thanks! |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Thu Jun 26, 2008 2:40 am Post subject: |
|
|
I don't need, it's working for me and it's ok :)
Btw: Some homebrew is not loaded correctly and freeze on loading. _________________
Upgrade your PSP |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Thu Jun 26, 2008 3:22 am Post subject: |
|
|
If you have a good solution can post it here?
I've try to start the eboot, but I get always error 80010002! :( |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Thu Jun 26, 2008 3:30 am Post subject: |
|
|
that error means the eboot does not exist so you are passing the file path wrong.
Anyway I fixed my problem, I was not setting correctly a module ID _________________
Upgrade your PSP |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Sat Jun 28, 2008 4:31 am Post subject: |
|
|
I've a stupid error!
I've writed this funct in my bootloader eboot!
| Code: |
int main_thread(SceSize args, void *argp)
{
char file[128];
FILE* filedata;
filedata = fopen("ms0:/log.txt", "r");
fscanf(filedata,"%s",file);
fclose(filedata);
SceUID mod = sceKernelLoadModule("ms0:/krnlmod.prx", 0, NULL);
if (mod < 0)
{
return_();
}
else
{
mod = sceKernelStartModule(mod, strlen(file)+1, file, NULL, NULL);
if (mod < 0)
{
return_();
}
}
return sceKernelExitDeleteThread(0);
}
|
What's bad? If I launch it the pbp writed in the text file is not loaded, but with this it works perfect!
| Code: |
int main_thread(SceSize args, void *argp)
{
char* file="ms0:/EBOOT.PBP";
/*
FILE* filedata;
filedata = fopen("ms0:/log.txt", "r");
fscanf(filedata,"%s",file);
fclose(filedata);
*/
SceUID mod = sceKernelLoadModule("ms0:/myprx.prx", 0, NULL);
if (mod < 0)
{
return_();
}
else
{
mod = sceKernelStartModule(mod, strlen(file)+1, file, NULL, NULL);
if (mod < 0)
{
return_();
}
}
return sceKernelExitDeleteThread(0);
}
|
?????
I think is a problem in the return of fscanf...
What's the problem? |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sat Jun 28, 2008 4:37 am Post subject: |
|
|
| Well, your prxs have different names, and you don't bother checking if the file opened or not. Add that to the chance that your fscanf has a chance of overflowing your stack var and we all see that your coding skills need some work. :) |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Sat Jun 28, 2008 4:48 am Post subject: |
|
|
Excuse for the old name, but the second is a old funct and I've not changed the name, sorry...
I've already try to check if the file is opened and I've do a "printf" af the results and it is perfect, but is not perfect for pass it to the function sceKernelStartModule I think, but why?
J.F., I've already do the basic control, but the results says that the function it is perfect, but is not true... |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sat Jun 28, 2008 8:47 am Post subject: |
|
|
Put prints after each step along with a 3 second delay and see which part is going boom. In any case, you should probably be using fgets(), not fscanf(). It prevents stack overflows.
In case you aren't familiar with posix functions... http://www.opengroup.org/onlinepubs/7990989799/xsh/fgets.html
You'll find all the normal posix file commands there. |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Sat Jun 28, 2008 8:17 pm Post subject: |
|
|
The problem is not a overflow because the code works but it pass a wrong arg to the sceKernelStartModule, because the prx loaded is loaded but the file
is not loaded by the prx, and than ( I think ) the problem is in the fscanf that return a bad formatted string, I'll try to print all the caracter of the string as a integer and I'll see what appens |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Sat Jun 28, 2008 9:28 pm Post subject: |
|
|
If that really is your code, you need to check and fix the compiler warnings that it is surely giving you on the fscanf line!
<edit>sorry, that's crap, but just watch you're not scanf'ing over a constant string.
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Sat Jun 28, 2008 10:01 pm Post subject: |
|
|
????
I've try to printf the result string as integer and compare to the true string and it's equal, however I've coded a new solution, without write or read files...
Thanks to all! :) |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sun Jun 29, 2008 8:13 am Post subject: |
|
|
I ncase you don't know, Dax released a sample which comes with 4.0.1 SDK (from 4.0.1 m33 rar/zip)
the sample uses the sctrlKernelLoadExecVSHWithApitype function so no need for modules or anything at all. (besides the prx driver)
also, the patch is not lost _________________
Upgrade your PSP |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Mon Jun 30, 2008 1:31 am Post subject: |
|
|
I've try to rebuilt the DAX example and it doesn't work for me...
but I've try to load my executables with sctrlKernelLoadExecVSHWithApitype and my patch is lost... why?
I've try to comment the sctrlKernelLoadExecVSHWithApitype for check if the patch works and it works great!!
The prx of DAX patch only the ExitGame function, nothing else but ( I've not try it) his patch is not lost!
EDIT:
The new sctrlHENLoadModuleOnReboot function works only on 4.01M33 or can used on 3.90 M33-3 fw ? |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Mon Jun 30, 2008 3:06 am Post subject: |
|
|
The only thing that does not work for me is the UMD, so I created a prx which launches the umd with the load module function.
the sctrlLoadExecVSHWithApitype keeps the patch as far as I know (at least it works)
and yes it only patches the sceKernelExitGame function but you can patch anything else.
this function:
sctrlHENLoadModuleOnReboot
Only works on 4.0.1 M33-X _________________
Upgrade your PSP |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Mon Jun 30, 2008 3:29 am Post subject: |
|
|
Thanks very much!
Now I know that the DAX example is only for 4.01, and then if I do sctrlLoadExecVSHWithApitype for load a module my patch is unloaded!
uff... |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Mon Jun 30, 2008 3:34 am Post subject: |
|
|
[quote=darkness]
Thanks very much!
Now I know that the DAX example is only for 4.01, and then if I do sctrlLoadExecVSHWithApitype for load a module my patch is unloaded!
uff...
[/quote]
your patch is not unloaded.
My bridge.pbp (based on dax sample and my old bridge.pbp) and my both prx(patchexit_driver.prx and umdexec.prx) work on 3.xx too.
As long as you don't use the sctrlHENLoadModuleOnReboot, it works _________________
Upgrade your PSP |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Mon Jun 30, 2008 3:40 am Post subject: |
|
|
????
This function works because the prx is placed in memory and when launch a new app it's loaded from the memory...
But if I delete the sctrlHENLoadModuleOnReboot the patch is unloaded...
This is want I think, maybe it isn't true... |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Mon Jun 30, 2008 3:54 am Post subject: |
|
|
| darkness wrote: | ????
This function works because the prx is placed in memory and when launch a new app it's loaded from the memory...
But if I delete the sctrlHENLoadModuleOnReboot the patch is unloaded...
This is want I think, maybe it isn't true... |
not actually.
EVERYTHING you see(and what you can't see) on your psp is loaded into memory.
the prx is loaded into memory by the EBOOT.PBP (from bootload sample) but on my program from bridge.pbp.
the GAME4XX/bootload is only if you want to make the patch resident even if you are not running your program _________________
Upgrade your PSP |
|
| Back to top |
|
 |
darkness
Joined: 15 Jun 2008 Posts: 121
|
Posted: Tue Jul 01, 2008 3:29 am Post subject: |
|
|
I've tryed but it doesn't works without this funct,
however I'm working on a (I think) better solution!!
Thanks |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Tue Jul 01, 2008 3:37 am Post subject: |
|
|
Yeh without this it does not work.
| Code: |
SceUID fd = sceIoOpen("flash1:/NervOS/system/patchexit_driver.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);
|
this is what makes the patch resident. The only way of keeping your path is using the loadmodule functions. _________________
Upgrade your PSP |
|
| Back to top |
|
 |
|