trying to do an xmb in-game

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

Moderators: cheriff, TyRaNiD

Post Reply
krosk
Posts: 21
Joined: Sun Aug 24, 2008 8:54 pm

trying to do an xmb in-game

Post by krosk »

hi, I'm trying to do an xmb in-game. I'm using rdriver from the dark-alex bootload example to replace the sceKernelRegisterExitCallback function, with that code:

Code: Select all

int ExitPatched3(int cbid)
{
	int k1 = pspSdkSetK1(0);
	SceCtrlData pad;
	while(!done){
		sceCtrlReadBufferPositive(&pad, 1);
		if (pad.Buttons != 0){
			if (pad.Buttons & PSP_CTRL_HOME){
				done = 1;
			}
		}
	}
	sceKernelExitGame();
	pspSdkSetK1(k1);
	return 0;
}
and that:

Code: Select all

orig_funcs[2] = sctrlHENFindFunction("sceLoadExec", "LoadExecForUser", 0x4AC57943);
sctrlHENPatchSyscall(orig_funcs[2], ExitPatched3); // sceKernelRegisterExitCallback
When I enter to a game using rdriver, it patches the Register exit callback function, because If I press home I can't see the exit menu, but the psp doesn't return to my shell... any ideas of how to do it?
Last edited by krosk on Fri Oct 17, 2008 6:30 am, edited 1 time in total.
angelo
Posts: 168
Joined: Wed Aug 29, 2007 9:34 pm

Post by angelo »

It's called a callback. It been discussed before... ;)
krosk
Posts: 21
Joined: Sun Aug 24, 2008 8:54 pm

Post by krosk »

angelo wrote:It's called a callback. It been discussed before... ;)
can you help me a little bit? I can't find anything...
angelo
Posts: 168
Joined: Wed Aug 29, 2007 9:34 pm

Post by angelo »

Sorry not a callback... a bootstrap!

I had the wrongpiece of jargon in my head! Sorry!

Angelo
krosk
Posts: 21
Joined: Sun Aug 24, 2008 8:54 pm

Post by krosk »

angelo wrote:Sorry not a callback... a bootstrap!

I had the wrongpiece of jargon in my head! Sorry!

Angelo
The prx that I'm using is a bootstrap... If you readed my information, isn't a problem that the prx isn't being loaded, it's a problem with the code to patch the function sceKernelRegisterExitCallback
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

The sceKernelRegisterExitCallback isn't the function that blit the Exit screen, it is only a function that go to register the callback to wakeup when you press X in the Exit Screen!
The default callback is something like this:

Code: Select all

int exit_callback(int arg1, int arg2, void *common)
{
        sceKernelExitGame();
	return 0;
}
This will exit the game!
So if you want you can doesn't call the "SetupCallbacks" function and rewrite it by youself with a personal one!
If you want the sce style you can use the vlf library...
krosk
Posts: 21
Joined: Sun Aug 24, 2008 8:54 pm

Post by krosk »

ne0h wrote:The sceKernelRegisterExitCallback isn't the function that blit the Exit screen, it is only a function that go to register the callback to wakeup when you press X in the Exit Screen!
The default callback is something like this:

Code: Select all

int exit_callback(int arg1, int arg2, void *common)
{
        sceKernelExitGame();
	return 0;
}
This will exit the game!
So if you want you can doesn't call the "SetupCallbacks" function and rewrite it by youself with a personal one!
If you want the sce style you can use the vlf library...
How can I say that I wasn't talking about that? all people responses are the same... anyway, I have recently fixed the hooking and it works fully...

If someones is interested, here is a bootload that has a custom exit function(when you press home directly you get out of the game):

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspsysmem_kernel.h>
#include <psploadexec_kernel.h>
#include <pspreg.h>
#include <pspctrl.h>
#include <psprtc.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <psppower.h>
#include <systemctrl.h>
#include <systemctrl_se.h>
#include <stdio.h>
#include <string.h>

PSP_MODULE_INFO&#40;"rdriver", 0x1007, 1, 0&#41;;

u32 orig_funcs&#91;3&#93;;
int done = 0;


int ExitPatched&#40;&#41;
&#123;
	int k1 = pspSdkSetK1&#40;0&#41;;
	
	// Using fixed path. See remarks in module_start of what you could do to avoid this
	char *program = "ms0&#58;/PSP/GAME/krosk/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 ExitPatched3&#40;int cbid&#41;
&#123;
	int k1 = pspSdkSetK1&#40;0&#41;;
	SceCtrlData pad;
	while&#40;!done&#41;&#123;
		sceCtrlPeekBufferPositive&#40;&pad, 1&#41;;
		if &#40;pad.Buttons != 0&#41;&#123;
			if &#40;pad.Buttons & PSP_CTRL_HOME&#41;&#123;
				done = 1;
			&#125;
		&#125;
	sceKernelDelayThread&#40;200&#41;;
	&#125;
	if&#40;done==1&#41;&#123;
		ExitPatched&#40;&#41;;
	&#125;
	pspSdkSetK1&#40;k1&#41;;
	return 0;
&#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;; 
	sctrlHENPatchSyscall&#40;&#40;u32&#41;ExitPatched3, &#40;void *&#41;orig_funcs&#91;2&#93;&#41;; 
	done = 2;
	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 module_start&#40;SceSize args, void *argp&#41;
