forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Solved] VSHMAIN.PRX replacement module

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Thu May 29, 2008 4:59 am    Post subject: [Solved] VSHMAIN.PRX replacement module Reply with quote

I'm trying to make a module to replace vshmain.prx to do some stuff, and then launch the original vshmain_real.prx

Code:

#include <pspkernel.h>
#include <pspthreadman.h>
#include <pspdebug.h>
#include <stdio.h>

PSP_MODULE_INFO("Password", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
//PSP_HEAP_SIZE_KB(1024);

#define printf   pspDebugScreenPrintf
#define VSHMAIN "flash0:/vsh/module/vshmain_real.prx"

SceUID load_module(const char *path, int flags, int type)
{
   SceKernelLMOption option;
   SceUID mpid;

   /* If the type is 0, then load the module in the kernel partition, otherwise load it
      in the user partition. */
   if (type == 0) {
      mpid = 1;
   } else {
      mpid = 2;
   }

   memset(&option, 0, sizeof(option));
   option.size = sizeof(option);
   option.mpidtext = mpid;
   option.mpiddata = mpid;
   option.position = 0;
   option.access = 1;

   return sceKernelLoadModule(path, flags, type > 0 ? &option : NULL);
}

int main_thread(SceSize args, void *argp)
{
   pspDebugScreenInit();
    printf("Arguement Size = %d\n",args);
       
   SceUID mod;
   mod = load_module(VSHMAIN, 0, 0);
   
   if (mod > 0)
   {
      sceKernelStartModule(mod, args, argp, NULL, NULL);
   }
   else
   {
       printf("Start failed %x",mod);
   }
   
   sceKernelExitDeleteThread(0);

   return 0;
}

int module_start(SceSize args, void *argp)
{
   SceUID th;
   th = sceKernelCreateThread("main_thread", main_thread, 0x20, 0x10000, 0, NULL);

   if (th >= 0)
   {
      sceKernelStartThread(th, args, argp);
   }

   return 0;
}



Code:

TARGET = password
OBJS = main.o

INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

BUILD_PRX = 1
PSP_FW_VERSION = 390

LIBDIR =
LIBS =
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Password
#PSP_EBOOT_ICON="icon0.png"
#PSP_EBOOT_PIC1="pic1.png"
#PSP_EBOOT_SND0="snd0.at3"

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak



sceKernelStartModule always returns 0x80020148 (unsupported PRX type). I tried launching a vshmain_real.prx from ms0: as well because I read that in user mode you can't start a module from flash0:.


Last edited by Torch on Sat May 31, 2008 7:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Thu May 29, 2008 10:43 pm    Post subject: Reply with quote

I tried it with pspSdkLoadStartModule but it also gives 0x80020148
Back to top
View user's profile Send private message
angelo



Joined: 29 Aug 2007
Posts: 168

PostPosted: Thu May 29, 2008 11:17 pm    Post subject: Same problem... Reply with quote

That's odd... I suffer from the same problem.

If I come up with the solution, I'll let you know. ;)
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Thu May 29, 2008 11:19 pm    Post subject: Reply with quote

I also tried loading it as a VSH module with 0x800 and PSP_THREAD_ATTR_VSH, as well as trying to load vshmain_real.prx in kernel and user memory.
Back to top
View user's profile Send private message
phobox



Joined: 24 Mar 2008
Posts: 140

PostPosted: Fri May 30, 2008 5:59 am    Post subject: Reply with quote

have a look at the sources of the 1.50 custom firmware by dark alex (www.dark-alex.org)
_________________
Ciao! from Italy
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Fri May 30, 2008 1:27 pm    Post subject: Reply with quote

phobox wrote:
have a look at the sources of the 1.50 custom firmware by dark alex (www.dark-alex.org)


Thats what I based this on in the first place. It doesn't want to work in newer firmwares.
Back to top
View user's profile Send private message
adrahil



Joined: 16 Mar 2006
Posts: 277

PostPosted: Fri May 30, 2008 5:24 pm    Post subject: Reply with quote

SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE is pretty obvious :)
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sat May 31, 2008 12:31 pm    Post subject: Reply with quote

adrahil wrote:
SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE is pretty obvious :)


I'm a total noob. Please explain how to launch a renamed vshmain.prx
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Sat May 31, 2008 7:43 pm    Post subject: Reply with quote

try with 0x800 flag.

EDIT: ups you tried. Maybe it can only run inside the ~PSP format (that includes m33 packed files). It is odd that totally plain prx's don't run in the specific loadmodule api that loads vshmain as they load in all others loadmodule functions.
That remembers me that I have to finalize the support in M33 to pack any kind of module in a generic way (not firmware dependent), and release the packer tool to public.


Last edited by moonlight on Sat May 31, 2008 7:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sat May 31, 2008 7:43 pm    Post subject: Reply with quote

Solved. Have to use M33SDK.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sat May 31, 2008 7:45 pm    Post subject: Reply with quote

moonlight wrote:
try with 0x800 flag.

I did. I tried all possible combinations, kernel mode, usermode, different thread modes, call from external prx, all were giving 80020148.

Finally used kubridge kukernelloadmodule and it worked!
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Sat May 31, 2008 7:53 pm    Post subject: Reply with quote

Ah ok, i understood bad the problem, i thought you couldn't launch your module, not the real vshmain. Yeah the user function of modulemgr won't load vshmain, the firmware uses a specific function to load vshmain (they have tons of sceKernelLoadModule* functions for different purposes), but yeah kuKernelLoadModule works too.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sat May 31, 2008 7:55 pm    Post subject: Reply with quote

moonlight wrote:
Ah ok, i understood bad the problem, i thought you couldn't launch your module, not the real vshmain. Yeah the user function of modulemgr won't load vshmain, the firmware uses a specific function to load vshmain (they have tons of sceKernelLoadModule* functions for different purposes), but yeah kuKernelLoadModule works too.

So many things i don't know...
Is there any problem with using 3.71M33SDK when compiling stuff? Will some compiled stuff be incompatible with later firmwares?

And when extracting the files, should I only extract the additional files, or should I overwrite the common files as well with the ones from M33SDK?

I think the common files are newer versions in the latest PSPSDK..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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