From 5c12a2925a0df1a3f506647ab58587e0eb8a6ce3 Mon Sep 17 00:00:00 2001 From: TheOfficialFloW <14246466+TheOfficialFloW@users.noreply.github.com> Date: Tue, 13 Mar 2018 22:20:09 +0100 Subject: [PATCH] Get NIDs manually (#19) --- plugin/CMakeLists.txt | 1 - plugin/main.c | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index a50b42e..1533ee3 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -22,7 +22,6 @@ target_link_libraries(usbmc SceIofilemgrForDriver_stub SceSysclibForDriver_stub SceSysmemForDriver_stub - SceModulemgrForKernel_stub SceModulemgrForDriver_stub SceThreadmgrForDriver_stub taihenForKernel_stub diff --git a/plugin/main.c b/plugin/main.c index 9ba8418..3a4c4a4 100644 --- a/plugin/main.c +++ b/plugin/main.c @@ -31,6 +31,7 @@ const char check_patch[] = {0x01, 0x20, 0x01, 0x20}; +int module_get_export_func(SceUID pid, const char *modname, uint32_t libnid, uint32_t funcnid, uintptr_t *func); int module_get_offset(SceUID pid, SceUID modid, int segidx, size_t offset, uintptr_t *addr); typedef struct { @@ -135,6 +136,8 @@ int shellKernelUnredirectUx0() { void _start() __attribute__ ((weak, alias("module_start"))); int module_start(SceSize args, void *argp) { + int (* _ksceKernelMountBootfs)(const char *bootImagePath); + int (* _ksceKernelUmountBootfs)(void); SceUID tmp1, tmp2; int ret; @@ -159,13 +162,25 @@ int module_start(SceSize args, void *argp) { return SCE_KERNEL_START_NO_RESIDENT; } + ret = module_get_export_func(KERNEL_PID, "SceKernelModulemgr", 0xC445FA63, 0x01360661, (uintptr_t *)&_ksceKernelMountBootfs); + if (ret < 0) + ret = module_get_export_func(KERNEL_PID, "SceKernelModulemgr", 0x92C9FFC2, 0x185FF1BC, (uintptr_t *)&_ksceKernelMountBootfs); + if (ret < 0) + return SCE_KERNEL_START_NO_RESIDENT; + + ret = module_get_export_func(KERNEL_PID, "SceKernelModulemgr", 0xC445FA63, 0x9C838A6B, (uintptr_t *)&_ksceKernelUmountBootfs); + if (ret < 0) + ret = module_get_export_func(KERNEL_PID, "SceKernelModulemgr", 0x92C9FFC2, 0xBD61AD4D, (uintptr_t *)&_ksceKernelUmountBootfs); + if (ret < 0) + return SCE_KERNEL_START_NO_RESIDENT; + // Load SceUsbMass // First try loading from bootimage SceUID modid; - if (ksceKernelMountBootfs("os0:kd/bootimage.skprx") >= 0) { + if (_ksceKernelMountBootfs("os0:kd/bootimage.skprx") >= 0) { modid = ksceKernelLoadModule("os0:kd/umass.skprx", 0x800, NULL); - ksceKernelUmountBootfs(); + _ksceKernelUmountBootfs(); } else { // try loading from VitaShell modid = ksceKernelLoadModule("ux0:VitaShell/module/umass.skprx", 0, NULL);