Add support for PSM Unity. (and fix dots-tb's plugin lol
This commit is contained in:
parent
12e870dd5f
commit
56935b455f
|
@ -9,46 +9,38 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
|||
endif()
|
||||
|
||||
project(MakePsmGreatAgain)
|
||||
include("$ENV{VITASDK}/share/vita.cmake" REQUIRED)
|
||||
include("${VITASDK}/share/vita.cmake" REQUIRED)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -std=gnu99")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions")
|
||||
|
||||
include_directories(
|
||||
)
|
||||
|
||||
link_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
MakePsmGreatAgain.c
|
||||
if (NOT ${RELEASE})
|
||||
add_definitions(-DENABLE_LOGGING)
|
||||
endif()
|
||||
|
||||
add_executable(MakePsmGreatAgain
|
||||
MakePsmGreatAgain.c
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
SceSysmemForDriver_stub
|
||||
SceSysclibForDriver_stub
|
||||
SceModulemgrForDriver_stub
|
||||
SceThreadmgrForDriver_stub
|
||||
SceIofilemgrForDriver_stub
|
||||
SceUdcdForDriver_stub
|
||||
SceSysrootForKernel_stub
|
||||
SceUsbSerialForDriver_stub
|
||||
SceDebugForDriver_stub
|
||||
taihenForKernel_stub
|
||||
gcc
|
||||
target_link_libraries(MakePsmGreatAgain
|
||||
taihen_stub
|
||||
SceLibc_stub
|
||||
SceAppMgr_stub
|
||||
SceLibKernel_stub
|
||||
SceIofilemgr_stub
|
||||
)
|
||||
vita_create_self(${PROJECT_NAME}.skprx ${PROJECT_NAME}
|
||||
UNSAFE
|
||||
|
||||
set_target_properties(MakePsmGreatAgain
|
||||
PROPERTIES LINK_FLAGS "-nostdlib"
|
||||
)
|
||||
|
||||
vita_create_self(MakePsmGreatAgain.suprx MakePsmGreatAgain
|
||||
CONFIG ${CMAKE_SOURCE_DIR}/exports.yml
|
||||
)
|
||||
vita_create_stubs(${PROJECT_NAME}-stubs ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/exports.yml
|
||||
KERNEL
|
||||
)
|
||||
|
||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-stubs/
|
||||
DESTINATION lib
|
||||
FILES_MATCHING PATTERN "*.a"
|
||||
)
|
||||
|
||||
install(FILES savestates.h
|
||||
DESTINATION include
|
||||
)
|
||||
)
|
|
@ -1,28 +1,35 @@
|
|||
//MakePSMGreatAgain
|
||||
//Build a wall and make Sony pay for it!
|
||||
//Probably with he money they stole from us
|
||||
//by deleting our PSM Purchases
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
//MakePsmGreatAgain
|
||||
//We need to build a wall and make SONY pay for it (with all the money they stole from deleting our PSM Purchases!)
|
||||
|
||||
#include <taihen.h>
|
||||
#include <vitasdkkern.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <vitasdk.h>
|
||||
#include "licenseinfo.h"
|
||||
#define printf sceClibPrintf
|
||||
|
||||
#define printf ksceDebugPrintf
|
||||
static SceUID mountCacheHook;
|
||||
static tai_hook_ref_t ref_mountCacheHook;
|
||||
|
||||
static SceUID mountCacheHook;
|
||||
static tai_hook_ref_t ref_mountCacheHook;
|
||||
|
||||
static SceUID tickHook;
|
||||
static tai_hook_ref_t ref_tickHook;
|
||||
|
||||
static SceUID networkHook;
|
||||
static tai_hook_ref_t ref_networkHook;
|
||||
|
||||
int ret;
|
||||
int UNITY = 0;
|
||||
int SUITE = 0;
|
||||
|
||||
//e23e8c7b15a198 SUITE
|
||||
//e23e8c93b8ed90 UNITY
|
||||
|
||||
int getFileSize(const char *file) {
|
||||
SceUID fd = ksceIoOpen(file, SCE_O_RDONLY, 0);
|
||||
SceUID fd = sceIoOpen(file, SCE_O_RDONLY, 0);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
int fileSize = ksceIoLseek(fd, 0, SCE_SEEK_END);
|
||||
ksceIoClose(fd);
|
||||
int fileSize = sceIoLseek(fd, 0, SCE_SEEK_END);
|
||||
sceIoClose(fd);
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
|
@ -37,165 +44,141 @@ int fileExists(const char *file) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int ReadFile(char *file, void *buf, int size) {
|
||||
SceUID fd = ksceIoOpen(file, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
int read = ksceIoRead(fd, buf, size);
|
||||
|
||||
ksceIoClose(fd);
|
||||
return read;
|
||||
}
|
||||
|
||||
|
||||
int WriteFile(char *file, void *buf, int size) {
|
||||
SceUID fd = ksceIoOpen(file, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
int written = ksceIoWrite(fd, buf, size);
|
||||
|
||||
ksceIoClose(fd);
|
||||
return written;
|
||||
}
|
||||
|
||||
|
||||
static int secureHook = -1;
|
||||
static tai_hook_ref_t secureHook_ref;
|
||||
|
||||
static int runHook = -1;
|
||||
static tai_hook_ref_t runHook_ref;
|
||||
|
||||
static int isAllowedSerialHook = -1;
|
||||
static tai_hook_ref_t isAllowedSerial_ref;
|
||||
|
||||
int ret = 0;
|
||||
int pid;
|
||||
|
||||
unsigned int SUITE_LICENSE_VALID[2] = {0x7b15a198,0xe23e8c};
|
||||
unsigned int UNITY_LICENSE_VALID[2] = {0x93b8ed90,0xe23e8c};
|
||||
char titleid[12];
|
||||
|
||||
int ksceRtcGetCurrentSecureTick_patched(unsigned int* timestamp) //fake valid time
|
||||
int sceRtcGetCurrentNetworkTick_patch(SceRtcTick *ptick)
|
||||
{
|
||||
printf("SceRtcGetSecure called!\n");
|
||||
|
||||
ret = TAI_CONTINUE(int, secureHook_ref,timestamp);
|
||||
|
||||
pid = ksceKernelGetProcessId();
|
||||
ksceKernelGetProcessTitleId(pid,titleid,12);
|
||||
|
||||
|
||||
if(!strcmp(titleid,"PCSI00007")) //SUITE
|
||||
ret = TAI_CONTINUE(int, ref_networkHook, ptick);
|
||||
printf("getCurrentNetworkTick %llx",ptick->tick);
|
||||
if(UNITY)
|
||||
{
|
||||
printf("Spoofing time to %x%x\n",SUITE_LICENSE_VALID[1],SUITE_LICENSE_VALID[0]);
|
||||
|
||||
timestamp[0] = SUITE_LICENSE_VALID[0];
|
||||
timestamp[1] = SUITE_LICENSE_VALID[1];
|
||||
return 0;
|
||||
ptick->tick = UNITY_LICENSE_VALID;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptick->tick = SUITE_LICENSE_VALID;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int isAllowedSerial_patch(int arg1, int arg2, int arg3, int arg4) { //Tell f00d to fuck off
|
||||
TAI_CONTINUE(int, isAllowedSerial_ref,arg1,arg2,arg3,arg4);
|
||||
return 1;
|
||||
int ReadFile(char *file, void *buf, int size) {
|
||||
SceUID fd = sceIoOpen(file, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
int read = sceIoRead(fd, buf, size);
|
||||
|
||||
sceIoClose(fd);
|
||||
return read;
|
||||
}
|
||||
|
||||
|
||||
static SceUID _ksceKernelLaunchAppPatched(void *args)
|
||||
{
|
||||
char *titleid = (char *)((uintptr_t *)args)[0];
|
||||
uint32_t flags = (uint32_t)((uintptr_t *)args)[1];
|
||||
char *path = (char *)((uintptr_t *)args)[2];
|
||||
void *unk = (void *)((uintptr_t *)args)[3];
|
||||
|
||||
if ((flags == 0x1000000 && strstr(path, "PCSI00007")))
|
||||
{
|
||||
|
||||
|
||||
ksceIoMkdir("ux0:/cache/PCSI00007/_System",6);
|
||||
|
||||
if(!fileExists("ux0:/cache/PCSI00007/_System/Code"))
|
||||
{
|
||||
printf("Writing 'Code'\n");
|
||||
WriteFile("ux0:/cache/PCSI00007/_System/Code",&SUITE_CODE,sizeof(SUITE_CODE));
|
||||
}
|
||||
|
||||
if(!fileExists("ux0:/cache/PCSI00007/_System/target_kdbg_list.dat"))
|
||||
{
|
||||
printf("Writing 'target_kdbg_list'\n");
|
||||
WriteFile("ux0:/cache/PCSI00007/_System/target_kdbg_list.dat",&SUITE_TARGET,sizeof(SUITE_TARGET));
|
||||
}
|
||||
|
||||
if(!fileExists("ux0:/cache/PCSI00007/_System/vseed.dat"))
|
||||
{
|
||||
printf("Writing 'vseed'\n");
|
||||
WriteFile("ux0:/cache/PCSI00007/_System/vseed.dat",&SUITE_VSEED,sizeof(SUITE_VSEED));
|
||||
}
|
||||
|
||||
//Write KConsole and PSMDrmBoot
|
||||
printf("Writing 'protected_kconsole_cache'\n");
|
||||
WriteFile("ux0:/cache/PCSI00007/_System/protected_kconsole_cache.dat",&SUITE_KCONSOLE, sizeof(SUITE_KCONSOLE));
|
||||
printf("Writing 'psmdrmboot'\n");
|
||||
WriteFile("ux0:/cache/PCSI00007/_System/psmdrmboot.dat",&SUITE_PSMDRMBOOT, sizeof(SUITE_PSMDRMBOOT));
|
||||
|
||||
int WriteFile(char *file, void *buf, int size) {
|
||||
SceUID fd = sceIoOpen(file, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
ret = TAI_CONTINUE(int, runHook_ref, titleid, flags, path, unk);
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
int written = sceIoWrite(fd, buf, size);
|
||||
|
||||
return TAI_CONTINUE(int, runHook_ref, titleid, flags, path, unk); // returns pid
|
||||
sceIoClose(fd);
|
||||
return written;
|
||||
}
|
||||
|
||||
static SceUID ksceKernelLaunchApp_patched(char *titleid, uint32_t flags, char *path, void *unk)
|
||||
{
|
||||
uintptr_t args[4];
|
||||
args[0] = (uintptr_t)titleid;
|
||||
args[1] = (uintptr_t)flags;
|
||||
args[2] = (uintptr_t)path;
|
||||
args[3] = (uintptr_t)unk;
|
||||
|
||||
return ksceKernelRunWithStack(0x4000, _ksceKernelLaunchAppPatched, args);
|
||||
}
|
||||
|
||||
|
||||
void _start() __attribute__ ((weak, alias ("module_start")));
|
||||
int module_start(SceSize argc, const void *args)
|
||||
|
||||
int sceAppUtilCacheMount_patch()
|
||||
{
|
||||
ret = TAI_CONTINUE(int,ref_mountCacheHook);
|
||||
//Create Publishing License if it Doesnt Exist
|
||||
if(UNITY)
|
||||
{
|
||||
sceIoMkdir("cache0:/_System",6);
|
||||
|
||||
runHook = taiHookFunctionExportForKernel(KERNEL_PID, &runHook_ref, "SceProcessmgr", 0x7A69DE86, 0x71CF71FD, ksceKernelLaunchApp_patched);
|
||||
if (runHook < 0)
|
||||
runHook = taiHookFunctionExportForKernel(KERNEL_PID, &runHook_ref, "SceProcessmgr", 0xEB1F8EF7, 0x68068618, ksceKernelLaunchApp_patched);
|
||||
|
||||
secureHook = taiHookFunctionExportForKernel(KERNEL_PID,
|
||||
&secureHook_ref,
|
||||
"SceRtc",
|
||||
0x0351D827, // SceRtcForDriver
|
||||
0x401C0954, // ksceRtcGetCurrentSecureTick
|
||||
ksceRtcGetCurrentSecureTick_patched);
|
||||
|
||||
isAllowedSerialHook = taiHookFunctionExportForKernel(KERNEL_PID,
|
||||
&isAllowedSerial_ref,
|
||||
"SceSblACMgr",
|
||||
0x9AD8E213, // SceSblACMgrForDriver
|
||||
0x062CAEB2, // isAllowedSerial
|
||||
isAllowedSerial_patch);
|
||||
|
||||
|
||||
printf("RunHook: %x\n",runHook);
|
||||
printf("SecureHook: %x\n",secureHook);
|
||||
printf("isAllowedSerialHook: %x\n",isAllowedSerialHook);
|
||||
if(!fileExists("cache0:/_System/Code"))
|
||||
{
|
||||
printf("Writing 'Code'\n");
|
||||
WriteFile("cache0:/_System/Code",&UNITY_CODE,sizeof(UNITY_CODE));
|
||||
}
|
||||
|
||||
if(!fileExists("cache0:/_System/target_kdbg_list.dat"))
|
||||
{
|
||||
printf("Writing 'target_kdbg_list'\n");
|
||||
WriteFile("cache0:/_System/target_kdbg_list.dat",&UNITY_TARGET,sizeof(UNITY_TARGET));
|
||||
}
|
||||
|
||||
if(!fileExists("cache0:/_System/vseed.dat"))
|
||||
{
|
||||
printf("Writing 'vseed'\n");
|
||||
WriteFile("cache0:/_System/vseed.dat",&UNITY_VSEED,sizeof(UNITY_VSEED));
|
||||
}
|
||||
|
||||
//Write Protected KConsole and PSMDrmBoot
|
||||
printf("Writing 'protected_kconsole_cache'\n");
|
||||
WriteFile("cache0:/_System/protected_kconsole_cache.dat",&UNITY_KCONSOLE, sizeof(UNITY_KCONSOLE));
|
||||
printf("Writing 'psmdrmboot'\n");
|
||||
WriteFile("cache0:/_System/psmdrmboot.dat",&UNITY_PSMDRMBOOT, sizeof(UNITY_PSMDRMBOOT));
|
||||
}
|
||||
else
|
||||
{
|
||||
sceIoMkdir("cache0:/_System",6);
|
||||
|
||||
if(!fileExists("cache0:/_System/Code"))
|
||||
{
|
||||
printf("Writing 'Code'\n");
|
||||
WriteFile("cache0:/_System/Code",&SUITE_CODE,sizeof(SUITE_CODE));
|
||||
}
|
||||
|
||||
if(!fileExists("cache0:/_System/target_kdbg_list.dat"))
|
||||
{
|
||||
printf("Writing 'target_kdbg_list'\n");
|
||||
WriteFile("cache0:/_System/target_kdbg_list.dat",&SUITE_TARGET,sizeof(SUITE_TARGET));
|
||||
}
|
||||
|
||||
if(!fileExists("cache0:/_System/vseed.dat"))
|
||||
{
|
||||
printf("Writing 'vseed'\n");
|
||||
WriteFile("cache0:/_System/vseed.dat",&SUITE_VSEED,sizeof(SUITE_VSEED));
|
||||
}
|
||||
|
||||
//Write Protected KConsole and PSMDrmBoot
|
||||
printf("Writing 'protected_kconsole_cache'\n");
|
||||
WriteFile("cache0:/_System/protected_kconsole_cache.dat",&SUITE_KCONSOLE, sizeof(SUITE_KCONSOLE));
|
||||
printf("Writing 'psmdrmboot'\n");
|
||||
WriteFile("cache0:/_System/psmdrmboot.dat",&SUITE_PSMDRMBOOT, sizeof(SUITE_PSMDRMBOOT));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int module_start(SceSize argc, const void *args) {
|
||||
char titleid[12];
|
||||
sceAppMgrAppParamGetString(0, 12, titleid, 256); //Which devagent is this?
|
||||
|
||||
if(!strcmp(titleid,"PCSI00007")) //SUITE
|
||||
{
|
||||
SUITE = 1;
|
||||
UNITY = 0;
|
||||
}
|
||||
|
||||
if(!strcmp(titleid,"PCSI00009")) //UNITY
|
||||
{
|
||||
SUITE = 0;
|
||||
UNITY = 1;
|
||||
}
|
||||
sceClibPrintf("Running on %s",titleid);
|
||||
mountCacheHook = taiHookFunctionImport(&ref_mountCacheHook,
|
||||
TAI_MAIN_MODULE,
|
||||
TAI_ANY_LIBRARY,
|
||||
0x0AA56143, // sceAppUtilCacheMount
|
||||
sceAppUtilCacheMount_patch);
|
||||
ksceUdcdStopCurrentInternal(2);
|
||||
return SCE_KERNEL_START_SUCCESS;
|
||||
}
|
||||
|
||||
int module_stop(SceSize argc, const void *args)
|
||||
{
|
||||
return SCE_KERNEL_STOP_SUCCESS;
|
||||
int module_stop(SceSize argc, const void *args) {
|
||||
|
||||
// release hooks
|
||||
if (mountCacheHook >= 0) taiHookRelease(mountCacheHook, ref_mountCacheHook);
|
||||
|
||||
|
||||
return SCE_KERNEL_STOP_SUCCESS;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue