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 

trying to do an xmb in-game

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



Joined: 24 Aug 2008
Posts: 21

PostPosted: Fri Oct 17, 2008 4:57 am    Post subject: trying to do an xmb in-game Reply with quote

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:
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:
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
Back to top
View user's profile Send private message
angelo



Joined: 29 Aug 2007
Posts: 168

PostPosted: Fri Oct 17, 2008 5:25 am    Post subject: Reply with quote

It's called a callback. It been discussed before... ;)
Back to top
View user's profile Send private message Send e-mail MSN Messenger
krosk



Joined: 24 Aug 2008
Posts: 21

PostPosted: Fri Oct 17, 2008 6:02 am    Post subject: Reply with quote

angelo wrote:
It's called a callback. It been discussed before... ;)

can you help me a little bit? I can't find anything...
Back to top
View user's profile Send private message
angelo



Joined: 29 Aug 2007
Posts: 168

PostPosted: Fri Oct 17, 2008 9:01 am    Post subject: Reply with quote

Sorry not a callback... a bootstrap!

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

Angelo
Back to top
View user's profile Send private message Send e-mail MSN Messenger
krosk



Joined: 24 Aug 2008
Posts: 21

PostPosted: Sat Oct 18, 2008 12:24 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Sat Oct 18, 2008 11:20 pm    Post subject: Reply with quote

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:

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...
_________________
Get Xplora!
Back to top
View user's profile Send private message
krosk



Joined: 24 Aug 2008
Posts: 21

PostPosted: Mon Oct 20, 2008 3:01 am    Post subject: Reply with quote

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:

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:
#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("rdriver", 0x1007, 1, 0);

u32 orig_funcs[3];
int done = 0;


int ExitPatched()
{
   int k1 = pspSdkSetK1(0);
   
   // Using fixed path. See remarks in module_start of what you could do to avoid this
   char *program = "ms0:/PSP/GAME/krosk/EBOOT.PBP";
   struct SceKernelLoadExecVSHParam param;

   memset(&param, 0, sizeof(param));
   param.size = sizeof(param);
   param.args = strlen(program)+1;
   param.argp = program;
   param.key = "game";

   int res = sctrlKernelLoadExecVSHMs2(program, &param);
   pspSdkSetK1(k1);
   return res;
}

int ExitPatched2()
{
   return ExitPatched();
}

int ExitPatched3(int cbid)
{
   int k1 = pspSdkSetK1(0);
   SceCtrlData pad;
   while(!done){
      sceCtrlPeekBufferPositive(&pad, 1);
      if (pad.Buttons != 0){
         if (pad.Buttons & PSP_CTRL_HOME){
            done = 1;
         }
      }
   sceKernelDelayThread(200);
   }
   if(done==1){
      ExitPatched();
   }
   pspSdkSetK1(k1);
   return 0;
}


int RestoreExitGame()
{
   int k1 = pspSdkSetK1(0);
   
   sctrlHENPatchSyscall((u32)ExitPatched, (void *)orig_funcs[0]);
   sctrlHENPatchSyscall((u32)ExitPatched2, (void *)orig_funcs[1]);
   sctrlHENPatchSyscall((u32)ExitPatched3, (void *)orig_funcs[2]);
   done = 2;
   pspSdkSetK1(k1);
   return 0;
}

void SetConfFile(int n)
{
   int k1 = pspSdkSetK1(0);
   sctrlSESetBootConfFileIndex(n);
   pspSdkSetK1(k1);
}

void SetUmdFile(char *umdfile)
{
   int k1 = pspSdkSetK1(0);
   sctrlSESetUmdFile(umdfile);
   pspSdkSetK1(k1);
}



