Make it work with VITA licenses

This commit is contained in:
Li 2024-04-23 17:32:04 +12:00
parent c74ad08297
commit b48a82c7e1
2 changed files with 29 additions and 4 deletions

View File

@ -1,5 +1,6 @@
#include <jni.h>
#include <string.h>
#include <stdlib.h>
#include <dlfcn.h>
#include "nopsmdrm.h"
@ -10,10 +11,20 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
LOGFUNCTION();
void* handle = dlopen("/data/data/com.playstation.psstore/lib/libdefault_real.so", RTLD_LAZY);
LOG("dlopen libdefault_real.so @ %p", handle);
LOG("dlopen libdefault_real.so @ %p errno = %x", handle, errno);
if(handle == NULL) {
handle = dlopen("libdefault_real.so", RTLD_LAZY);
LOG("fail... trying just the raw name libdefault_real.so @ %p errno = %x", handle, errno);
}
JNI_OnLoad_real = dlsym(handle, "JNI_OnLoad");
if(JNI_OnLoad_real == NULL) {
LOG("Cannot run PSM, JNI_OnLoad_real was nullptr");
return 0;
}
LOG("RUN JNI_OnLoad_real @ %p", JNI_OnLoad_real);
jint res = JNI_OnLoad_real(vm, reserved);
LOG("Install Pathces");

View File

@ -11,6 +11,7 @@ static void* LIB_DEFAULT_HANDLE = NULL;
int (*scePsmDrmGetKeySet_orig)(ScePsmDrmLicense*, char*, int*, uint64_t*, uint64_t*) = NULL;
void* (*scePsmDrmGetRif_orig)(char*, char*, ScePsmDrmLicense *) = NULL;
uintptr_t verify_rif_top_part_orig = NULL;
void* get_func_addr(char* function_name) {
@ -62,7 +63,7 @@ void GetAllLicenses(char* psm_folder) {
struct dirent* ent = NULL;
while((ent = readdir(dfd)) != NULL) {
snprintf(contentId, sizeof(contentId) - 1, "UM0105-%s-0000000000000000", ent->d_name);
snprintf(contentId, sizeof(contentId) - 1, "UM0105-%s_00-0000000000000000", ent->d_name);
LOG("obtaining rif for: %s", contentId);
int res = scePsmDrmGetRif_orig(contentId, psm_folder, &license);
@ -145,22 +146,35 @@ int scePsmDrmGetRif_patch(char *contentid, char *psm_folder, ScePsmDrmLicense *r
return res;
}
int verify_rif_top_part_patch() {
return 0;
}
int patch_libdefault(void* handle) {
LIB_DEFAULT_HANDLE = handle;
LOG("Hooking scePsmDrmGetRif");
uintptr_t* scePsmDrmGetRif = get_func_addr("scePsmDrmGetRif");
LOG("Hooking scePsmDrmGetRif %p", scePsmDrmGetRif);
int res = registerInlineHook((uintptr_t)scePsmDrmGetRif, (uintptr_t)scePsmDrmGetRif_patch, (uintptr_t**)&scePsmDrmGetRif_orig);
if(res == 0)
inlineHook((uintptr_t)scePsmDrmGetRif);
LOG("Hooking scePsmDrmGetKeySet");
uintptr_t* scePsmDrmGetKeySet = get_func_addr("scePsmDrmGetKeySet");
LOG("Hooking scePsmDrmGetKeySet %p", scePsmDrmGetKeySet);
res = registerInlineHook((uintptr_t)scePsmDrmGetKeySet, (uintptr_t)scePsmDrmGetKeySet_patch, (uintptr_t**)&scePsmDrmGetKeySet_orig);
if(res == 0)
inlineHook((uintptr_t)scePsmDrmGetKeySet);
uintptr_t verify_rif_top_part = get_func_addr("scePsmInitialize") + 0x302EE0;
LOG("Hooking verify_rif_top_part %p", verify_rif_top_part);
res = registerInlineHook((uintptr_t)verify_rif_top_part, (uintptr_t)verify_rif_top_part_patch, (uintptr_t**)&verify_rif_top_part_orig);
if(res == 0)
inlineHook((uintptr_t)verify_rif_top_part);
return 0;
}