-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
792c8e1
commit c165287
Showing
3 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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(LowMemMode) | ||
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(LowMemMode | ||
LowMemMode.c | ||
) | ||
|
||
target_link_libraries(LowMemMode | ||
taihen_stub | ||
SceLibKernel_stub | ||
SceKernelModulemgr_stub | ||
) | ||
|
||
set_target_properties(LowMemMode | ||
PROPERTIES LINK_FLAGS "-nostdlib" | ||
) | ||
|
||
vita_create_self(LowMemMode.suprx LowMemMode | ||
CONFIG ${CMAKE_SOURCE_DIR}/LowMemMode.yml | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include <taihen.h> | ||
#include <vitasdk.h> | ||
#include <psp2/kernel/modulemgr.h> | ||
|
||
static SceUID g_hooks[1]; | ||
uint32_t text_addr, text_size, data_addr, data_size; | ||
|
||
void _start() __attribute__ ((weak, alias ("module_start"))); | ||
|
||
static tai_hook_ref_t ref_hook0; | ||
static int sub_8126A8CA_patched(int a1, int a2) | ||
{ | ||
//Returns > 1 if normal app | ||
//Returns 0 if NPXS10015 SceSettings (Launch in PHYMEMLOW mode) | ||
//??? Returns < 0 if NPXS10104 SceMiniSettings (Launch in special PHYMEMLOW mode) ??? | ||
return 0; | ||
} | ||
|
||
int module_start(SceSize argc, const void *args) | ||
{ | ||
tai_module_info_t info; | ||
info.size = sizeof(info); | ||
int ret = taiGetModuleInfo("SceShell", &info); | ||
if (ret < 0) { | ||
return SCE_KERNEL_START_FAILED; | ||
} | ||
|
||
// Modified from TheOfficialFloW/Adrenaline | ||
SceKernelModuleInfo mod_info; | ||
mod_info.size = sizeof(SceKernelModuleInfo); | ||
ret = sceKernelGetModuleInfo(info.modid, &mod_info); | ||
if (ret < 0) { | ||
return SCE_KERNEL_START_FAILED; | ||
} | ||
text_addr = (uint32_t)mod_info.segments[0].vaddr; | ||
text_size = (uint32_t)mod_info.segments[0].memsz; | ||
data_addr = (uint32_t)mod_info.segments[1].vaddr; | ||
data_size = (uint32_t)mod_info.segments[1].memsz; | ||
|
||
int offset; | ||
|
||
switch (info.module_nid) { | ||
|
||
case 0x0552F692: // retail 3.60 SceShell | ||
offset = 0x27246E; | ||
break; | ||
|
||
case 0x5549BF1F: // retail 3.65 SceShell | ||
case 0x34B4D82E: // retail 3.67 SceShell | ||
case 0x12DAC0F3: // retail 3.68 SceShell | ||
offset = 0x272526; | ||
break; | ||
|
||
//For testing | ||
case 0x587F9CED: // PTEL 3.65 SceShell | ||
offset = 0x26A8CA; | ||
break; | ||
|
||
default: | ||
return SCE_KERNEL_START_FAILED; | ||
} | ||
g_hooks[0] = taiHookFunctionOffset(&ref_hook0, | ||
info.modid, | ||
0, // segidx | ||
offset, // offset | ||
1, // thumb | ||
sub_8126A8CA_patched); | ||
|
||
return SCE_KERNEL_START_SUCCESS; | ||
} | ||
|
||
int module_stop(SceSize argc, const void *args) { | ||
if (g_hooks[0] >= 0) taiHookRelease(g_hooks[0], ref_hook0); | ||
return SCE_KERNEL_STOP_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
LowMemMode: | ||
attributes: 0 | ||
version: | ||
major: 1 | ||
minor: 1 | ||
main: | ||
start: module_start | ||
stop: module_stop |