Install a bootstrap and return to application... how?
I've try to load the module of the exported function with loadstartmodule and pspSdkLoadStartModule but I've still get error 0x80020149!
Here is the stub file created: ( Execute is my function )
Export file:
Here is the prx:
Execute function:
And here is the function in the main programm:
Here is the stub file created: ( Execute is my function )
Code: Select all
.set noreorder
#include "pspstub.s"
STUB_START "RDLib",0x40090000,0x00030005
STUB_FUNC 0x7F3D307A,SetConfFile
STUB_FUNC 0xB64186D0,SetUmdFile
STUB_FUNC 0xE86CA36E,Execute
STUB_END
Code: Select all
# Define the exports for the prx
PSP_BEGIN_EXPORTS
# These four lines are mandatory (although you can add other functions like module_stop)
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END
PSP_EXPORT_START(RDLib, 0, 0x4001)
PSP_EXPORT_FUNC(SetConfFile)
PSP_EXPORT_FUNC(SetUmdFile)
PSP_EXPORT_FUNC(Execute)
PSP_EXPORT_END
PSP_END_EXPORTS
Code: Select all
PSP_MODULE_INFO("KrnlMod", 0x1007, 1, 0);
PSP_HEAP_SIZE_KB(1024);
#define printf pspDebugScreenPrintf
#define sleep(n) sceKernelDelayThread(n)
u32 orig_funcs[2];
int ExitPatched()
{
int k1 = pspSdkSetK1(0);
char *program = "ms0:/PSP/GAME/Xplora_v1.0/EBOOT.PBP";
struct SceKernelLoadExecVSHParam param;
memset(¶m, 0, sizeof(param));
param.size = sizeof(param);
param.args = strlen(program)+1;
param.argp = program;
param.key = "game";
int res = sctrlKernelLoadExecVSHMs2(program, ¶m);
pspSdkSetK1(k1);
return res;
}
int ExitPatched2()
{
return ExitPatched();
}
void SetConfFile(int n)
{
int k1 = pspSdkSetK1(0);
sctrlSESetBootConfFileIndex(n);
pspSdkSetK1(k1);
}
void SetUmdFile(char *umdfile)
{
int k1 = pspSdkSetK1(0);
sctrlSESetUmdFile(umdfile);
pspSdkSetK1(k1);
}
void Execute(char* target)
{
SceUID mod = sceKernelLoadModuleMs2(target, 0, NULL);
if (mod >= 0)
{
mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
if (mod < 0)
pspDebugScreenInit();
printf("\nError 0x%08X starting module.\n", mod);
sleep(3000000);
}
else
{
if (mod == SCE_KERNEL_ERROR_EXCLUSIVE_LOAD)
{
// Ignore this error, it means the module loaded on reboot
}
else
{
pspDebugScreenInit();
printf("\nError 0x%08X loading module.\n", mod);
sleep(3000000);
}
}
return;
}
int main_thread(SceSize args, void *argp)
{
/*
pspDebugScreenInit();
char* argm = argp;
char* arg = strtok(argm, "{");
char arguments[4][128];
int n=0;
while(arg!=NULL)
{
sprintf(arguments[n], "%s", arg);
arg = strtok(NULL, "{");
n++;
}
// printf("\nArg0: %s\nArg1: %s\nArg2: %s\nArg3: %s", arguments[0], arguments[1], arguments[2], arguments[3]);
// sceKernelDelayThread(3000000);
*/
// Patcher function
orig_funcs[0] = sctrlHENFindFunction("sceLoadExec", "LoadExecForUser", 0x05572A5F);
orig_funcs[1] = sctrlHENFindFunction("sceLoadExec", "LoadExecForUser", 0x2AC9954B);
sctrlHENPatchSyscall(orig_funcs[0], ExitPatched); // sceKernelExitGame
sctrlHENPatchSyscall(orig_funcs[1], ExitPatched2); // sceKernelExitGameWithStatus
/*
// Loader funcions
sceDisplaySetHoldMode(1);
SceUID mod = sceKernelLoadModuleMs2("ms0:/PSP/GAME/Filer_5.0/EBOOT.PBP", 0, NULL);
// Starter function
if (mod >= 0)
{
mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
if (mod < 0)
printf("\nError 0x%08X starting module.\n", mod);
sleep(3000000);
}
else
{
if (mod == SCE_KERNEL_ERROR_EXCLUSIVE_LOAD)
{
// Ignore this error, it means the module loaded on reboot
}
else
{
printf("\nError 0x%08X loading module.\n", mod);
sleep(3000000);
}
}
*/
return 0;
}
int module_start(SceSize args, void *argp)
{
SceUID th = sceKernelCreateThread("main_thread", main_thread, 8, 4*1024, 0, NULL);
if (th >= 0)
{
sceKernelStartThread(th, args, argp);
}
return 0;
}
int module_stop(SceSize args, void *argp)
{
return 0;
}
Code: Select all
void Execute(char* target)
{
SceUID mod = sceKernelLoadModuleMs2(target, 0, NULL);
if (mod >= 0)
{
mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
if (mod < 0)
pspDebugScreenInit();
printf("\nError 0x%08X starting module.\n", mod);
sleep(3000000);
}
else
{
pspDebugScreenInit();
printf("\nError 0x%08X loading module.\n", mod);
sleep(3000000);
}
}
Code: Select all
SceUID mod = pspSdkLoadStartModule("ms0:/krnlmod.prx", PSP_MEMORY_PARTITION_KERNEL);
if(mod<0)
{
if (mod == SCE_KERNEL_ERROR_EXCLUSIVE_LOAD)
{
// Ignore this error, it means the module loaded on reboot
}
else
{
pspDebugScreenInit();
printf("\n(krnlmod.prx)Errore 0x%08X loading module.\n", mod);
sleep(3000000);
}
}
Execute("ms0:/PSP/GAME/HOMEBREW/EBOOT.PBP");
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
Code: Select all
/**
* Load a PBP (used for non updater pbp's) (0x141)
*
* @param path - The path to the module to load.
* @param flags - Unused, always 0 .
* @param option - Pointer to a mod_param_t structure. Can be NULL.
*
* @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
*/
SceUID ModuleMgrForKernel_49C5B9E1(const char *path, int flags, SceKernelLMOption *option);
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
try this:
and use &option instead of NULL
Code: Select all
SceKernelLMOption option;
SceUID mpid = PSP_MEMORY_PARTITION_USER;
memset(&option, 0, sizeof(option));
option.size = sizeof(option);
option.mpidtext = mpid;
option.mpiddata = mpid;
option.position = 0;
option.access = 1;
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
when loading the kernel prx I believe.
right? (as you are not checking anything when using the Execute function)
Edit:
this should be your Execute function:
Edit 2:
make sure you have a build_args function in your code.
Use this one(I got it from psplink's source code)
right? (as you are not checking anything when using the Execute function)
Edit:
this should be your Execute function:
Code: Select all
SceUID modid;
int status;
char args[1024];
int len;
SceKernelLMOption option;
SceUID mpid = PSP_MEMORY_PARTITION_USER;
memset(&option, 0, sizeof(option));
option.size = sizeof(option);
option.mpidtext = mpid;
option.mpiddata = mpid;
option.position = 0;
option.access = 1;
uid = sceKernelLoadModuleMs2(Line[0], 0, &option);
if (uid < 0)
{
// error
}
else {
len = build_args(args, Line[0], 0, NULL);
modid = sceKernelStartModule(uid, len, (void *) args, &status, NULL);
if (modid < 0)
{
// error
}
else {
// success
}
}
make sure you have a build_args function in your code.
Use this one(I got it from psplink's source code)
Code: Select all
int build_args(char *args, const char *execfile, int argc, char **argv)
{
int loc = 0;
int i;
strcpy(args, execfile);
loc += strlen(execfile) + 1;
for(i = 0; i < argc; i++)
{
strcpy(&args[loc], argv[i]);
loc += strlen(argv[i]) + 1;
}
return loc;
}
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 203
- Joined: Sat Jul 05, 2008 8:03 am
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
try what I posted:
Code: Select all
int Execute(char *file)
{
SceUID modid;
int status;
char args[1024];
int len;
SceKernelLMOption option;
SceUID mpid = PSP_MEMORY_PARTITION_USER;
memset(&option, 0, sizeof(option));
option.size = sizeof(option);
option.mpidtext = mpid;
option.mpiddata = mpid;
option.position = 0;
option.access = 1;
uid = sceKernelLoadModuleMs2(file, 0, &option);
if (uid < 0)
{
// error
return uid;
}
else {
len = build_args(args, file, 0, NULL);
modid = sceKernelStartModule(uid, len, (void *) args, &status, NULL);
if (modid < 0)
{
// error
return modid;
}
else {
// success
}
}
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
Ok, I've tryed to edit the DAX sample and if I try to execute a file using the exported function I've error 0x80020149 ( I think it's because I cannot use the module mgr function in a exported funct ) and if I try to load with your Execute function the PSP crash before the error is completely printed!
( For example the last time that I've try to start it I've seen on the screen:
"Erro" and the PSP crash before I can see the error! Why??
EDIT:
Have you already found a solution for that I'm trying to do?
( For example the last time that I've try to start it I've seen on the screen:
"Erro" and the PSP crash before I can see the error! Why??
EDIT:
Have you already found a solution for that I'm trying to do?
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
you know what you need to load your prx before using the Execute function right?
anyway
Do this instead:
create a pbp.
create a prx which has the execute function. (dont export it)
load the prx from the pbp. the prx loads the path from a file written by the pbp. the prx uses the path got from the file and uses it in the execute function.
Make sure you use the apihook lib from psplink (included in the sample by cpasjuste).
just hook sceKernelExitGame instead of loading dax's driver as it is just useful for 4.xx kernel
anyway
Do this instead:
create a pbp.
create a prx which has the execute function. (dont export it)
load the prx from the pbp. the prx loads the path from a file written by the pbp. the prx uses the path got from the file and uses it in the execute function.
Make sure you use the apihook lib from psplink (included in the sample by cpasjuste).
just hook sceKernelExitGame instead of loading dax's driver as it is just useful for 4.xx kernel
Yes, I know, if I didn't load the prx the function isn't executed without errors!
However, I'm using the DAx function for patch the exit game function and it works great!
Anyway why I have to load the path from file? Can't I pass it as a arg? I've already do it and it works fine! ( exep the load error ).
Thanks very much, I'll try your solution!
However, I'm using the DAx function for patch the exit game function and it works great!
Anyway why I have to load the path from file? Can't I pass it as a arg? I've already do it and it works fine! ( exep the load error ).
Thanks very much, I'll try your solution!
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am