 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Stewie87
Joined: 03 Apr 2008 Posts: 39
|
Posted: Tue Apr 06, 2010 8:02 am Post subject: Passing arguments to a Kernel module. How? |
|
|
First of all, sorry for my poor English... :P
I made a User-Mode homebrew which, at a certain point, loads a kernel module (PRX). This kernel module has the only purpose to start a EBOOT.PBP (thing that does not work in usermode).
Now, my problem is that I have to give to kernel module the path of the EBOOT.PBP to start. So, essentially, in (usermode) homebrew I have to pass to (kernelmode) PRX an argument.
This is the code of my (Kernel-mode) PRX:
| Code: | int threadMain(SceSize args, void *argp)
{
exec(...);
return 0;
}
int module_start(SceSize args, void *argp)
{
main_thid = sceKernelCreateThread("hbb_main", threadMain, 6, 0x800, 0, NULL);
if(main_thid >= 0) sceKernelStartThread(main_thid, args, argp);
return 0;
sceKernelExitDeleteThread(0);
}
int module_stop(SceSize args, void *argp)
{
return 0;
} |
And, in the (usermode) homebrew I load the module with:
| Code: | 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;
}
int loadStartModule(const char *name, int argc, char **argv)
{
SceUID modid;
int status;
char args[128];
int len;
modid = sceKernelLoadModule(name, 0, NULL);
if(modid >= 0)
{
len = build_args(args, name, argc, argv);
modid = sceKernelStartModule(modid, len, (void *) args, &status, NULL);
}
return modid;
} |
So I have to give to exec(...) function the path of the EBOOT.PBP to start.
I tried to use char *argv[] like main functions, but sceKernelStartModule() use void* and don't accept any type of my arguments :S
In what way i could give my path to exec(...) from the hombrew? Thx |
|
| Back to top |
|
 |
willow :--)
Joined: 13 Jan 2007 Posts: 126
|
|
| Back to top |
|
 |
psPea
Joined: 01 Sep 2007 Posts: 64
|
Posted: Tue Apr 06, 2010 8:14 am Post subject: |
|
|
how about exporting exec(...) from your kernel module and calling it from your app _________________ Click ME! |
|
| Back to top |
|
 |
carl0sgs
Joined: 10 Dec 2009 Posts: 41
|
Posted: Tue Apr 06, 2010 8:24 am Post subject: |
|
|
I did it like this:
Sending the string to the module:
int runPRX(char *path, SceSize args, void *argp) {//Load and start module
SceUID mod = sceKernelLoadModule(path, 0, NULL);
if (mod > 0) {
return sceKernelStartModule(mod, args, argp, NULL, NULL);
}
return 0;
}
And in your code:
char path[500];
sprintf(path, "ms0:/eboot.pbp");
runPRX("ms0:/yourmodule.prx",strlen(path)+1,path);//+1 is important (\0 character).
Receiving the string in the module:
int threadMain(SceSize args, void *argp)
{
if(args > 0) {
char path[args];
sprintf(path,argp);
//The path you want is in "path"
exec(path);
return 0;
}
Hope it helped :-P |
|
| Back to top |
|
 |
carl0sgs
Joined: 10 Dec 2009 Posts: 41
|
Posted: Tue Apr 06, 2010 8:25 am Post subject: |
|
|
| double post sorry >< |
|
| Back to top |
|
 |
Stewie87
Joined: 03 Apr 2008 Posts: 39
|
Posted: Tue Apr 06, 2010 8:43 am Post subject: |
|
|
| carl0sgs wrote: | I did it like this:
Sending the string to the module:
int runPRX(char *path, SceSize args, void *argp) {//Load and start module
SceUID mod = sceKernelLoadModule(path, 0, NULL);
if (mod > 0) {
return sceKernelStartModule(mod, args, argp, NULL, NULL);
}
return 0;
}
And in your code:
char path[500];
sprintf(path, "ms0:/eboot.pbp");
runPRX("ms0:/yourmodule.prx",strlen(path)+1,path);//+1 is important (\0 character).
Receiving the string in the module:
int threadMain(SceSize args, void *argp)
{
if(args > 0) {
char path[args];
sprintf(path,argp);
//The path you want is in "path"
exec(path);
return 0;
}
Hope it helped :-P |
Wow, it worked and on first attempt! Thank you very much :) |
|
| Back to top |
|
 |
carl0sgs
Joined: 10 Dec 2009 Posts: 41
|
Posted: Tue Apr 06, 2010 3:27 pm Post subject: |
|
|
| You are welcome ;-) |
|
| 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
|