diff --git a/lib/build.mak b/lib/build.mak index 431b827..b25f020 100644 --- a/lib/build.mak +++ b/lib/build.mak @@ -16,10 +16,14 @@ PRX_EXPORTS = exports.exp EXPORT_OBJ=$(patsubst %.exp,%.o,$(PRX_EXPORTS)) EXPORT_C=$(PRX_EXPORTS:.exp=.c) -ifdef DEBUG +ifeq ($(DEBUG),1) CFLAGS += -DDEBUG LIBS := -ldebug -lpspdebug $(LIBS) -lSysclibForKernel -lsceDisplay -lsceGe_user -lIoFileMgrForKernel -lsceSyscon_driver endif +ifeq ($(INSTALLER),1) +CFLAGS += -DINSTALLER +OBJS := $(PATCH_OBJS) $(OBJS) +endif MODULE_STUBS=$(foreach mod,$(MODULES), $($(mod)_STUBS)) diff --git a/src/loadexec/Makefile b/src/loadexec/Makefile index b4cb25b..8b8ec87 100644 --- a/src/loadexec/Makefile +++ b/src/loadexec/Makefile @@ -3,8 +3,10 @@ TARGET = loadexec OBJS = kl4e.o loadexec.o +PATCH_OBJS = patch.o -#DEBUG = 1 +DEBUG = 0 +INSTALLER = 1 LIBS = -lSysMemForKernel -lsceSuspendForKernel -lKDebugForKernel -lLoadCoreForKernel -lInterruptManagerForKernel -lSysclibForKernel -lThreadManForKernel -lIoFileMgrForKernel -lModuleMgrForKernel -lInitForKernel -lUtilsForKernel diff --git a/src/loadexec/loadexec.c b/src/loadexec/loadexec.c index d9f7d98..62de36d 100644 --- a/src/loadexec/loadexec.c +++ b/src/loadexec/loadexec.c @@ -22,6 +22,10 @@ #include "loadexec_int.h" #include "reboot.h" +#ifdef INSTALLER +# include "patch.h" +#endif + SCE_MODULE_INFO("sceLoadExec", SCE_MODULE_KIRK_MEMLMD_LIB | SCE_MODULE_KERNEL | SCE_MODULE_ATTR_EXCLUSIVE_START | SCE_MODULE_ATTR_EXCLUSIVE_LOAD | SCE_MODULE_ATTR_CANT_STOP, 1, 15); SCE_MODULE_BOOTSTART("LoadExecInit"); @@ -115,7 +119,7 @@ void copyArgsToRebootParam(SceKernelRebootParam *hwOpt, SceKernelLoadExecVSHPara if (opt->extArgs == 0) { // b28 if (sceKernelGetChunk(4) > 0) { - hwOpt->args[hwOpt->curArgs].argp = InitForKernel_D83A9BD7(&hwOpt->args[hwOpt->curArgs].args); + hwOpt->args[hwOpt->curArgs].argp = sceKernelInitParamSfo(&hwOpt->args[hwOpt->curArgs].args); hwOpt->args[hwOpt->curArgs].type = SCE_KERNEL_REBOOT_ARGTYPE_EXT; hwOpt->curArgs++; } @@ -637,16 +641,20 @@ s32 sceKernelExitVSHVSH(SceKernelLoadExecVSHParam *opt) pspSetK1(oldK1); return SCE_ERROR_KERNEL_CANNOT_BE_CALLED_FROM_INTERRUPT; } +#ifndef INSTALLER if (pspK1IsUserMode()) { pspSetK1(oldK1); return SCE_ERROR_KERNEL_ILLEGAL_PERMISSION_CALL; } +#endif // 16B0 +#ifndef INSTALLER if (sceKernelGetUserLevel() != 4) { pspSetK1(oldK1); return SCE_ERROR_KERNEL_ILLEGAL_PERMISSION_CALL; } +#endif s32 ret = checkVSHParam(opt); if (ret < 0) { pspSetK1(oldK1); @@ -1077,13 +1085,19 @@ s32 loadExecVSH(s32 apiType, char *file, SceKernelLoadExecVSHParam *opt, u32 fla { s32 oldK1 = pspShiftK1(); if (sceKernelIsIntrContext() == 0) { +#ifndef INSTALLER if (!pspK1IsUserMode()) { +#else + if (1) { +#endif s32 iocmd, devcmd; // 23EC +#ifndef INSTALLER if (sceKernelGetUserLevel() != 4) { pspSetK1(oldK1); return SCE_ERROR_KERNEL_ILLEGAL_PERMISSION_CALL; } +#endif if (file == NULL) { pspSetK1(oldK1); return SCE_ERROR_KERNEL_ILLEGAL_ADDR; @@ -1668,7 +1682,11 @@ s32 runReboot(RunExecParams *opt) if (opt->apiType == SCE_INIT_APITYPE_DEBUG) return ret; sceKernelMemset((void*)0x88600000, 0, 0x200000); +#ifndef INSTALLER ret = decodeKL4E((void*)0x88600000, 0x200000, (void*)g_reboot + 4, 0); +#else + ret = (*decodeKL4EPtr)((void*)0x88600000, 0x200000, (void*)g_reboot + 4, 0); +#endif if (ret < 0) { // 2DD0 sceKernelCpuSuspendIntr(); @@ -1684,7 +1702,11 @@ s32 runReboot(RunExecParams *opt) UtilsForKernel_39FFB756(0); Kprintf("***** reboot start *****\n"); Kprintf("\n\n\n"); +#ifndef INSTALLER s32 (*reboot)(SceKernelRebootParam *, SceKernelLoadExecVSHParam *, s32, s32) = (void*)0x88600000; +#else + s32 (*reboot)(SceKernelRebootParam *, SceKernelLoadExecVSHParam *, s32, s32) = (void*)0x88FC0000; +#endif reboot(hwOpt, opt->vshParam, opt->apiType, rand); return ret; } diff --git a/src/loadexec/loadexec_int.h b/src/loadexec/loadexec_int.h index 956e3e0..80755ab 100644 --- a/src/loadexec/loadexec_int.h +++ b/src/loadexec/loadexec_int.h @@ -32,7 +32,7 @@ typedef struct typedef struct { void *argp; // 0 - s32 args; // 4 + u32 args; // 4 SceKernelRebootArgType type; // 8 s32 unk12; s32 unk16; diff --git a/src/loadexec/patch.S b/src/loadexec/patch.S new file mode 100644 index 0000000..ea1404e --- /dev/null +++ b/src/loadexec/patch.S @@ -0,0 +1,9 @@ +#include "common_asm.h" + + .text + .globl decodeKL4EPtr +decodeKL4EPtr: + .word decodeKL4E + .word decodeKL4E + .word loadExecVSH + diff --git a/src/loadexec/patch.h b/src/loadexec/patch.h new file mode 100644 index 0000000..4ad2d61 --- /dev/null +++ b/src/loadexec/patch.h @@ -0,0 +1,7 @@ +#ifndef PATCH_H +#define PATCH_H + +extern s32 (*decodeKL4EPtr)(); + +#endif + diff --git a/utils/diff.sh b/utils/diff.sh index a97e40f..ecb63ae 100755 --- a/utils/diff.sh +++ b/utils/diff.sh @@ -74,10 +74,10 @@ fi cd $dir if [ ! -f $prxtmp1 ]; then - prxtool -w ../$1 > $prxtmp1 + prxtool -w $1 > $prxtmp1 fi if [ ! -f $prxtmp2 ]; then - prxtool -w ../$2 > $prxtmp2 + prxtool -w $2 > $prxtmp2 fi list1=`genlist $prxtmp1`