Install a bootstrap and return to application... how?
-
- Posts: 10
- Joined: Mon Nov 12, 2007 7:48 pm
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
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:
And Makefile:
( My programm is in user mode, is possible to start a prx in user mode? )
Here is the complete code:
Code: Select all
#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;
}
Code: Select all
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
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 10
- Joined: Mon Nov 12, 2007 7:48 pm
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
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
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
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
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
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
I've a stupid error!
I've writed this funct in my bootloader eboot!
What's bad? If I launch it the pbp writed in the text file is not loaded, but with this it works perfect!
?????
I think is a problem in the return of fscanf...
What's the problem?
I've writed this funct in my bootloader eboot!
Code: Select all
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);
}
Code: Select all
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?
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...
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...
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/799 ... fgets.html
You'll find all the normal posix file commands there.
In case you aren't familiar with posix functions... http://www.opengroup.org/onlinepubs/799 ... fgets.html
You'll find all the normal posix file commands there.
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
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
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
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 ?
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 ?
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
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
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
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
your patch is not unloaded.darkness wrote: 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...
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
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
not actually.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...
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
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
Yeh without this it does not work.
this is what makes the patch resident. The only way of keeping your path is using the loadmodule functions.
Code: Select all
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);