diff --git a/CMakeLists.txt b/app/CMakeLists.txt
similarity index 96%
rename from CMakeLists.txt
rename to app/CMakeLists.txt
index 4c06786..aebf209 100644
--- a/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -8,12 +8,12 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
endif()
endif()
-project(trophy_mount)
+project(TrophaxSE)
include("${VITASDK}/share/vita.cmake" REQUIRED)
set(VITA_APP_NAME ${PROJECT_NAME})
-set(VITA_TITLEID "TROPMOUNT")
+set(VITA_TITLEID "TROPHAXSE")
set(VITA_VERSION "01.00")
@@ -65,4 +65,4 @@ vita_create_vpk(${PROJECT_NAME}.vpk ${VITA_TITLEID} eboot.bin
#FILE sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png
#FILE sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
#FILE sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml
-)
+)
\ No newline at end of file
diff --git a/debugScreen.h b/app/src/debugScreen.h
similarity index 100%
rename from debugScreen.h
rename to app/src/debugScreen.h
diff --git a/debugScreenFont.c b/app/src/debugScreenFont.c
similarity index 100%
rename from debugScreenFont.c
rename to app/src/debugScreenFont.c
diff --git a/main.c b/app/src/main.c
similarity index 100%
rename from main.c
rename to app/src/main.c
diff --git a/np.h b/app/src/np.h
similarity index 100%
rename from np.h
rename to app/src/np.h
diff --git a/build.sh b/build.sh
new file mode 100644
index 0000000..0ca0eab
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,20 @@
+export VITASDK=/usr/local/vitasdk
+export PATH=$VITASDK/bin:$PATH
+
+
+cd kernel/
+cmake .
+make install
+
+
+
+cd ../user/
+cmake .
+make install
+
+
+cd ../app/
+mv ../kernel/kernel.skprx kernel.skprx
+mv ../user/user.suprx user.suprx
+cmake .
+make
\ No newline at end of file
diff --git a/kernel.skprx b/kernel.skprx
deleted file mode 100644
index 012b4bd..0000000
Binary files a/kernel.skprx and /dev/null differ
diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt
new file mode 100644
index 0000000..7efc585
--- /dev/null
+++ b/kernel/CMakeLists.txt
@@ -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(SceAppMgrKernel2)
+include("${VITASDK}/share/vita.cmake" REQUIRED)
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -nostdlib")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
+
+add_executable(${PROJECT_NAME}
+ src/main.c
+)
+
+target_link_libraries(${PROJECT_NAME}
+ SceIofilemgrForDriver_stub
+ SceSysclibForDriver_stub
+ SceSysmemForDriver_stub
+ SceModulemgrForDriver_stub
+ SceThreadmgrForDriver_stub
+ SceProcessmgrForDriver_stub
+ #SceNpDrmForDriver_stub
+ taihenForKernel_stub
+ taihenModuleUtils_stub
+)
+
+vita_create_self(kernel.skprx ${PROJECT_NAME} CONFIG exports.yml UNSAFE)
+
+vita_create_stubs(stubs ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/exports.yml KERNEL)
+
+install(DIRECTORY ${CMAKE_BINARY_DIR}/stubs/
+ DESTINATION lib
+ FILES_MATCHING PATTERN "*.a"
+)
+
+install(FILES src/appmgr_kernel.h
+ DESTINATION include
+)
diff --git a/kernel/src/appmgr_kernel.h b/kernel/src/appmgr_kernel.h
new file mode 100644
index 0000000..1ae8b09
--- /dev/null
+++ b/kernel/src/appmgr_kernel.h
@@ -0,0 +1,17 @@
+
+#ifndef __SCEAPPMGR_KERNEL_H__
+#define __SCEAPPMGR_KERNEL_H__
+
+typedef struct {
+ int id;
+ const char *process_titleid;
+ const char *path;
+ const char *desired_mount_point;
+ const void *klicensee;
+ char *mount_point;
+} SceAppMgrMountIdArgs;
+
+
+int sceAppMgrKernelMountById(SceAppMgrMountIdArgs *args);
+
+#endif
\ No newline at end of file
diff --git a/kernel/src/main.c b/kernel/src/main.c
new file mode 100644
index 0000000..f3e6455
--- /dev/null
+++ b/kernel/src/main.c
@@ -0,0 +1,141 @@
+/*
+ VitaShell
+ Copyright (C) 2015-2016, TheFloW
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+
+#include "appmgr_kernel.h"
+
+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);
+
+void *(* sceAppMgrFindProcessInfoByPid)(void *data, SceUID pid);
+int (* sceAppMgrMountById)(SceUID pid, void *info, int id, const char *titleid, const char *path, const char *desired_mount_point, const void *klicensee, char *mount_point);
+int (* _ksceKernelGetModuleInfo)(SceUID pid, SceUID modid, SceKernelModuleInfo *info);
+
+tai_module_info_t tai_info;
+
+int _sceAppMgrKernelMountById(SceAppMgrMountIdArgs *args) {
+ int res;
+
+ res = module_get_export_func(KERNEL_PID, "SceKernelModulemgr", 0xC445FA63, 0xD269F915, (uintptr_t *)&_ksceKernelGetModuleInfo);
+ if (res < 0)
+ res = module_get_export_func(KERNEL_PID, "SceKernelModulemgr", 0x92C9FFC2, 0xDAA90093, (uintptr_t *)&_ksceKernelGetModuleInfo);
+ if (res < 0)
+ return res;
+
+ // Module info
+ SceKernelModuleInfo mod_info;
+ mod_info.size = sizeof(SceKernelModuleInfo);
+ res = _ksceKernelGetModuleInfo(KERNEL_PID, tai_info.modid, &mod_info);
+ if (res < 0)
+ return res;
+
+ uint32_t appmgr_data_addr = (uint32_t)mod_info.segments[1].vaddr;
+
+ SceUID process_id = ksceKernelGetProcessId();
+
+ void *info = sceAppMgrFindProcessInfoByPid((void *)(appmgr_data_addr + 0x500), process_id);
+ if (!info)
+ return -1;
+
+ char process_titleid[12];
+ char path[256];
+ char desired_mount_point[16];
+ char mount_point[16];
+ char klicensee[16];
+
+ memset(mount_point, 0, sizeof(mount_point));
+
+ if (args->process_titleid)
+ ksceKernelStrncpyUserToKernel(process_titleid, (uintptr_t)args->process_titleid, 11);
+ if (args->path)
+ ksceKernelStrncpyUserToKernel(path, (uintptr_t)args->path, 255);
+ if (args->desired_mount_point)
+ ksceKernelStrncpyUserToKernel(desired_mount_point, (uintptr_t)args->desired_mount_point, 15);
+ if (args->klicensee)
+ ksceKernelMemcpyUserToKernel(klicensee, (uintptr_t)args->klicensee, 0x10);
+
+ res = sceAppMgrMountById(process_id, info + 0x580, args->id, args->process_titleid ? process_titleid : NULL, args->path ? path : NULL,
+ args->desired_mount_point ? desired_mount_point : NULL, args->klicensee ? klicensee : NULL, mount_point);
+
+ if (args->mount_point)
+ ksceKernelStrncpyKernelToUser((uintptr_t)args->mount_point, mount_point, 15);
+
+ return res;
+}
+
+int sceAppMgrKernelMountById(SceAppMgrMountIdArgs *args) {
+ uint32_t state;
+ ENTER_SYSCALL(state);
+
+ SceAppMgrMountIdArgs k_args;
+ ksceKernelMemcpyUserToKernel(&k_args, (uintptr_t)args, sizeof(SceAppMgrMountIdArgs));
+
+ int res = ksceKernelRunWithStack(0x2000, (void *)_sceAppMgrKernelMountById, &k_args);
+
+ EXIT_SYSCALL(state);
+ return res;
+}
+
+
+void _start() __attribute__ ((weak, alias("module_start")));
+int module_start(SceSize args, void *argp) {
+
+
+
+ // Get tai module info
+
+ tai_info.size = sizeof(tai_module_info_t);
+ if (taiGetModuleInfoForKernel(KERNEL_PID, "SceAppMgr", &tai_info) < 0)
+ return SCE_KERNEL_START_SUCCESS;
+
+ switch (tai_info.module_nid) {
+ case 0xDBB29DB7: // 3.60 retail
+ module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x2DE1, (uintptr_t *)&sceAppMgrFindProcessInfoByPid);
+ module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x19B51, (uintptr_t *)&sceAppMgrMountById);
+ break;
+
+ case 0x1C9879D6: // 3.65 retail
+ module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x2DE1, (uintptr_t *)&sceAppMgrFindProcessInfoByPid);
+ module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x19E61, (uintptr_t *)&sceAppMgrMountById);
+ break;
+
+ case 0x54E2E984: // 3.67 retail
+ module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x2DE1, (uintptr_t *)&sceAppMgrFindProcessInfoByPid);
+ module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x19E6D, (uintptr_t *)&sceAppMgrMountById);
+ break;
+ }
+
+
+ return SCE_KERNEL_START_SUCCESS;
+}
+
+int module_stop(SceSize args, void *argp) {
+
+ return SCE_KERNEL_STOP_SUCCESS;
+}
diff --git a/user.suprx b/user.suprx
deleted file mode 100644
index 7a1444c..0000000
Binary files a/user.suprx and /dev/null differ
diff --git a/user/CMakeLists.txt b/user/CMakeLists.txt
new file mode 100644
index 0000000..21a2e76
--- /dev/null
+++ b/user/CMakeLists.txt
@@ -0,0 +1,39 @@
+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(SceAppMgrUser)
+include("${VITASDK}/share/vita.cmake" REQUIRED)
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -nostdlib")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
+
+add_executable(${PROJECT_NAME}
+ src/main.c
+)
+
+target_link_libraries(${PROJECT_NAME}
+ SceLibKernel_stub
+ SceIofilemgr_stub
+ SceAppMgrKernel2_stub
+)
+
+vita_create_self(user.suprx ${PROJECT_NAME} CONFIG exports.yml UNSAFE)
+
+vita_create_stubs(stubs ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/exports.yml)
+
+install(DIRECTORY ${CMAKE_BINARY_DIR}/stubs/
+ DESTINATION lib
+ FILES_MATCHING PATTERN "*.a"
+)
+
+install(FILES src/appmgr_user.h
+ DESTINATION include
+)
+
diff --git a/user/src/appmgr_user.h b/user/src/appmgr_user.h
new file mode 100644
index 0000000..7f9b9bc
--- /dev/null
+++ b/user/src/appmgr_user.h
@@ -0,0 +1,3 @@
+#include
+
+int sceAppMgrUserMountById(SceAppMgrMountIdArgs *args);
diff --git a/user/src/main.c b/user/src/main.c
new file mode 100644
index 0000000..b442748
--- /dev/null
+++ b/user/src/main.c
@@ -0,0 +1,36 @@
+/*
+ VitaShell
+ Copyright (C) 2015-2016, TheFloW
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+
+#include
+#include "appmgr_user.h"
+
+
+int sceAppMgrUserMountById(SceAppMgrMountIdArgs *args) {
+ return sceAppMgrKernelMountById(args);
+}
+
+
+void _start() __attribute__ ((weak, alias("module_start")));
+int module_start(SceSize args, void *argp) {
+ return SCE_KERNEL_START_SUCCESS;
+}
+
+int module_stop(SceSize args, void *argp) {
+ return SCE_KERNEL_STOP_SUCCESS;
+}