sceKernelLoadExec --> vshmain.prx

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

Moderators: cheriff, TyRaNiD

Post Reply
fuzzzzy
Posts: 9
Joined: Thu Apr 26, 2007 12:01 pm

sceKernelLoadExec --> vshmain.prx

Post by fuzzzzy »

I am trying to intercept the execution of the vshmain.prx (currently only for experimental purposes). Here is my code so far. I only want it to load when L is pressed.

Code: Select all

/* vsh loadup module // By fuzzzzy  */


//includes//

//psp sdk//
#include <pspkernel.h>
#include <pspsdk.h>
#include <pspctrl.h>

//from local file
#include <psploadexec_kernel.h>
#include <pspvshbridge.h>


PSP_MODULE_INFO&#40;"vshLoad", 0x1000, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

#define PATH "flash0&#58;/vsh/nodule/vshmain_real.prx"

//init from flash//
int main_thread&#40;SceSize args, void *argp&#41;
&#123;
   SceCtrlData pad; 
  
   while&#40;1&#41; &#123;
   sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
    
    if&#40;pad.Buttons & PSP_CTRL_LTIRGGER&#41;
    &#123;
       

       struct SceKernelLoadExecParam param;

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

       sceKernelLoadExec&#40;PATH, &param&#41;; 

    &#125;

&#125;
return 0;
&#125;

Im not quite sure if I should use sceKernelLoadExec() or pspSdkLoadStartModule() to start the vshmain.prx.


I have already posted this on lan.st but none seemed to really know. So im hoping that someone here can help since all the greats are here.

Thank you to all who help <-------------------
Last edited by fuzzzzy on Wed May 23, 2007 9:58 am, edited 1 time in total.
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Hi, i think that your first problem is that there is no main loop in your code, so your binary is just finnished as soon as it is launched. You should begin by adding a loop. Also note that your are not intercepting anything right now. You should test your code with psplinkusb.

Exemple :

Code: Select all

/* vsh loadup module // By fuzzzzy  */


//includes//

//psp sdk//
#include <pspkernel.h>
#include <pspsdk.h>
#include <psppower.h>
#include <math.h>
#include <string.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>
//standard C//
#include <stdio.h>
#include <stdlib.h>

//from local file
#include <psploadexec_kernel.h>
#include <pspvshbridge.h>


PSP_MODULE_INFO&#40;"vshLoad", 0x1000, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

#define PATH "flash0&#58;/vsh/nodule/vshmain.prx"

//init from flash//
int main_thread&#40;SceSize args, void *argp&#41;
&#123;
   SceCtrlData pad;

   
	while&#40;0&#41; 
	&#123;
	
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;;

		if&#40;pad.Buttons & PSP_CTRL_LTIRGGER&#41;
		&#123;
		
		struct SceKernelLoadExecParam param;

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

		sceKernelLoadExec&#40;PATH, &param&#41;;
		&#125;
	&#125;	

return 0;
&#125; 
fuzzzzy
Posts: 9
Joined: Thu Apr 26, 2007 12:01 pm

Post by fuzzzzy »

thnk you for pointing that out. I totally forgot that lol. Even though i added the loop it still doesnt work. And yes I am intercepting it. I want to name my module to vshmain.prx. So basically my module is taking the place of vshmain and only booting the vsh if L i pressed. Then it will load the vshmain_real.prx to start the xmb.
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Are you using the code pasted without changes ? Because right now you are launching "vshmain.prx" when L is pressed that wont work for sure if the vsh isn't stopped before. Like i said you should use psplinkusb to test your code (add some printf to debug) and/or look at psplink source to see how modules are loaded.
fuzzzzy
Posts: 9
Joined: Thu Apr 26, 2007 12:01 pm

thnx

Post by fuzzzzy »

thnx for te heads up. Il try it out.
Gh0sT
Posts: 5
Joined: Tue Jun 06, 2006 2:38 am

Post by Gh0sT »

Sorry, to point this out, but I hope you're not just c&p-ing:

if(pad.Buttons & PSP_CTRL_LTIRGGER)?

Greets
fuzzzzy
Posts: 9
Joined: Thu Apr 26, 2007 12:01 pm

thnx

Post by fuzzzzy »

thnx for pointing out that typo lol
fuzzzzy
Posts: 9
Joined: Thu Apr 26, 2007 12:01 pm

notin works

Post by fuzzzzy »

well nothing seems to work. Neither sceKernelLoadExec() or sceKernelLoadModule(). Wtf none of them seem to execute vshmain.prx. I must be doing somthing wrong. Someone must know the answer lol.
johnmph
Posts: 119
Joined: Sat Jul 23, 2005 11:48 pm

Re: notin works

Post by johnmph »

fuzzzzy wrote:well nothing seems to work. Neither sceKernelLoadExec() or sceKernelLoadModule(). Wtf none of them seem to execute vshmain.prx. I must be doing somthing wrong. Someone must know the answer lol.
You must load and start other modules required before to load and start vshmain.prx

Code: Select all

/kd/chkreg.prx
/kd/msaudio.prx
/kd/vshbridge.prx
/vsh/module/heaparea1.prx
/vsh/module/paf.prx
/vsh/module/common_gui.prx
/vsh/module/common_util.prx

/vsh/module/vshmain.prx
For 1.50 kernel, maybe other modules are necessary in greater firmware, use kprintf handler to know which modules are necessary.

EDIT :

Oups, i didn't see your second post, forget what i said, if you rename your module for it starts instead of real vshmain.prx, you don't need to load other modules, the firmware will do it for you.
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

How is this different from loading any other module :P
i think the problem is that you are not loading and starting
your module to use VSH_MODE(0x800) instead of USER_MODE(0x0)
(if you pick KERNEL_MODE(0x1000) it doesnt matter really, which you do)
but you DEFINITELY ! do not want to use any LoadExec** calls to load a
module on top of any other modules ...as loadExec will simply restart
the system and then load your module in whatever mode you choose

so it is preferred to use the pspSDK** loading/starting of modules
just make sure you know which memory area/partition you are loading into
as this is very important in the module properly working ...ie .. if you use a
kernel function in a kernel module you obviously want to load into a kernel
memory partition, second do not use the stdlib C lib, using newlib in a kernel
area always gives problems so it is best to use the PSP's own kernel libc
which you can easily use by setting your makefile to include USE_KERNEL_LIBC = 1, course this all works great on a 1.5 firmware PSP :P
as for further firmware revisions there is a bug in the kernel for loading
modules, you can try to edit the loadmodule sample that is in the PSPSDK
but remember that if your not on 1.5 then that warning right at the top of
the sample could very well mean that the bug also exists in your firmware
lastly, it is always better to load a kernel EBOOT first that can handle your
module and conduct its actions ...usually we use psplinkusb as it works magic
but you are always welcome to use your own EBOOT, as long as you set
that EBOOT to be in KERNEL_MODE, and then have this kmode eboot handle
the loading and starting and possibly setting where in memory to load your
custom module for whatever you are doing, apart from these things i do not
know what else could cause you this problem, as i can load any number of
modules as memory space allows me to load

if anything else, taking a look at the psplink source is always a great way
to start seeing how to properly load your modules, so it might help you to do that
10011011 00101010 11010111 10001001 10111010
Post Reply