Install a bootstrap and return to application... how?

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

Moderators: cheriff, TyRaNiD

darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

Yes, this is that I try to say you! :)
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

Anyway I am already creating a patch for my NervOS 2.0.7 BETA to allow 3.xx users to run ISO's, Homebrew and PSX games without loosing the patch.
It uses the loadmodule* functions.
Image
Upgrade your PSP
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

Excuse me,
I've builted a prx for load all the executables, but when I try to load another module from the loaded prx I have error 0x80020143 ( MODULE_MRG_BUSY)!
I think is because I'm load a module from a loaded prx, so I've to unload it for load another module or I can load it with another function from main program?
( I've to pass arguments to the module );
Thanks in advance!

EDIT:
Can I use a simple sceKernelLoadExec?
I can use all the user mode funct for load the prx because there's not patch loaded!

Ok, I'm working on pspSdkLoadStartModule ( maybe resolved )! :D
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

You can't load/start stop/unload a module inside module_start, module_stop functions. Create a thread and load/start it from there.
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

pspSdkLoadStartModule does not work inside prx which uses KERNEL_LIBS or KERNEL_LIBC.
Image
Upgrade your PSP
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

Thnks!!
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

??? I've try to load a module but I get always error 0x800200D9!
Where is the possible problem?
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

code?
Image
Upgrade your PSP
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

Code: Select all

SceUID mod = sceKernelLoadModuleMs2(arguments[2], 0, data);
    if (mod >= 0)
    {
            mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
            if &#40;mod < 0&#41;
                printf&#40;"\nError 0x%08X starting module.\n", mod&#41;;
                sleep&#40;3000000&#41;;
    &#125;
    else
    &#123;
            if &#40;mod == SCE_KERNEL_ERROR_EXCLUSIVE_LOAD&#41;
            &#123;
                    // Ignore this error, it means the module loaded on reboot
            &#125;
            else
            &#123;
                printf&#40;"\nError 0x%08X loading module.\n",  mod&#41;; <---- Here I get the error
                sleep&#40;3000000&#41;;
            &#125;
    &#125;
This code is in a kernel mode prx loaded by the main programm with load / start module. ( Main programm is user mode)
Last edited by darkness on Thu Jul 03, 2008 4:55 am, edited 1 time in total.
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

I don't think that part of code is the problem
do you get the error from:
printf("\nError 0x%08X loading modules.\n", mod);
or when running that prx (which uses the code you posted)
Image
Upgrade your PSP
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

I've modified the code, see it!

P.S: I've to set the heap size or else?
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

depends of what you are trying to load and what format is your program.
is that code inside prx or pbp?
Image
Upgrade your PSP
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

No it's not true because he is using the load module * functions and not load exec* functions
@psp.padawan, 4.0 sdk comes with a better sample :) and even with loadexec (the patch is not lost on 4.0 or higher), I needed to create a 3xxkernel.prx to use the load module functions
Image
Upgrade your PSP
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

Is a kernel mode prx...
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

what are you talking about?
Image
Upgrade your PSP
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

depends of what you are trying to load and what format is your program.
is that code inside prx or pbp?
My "loader" is a kernel mode prx...
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

you deleted your other post and you made me look dumb.
don't it again with me please or I won't help you anymore.
but psp.padawan also deleted his post
yeh set the heap and try again
Image
Upgrade your PSP
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

Oh, excuse me, sorry!
I've tried to set heap size to 32 and 1024 but I still get the same error! :(
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

I think the problem is pbp you are trying to load
Image
Upgrade your PSP
psp.padawan
Posts: 10
Joined: Mon Nov 12, 2007 7:48 pm

Post by psp.padawan »

Pirata Nervo wrote:you deleted your other post and you made me look dumb.
don't it again with me please or I won't help you anymore.
but psp.padawan also deleted his post
yeh set the heap and try again
Pirata Nervo, I have not deleted any of my posts. The last one I had was the one with the sample. Yeah, Ive seen the 4.01 sdk sample. It works pretty good :)
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

I've tried to load another pbp but I've the same error!
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

@psp.padawan I am sure there was post by you above the one (mine) which says:
No it's not true because he is using the load module * functions and not load exec* functions
@psp.padawan, 4.0 sdk comes with a better sample :) and even with loadexec (the patch is not lost on 4.0 or higher), I needed to create a 3xxkernel.prx to use the load module functions

And there was a post by by darkness too but he deleted it.

O.o

@darkness, if you dont post your code I cant help you :/
Image
Upgrade your PSP
psp.padawan
Posts: 10
Joined: Mon Nov 12, 2007 7:48 pm

Post by psp.padawan »

Pirata Nervo wrote:@psp.padawan I am sure there was post by you above the one (mine) which says:
No it's not true because he is using the load module * functions and not load exec* functions
@psp.padawan, 4.0 sdk comes with a better sample :) and even with loadexec (the patch is not lost on 4.0 or higher), I needed to create a 3xxkernel.prx to use the load module functions
Nope I have not responded in this thread until today where I said I did not delete any of my posts. I might be wrong, but I dont think posts can be deleted. The text can be edited but I have not seen a delete option. Anyway, the name of the person should still be there even if the post has been edited.
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

??? I've already posted the code!!
Maybe you want a complete src!

Code: Select all

PSP_MODULE_INFO&#40;"Xp", 0x1000, 1, 0&#41;;

PSP_HEAP_SIZE_KB&#40;1024&#41;;

