[Solved] VSHMAIN.PRX replacement module

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

[Solved] VSHMAIN.PRX replacement module

Post by Torch »

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

Code: Select all

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

PSP_MODULE_INFO&#40;"Password", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER&#41;;
//PSP_HEAP_SIZE_KB&#40;1024&#41;;

#define printf	pspDebugScreenPrintf
#define VSHMAIN "flash0&#58;/vsh/module/vshmain_real.prx"

SceUID load_module&#40;const char *path, int flags, int type&#41;
&#123;
	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 &#40;type == 0&#41; &#123;
		mpid = 1;
	&#125; else &#123;
		mpid = 2;
	&#125;

	memset&#40;&option, 0, sizeof&#40;option&#41;&#41;;
	option.size = sizeof&#40;option&#41;;
	option.mpidtext = mpid;
	option.mpiddata = mpid;
	option.position = 0;
	option.access = 1;

	return sceKernelLoadModule&#40;path, flags, type > 0 ? &option &#58; NULL&#41;;
&#125;

int main_thread&#40;SceSize args, void *argp&#41;
&#123;
	pspDebugScreenInit&#40;&#41;;
 	printf&#40;"Arguement Size = %d\n",args&#41;;
 		
	SceUID mod;
	mod = load_module&#40;VSHMAIN, 0, 0&#41;;
	
	if &#40;mod > 0&#41;
	&#123;
		sceKernelStartModule&#40;mod, args, argp, NULL, NULL&#41;;
	&#125;
	else
	&#123;
	 	printf&#40;"Start failed %x",mod&#41;;
	&#125;
	
	sceKernelExitDeleteThread&#40;0&#41;;

	return 0;
&#125;

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

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

	return 0;
&#125;

Code: Select all

TARGET = password
OBJS = main.o

INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

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=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/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.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

I tried it with pspSdkLoadStartModule but it also gives 0x80020148
angelo
Posts: 168
Joined: Wed Aug 29, 2007 9:34 pm

Same problem...

Post by angelo »

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

If I come up with the solution, I'll let you know. ;)
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

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.
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

have a look at the sources of the 1.50 custom firmware by dark alex (www.dark-alex.org)
Ciao! from Italy
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

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.
adrahil
Posts: 274
Joined: Thu Mar 16, 2006 1:55 am

Post by adrahil »

SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE is pretty obvious :)
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

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
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

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.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Solved. Have to use M33SDK.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

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!
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

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.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

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..
Post Reply