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("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(¶m, 0, sizeof(param));
param.size = sizeof(param);
param.args = strlen(program)+1;
param.argp = program;
param.key = "game";
int res = sctrlKernelLoadExecVSHMs2(program, ¶m);
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;
}