int module_start(SceSize args, void *argp)
{
   // 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 (for example seplugins)
   // the path of the program first time is run in the vsh
   
   SceUID fd = sceIoOpen("ms0:/PSP/GAME/krosk/rdriver.prx", PSP_O_RDONLY, 0);
   if (fd < 0)
   {
      return 0;
   }

   int size = sceIoLseek(fd, 0, PSP_SEEK_END);
   sceIoLseek(fd, 0, PSP_SEEK_SET);

   SceUID pid = sceKernelAllocPartitionMemory(PSP_MEMORY_PARTITION_KERNEL, "", PSP_SMEM_Low, size, NULL);
   if (pid < 0)
      return 0;

   sceIoRead(fd, sceKernelGetBlockHeadAddr(pid), size);
   
   sctrlHENLoadModuleOnReboot("/kd/usersystemlib.prx", sceKernelGetBlockHeadAddr(pid), size, BOOTLOAD_GAME | BOOTLOAD_POPS | BOOTLOAD_UMDEMU);
   
   orig_funcs[0] = sctrlHENFindFunction("sceLoadExec", "LoadExecForUser", 0x05572A5F);
   orig_funcs[1] = sctrlHENFindFunction("sceLoadExec", "LoadExecForUser", 0x2AC9954B);
   orig_funcs[2] = sctrlHENFindFunction("sceLoadExec", "LoadExecForUser", 0x4AC57943);
   sctrlHENPatchSyscall(orig_funcs[0], ExitPatched); // sceKernelExitGame
   sctrlHENPatchSyscall(orig_funcs[1], ExitPatched2); // sceKernelExitGameWithStatus
   sctrlHENPatchSyscall(orig_funcs[2], ExitPatched3); // sceKernelRegisterExitCallback

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

   sceKernelDcacheWritebackAll();
   sceKernelIcacheClearAll();
   
   return 0;
}
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Mon Oct 20, 2008 7:02 am    Post subject: Reply with quote

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.
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
krosk



Joined: 24 Aug 2008
Posts: 21

PostPosted: Mon Oct 20, 2008 7:14 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Mon Oct 20, 2008 7:25 am    Post subject: Reply with quote

And that worked?
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
krosk



Joined: 24 Aug 2008
Posts: 21

PostPosted: Tue Oct 21, 2008 6:50 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Tue Oct 21, 2008 7:57 am    Post subject: Reply with quote

Alright thanks
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
krosk



Joined: 24 Aug 2008
Posts: 21

PostPosted: Thu Oct 23, 2008 1:15 am    Post subject: Reply with quote

Pirata Nervo wrote:
Alright thanks


hope that this code will help you in nervOS
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Thu Oct 23, 2008 2:38 am    Post subject: Reply with quote

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
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
Cruiserx



Joined: 23 Oct 2008
Posts: 8

PostPosted: Thu Oct 23, 2008 11:09 am    Post subject: Reply with quote

Thanks for this krosk but when i try to compile, with a makefile, i get errors. Could you help?
Back to top
View user's profile Send private message
krosk



Joined: 24 Aug 2008
Posts: 21

PostPosted: Sun Oct 26, 2008 5:45 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Cruiserx



Joined: 23 Oct 2008
Posts: 8

PostPosted: Mon Oct 27, 2008 4:14 am    Post subject: Reply with quote

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?image=81168042lc9.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.
Back to top
View user's profile Send private message
Onii



Joined: 05 Oct 2008
Posts: 40

PostPosted: Mon Oct 27, 2008 5:33 am    Post subject: Reply with quote

The implicit declaration warnings mean that you forgot to include the .h file that defines those functions. Double check your includes
Back to top
View user's profile Send private message
Cruiserx



Joined: 23 Oct 2008
Posts: 8

PostPosted: Mon Oct 27, 2008 6:02 am    Post subject: Reply with quote

You were right Onii i checked and it worked without errors, thanks. But i cannot get it to work :s.
Back to top
View user's profile Send private message
krosk



Joined: 24 Aug 2008
Posts: 21

PostPosted: Wed Oct 29, 2008 5:17 am    Post subject: Reply with quote

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 ;)
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Thu Oct 30, 2008 2:01 am    Post subject: Reply with quote

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!
_________________
Get Xplora!
Back to top
View user's profile Send private message
krosk



Joined: 24 Aug 2008
Posts: 21

PostPosted: Thu Oct 30, 2008 5:55 am    Post subject: Reply with quote

Didn't know about that function. I will try it later.
Back to top
View user's profile Send private message
Kreationz



Joined: 18 May 2008
Posts: 53

PostPosted: Thu Oct 30, 2008 2:17 pm    Post subject: Reply with quote

I'll have to remember this little piece of info. It can allow custom options menus similar to POPS.
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