#define printf pspDebugScreenPrintf
#define sleep&#40;n&#41; sceKernelDelayThread&#40;n&#41;

u32 orig_funcs&#91;2&#93;;

int ExitPatched&#40;&#41;
&#123;
	int k1 = pspSdkSetK1&#40;0&#41;;

	char *program = "ms0&#58;/PSP/GAME/Xplora_v1.0/EBOOT.PBP";
	struct SceKernelLoadExecVSHParam param;

	memset&#40;&param, 0, sizeof&#40;param&#41;&#41;;
	param.size = sizeof&#40;param&#41;;
	param.args = strlen&#40;program&#41;+1;
	param.argp = program;
	param.key = "game";

	int res = sctrlKernelLoadExecVSHMs2&#40;program, &param&#41;;
	pspSdkSetK1&#40;k1&#41;;
	return res;
&#125;

int ExitPatched2&#40;&#41;
&#123;
	return ExitPatched&#40;&#41;;
&#125;

int RestoreExitGame&#40;&#41;
&#123;
	int k1 = pspSdkSetK1&#40;0&#41;;
	
	sctrlHENPatchSyscall&#40;&#40;u32&#41;ExitPatched, &#40;void *&#41;orig_funcs&#91;0&#93;&#41;;
	sctrlHENPatchSyscall&#40;&#40;u32&#41;ExitPatched2, &#40;void *&#41;orig_funcs&#91;1&#93;&#41;;

	pspSdkSetK1&#40;k1&#41;;
	return 0;
&#125;

void SetConfFile&#40;int n&#41;
&#123;
	int k1 = pspSdkSetK1&#40;0&#41;;
	sctrlSESetBootConfFileIndex&#40;n&#41;;
	pspSdkSetK1&#40;k1&#41;;
&#125;

void SetUmdFile&#40;char *umdfile&#41;
&#123;
	int k1 = pspSdkSetK1&#40;0&#41;;
	sctrlSESetUmdFile&#40;umdfile&#41;;
	pspSdkSetK1&#40;k1&#41;;
&#125;

int main_thread&#40;SceSize args, void *argp&#41;
&#123;
    pspDebugScreenInit&#40;&#41;;
    
    // Patcher function
    orig_funcs&#91;0&#93; = sctrlHENFindFunction&#40;"sceLoadExec", "LoadExecForUser", 0x05572A5F&#41;;
    orig_funcs&#91;1&#93; = sctrlHENFindFunction&#40;"sceLoadExec", "LoadExecForUser", 0x2AC9954B&#41;;
    sctrlHENPatchSyscall&#40;orig_funcs&#91;0&#93;, ExitPatched&#41;;
    sctrlHENPatchSyscall&#40;orig_funcs&#91;1&#93;, ExitPatched2&#41;;
    
    
    // Loader funcions
    
    SceUID mod = sceKernelLoadModuleMs2&#40;"ms0&#58;/PSP/GAME/Filer_5.0/EBOOT.PBP", 0, NULL&#41;;
    
    
    // Starter function
    
    if &#40;mod >= 0&#41;
    &#123;
            mod = sceKernelStartModule&#40;mod, 0, NULL, NULL, NULL&#41;;
            if &#40;mod < 0&#41;
                printf&#40;"\nError 0x%08X starting module.\n", mod&#41;;
                sleep&#40;3000000&#41;;
    &#125;
    else
    &#123;
            if &#40;mod == SCE_KERNEL_ERROR_EXCLUSIVE_LOAD&#41;
            &#123;
                    // Ignore this error, it means the module loaded on reboot
            &#125;
            else
            &#123;
                printf&#40;"\nError 0x%08X loading module.\n",  mod&#41;;
                sleep&#40;3000000&#41;;
            &#125;
    &#125;
    
    return 0;
&#125;



int module_start&#40;SceSize args, void *argp&#41;
&#123;
    SceUID th = sceKernelCreateThread&#40;"main_thread", main_thread, 8, 4*1024, 0, NULL&#41;;

    if &#40;th >= 0&#41;
    &#123;
      sceKernelStartThread&#40;th, args, argp&#41;;
    &#125;
    return 0;
&#125;


int module_stop&#40;SceSize args, void *argp&#41;
&#123;
    return 0;
&#125;
(I've never delete a post, maybe I've edit it for add info or else...)
However thanks!
psp.padawan
Posts: 10
Joined: Mon Nov 12, 2007 7:48 pm

Post by psp.padawan »

darkness, that code is from the rdriver code from 401M33 sdk sample right? It was originally coded as a kernel library ( 0x1007 ). You have mixed the kernel library code with kernel module code (0x1000).
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

yeh he is misunderstanding 0x1000 with 0x1006/0x1007 lool.

use prx for exports and a pbp to use the exports ;)

I guess I am having illusions lol, wtf
Image
Upgrade your PSP
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

This is only a try, if I put it in 0x1007 I have the same error!
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

No, you do not understand what is 0x1007/0x1006 supposed to be used on.
You can create a prx (like dax did for the sample) to export kernel functions to a usermode pbp
Image
Upgrade your PSP
darkness
Posts: 121
Joined: Sun Jun 15, 2008 8:42 pm

Post by darkness »

Ok, thanks very much, I'll try to write my first stub file for export the functions!

P.S: If I call a external function in main prog the problem of load module is solved or the problem remain?
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

you don't write stubs, you must type:
psp-build-exports -s nameofexportsfile.exp

and it makes the stub for you.
yes the problem should be solved
Image
Upgrade your PSP
Post Reply