&#123;
	// As in reboot we are executed with no params and we don't know our path,
	// we need to use a fixed path.
	// This could be solved if the program stores in a known location &#40;for example seplugins&#41;
	// the path of the program first time is run in the vsh
	
	SceUID fd = sceIoOpen&#40;"ms0&#58;/PSP/GAME/krosk/rdriver.prx", PSP_O_RDONLY, 0&#41;;
	if &#40;fd < 0&#41;
	&#123;
		return 0;
	&#125;

	int size = sceIoLseek&#40;fd, 0, PSP_SEEK_END&#41;;
	sceIoLseek&#40;fd, 0, PSP_SEEK_SET&#41;;

	SceUID pid = sceKernelAllocPartitionMemory&#40;PSP_MEMORY_PARTITION_KERNEL, "", PSP_SMEM_Low, size, NULL&#41;;
	if &#40;pid < 0&#41;
		return 0;

	sceIoRead&#40;fd, sceKernelGetBlockHeadAddr&#40;pid&#41;, size&#41;;
	
	sctrlHENLoadModuleOnReboot&#40;"/kd/usersystemlib.prx", sceKernelGetBlockHeadAddr&#40;pid&#41;, size, BOOTLOAD_GAME | BOOTLOAD_POPS | BOOTLOAD_UMDEMU&#41;;
	
	orig_funcs&#91;0&#93; = sctrlHENFindFunction&#40;"sceLoadExec", "LoadExecForUser", 0x05572A5F&#41;;
	orig_funcs&#91;1&#93; = sctrlHENFindFunction&#40;"sceLoadExec", "LoadExecForUser", 0x2AC9954B&#41;;
	orig_funcs&#91;2&#93; = sctrlHENFindFunction&#40;"sceLoadExec", "LoadExecForUser", 0x4AC57943&#41;;
	sctrlHENPatchSyscall&#40;orig_funcs&#91;0&#93;, ExitPatched&#41;; // sceKernelExitGame
	sctrlHENPatchSyscall&#40;orig_funcs&#91;1&#93;, ExitPatched2&#41;; // sceKernelExitGameWithStatus
	sctrlHENPatchSyscall&#40;orig_funcs&#91;2&#93;, ExitPatched3&#41;; // sceKernelRegisterExitCallback

	// Alternativelly you would patch kernel functions here too
	// to avoid errors returning to xmb, or to avoid kernel homebrew exiting to xmb

	sceKernelDcacheWritebackAll&#40;&#41;;
	sceKernelIcacheClearAll&#40;&#41;;
	
	return 0;
&#125;
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

so what does that exactly do?
I know it patches 3 functions (sceKernelExitGame, sceKernelExitGameWithStatus, sceKernelRegisterExitCallback) but I don't see why patching the 3 instead of patching only the first one and the second.
Image
Upgrade your PSP
krosk
Posts: 21
Joined: Sun Aug 24, 2008 8:54 pm

Post by krosk »

coz with the third you can do a custom exit menu, not the default one... and I'm trying to do a XMB-ingame, so when I press home I need that the default exit screen doesn't come on the screen.
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

And that worked?
Image
Upgrade your PSP
krosk
Posts: 21
Joined: Sun Aug 24, 2008 8:54 pm

Post by krosk »

Pirata Nervo wrote:And that worked?
yes, atm when you press home, it will not show you the exit screen and will exit directly... I'm looking now for libraries that can work on plugins.
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

Alright thanks
Image
Upgrade your PSP
krosk
Posts: 21
Joined: Sun Aug 24, 2008 8:54 pm

Post by krosk »

Pirata Nervo wrote:Alright thanks
hope that this code will help you in nervOS
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

I have been thinking about how to do that for a long time but never tried it but now that I know it works I may use it :)
thank you once more
Image
Upgrade your PSP
Cruiserx
Posts: 8
Joined: Thu Oct 23, 2008 11:06 am

Post by Cruiserx »

Thanks for this krosk but when i try to compile, with a makefile, i get errors. Could you help?
krosk
Posts: 21
Joined: Sun Aug 24, 2008 8:54 pm

Post by krosk »

Cruiserx wrote:Thanks for this krosk but when i try to compile, with a makefile, i get errors. Could you help?
can you post your errors?
Cruiserx
Posts: 8
Joined: Thu Oct 23, 2008 11:06 am

Post by Cruiserx »

krosk wrote:
Cruiserx wrote:Thanks for this krosk but when i try to compile, with a makefile, i get errors. Could you help?
can you post your errors?
This is what i got at the beginning:
http://img380.imageshack.us/my.php?imag ... 042lc9.png
But after i added "-lpspsystemctrl_kernel" to LIBS in the makefile i received this:
http://img76.imageshack.us/my.php?image=40665621ks8.png
Thank you for the help krosk.
Onii
Posts: 40
Joined: Sun Oct 05, 2008 1:07 pm

Post by Onii »

The implicit declaration warnings mean that you forgot to include the .h file that defines those functions. Double check your includes
Cruiserx
Posts: 8
Joined: Thu Oct 23, 2008 11:06 am

Post by Cruiserx »

You were right Onii i checked and it worked without errors, thanks. But i cannot get it to work :s.
krosk
Posts: 21
Joined: Sun Aug 24, 2008 8:54 pm

Post by krosk »

The lastest M33 SDK comes with a bootload example... just replace the main.c of the example with my main.c and you are done ;)
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Why don't use setHomePopup to delete the exit game screen?
And hook the ctrl functions to check if Home is pressed, maybe is simple that your!
krosk
Posts: 21
Joined: Sun Aug 24, 2008 8:54 pm

Post by krosk »

Didn't know about that function. I will try it later.
Kreationz
Posts: 52
Joined: Sun May 18, 2008 11:01 am

Post by Kreationz »

I'll have to remember this little piece of info. It can allow custom options menus similar to POPS.
Post Reply