PRX & Moduling Help

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Devun_06
Posts: 15
Joined: Sat Jun 17, 2006 7:01 pm

PRX & Moduling Help

Post by Devun_06 »

I'm trying to get my homebrew to load other eboots and call itself back up upon the exiting of the eboot my homebrew has loaded, but so far... I can't even tackle my first attempt at this moduling thing... can some one help me with this... my code doesn't look wrong to me.

Execution:

Code: Select all

//////////////////////Loading a PRX
int LoadAndStartModule_PRX(char *ModuleFILE, int UserMode)//UserMode mode: 1==true; 0 == false;
{//start moduling
SceKernelLMOption moduleprx;
                  moduleprx.mpidtext = (UserMode+1);// 2 is equivalent to usermode ;)
                  moduleprx.mpiddata = (UserMode+1);// 2 is equivalent to usermode ;)
                  moduleprx.position = 0;
                  moduleprx.access = 1;
                  moduleprx.size = sizeof(moduleprx);
SceUID PrxID=0;
PrxID = sceKernelLoadModuleMs(ModuleFILE,0,UserMode > 0 ? &moduleprx : NULL);// If in usermode, don't call as NULL >:// this carrys MS for Memory Stick ;)
int prxstatus=-1;
if( ( sceKernelStartModule (PrxID, 0,NULL,&prxstatus,NULL) ) !=0)// it was :if( ( sceKernelStartModule (PrxID, 0,NULL,&prxstatus,moduleprx) ) !=0)
&#123;//I think this is an okay error check<-
    //do nothing until necessary... &#58;&#41;, but this is on an errors existance
&#125;//last argument is 0 for usermode! #3 is NULL becaus it's okay, and I don't know wtf it's it's honestly asking for... &#58;'&#40;
//Finish MODULING&#58; Stop & Unload Relative MODULE
sceKernelStopModule&#40;PrxID, 0, NULL,&prxstatus,NULL&#41;;// it was&#58;sceKernelStopModule&#40;PrxID, 0, NULL,&prxstatus,moduleprx&#41;;
sceKernelUnloadModule&#40;PrxID&#41;;
return prxstatus;
&#125;//end moduling
//////////////////////Loading a PRX
Preperation:

Code: Select all

if&#40;Controller.Buttons & PSP_CTRL_LTRIGGER&#41;&#123;LoadAndStartModule_PRX&#40;"ms0&#58;/XT1_Module.prx", 0&#41;;&#125;
* I'm using the Sample PRX Renamed.
* It's in the right directory.
* After changing the name read in the sample loader, the PRX tested as *Working*

Thank You!!
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

I suppose that you have previously called pspSdkInstallNoPlainModuleCheckPatch (which requires kernel mode), right?

Also, if you call pspSdkInstallNoDeviceCheckPatch, you wouldn't need the sceKernelLoadModuleMs, the normal sceKernelLoadModule would work better.
It seems that the sceKernelLoadModuleMs has problems in loading user mode prx's (no problems with kernel ones), that's why you should use sceKernelLoadModule instead.
Devun_06
Posts: 15
Joined: Sat Jun 17, 2006 7:01 pm

Post by Devun_06 »

moonlight wrote:I suppose that you have previously called pspSdkInstallNoPlainModuleCheckPatch (which requires kernel mode), right?

Also, if you call pspSdkInstallNoDeviceCheckPatch, you wouldn't need the sceKernelLoadModuleMs, the normal sceKernelLoadModule would work better.
It seems that the sceKernelLoadModuleMs has problems in loading user mode prx's (no problems with kernel ones), that's why you should use sceKernelLoadModule instead.
Thanks
Last edited by Devun_06 on Sat Jul 29, 2006 5:59 am, edited 1 time in total.
subbie
Posts: 122
Joined: Thu May 05, 2005 4:14 am

Post by subbie »

I have a minor prx question. How do you figure out the STUB info to use in the program that loads the prx?
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

subbie, make your export.exp with the functions you want to export then do psp-build-exports -s export.exp and that will spit out a file with LibName.S where libname is the name of your library you specified in the export.exp file. Then just copy that across to your loader application and add it to your makefile.
subbie
Posts: 122
Joined: Thu May 05, 2005 4:14 am

Post by subbie »

TyRaNiD wrote:subbie, make your export.exp with the functions you want to export then do psp-build-exports -s export.exp and that will spit out a file with LibName.S where libname is the name of your library you specified in the export.exp file. Then just copy that across to your loader application and add it to your makefile.
Sweet, Thanks !! :D
Devun_06
Posts: 15
Joined: Sat Jun 17, 2006 7:01 pm

Post by Devun_06 »

Okay, I've made the necessary changes now, but I'm still not getting anything to boot from it except now the PSP doesn't crash unless I release the error codes as comments. What exactly is messing up my code now?

Code: Select all

int LoadAndStartModule_PRX&#40;char *ModuleFILE, int UserMode&#41;//UserMode mode&#58; 1==true; 0 == false;
&#123;//start moduling
//**ERROR INSTALL HANDLERS**\//
//pspDebugInstallKprintfHandler&#40;NULL&#41;;
//pspDebugInstallErrorHandler&#40;NULL&#41;;
//pspDebugInstallStdoutHandler&#40;pspDebugScreenPrintData&#41;;
//pspSdkInstallNoPlainModuleCheckPatch&#40;&#41;;//uses &#58; #include <pspsdk.h>
SceKernelLMOption moduleprx;
                  moduleprx.mpidtext = &#40;UserMode+1&#41;;// 2 is equivalent to usermode ;&#41;
                  moduleprx.mpiddata = &#40;UserMode+1&#41;;// 2 is equivalent to usermode ;&#41;
                  moduleprx.position = 0;
                  moduleprx.access = 1;
                  moduleprx.size = sizeof&#40;moduleprx&#41;;
SceUID PrxID=0;
PrxID = sceKernelLoadModule&#40;ModuleFILE,0,UserMode > 0 ? &moduleprx &#58; NULL&#41;;// If in usermode, don't call as NULL >&#58; 
int prxstatus=-1;
if&#40; &#40; sceKernelStartModule &#40;PrxID, 0,NULL,&prxstatus,NULL&#41; &#41; !=0&#41;// it was &#58;if&#40; &#40; sceKernelStartModule &#40;PrxID, 0,NULL,&prxstatus,moduleprx&#41; &#41; !=0&#41;
&#123;//I think this is an okay error check<-
    //do nothing until necessary... &#58;&#41;, but this is on an errors existance
&#125;//last argument is 0 for usermode! #3 is NULL because it's okay, and I don't know what it's honestly asking for... &#58;'&#40;
//Finish MODULING&#58; Stop & Unload Relative MODULE
sceKernelStopModule&#40;PrxID, 0, NULL,&prxstatus,NULL&#41;;// it was&#58;sceKernelStopModule&#40;PrxID, 0, NULL,&prxstatus,moduleprx&#41;;
sceKernelUnloadModule&#40;PrxID&#41;;
return prxstatus;
&#125;//end moduling
Post Reply