From f820c5ea02336444eca2122b832561b8e2948a92 Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 14 Feb 2023 22:59:51 -0700 Subject: [PATCH] Add daemon loader --- Playstation/OrbisLibAPI/Version.h | 22 ++++---- Playstation/OrbisLibGeneralHelper/build.bat | 2 +- Playstation/OrbisSuite/build.bat | 2 +- Playstation/OrbisSuite/main.cpp | 44 +++++++++++++--- Playstation/OrbisToolbox-2.0/Menu.cpp | 11 +++- .../OrbisToolbox-2.0.vcxproj.filters | 4 -- Playstation/OrbisToolbox-2.0/Utilities.cpp | 52 +++++++++++++++---- Playstation/OrbisToolbox-2.0/Utilities.h | 4 +- Playstation/OrbisToolbox-2.0/Version.h | 22 ++++---- Playstation/OrbisToolbox-2.0/build.bat | 4 +- .../OrbisToolbox-2.0/orbis_toolbox.xml | 8 ++- 11 files changed, 126 insertions(+), 49 deletions(-) diff --git a/Playstation/OrbisLibAPI/Version.h b/Playstation/OrbisLibAPI/Version.h index 4c1fa46..0c023ef 100644 --- a/Playstation/OrbisLibAPI/Version.h +++ b/Playstation/OrbisLibAPI/Version.h @@ -1,11 +1,11 @@ -#pragma once -#define ORBISLIB_MAJOR 3 -#define ORBISLIB_MINOR 0 -#define ORBISLIB_BUILDVERSION 1070 -#define stringify(a) stringify_(a) -#define stringify_(a) #a -#if defined(_DEBUG) -#define ORBISLIB_BUILDSTRING ("[OrbisLib Daemon " stringify(ORBISLIB_MAJOR) "." stringify(ORBISLIB_MINOR) "] Dev Build " stringify(ORBISLIB_BUILDVERSION) " " __DATE__ " " __TIME__) -#else -#define ORBISLIB_BUILDSTRING ("[OrbisLib Daemon " stringify(ORBISLIB_MAJOR) "." stringify(ORBISLIB_MINOR) "] Build " stringify(ORBISLIB_BUILDVERSION) " " __DATE__ " " __TIME__) -#endif +#pragma once +#define ORBISLIB_MAJOR 3 +#define ORBISLIB_MINOR 0 +#define ORBISLIB_BUILDVERSION 1071 +#define stringify(a) stringify_(a) +#define stringify_(a) #a +#if defined(_DEBUG) +#define ORBISLIB_BUILDSTRING ("[OrbisLib Daemon " stringify(ORBISLIB_MAJOR) "." stringify(ORBISLIB_MINOR) "] Dev Build " stringify(ORBISLIB_BUILDVERSION) " " __DATE__ " " __TIME__) +#else +#define ORBISLIB_BUILDSTRING ("[OrbisLib Daemon " stringify(ORBISLIB_MAJOR) "." stringify(ORBISLIB_MINOR) "] Build " stringify(ORBISLIB_BUILDVERSION) " " __DATE__ " " __TIME__) +#endif diff --git a/Playstation/OrbisLibGeneralHelper/build.bat b/Playstation/OrbisLibGeneralHelper/build.bat index e27ebeb..3357b63 100644 --- a/Playstation/OrbisLibGeneralHelper/build.bat +++ b/Playstation/OrbisLibGeneralHelper/build.bat @@ -48,7 +48,7 @@ copy "%outputPrx%" "%outputPath%\Playstation\Build\pkg\Orbis Suite\%targetname%. del "%outputPrx%" REM Generate the script. Will overwrite any existing temp.txt -echo open 1.1.0.14 2121> temp.txt +echo open 1.1.0.15 2121> temp.txt echo anonymous>> temp.txt echo anonymous>> temp.txt echo cd "/data/Orbis Suite/">> temp.txt diff --git a/Playstation/OrbisSuite/build.bat b/Playstation/OrbisSuite/build.bat index d274287..27a3311 100644 --- a/Playstation/OrbisSuite/build.bat +++ b/Playstation/OrbisSuite/build.bat @@ -1,7 +1,7 @@ SETLOCAL EnableDelayedExpansion Rem Libraries to link in -set libraries=-lc++ -lc -lSceSysModule -lkernel -lSceVideoOut -lSceSystemService -lSceSysCore -lSceSystemStateMgr -lSceNet -lScePad -lSceUserService -lSceRegMgr -lSceFreeType -lSceMsgDialog -lSceCommonDialog -lGoldHEN_Hook +set libraries=-lc++ -lc -lSceSysModule -lkernel -lSceVideoOut -lSceSystemService -lSceSysCore -lSceSystemStateMgr -lSceNet -lScePad -lSceUserService -lSceRegMgr -lSceFreeType -lSceMsgDialog -lSceCommonDialog -lGoldHEN_Hook -lSceLncUtil Rem Read the script arguments into local vars set intdir=%1 diff --git a/Playstation/OrbisSuite/main.cpp b/Playstation/OrbisSuite/main.cpp index fae4115..fbfaa3d 100644 --- a/Playstation/OrbisSuite/main.cpp +++ b/Playstation/OrbisSuite/main.cpp @@ -1,5 +1,10 @@ #include "Common.h" #include "GoldHEN.h" +#include +#include +#include + +#define DEBUG int main() { @@ -32,14 +37,41 @@ int main() mount_large_fs("/dev/da0x4.crypt", "/system", "exfatfs", "511", MNT_UPDATE); // Install all the things! :D - //InstallDaemon("ORBS30000"); // Orbis Lib - //InstallOrbisToolbox(); - //InstallOrbisSuite(); + InstallDaemon("ORBS30000"); // Orbis Lib + InstallOrbisToolbox(); + InstallOrbisSuite(); + + // Start the API. + auto appId = sceLncUtilGetAppId("ORBS30000"); + if (appId) + { +#ifdef DEBUG + sceLncUtilKillApp(appId); +#else + sceSystemServiceLoadExec("exit", 0); + return 0; +#endif + } + + LaunchAppParam appParam; + appParam.size = sizeof(LaunchAppParam); + sceUserServiceGetForegroundUser(&appParam.userId); + appParam.enableCrashReport = 0; + appParam.checkFlag = 0; + appParam.appAttr = 0; + + auto res = sceLncUtilLaunchApp("ORBS30000", nullptr, &appParam); + +#ifdef DEBUG + if (res != 0) + { + klog("Failed to load Daemon.\n"); + } +#endif // DEBUG //TODO: use IPC to see if prx is already loaded. - // Use GoldHEN SDK to load PRX to SceShellUI. - /*auto Handle = sys_sdk_proc_prx_load("SceShellUI", "/user/data/Orbis Toolbox/OrbisToolbox-2.0.sprx"); + auto Handle = sys_sdk_proc_prx_load("SceShellUI", "/user/data/Orbis Toolbox/OrbisToolbox-2.0.sprx"); if (Handle > 0) klog("Orbis Toolbox loaded! %d\n", Handle); @@ -47,7 +79,7 @@ int main() { klog("error: %d\n", Handle); Notify("Failed to load Orbis Toolbox!"); - }*/ + } sceSystemServiceLoadExec("exit", 0); diff --git a/Playstation/OrbisToolbox-2.0/Menu.cpp b/Playstation/OrbisToolbox-2.0/Menu.cpp index 3faa4e9..5905887 100644 --- a/Playstation/OrbisToolbox-2.0/Menu.cpp +++ b/Playstation/OrbisToolbox-2.0/Menu.cpp @@ -76,7 +76,7 @@ void Menu::Init() End: free(Dent_Buffer); - }); + })->Visible = false; Add_Option("id_option_daemon_refresh", []() -> void { @@ -126,7 +126,7 @@ void Menu::Init() End: free(Dent_Buffer); - }); + })->Visible = false; // ShellUI Plugin Manager Add_Option("id_plugins")->Visible = false; @@ -162,6 +162,8 @@ void Menu::Init() Add_Option("id_system_disp_devkit_panel", &Debug_Feature::DevkitPanel::ShowPanel, Type_Boolean, Debug_Feature::DevkitPanel::Update); Add_Option("id_system_disp_debug_settings_panel", &Debug_Feature::Custom_Content::Show_Debug_Settings, Type_Boolean, UI::Utilities::ReloadItemList); Add_Option("id_system_disp_app_home_panel", &Debug_Feature::Custom_Content::Show_App_Home, Type_Boolean, UI::Utilities::ReloadItemList); + Add_Option("id_mount_system_rw", []() -> void { mount_large_fs("/dev/da0x4.crypt", "/system", "exfatfs", "511", MNT_UPDATE); Notify("/system mounted as R/W."); }); + Add_Option("id_disable_system_updates", []() -> void { DisableUpdates(); Notify("System updates are disabled/blocked.\nMake sure to do this after every database rebuild just in case."); }); //Debug Overlay Add_Option("id_overlay_dbg", &Build_Overlay::Draw, Type_Boolean, Build_Overlay::Update); @@ -199,7 +201,12 @@ void Menu::Init() }); Add_Option("id_save_settings", []() -> void { Config::Write(SETTIN_DIR) ? Notify("Orbis Toolbox: Saved Settings Sucessfully!") : Notify("Orbis Toolbox: Failed to Save Settings..."); }); + + // Orbis Suite Debug + Add_Option("orbis_debug", []() -> void + { + })->Visible = false; Add_Option("id_orbis_api", []() -> void { }); diff --git a/Playstation/OrbisToolbox-2.0/OrbisToolbox-2.0.vcxproj.filters b/Playstation/OrbisToolbox-2.0/OrbisToolbox-2.0.vcxproj.filters index 84bfded..9bbf8d0 100644 --- a/Playstation/OrbisToolbox-2.0/OrbisToolbox-2.0.vcxproj.filters +++ b/Playstation/OrbisToolbox-2.0/OrbisToolbox-2.0.vcxproj.filters @@ -9,10 +9,6 @@ {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - {a1e7d8c0-9965-4dae-9e21-fec87fa057a9} diff --git a/Playstation/OrbisToolbox-2.0/Utilities.cpp b/Playstation/OrbisToolbox-2.0/Utilities.cpp index 30c9d8e..597c7c7 100644 --- a/Playstation/OrbisToolbox-2.0/Utilities.cpp +++ b/Playstation/OrbisToolbox-2.0/Utilities.cpp @@ -62,21 +62,14 @@ void Notify_Custom(const char* IconURI, const char* MessageFMT, ...) // I found some clues on how to build the buffer. } -struct Myiovec -{ - void* iov_base; - size_t iov_len; -}; - -void build_iovec(Myiovec** iov, int* iovlen, const char* name, const void* val, size_t len) -{ +static void build_iovec(iovec** iov, int* iovlen, const char* name, const void* val, size_t len) { int i; if (*iovlen < 0) return; i = *iovlen; - *iov = (Myiovec*)realloc(*iov, sizeof **iov * (i + 2)); + *iov = (iovec*)realloc(*iov, sizeof * *iov * (i + 2)); if (*iov == NULL) { *iovlen = -1; return; @@ -98,6 +91,47 @@ void build_iovec(Myiovec** iov, int* iovlen, const char* name, const void* val, *iovlen = ++i; } +int nmount(struct iovec* iov, uint32_t niov, int flags) +{ + return syscall(378, iov, niov, flags); +} + +int unmount(const char* dir, int flags) +{ + return syscall(22, dir, flags); +} + +int mount_large_fs(const char* device, const char* mountpoint, const char* fstype, const char* mode, unsigned int flags) +{ + struct iovec* iov = NULL; + int iovlen = 0; + + build_iovec(&iov, &iovlen, "fstype", fstype, -1); + build_iovec(&iov, &iovlen, "fspath", mountpoint, -1); + build_iovec(&iov, &iovlen, "from", device, -1); + build_iovec(&iov, &iovlen, "large", "yes", -1); + build_iovec(&iov, &iovlen, "timezone", "static", -1); + build_iovec(&iov, &iovlen, "async", "", -1); + build_iovec(&iov, &iovlen, "ignoreacl", "", -1); + + if (mode) { + build_iovec(&iov, &iovlen, "dirmask", mode, -1); + build_iovec(&iov, &iovlen, "mask", mode, -1); + } + + return nmount(iov, iovlen, flags); +} + +void DisableUpdates() +{ + sceKernelUnlink("/update/PS4UPDATE.PUP.net.temp"); + sceKernelRmdir("/update/PS4UPDATE.PUP.net.temp"); + sceKernelMkdir("/update/PS4UPDATE.PUP.net.temp", 777); + + sceKernelUnlink("/update/PS4UPDATE.PUP"); + sceKernelRmdir("/update/PS4UPDATE.PUP"); + sceKernelMkdir("/update/PS4UPDATE.PUP", 777); +} /* diff --git a/Playstation/OrbisToolbox-2.0/Utilities.h b/Playstation/OrbisToolbox-2.0/Utilities.h index 3c5ffae..c2699f3 100644 --- a/Playstation/OrbisToolbox-2.0/Utilities.h +++ b/Playstation/OrbisToolbox-2.0/Utilities.h @@ -14,12 +14,14 @@ typedef unsigned char vm_prot_t; /* protection codes */ #define VM_PROT_RW (VM_PROT_READ|VM_PROT_WRITE) #define VM_PROT_DEFAULT VM_PROT_ALL -#define MNT_UPDATE 0x0000000000010000ULL /* not real mount, just update */ +#define MNT_UPDATE 0x00010000 /* not real mount, just update */ void klog(const char* fmt, ...); void Notify(const char* MessageFMT, ...); void Notify_Custom(const char* IconURI, const char* MessageFMT, ...); +int mount_large_fs(const char* device, const char* mountpoint, const char* fstype, const char* mode, unsigned int flags); +void DisableUpdates(); void Get_Page_Table_Stats(int vm, int type, int* Used, int* Free, int* Total); bool SockSendInt(OrbisNetId Sock, int val); diff --git a/Playstation/OrbisToolbox-2.0/Version.h b/Playstation/OrbisToolbox-2.0/Version.h index 1461c20..7c43139 100644 --- a/Playstation/OrbisToolbox-2.0/Version.h +++ b/Playstation/OrbisToolbox-2.0/Version.h @@ -1,11 +1,11 @@ -#pragma once -#define ORBIS_TOOLBOX_MAJOR 2 -#define ORBIS_TOOLBOX_MINOR 0 -#define ORBIS_TOOLBOX_BUILDVERSION 342 -#define stringify(a) stringify_(a) -#define stringify_(a) #a -#if defined(ORBIS_TOOLBOX_DEBUG) -#define ORBIS_TOOLBOX_BUILDSTRING ("[Orbis Toolbox " stringify(ORBIS_TOOLBOX_MAJOR) "." stringify(ORBIS_TOOLBOX_MINOR) "] Dev Build " stringify(ORBIS_TOOLBOX_BUILDVERSION) " " __DATE__ " " __TIME__) -#else -#define ORBIS_TOOLBOX_BUILDSTRING ("[Orbis Toolbox " stringify(ORBIS_TOOLBOX_MAJOR) "." stringify(ORBIS_TOOLBOX_MINOR) "] Build " stringify(ORBIS_TOOLBOX_BUILDVERSION) " " __DATE__ " " __TIME__) -#endif +#pragma once +#define ORBIS_TOOLBOX_MAJOR 2 +#define ORBIS_TOOLBOX_MINOR 0 +#define ORBIS_TOOLBOX_BUILDVERSION 345 +#define stringify(a) stringify_(a) +#define stringify_(a) #a +#if defined(ORBIS_TOOLBOX_DEBUG) +#define ORBIS_TOOLBOX_BUILDSTRING ("[Orbis Toolbox " stringify(ORBIS_TOOLBOX_MAJOR) "." stringify(ORBIS_TOOLBOX_MINOR) "] Dev Build " stringify(ORBIS_TOOLBOX_BUILDVERSION) " " __DATE__ " " __TIME__) +#else +#define ORBIS_TOOLBOX_BUILDSTRING ("[Orbis Toolbox " stringify(ORBIS_TOOLBOX_MAJOR) "." stringify(ORBIS_TOOLBOX_MINOR) "] Build " stringify(ORBIS_TOOLBOX_BUILDVERSION) " " __DATE__ " " __TIME__) +#endif diff --git a/Playstation/OrbisToolbox-2.0/build.bat b/Playstation/OrbisToolbox-2.0/build.bat index 6622c9d..c3a9aa9 100644 --- a/Playstation/OrbisToolbox-2.0/build.bat +++ b/Playstation/OrbisToolbox-2.0/build.bat @@ -1,7 +1,7 @@ SETLOCAL EnableDelayedExpansion Rem Libraries to link in -set libraries=-lSceLibcInternal -lSceLibcInternalExt -lkernel -lmonosgen -lSceSystemService -lSceLncUtil -lSceUserService -lSceRegMgr -lSceFreeType -lSceSysCore -lSceSystemStateMgr -lSceNet +set libraries=-lc++ -lc -lSceLibcInternal -lSceLibcInternalExt -lkernel -lmonosgen -lSceSystemService -lSceLncUtil -lSceUserService -lSceRegMgr -lSceFreeType -lSceSysCore -lSceSystemStateMgr -lSceNet Rem Read the script arguments into local vars set intdir=%1 @@ -48,7 +48,7 @@ copy "%outputPrx%" "%outputPath%\Playstation\Build\pkg\Orbis Toolbox\%targetname del "%outputPrx%" REM Generate the script. Will overwrite any existing temp.txt -echo open 1.1.0.14 2121> temp.txt +echo open 1.1.0.15 2121> temp.txt echo anonymous>> temp.txt echo anonymous>> temp.txt echo cd "/data/Orbis Toolbox/">> temp.txt diff --git a/Playstation/OrbisToolbox-2.0/orbis_toolbox.xml b/Playstation/OrbisToolbox-2.0/orbis_toolbox.xml index 5b3751f..1509d05 100644 --- a/Playstation/OrbisToolbox-2.0/orbis_toolbox.xml +++ b/Playstation/OrbisToolbox-2.0/orbis_toolbox.xml @@ -143,12 +143,18 @@ - + + +