Load PRX from Eboot

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

Moderators: cheriff, TyRaNiD

Post Reply
homemister
Posts: 25
Joined: Mon Mar 24, 2008 12:16 pm

Load PRX from Eboot

Post by homemister »

Hi all,
I am trying to include prx files into my eboot using bin/o and then load them into kernel memory when they are needed.

i use this function to store the prx file in the eboot.

syslib.o : syslib.prx
bin2o -i syslib.prx syslib.o syslib

But how do i load if from the memory?
Regards
Homemister
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)

I never used bin2o, but if it works like bin2c it should declare a variable named as the label parameter:

Code: Select all

static unsigned char label[] __attribute__((aligned(16)))
Ciaooo
Sakya
homemister
Posts: 25
Joined: Mon Mar 24, 2008 12:16 pm

Post by homemister »

how do you do bin2c?
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
homemister wrote:how do you do bin2c?
Almost the same way you used bin2o: :)

Code: Select all

bin2c syslib.prx syslib.h syslib
And you get a header file with the declaration of

Code: Select all

static unsigned char syslib[] __attribute__((aligned(16))) = {
....
};
Ciaooo
Sakya
homemister
Posts: 25
Joined: Mon Mar 24, 2008 12:16 pm

Post by homemister »

how do i then load it into the kernal memory?
Sorry for all of the trouble, but i have never done this before.
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
homemister wrote:how do i then load it into the kernal memory?
Sorry for all of the trouble, but i have never done this before.
Sorry, I don't know if it is possible to load a prx from memory and not from ms/flash.
If there's no way to do this I think you can at last save the data to a file and then load it. ;)

EDIT: Try to have a look to this function:

Code: Select all

/**
 * Load a module from a buffer using the USB/WLAN API.
 *
 * Can only be called from kernel mode, or from a thread that has attributes of 0xa0000000.
 *
 * @param bufsize - Size (in bytes) of the buffer pointed to by buf.
 * @param buf - Pointer to a buffer containing the module to load.  The buffer must reside at an
 *              address that is a multiple to 64 bytes.
 * @param flags - Unused, always 0.
 * @param option - Pointer to an optional ::SceKernelLMOption structure.
 *
 * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
 */
SceUID sceKernelLoadModuleBufferUsbWlan(SceSize bufsize, void *buf, int flags, SceKernelLMOption *option);
But if this function works only in kernel mode you'll need a kernel prx to use it...so the problem isn't solved. :)

Ciaooo
Sakya
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

You can write the bin2o variable to a temporary file in ms0:/ and load it normally, then delete it.
Thats what IRShell does to continue running in the background after launching a game.
homemister
Posts: 25
Joined: Mon Mar 24, 2008 12:16 pm

Post by homemister »

sorry for this question. But i am still learing about bin2c and bin2o.

How would i write the bin2o file to the memory stick?
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

In your program, in the global area, declare the following

extern unsigned char syslib_start[];
extern u32 syslib_size[];

Then you can write it to a file using sceIoWrite(fp, syslib_start, syslib_size);
homemister
Posts: 25
Joined: Mon Mar 24, 2008 12:16 pm

Post by homemister »

Thx verry much Torch.
Mashphealh
Posts: 18
Joined: Wed Nov 28, 2007 4:18 am

Post by Mashphealh »

You also can use this :

Code: Select all

int LoadStartModuleBuffer(void *buffer, int size, int a2)
{
    SceUID v0 = vshKernelLoadModuleBufferVSH&#40;size, buffer, 0, 0&#41; < 0&#41; return -1;
    if&#40;v0 < 0&#41;
           return -1;
           
    if&#40;a2 == 0&#41;
          return sceKernelStartModule&#40;v0, 0, 0, 0, 0&#41;;
          
    return 0;
&#125;
In my SDK, the function vshKernelLoad... hasn't been defined, so you can use a paralel function found at pspmodulemgr_kernel.h , his name is sceKernelLoadModuleBuffer.

Personally, I didn't test it function, and I don't know if that function will work in vsh mode.

The usage of LoadStartModuleBuffer is easy, just write LoadStartModuleBuffer(buffer, sizeof(buffer), 0);
Post Reply