diff --git a/app/src/main.c b/app/src/main.c index beee4ac..a743de5 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -228,8 +228,18 @@ void sceNpTrophySetupDialogParamInit(SceNpTrophySetupDialogParam* param) int setSecureTick(unsigned long long int psTime) { - printf("setSecureTick: %llx\n",psTime); + + + SceRtcTick utcTime = {0}; + SceRtcTick localTime = {0}; + + utcTime.tick = psTime; + sceRtcConvertUtcToLocalTime(&utcTime,&localTime); + psTime = localTime.tick; + + printf("setSecureTick: %llx\n",psTime); + printf("Creating splits..\n"); char hexint[15]; memset(hexint,0,15); @@ -323,7 +333,7 @@ start: printf("\e[%i;%iH%s", SCREEN_ROW, CENTERX(buf), buf); memset(&pad, 0, sizeof(pad)); sceCtrlPeekBufferPositive(0, &pad, 1); - + if (pad.buttons == SCE_CTRL_UP) { if (selection <= size - WINDOW_HEIGHT){ @@ -673,7 +683,7 @@ TrophyMenu: //set options strcpy(option_list[0].path, "Unlock a Trophy"); strcpy(option_list[1].path, "Unlock All Trophys"); - strcpy(option_list[2].path, "Exit"); + strcpy(option_list[3].path, "Exit"); while(1) { @@ -1131,10 +1141,6 @@ selectTrophyMenu: { dateTime.year ++; } - if(dateTime.year < 2015) - { - dateTime.year = 2015; - } } if(selectedPartOfTime == 3) { @@ -1177,12 +1183,8 @@ selectTrophyMenu: printf("Unlocking trophy %i\n",selection); SceNpTrophyId id = selection; SceNpTrophyId platid; + FakeTimes(1); ret = setSecureTick(fakeTime.tick); - if(ret < 0){ - printf("setSecureTick() failed. ret = 0x%x\n", ret); - sceKernelDelayThread(500000); - goto selectTrophyMenu; - } ret = sceNpTrophyUnlockTrophy(trophyContext,handle,id,&platid); if(ret < 0){ if(ret == 0x8055160f) @@ -1206,13 +1208,7 @@ selectTrophyMenu: } - sceRtcGetCurrentTick(&fakeTime); - ret = setSecureTick(fakeTime.tick); - if(ret < 0){ - printf("setSecureTick() failed. ret = 0x%x\n", ret); - sceKernelDelayThread(500000); - goto selectTrophyMenu; - } + FakeTimes(0); sceKernelDelayThread(500000); goto selectTrophyMenu; @@ -1239,6 +1235,7 @@ selectTrophyMenu: else if(selection == 1) { + psvDebugScreenClear(); //clear screen SceNpTrophyId id = 0; SceNpTrophyId platid; diff --git a/app/src/np.h b/app/src/np.h index 11725ce..50465af 100644 --- a/app/src/np.h +++ b/app/src/np.h @@ -5,6 +5,16 @@ typedef struct SceNpOptParam { SceSize optParamSize; } SceNpOptParam; +//SceNpCommunicationId +/*typedef struct SceNpCommunicationId { + char data[9]; + char term; + SceUChar8 num; + char dummy; +} SceNpCommunicationId; + +allready in vitasdk?*/ + //SceNpCommunicationPassphrase typedef struct SceNpCommunicationPassphrase { SceUChar8 data[128]; diff --git a/app/src/rtc.h b/app/src/rtc.h index 4f0ef2e..1d96047 100644 --- a/app/src/rtc.h +++ b/app/src/rtc.h @@ -1,3 +1,4 @@ //Defines functions relating to changing timestamps int SetTrophyTimes(unsigned int timestamp1,unsigned int timestamp2); +int FakeTimes(int value); \ No newline at end of file diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 6162124..7f433ee 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -26,6 +26,7 @@ target_link_libraries(${PROJECT_NAME} SceThreadmgrForDriver_stub SceProcessmgrForDriver_stub SceRtcForDriver_stub + SceDebugForDriver_stub #SceNpDrmForDriver_stub taihenForKernel_stub taihenModuleUtils_stub diff --git a/kernel/exports.yml b/kernel/exports.yml index a8b3c5d..57e5e1b 100644 --- a/kernel/exports.yml +++ b/kernel/exports.yml @@ -11,4 +11,5 @@ SceAppMgrKernel2: syscall: true functions: - sceAppMgrKernelMountById - - kSetTrophyTimes \ No newline at end of file + - kSetTrophyTimes + - kFakeTimes \ No newline at end of file diff --git a/kernel/src/main.c b/kernel/src/main.c index f10787e..cae55c9 100644 --- a/kernel/src/main.c +++ b/kernel/src/main.c @@ -17,11 +17,7 @@ */ -#include -#include -#include -#include -#include +#include #include #include @@ -30,6 +26,8 @@ #include "appmgr_kernel.h" +#define printf ksceDebugPrintf + 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); @@ -38,21 +36,48 @@ int (* sceAppMgrMountById)(SceUID pid, void *info, int id, const char *titleid, int (* _ksceKernelGetModuleInfo)(SceUID pid, SceUID modid, SceKernelModuleInfo *info); int ksceRtcSetCurrentSecureTick(unsigned int* timestamp); +int ksceRtcGetCurrentSecureTick(unsigned int* timestamp); + +static int hook = -1; +static tai_hook_ref_t ref_hook; tai_module_info_t tai_info; +int fakeTime[2]; +int spoofTime = 0; + +int getTimePatched(unsigned int* timestamp) +{ + + int ret; + ret = TAI_CONTINUE(int, ref_hook,timestamp); + if(spoofTime) + { + printf("[TROPHAXSE] Faking timestamp to %x%x",fakeTime[1],fakeTime[0]); + timestamp[0] = fakeTime[0]; + timestamp[1] = fakeTime[1]; + } + return ret; +} + +int kFakeTimes(int value) +{ + spoofTime = value; + return 0; +} + int kSetTrophyTimes(unsigned int timestamp1, unsigned int timestamp2) { - unsigned int timestamp[2]; - timestamp[0] = timestamp1; - timestamp[1] = timestamp2; + fakeTime[0] = timestamp1; + fakeTime[1] = timestamp2; - return ksceRtcSetCurrentSecureTick(timestamp); + return 0; } + int _sceAppMgrKernelMountById(SceAppMgrMountIdArgs *args) { int res; @@ -119,8 +144,14 @@ int sceAppMgrKernelMountById(SceAppMgrMountIdArgs *args) { void _start() __attribute__ ((weak, alias("module_start"))); int module_start(SceSize args, void *argp) { - - + printf("TrophaxSE Kernel Module loaded!\n"); + hook = taiHookFunctionExportForKernel(KERNEL_PID, + &ref_hook, + "SceRtc", + 0x0351D827, // SceRtcForDriver + 0x401C0954, // ksceRtcGetCurrentSecureTick + getTimePatched); + printf("[TROPHAXSE] hook: %x\n",hook); // Get tai module info @@ -150,12 +181,15 @@ int module_start(SceSize args, void *argp) { module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x19E95, (uintptr_t *)&sceAppMgrMountById); break; } + + return SCE_KERNEL_START_SUCCESS; } int module_stop(SceSize args, void *argp) { - + if (hook >= 0) taiHookReleaseForKernel(hook, ref_hook); return SCE_KERNEL_STOP_SUCCESS; } + \ No newline at end of file diff --git a/user/exports.yml b/user/exports.yml index 5628f92..8bb9da6 100644 --- a/user/exports.yml +++ b/user/exports.yml @@ -11,4 +11,5 @@ SceAppMgrUser: syscall: false functions: - sceAppMgrUserMountById - - SetTrophyTimes \ No newline at end of file + - SetTrophyTimes + - FakeTimes \ No newline at end of file diff --git a/user/src/appmgr_user.h b/user/src/appmgr_user.h index bad7747..5449f26 100644 --- a/user/src/appmgr_user.h +++ b/user/src/appmgr_user.h @@ -1,4 +1,5 @@ #include int sceAppMgrUserMountById(SceAppMgrMountIdArgs *args); -int kSetTrophyTimes(unsigned int timestamp1, unsigned int timestamp2); \ No newline at end of file +int kSetTrophyTimes(unsigned int timestamp1, unsigned int timestamp2); +int kFakeTimes(int value); \ No newline at end of file diff --git a/user/src/main.c b/user/src/main.c index bc40a6f..87d9c20 100644 --- a/user/src/main.c +++ b/user/src/main.c @@ -27,6 +27,11 @@ int SetTrophyTimes(unsigned int timestamp1,unsigned int timestamp2) return kSetTrophyTimes(timestamp1,timestamp2); } +int FakeTimes(int value) +{ + return kFakeTimes(value); +} + int sceAppMgrUserMountById(SceAppMgrMountIdArgs *args) { return sceAppMgrKernelMountById(args); }