mirror of
https://github.com/joel16/uofw.git
synced 2024-11-23 03:29:43 +00:00
Added dynamic loadexec patching support
This commit is contained in:
parent
f04d9d6a72
commit
a9bc5143a7
@ -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))
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
void *argp; // 0
|
||||
s32 args; // 4
|
||||
u32 args; // 4
|
||||
SceKernelRebootArgType type; // 8
|
||||
s32 unk12;
|
||||
s32 unk16;
|
||||
|
9
src/loadexec/patch.S
Normal file
9
src/loadexec/patch.S
Normal file
@ -0,0 +1,9 @@
|
||||
#include "common_asm.h"
|
||||
|
||||
.text
|
||||
.globl decodeKL4EPtr
|
||||
decodeKL4EPtr:
|
||||
.word decodeKL4E
|
||||
.word decodeKL4E
|
||||
.word loadExecVSH
|
||||
|
7
src/loadexec/patch.h
Normal file
7
src/loadexec/patch.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef PATCH_H
|
||||
#define PATCH_H
|
||||
|
||||
extern s32 (*decodeKL4EPtr)();
|
||||
|
||||
#endif
|
||||
|
@ -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`
|
||||
|
Loading…
Reference in New Issue
Block a user