From 3db707a7e7755246545ca256f96f1a8308fd3851 Mon Sep 17 00:00:00 2001 From: SilicaAndPina Date: Wed, 18 Dec 2019 15:39:19 +1300 Subject: [PATCH] Upload src code. --- CMakeLists.txt | 47 +++++++++++++++++++++ DolcePolce.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++ DolcePolce.yml | 8 ++++ 3 files changed, 166 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 DolcePolce.c create mode 100644 DolcePolce.yml diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..14652d3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 2.8) + +if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) + if(DEFINED ENV{VITASDK}) + set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file") + else() + message(FATAL_ERROR "Please define VITASDK to point to your SDK path!") + endif() +endif() + +project(DolcePolce) +include("${VITASDK}/share/vita.cmake" REQUIRED) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -std=gnu99") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions") + +include_directories( +) + +link_directories( + ${CMAKE_CURRENT_BINARY_DIR} +) + +if (NOT ${RELEASE}) + add_definitions(-DENABLE_LOGGING) +endif() + +add_executable(DolcePolce + DolcePolce.c +) + +target_link_libraries(DolcePolce + taihen_stub + SceLibKernel_stub + SceAppMgr_stub + SceLibc_stub + SceVshBridge_stub + SceIofilemgr_stub +) + +set_target_properties(DolcePolce + PROPERTIES LINK_FLAGS "-nostdlib" +) + +vita_create_self(DolcePolce.suprx DolcePolce + CONFIG ${CMAKE_SOURCE_DIR}/DolcePolce.yml +) \ No newline at end of file diff --git a/DolcePolce.c b/DolcePolce.c new file mode 100644 index 0000000..df26260 --- /dev/null +++ b/DolcePolce.c @@ -0,0 +1,111 @@ + +#include +#include +#include +#include + +static SceUID check_psm_allowed_hook = -1; +static tai_hook_ref_t check_psm_allowed_hook_ref; + +static SceUID check_vita_allowed_hook = -1; +static tai_hook_ref_t check_vita_allowed_hook_ref; + +static SceUID check_pspemu_allowed_hook = -1; +static tai_hook_ref_t check_pspemu_allowed_hook_ref; + + +static int check_psm_allowed(char **game, int *is_allowed, int *unk) { + int ret = TAI_CONTINUE(int, check_psm_allowed_hook_ref,game, is_allowed, unk); + sceClibPrintf("[DolcePolce] check_psm_allowed(%s,%x,%x); ret = %x!\n",*game, *is_allowed, *unk, ret); + + if(*is_allowed <= 0) + { + sceClibPrintf("[DolcePolce] check_psm_allowed: %s is blacklisted... launching anyway!\n",*game); + *is_allowed = 1; + } + + return ret; +} + +static int check_vita_allowed(char **game, int *is_allowed, int *unk) { + int ret = TAI_CONTINUE(int, check_vita_allowed_hook_ref, game, is_allowed, unk); + sceClibPrintf("[DolcePolce] check_vita_allowed(%s,%x,%x); ret = %x!\n",*game, *is_allowed, *unk, ret); + + if(*is_allowed <= 0) + { + sceClibPrintf("[DolcePolce] check_vita_allowed: %s is blacklisted... launching anyway!\n",*game); + *is_allowed = 1; + } + + return ret; +} + +static int check_pspemu_allowed(char **game, int *is_allowed, int *unk) { + int ret = TAI_CONTINUE(int, check_pspemu_allowed_hook_ref, game, is_allowed, unk); + sceClibPrintf("[DolcePolce] check_pspemu_allowed(%s,%x,%x); ret = %x!\n",*game, *is_allowed, *unk, ret); + + if(*is_allowed <= 0) + { + sceClibPrintf("[DolcePolce] check_pspemu_allowed %s is blacklisted... launching anyway!\n",*game); + *is_allowed = 1; + } + + return ret; +} + + + + +void _start() __attribute__ ((weak, alias ("module_start"))); +int module_start(SceSize argc, const void *args) { + + /* + * Read Fw Version + */ + + SceKernelFwInfo fwInfo; + fwInfo.size = sizeof(SceKernelFwInfo); + _vshSblGetSystemSwVersion(&fwInfo); + int fw = fwInfo.version; + + sceClibPrintf("[DolcePolce] Loaded! running on FW: %x\n",fw); + + /* + * Get SceShell Info + */ + tai_module_info_t tai_info; + tai_info.size = sizeof(tai_module_info_t); + taiGetModuleInfo("SceShell", &tai_info); + + if(fw >= 0x3650000) + { + check_psm_allowed_hook = taiHookFunctionOffset(&check_psm_allowed_hook_ref, tai_info.modid,0,0x2E928,1, check_psm_allowed); + check_vita_allowed_hook = taiHookFunctionOffset(&check_vita_allowed_hook_ref, tai_info.modid,0,0x2E480,1, check_vita_allowed); + check_pspemu_allowed_hook = taiHookFunctionOffset(&check_pspemu_allowed_hook_ref, tai_info.modid,0,0x2E78C,1, check_pspemu_allowed); + } + else + { + check_psm_allowed_hook = taiHookFunctionOffset(&check_psm_allowed_hook_ref, tai_info.modid,0,0x2E8D0,1, check_psm_allowed); + check_vita_allowed_hook = taiHookFunctionOffset(&check_vita_allowed_hook_ref, tai_info.modid,0,0x2E428,1, check_vita_allowed); + check_pspemu_allowed_hook = taiHookFunctionOffset(&check_pspemu_allowed_hook_ref, tai_info.modid,0,0x2E734,1, check_pspemu_allowed); + } + + + sceClibPrintf("[DolcePolce] check_psm_allowed: %x %x\n",check_psm_allowed_hook,check_psm_allowed_hook_ref); + sceClibPrintf("[DolcePolce] check_vita_allowed: %x %x\n",check_vita_allowed_hook,check_vita_allowed_hook_ref); + sceClibPrintf("[DolcePolce] check_pspemu_allowed: %x %x\n",check_pspemu_allowed_hook,check_pspemu_allowed_hook_ref); + + return SCE_KERNEL_START_SUCCESS; + +} + +int module_stop(SceSize argc, const void *args) { + + // release hooks + if (check_psm_allowed_hook >= 0) taiHookRelease(check_psm_allowed_hook, check_psm_allowed_hook_ref); + if (check_vita_allowed_hook >= 0) taiHookRelease(check_vita_allowed_hook, check_vita_allowed_hook_ref); + if (check_pspemu_allowed_hook >= 0) taiHookRelease(check_pspemu_allowed_hook, check_pspemu_allowed_hook_ref); + + + return SCE_KERNEL_STOP_SUCCESS; +} diff --git a/DolcePolce.yml b/DolcePolce.yml new file mode 100644 index 0000000..3332dfd --- /dev/null +++ b/DolcePolce.yml @@ -0,0 +1,8 @@ +MakePsmGreatAgain: + attributes: 0 + version: + major: 1 + minor: 1 + main: + start: module_start + stop: module_stop