diff --git a/Makefile b/Makefile index e7b629f2..74e9aff2 100644 --- a/Makefile +++ b/Makefile @@ -63,6 +63,7 @@ SUBDIRS = libs \ extras/150kernel/rebootex150 \ extras/150kernel/reboot150 \ extras/150kernel/systemctrl150 \ + extras/150kernel/vshctrl150 \ extras/150kernel/tmctrl150 \ extras/150kernel/installer diff --git a/core/vshctrl/vshpatch.c b/core/vshctrl/vshpatch.c index e4ce9f48..5f6d0aa0 100644 --- a/core/vshctrl/vshpatch.c +++ b/core/vshctrl/vshpatch.c @@ -46,7 +46,6 @@ typedef struct _HookUserFunctions { } HookUserFunctions; static STMOD_HANDLER previous; -//SEConfig conf; static void patch_sysconf_plugin_module(SceModule2 *mod); static void patch_game_plugin_module(SceModule2 *mod); @@ -73,38 +72,32 @@ static int vshpatch_module_chain(SceModule2 *mod) if(0 == strcmp(mod->modname, "sysconf_plugin_module")) { patch_sysconf_plugin_module(mod); - sync_cache(); goto exit; } if(0 == strcmp(mod->modname, "game_plugin_module")) { patch_game_plugin_module(mod); - sync_cache(); goto exit; } if(0 == strcmp(mod->modname, "vsh_module")) { patch_vsh_module(mod); patch_sceCtrlReadBufferPositive(); - sync_cache(); goto exit; } if(0 == strcmp(mod->modname, "msvideo_main_plugin_module")) { patch_msvideo_main_plugin_module(mod); - sync_cache(); goto exit; } if( 0 == strcmp(mod->modname, "update_plugin_module")) { patch_update_plugin_module(mod); - sync_cache(); goto exit; } if(0 == strcmp(mod->modname, "SceUpdateDL_Library")) { patch_SceUpdateDL_Library(mod); - sync_cache(); goto exit; } @@ -118,11 +111,11 @@ static int vshpatch_module_chain(SceModule2 *mod) patch_hibblock(mod); } - sync_cache(); goto exit; } exit: + sync_cache(); if (previous) previous(mod); } diff --git a/extras/150kernel/btcnf/pspbtcnf.txt b/extras/150kernel/btcnf/pspbtcnf.txt index b21fe47f..d075153c 100644 --- a/extras/150kernel/btcnf/pspbtcnf.txt +++ b/extras/150kernel/btcnf/pspbtcnf.txt @@ -61,7 +61,7 @@ /kd/chkreg.prx /kd/impose.prx /kd/vshbridge.prx -/kd/ark_vshctrl.prx +/kd/ark_vshctrl150.prx #for savedata /vsh/module/chnnlsv.prx diff --git a/extras/150kernel/systemctrl150/exports.exp b/extras/150kernel/systemctrl150/exports.exp index 246052ac..92f8419c 100644 --- a/extras/150kernel/systemctrl150/exports.exp +++ b/extras/150kernel/systemctrl150/exports.exp @@ -11,6 +11,7 @@ PSP_EXPORT_FUNC(sctrlHENFindFunction) PSP_EXPORT_FUNC(sctrlHENSetLoadRebootOverrideHandler) PSP_EXPORT_FUNC(sctrlHENSetRebootexOverride) PSP_EXPORT_FUNC(sctrlHENSetStartModuleHandler) +PSP_EXPORT_FUNC(sctrlHENPatchSyscall) PSP_EXPORT_END diff --git a/extras/150kernel/systemctrl150/src/sctrl_hen.c b/extras/150kernel/systemctrl150/src/sctrl_hen.c index a9eac897..73031b2a 100644 --- a/extras/150kernel/systemctrl150/src/sctrl_hen.c +++ b/extras/150kernel/systemctrl150/src/sctrl_hen.c @@ -81,4 +81,31 @@ unsigned int sctrlHENFindFunction(char * szMod, char * szLib, unsigned int nid) // Function not found return 0; +} + +// Replace Function in Syscall Table +void sctrlHENPatchSyscall(void * addr, void * newaddr) +{ + // Syscall Table + unsigned int * syscalls = NULL; + + // Get Syscall Table Pointer from Coprocessor + __asm__ volatile("cfc0 %0, $12\n" : "=r"(syscalls)); + + // Invalid Syscall Table + if(syscalls == NULL) return; + + // Skip Table Header + syscalls += 4; // 4 * 4 = 16 + + // Iterate Syscalls + for(int i = 0; i < 0xFF4; ++i) + { + // Found Matching Function + if((syscalls[i] & 0x0FFFFFFF) == (((unsigned int)addr) & 0x0FFFFFFF)) + { + // Replace Syscall Function + syscalls[i] = (unsigned int)newaddr; + } + } } \ No newline at end of file diff --git a/extras/150kernel/vshctrl150/Makefile b/extras/150kernel/vshctrl150/Makefile new file mode 100644 index 00000000..12918496 --- /dev/null +++ b/extras/150kernel/vshctrl150/Makefile @@ -0,0 +1,32 @@ +TARGET = vshctrl150 + +OBJS = \ + main.o \ + vshmenu.o \ + $(ARKROOT)/libs/ansi-c/strcasecmp.o + +all: $(TARGET).prx +INCDIR = $(ARKROOT)/common/include/ $(ARKROOT)/libs/graphics/ $(ARKROOT) +CFLAGS = -std=c99 -Os -G0 -Wall -fno-pic $(addprefix -I, $(INCDIR)) + +CFLAGS += -I include + +CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti +ASFLAGS = $(CFLAGS) + +BUILD_PRX = 1 +PRX_EXPORTS = exports.exp + +USE_KERNEL_LIBC=1 +USE_KERNEL_LIBS=1 + +LIBDIR = $(ARKROOT)/libs lib +LDFLAGS = -nostartfiles +LIBS = -lpspsystemctrl_kernel + +PSP_FW_VERSION = 150 + +include $(ARKROOT)/common/make/global.mak +PSPSDK=$(shell psp-config --pspsdk-path) +include $(PSPSDK)/lib/build.mak +include $(ARKROOT)/common/make/beauty.mak diff --git a/extras/150kernel/vshctrl150/exports.exp b/extras/150kernel/vshctrl150/exports.exp new file mode 100644 index 00000000..0b0f6870 --- /dev/null +++ b/extras/150kernel/vshctrl150/exports.exp @@ -0,0 +1,14 @@ +# Define the exports for the prx +PSP_BEGIN_EXPORTS + +PSP_EXPORT_START(syslib, 0, 0x8000) +PSP_EXPORT_FUNC_HASH(module_start) +PSP_EXPORT_VAR_HASH(module_info) +PSP_EXPORT_END + +PSP_EXPORT_START(VshCtrlLib, 0, 0x4001) +PSP_EXPORT_FUNC(vctrlVSHRegisterVshMenu) +PSP_EXPORT_FUNC(vctrlVSHExitVSHMenu) +PSP_EXPORT_END + +PSP_END_EXPORTS diff --git a/extras/150kernel/vshctrl150/main.c b/extras/150kernel/vshctrl150/main.c new file mode 100644 index 00000000..d431e9ea --- /dev/null +++ b/extras/150kernel/vshctrl150/main.c @@ -0,0 +1,154 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "macros.h" +#include +#include "functions.h" + +PSP_MODULE_INFO("VshCtrl", 0x1007, 1, 2); + +#define GAME150_PATCH "__150" + +static STMOD_HANDLER previous; + +extern int _sceCtrlReadBufferPositive(SceCtrlData *ctrl, int count); +extern int (*g_sceCtrlReadBufferPositive) (SceCtrlData *, int); + +// Flush Instruction and Data Cache +void sync_cache() +{ + // Flush Instruction Cache + sceKernelIcacheInvalidateAll(); + + // Flush Data Cache + sceKernelDcacheWritebackInvalidateAll(); +} + +static void patch_vsh_module(SceModule2* vshmain) +{ + SceModule* mod; + + mod = sceKernelFindModuleByName("sceVshBridge_Driver"); + hookImportByNID(mod, "sceCtrl_driver", 0x1F803938, _sceCtrlReadBufferPositive); + g_sceCtrlReadBufferPositive = (void *) sctrlHENFindFunction("sceController_Service", "sceCtrl", 0x1F803938); + sctrlHENPatchSyscall(g_sceCtrlReadBufferPositive, _sceCtrlReadBufferPositive); +} + + +void Fix150Path(const char *file) +{ + char str[256]; + + if (strstr(file, "ms0:/PSP/GAME/") == file) { + strcpy(str, (char *)file); + + char *p = strstr(str, GAME150_PATCH); + + if (p) { + strcpy((char *)file+13, "150/"); + strncpy((char *)file+17, str+14, p-(str+14)); + strcpy((char *)file+17+(p-(str+14)), p+5); + } + } +} + +static inline int is_game_dir(const char *dirname) +{ + const char *p; + char path[256]; + SceIoStat stat; + + p = strchr(dirname, '/'); + + if (p == NULL) { + return 0; + } + + if (0 != strnicmp(p, "/PSP/GAME", sizeof("/PSP/GAME")-1)) { + return 0; + } + + if (0 == strnicmp(p, "/PSP/GAME/_DEL_", sizeof("/PSP/GAME/_DEL_")-1)) { + return 0; + } + + strcpy(path, dirname); + strcat(path, "/EBOOT.PBP"); + + if(0 == sceIoGetstat(path, &stat)) { + return 0; + } + + strcpy(path, dirname); + strcat(path, "/PARAM.PBP"); + + if(0 == sceIoGetstat(path, &stat)) { + return 0; + } + + return 1; +} + +SceUID gamedopen(const char * dirname) +{ + SceUID result; + u32 k1; + + Fix150Path(dirname); + + result = sceIoDopen(dirname); + + if (result >= 0){ + if(is_game_dir(dirname)) { + + if (strcmp(dirname, "ms0:/PSP/GAME") == 0) { + k1 = pspSdkSetK1(0); + sceIoDclose(result); + result = sceIoDopen("ms0:/PSP/GAME150"); + pspSdkSetK1(k1); + } + + } + } + + return result; +} + +static void hook_directory_io(){ + void *fp = (void*)sctrlHENFindFunction("sceIOFileManager", "IoFileMgrForUser", 0xB29DDF9C); + if(fp != NULL) { + sctrlHENPatchSyscall(fp, gamedopen); + } +} + +static int vshpatch_module_chain(SceModule2 *mod) +{ + u32 text_addr = mod->text_addr; + + if(0 == strcmp(mod->modname, "vsh_module")) { + patch_vsh_module(mod); + goto exit; + } + +exit: + sync_cache(); + if (previous) previous(mod); +} + + +int module_start(SceSize args, void* argp) +{ + + previous = sctrlHENSetStartModuleHandler(&vshpatch_module_chain); + hook_directory_io(); + + return 0; +} \ No newline at end of file diff --git a/extras/150kernel/vshctrl150/vshmenu.c b/extras/150kernel/vshctrl150/vshmenu.c new file mode 100644 index 00000000..c124fe11 --- /dev/null +++ b/extras/150kernel/vshctrl150/vshmenu.c @@ -0,0 +1,211 @@ +/* + * This file is part of PRO CFW. + + * PRO CFW is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * PRO CFW is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PRO CFW. If not, see +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "systemctrl_private.h" + +#define SENSE_KEY (PSP_CTRL_CIRCLE|PSP_CTRL_TRIANGLE|PSP_CTRL_CROSS|PSP_CTRL_SQUARE|PSP_CTRL_START|PSP_CTRL_SELECT) + +#define ALL_ALLOW (PSP_CTRL_UP|PSP_CTRL_RIGHT|PSP_CTRL_DOWN|PSP_CTRL_LEFT) +#define ALL_BUTTON (PSP_CTRL_TRIANGLE|PSP_CTRL_CIRCLE|PSP_CTRL_CROSS|PSP_CTRL_SQUARE) +#define ALL_TRIGGER (PSP_CTRL_LTRIGGER|PSP_CTRL_RTRIGGER) +#define ALL_FUNCTION (PSP_CTRL_SELECT|PSP_CTRL_START|PSP_CTRL_HOME|PSP_CTRL_HOLD|PSP_CTRL_NOTE) +#define ALL_CTRL (ALL_ALLOW|ALL_BUTTON|ALL_TRIGGER|ALL_FUNCTION) +#define FORCE_LOAD (PSP_CTRL_SELECT|ALL_TRIGGER) + +static int (*g_VshMenuCtrl) (SceCtrlData *, int); +static SceUID g_satelite_mod_id = -1; + +int (*g_sceCtrlReadBufferPositive) (SceCtrlData *, int) = NULL; + +int vctrlVSHRegisterVshMenu(int (*ctrl)(SceCtrlData *, int)) +{ + u32 k1; + + k1 = pspSdkSetK1(0); + g_VshMenuCtrl = (void *) ((u32) ctrl | 0x80000000); + pspSdkSetK1(k1); + + return 0; +} + +int vctrlVSHExitVSHMenu(SEConfig *config, char *videoiso, int disctype) +{ + + g_VshMenuCtrl = NULL; + + return 0; +} + +static SceUID load_satelite(void) +{ + SceUID modid; + + SceKernelLMOption opt = { + .size = 0x14, + .flags = 0, + .access = 1, + .position = 1, + }; + + modid = sceKernelLoadModule("flash0:/vsh/module/ark_satelite150.prx", 0, &opt); + + return modid; +} + +SceUID get_thread_id(const char *name) +{ + int ret, count, i; + SceUID ids[128]; + + ret = sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, ids, sizeof(ids), &count); + + if(ret < 0) { + return -1; + } + + for(i=0; i= 0) { + if (sceKernelStopModule(g_satelite_mod_id, 0, 0, 0, 0) >= 0) { + sceKernelUnloadModule(g_satelite_mod_id); + } + } + } + } else { + + if ((ctrl->Buttons & FORCE_LOAD) == FORCE_LOAD){ + goto force_load_satelite; + } + + /* filter out fault PSP sending dead keyscan */ + if ((ctrl->Buttons & ALL_CTRL) != PSP_CTRL_SELECT) { + goto exit; + } + + // Block Satellite Menu in OSK + if (sceKernelFindModuleByName("sceVshOSK_Module")) + goto exit; + + // Block Satellite while using Skype + if (sceKernelFindModuleByName("Skyhost")) + goto exit; + + // Block Satellite Menu in HTML Viewer (Bugged on Thread Monitor too, this is faster...) + if (sceKernelFindModuleByName("htmlviewer_plugin_module")) + goto exit; + + // Block Satellite while mounting USB + if (sceKernelFindModuleByName("sceUSB_Stor_Driver")) + goto exit; + + // Block Recovery menu + if (sceKernelFindModuleByName("Recovery")) + goto exit; + + // Block Satellite Menu in NP Signup Module (Blue PSN Login Screen) + if (get_thread_id("SceNpSignupEvent") >= 0) + goto exit; + + // Block Satellite Menu while playing Music + if (get_thread_id("VshCacheIoPrefetchThread") >= 0) + goto exit; + + // Block Satellite Menu while watching Videos + if (get_thread_id("VideoDecoder") >= 0 || get_thread_id("AudioDecoder") >= 0) + goto exit; + + // Block Satellite Menu while a Standard Dialog / Error is displayed + if (get_thread_id("ScePafJob") >= 0) + goto exit; + + // Block Satellite Menu in PSN Store + if (get_thread_id("ScePSStoreBrowser2") >= 0) + goto exit; + + // Block Satellite while accessing a DHCP Router + if (get_thread_id("SceNetDhcpClient") >= 0) + goto exit; + + // Block Satellite Menu in Go!cam [Yoti] + if (sceKernelFindModuleByName("camera_plugin_module")) + goto exit; + + force_load_satelite: + + #ifdef DEBUG + printk("%s: loading satelite\n", __func__); + #endif + modid = load_satelite(); + + if (modid >= 0) { + g_satelite_mod_id = modid; + modid = sceKernelStartModule(g_satelite_mod_id, 0, 0, 0, 0); + #ifdef DEBUG + if (modid < 0) { + printk("%s: start module -> 0x%08X\n", __func__, modid); + } + #endif + ctrl->Buttons &= (~PSP_CTRL_SELECT); // Filter SELECT + } + } + +exit: + pspSdkSetK1(k1); + + return ret; +} diff --git a/extras/menus/arkMenu/src/system_mgr.cpp b/extras/menus/arkMenu/src/system_mgr.cpp index b73ad2e4..a539bbe1 100644 --- a/extras/menus/arkMenu/src/system_mgr.cpp +++ b/extras/menus/arkMenu/src/system_mgr.cpp @@ -486,7 +486,7 @@ void SystemMgr::initMenu(SystemEntry** e, int ne){ _sceImposeSetParam = (void *)sctrlHENFindFunction("sceImpose_Driver", "sceImpose_driver", 0x3C318569); stringstream version; - version << "FW " << fwmajor << "." << fwminor << fwmicro; + version << "" << fwmajor << "." << fwminor << fwmicro; version << " ARK " << major << "." << minor; if (micro>9) version << "." << micro; else if (micro>0) version << ".0" << micro;