├── exports.yml ├── .gitignore ├── README.md ├── LICENSE ├── CMakeLists.txt └── repatch.c /exports.yml: -------------------------------------------------------------------------------- 1 | repatch: 2 | attributes: 0 3 | version: 4 | major: 0 5 | minor: 2 6 | main: 7 | start: module_start 8 | stop: module_stop 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # How to use: 2 | 3 | 3.65 Confirmed working: https://twitter.com/dots_tb/status/972922611536576512 4 | 5 | IF THE PATCH REQUIRES AN EBOOT IT WILL NOT WORK ATM! 6 | 7 | First install the plugin by adding it to the *KERNEL line 8 | after that create a folder on ux0 called "rePatch" 9 | inside that folder put another folder of the titleid for the game 10 | and in there, simply place the files you want to replace, 11 | it works exactly the same as ux0:patch does on 3.60. 12 | only you dont need the param.sfo file in sce_sys. 13 | 14 | 15 | Developed by SilicaAndPina & dots-tb 16 | 17 | Intended to allow you to patch games even if theres an update installed. 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Silica 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) 4 | if(DEFINED ENV{VITASDK}) 5 | set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file") 6 | else() 7 | message(FATAL_ERROR "Please define VITASDK to point to your SDK path!") 8 | endif() 9 | endif() 10 | 11 | project(repatch) 12 | include("$ENV{VITASDK}/share/vita.cmake" REQUIRED) 13 | 14 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -std=gnu99") 15 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib") 16 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions") 17 | 18 | link_directories( 19 | ${CMAKE_CURRENT_BINARY_DIR} 20 | ) 21 | 22 | add_executable(${PROJECT_NAME} 23 | repatch.c 24 | ) 25 | 26 | target_link_libraries(${PROJECT_NAME} 27 | taihenForKernel_stub 28 | SceSysmemForDriver_stub 29 | SceSysclibForDriver_stub 30 | SceThreadmgrForDriver_stub 31 | SceIofilemgrForDriver_stub 32 | SceDebugForDriver_stub 33 | SceSysrootForKernel_stub 34 | ) 35 | vita_create_self(${PROJECT_NAME}.skprx ${PROJECT_NAME} 36 | UNSAFE 37 | CONFIG ${CMAKE_SOURCE_DIR}/exports.yml 38 | ) -------------------------------------------------------------------------------- /repatch.c: -------------------------------------------------------------------------------- 1 | // 2 | // SilicaTeam 2.0 @dots_tb @SilicaAndPina ‏ 3 | // RePatch -- PATCHING WITH FREEDOM 4 | 5 | // Based off ioPlus by @dots_tb: https://github.com/CelesteBlue-dev/PSVita-RE-tools/tree/master/ioPlus/ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define printf ksceDebugPrintf 13 | 14 | static int hooks_uid[3]; 15 | static tai_hook_ref_t ref_hooks[3]; 16 | 17 | static int ksceIoOpen_patched(const char *filename, int flag, SceIoMode mode) { 18 | int ret = -1, state; 19 | ENTER_SYSCALL(state); 20 | SceUID pid = ksceKernelGetProcessId(); 21 | char titleid[32]; 22 | ksceKernelGetProcessTitleId(pid, titleid, sizeof(titleid)); 23 | 24 | if (memcmp("main", titleid, sizeof("main") - 1)==0) { 25 | if (memcmp("ux0:/rePatch", filename, sizeof("ux0:/rePatch") - 1)!=0) { 26 | if ((strstr(filename, "eboot.bin") != NULL) && (strstr(filename, ":/eboot.bin") == NULL)) { 27 | char new_path[128]; 28 | char *old_path = strchr(filename, '/'); 29 | if (old_path != NULL) { 30 | old_path++; 31 | old_path = strchr(old_path, '/'); 32 | if (old_path != NULL) { 33 | old_path++; 34 | if(old_path[0] == '/') 35 | old_path++; 36 | snprintf(new_path, sizeof(new_path), "ux0:/rePatch/%s",old_path); 37 | ret = ksceIoOpen(new_path, flag, mode); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | 44 | if(ret < 0) ret = TAI_CONTINUE(int, ref_hooks[2], filename, flag, mode); 45 | EXIT_SYSCALL(state); 46 | return ret; 47 | } 48 | 49 | static int ksceIoOpenForPid_patched(SceUID pid, const char *filename, int flag, SceIoMode mode) { 50 | int ret = -1, state; 51 | ENTER_SYSCALL(state); 52 | if (memcmp("app0:", filename, sizeof("app0:") - 1)==0) { 53 | char new_path[128]; 54 | char titleid[32]; 55 | ret = ksceKernelGetProcessTitleId(pid, titleid, sizeof(titleid)); 56 | if(ret > -1) { 57 | char *old_path = strchr(filename, ':') + 1; 58 | if(old_path[0] == '/') 59 | old_path++; 60 | snprintf(new_path, sizeof(new_path), "ux0:/rePatch/%s/%s",titleid,old_path); 61 | ret = ksceIoOpen(new_path, flag, mode); 62 | } 63 | 64 | } 65 | if(ret < 0) ret = TAI_CONTINUE(int, ref_hooks[0], pid, filename, flag, mode); 66 | EXIT_SYSCALL(state); 67 | return ret; 68 | } 69 | 70 | static int _sceIoGetstat_patched(const char *file, SceIoStat *stat, int r2) { 71 | int ret = -1, state; 72 | SceIoStat k_stat; 73 | char filename[256]; 74 | ksceKernelStrncpyUserToKernel(&filename, (uintptr_t)file, sizeof(filename)); 75 | ENTER_SYSCALL(state); 76 | if (memcmp("app0:", filename, sizeof("app0:") - 1)==0) { 77 | char new_path[128]; 78 | char titleid[32]; 79 | ret = ksceKernelGetProcessTitleId(ksceKernelGetProcessId(), titleid, sizeof(titleid)); 80 | if(ret > -1) { 81 | char *old_path = strchr(filename, ':') + 1; 82 | if(old_path[0] == '/') 83 | old_path++; 84 | snprintf(new_path, sizeof(new_path), "ux0:/rePatch/%s/%s",titleid,old_path); 85 | ret = ksceIoGetstat(new_path, &k_stat); 86 | if(ret > -1) { 87 | ksceKernelMemcpyKernelToUser((uintptr_t)stat, &k_stat, sizeof(k_stat)); 88 | } 89 | } 90 | 91 | } 92 | if(ret < 0) ret = TAI_CONTINUE(int, ref_hooks[1], file, stat, r2); 93 | EXIT_SYSCALL(state); 94 | return ret; 95 | } 96 | 97 | void _start() __attribute__ ((weak, alias ("module_start"))); 98 | int module_start(SceSize argc, const void *args) { 99 | hooks_uid[0] = taiHookFunctionExportForKernel(KERNEL_PID, &ref_hooks[0], "SceIofilemgr", TAI_ANY_LIBRARY, 0xC3D34965, ksceIoOpenForPid_patched); 100 | hooks_uid[1] = taiHookFunctionExportForKernel(KERNEL_PID, &ref_hooks[1], "SceIofilemgr", TAI_ANY_LIBRARY, 0x8E7E11F2, _sceIoGetstat_patched); 101 | hooks_uid[2] = taiHookFunctionExportForKernel(KERNEL_PID, &ref_hooks[2], "SceIofilemgr", TAI_ANY_LIBRARY, 0x75192972, ksceIoOpen_patched); 102 | return SCE_KERNEL_START_SUCCESS; 103 | } 104 | 105 | int module_stop(SceSize argc, const void *args) { 106 | if (hooks_uid[0] >= 0) taiHookReleaseForKernel(hooks_uid[0], ref_hooks[0]); 107 | if (hooks_uid[1] >= 0) taiHookReleaseForKernel(hooks_uid[1], ref_hooks[1]); 108 | if (hooks_uid[2] >= 0) taiHookReleaseForKernel(hooks_uid[2], ref_hooks[2]); 109 | return SCE_KERNEL_STOP_SUCCESS; 110 | } --------------------------------------------------------------------------------