diff --git a/Playstation/Kernel/Kernel/source/OrbisLib/KDriver/Proc.cpp b/Playstation/Kernel/Kernel/source/OrbisLib/KDriver/Proc.cpp index 23b8413..076b945 100644 --- a/Playstation/Kernel/Kernel/source/OrbisLib/KDriver/Proc.cpp +++ b/Playstation/Kernel/Kernel/source/OrbisLib/KDriver/Proc.cpp @@ -254,7 +254,6 @@ int Proc::ProcessSPRX(caddr_t data) auto Input = (KDriver_ProcSPRX*)data; - klog("DoSwitch"); switch (Input->CallType) { case 0: diff --git a/Playstation/OrbisSuite/main.cpp b/Playstation/OrbisSuite/main.cpp index e2175c8..19bd5cd 100644 --- a/Playstation/OrbisSuite/main.cpp +++ b/Playstation/OrbisSuite/main.cpp @@ -67,7 +67,6 @@ int main() } klog("[Orbis Suite] Launching Toolbox!!\n"); - // Init Orbis Toolbox Handle = OrbisDriver::LoadSPRX("SceShellUI", "/data/Orbis Toolbox/OrbisToolbox-2.0.sprx"); if (Handle > 0) klog("Orbis Toolbox loaded! %d\n", Handle); @@ -82,9 +81,8 @@ int main() switch (MsgDialog::DialogResult.buttonId) { case ORBIS_MSG_DIALOG_BUTTON_ID_BUTTON1: - OrbisDriver::UnLoadSPRX("SceShellUI", "OrbisToolbox-2.0.sprx"); - - sceKernelSleep(3.0); + if (OrbisDriver::UnLoadSPRX("SceShellUI", "Orbis Toolbox-2.0.sprx") >= 0) + sceKernelSleep(2.0); if (!UnloadKernel()) { @@ -93,8 +91,9 @@ int main() break; case ORBIS_MSG_DIALOG_BUTTON_ID_BUTTON2: - OrbisDriver::UnLoadSPRX("SceShellUI", "Orbis Toolbox-2.0.sprx"); - sceKernelSleep(1.5); + if (OrbisDriver::UnLoadSPRX("SceShellUI", "Orbis Toolbox-2.0.sprx") >= 0) + sceKernelSleep(1.5); + OrbisDriver::LoadSPRX("SceShellUI", "/data/Orbis Toolbox/OrbisToolbox-2.0.sprx"); break; diff --git a/Playstation/OrbisToolbox-2.0/APIPackets.h b/Playstation/OrbisToolbox-2.0/APIPackets.h index b72a291..2b06e2b 100644 --- a/Playstation/OrbisToolbox-2.0/APIPackets.h +++ b/Playstation/OrbisToolbox-2.0/APIPackets.h @@ -8,31 +8,22 @@ enum APICommands /* ####### Proc functions ####### */ PROC_START, - API_PROC_GET_LIST, - API_PROC_ATTACH, - API_PROC_DETACH, - API_PROC_GET_CURRENT, - API_PROC_READ, - API_PROC_WRITE, - API_PROC_KILL, - API_PROC_LOAD_ELF, - API_PROC_CALL, - /* Remote Library functions */ - API_PROC_LOAD_SPRX, - API_PROC_UNLOAD_SPRX, - API_PROC_UNLOAD_SPRX_NAME, - API_PROC_RELOAD_SPRX_NAME, - API_PROC_RELOAD_SPRX_HANDLE, - API_PROC_DUMP_MODULE, - API_PROC_MODULE_LIST, + API_PROC_GET_LIST, + API_PROC_LOAD_ELF, + API_PROC_CALL, /* RPC Call. */ + PROC_END, /* ############################## */ /* ##### Debugger functions ##### */ DBG_START, - API_DBG_START, /* Debugger attach to target */ - API_DBG_STOP, /* Debugger detach from target */ + API_DBG_ATTACH, /* Debugger attach to target */ + API_DBG_DETACH, /* Debugger detach from target */ + API_DBG_GET_CURRENT, + API_DBG_READ, + API_DBG_WRITE, + API_DBG_KILL, API_DBG_BREAK, API_DBG_RESUME, API_DBG_SIGNAL, @@ -47,6 +38,12 @@ enum APICommands API_DBG_GET_DBGREG, API_DBG_SET_DBGREG, + /* Remote Library functions */ + API_DBG_LOAD_SPRX, + API_DBG_UNLOAD_SPRX, + API_DBG_RELOAD_SPRX, + API_DBG_MODULE_LIST, + /* Thread Management */ API_DBG_THREAD_LIST, API_DBG_THREAD_STOP, @@ -190,6 +187,14 @@ enum ConsoleTypes KRATOS, //0xA0 IMPOSSIBLE?? }; +struct MemoryInfo +{ + int Used; + int Free; + int Total; + float Percentage; +}; + struct TargetInfoPacket { int SDKVersion; @@ -217,7 +222,9 @@ struct TargetInfoPacket int SOCTemp; int ThreadCount; float AverageCPUUsage; - + int BusyCore; + MemoryInfo Ram; + MemoryInfo VRam; }; struct TargetNotifyPacket diff --git a/Playstation/OrbisToolbox-2.0/Debug.cpp b/Playstation/OrbisToolbox-2.0/Debug.cpp index ba4dab3..d406e85 100644 --- a/Playstation/OrbisToolbox-2.0/Debug.cpp +++ b/Playstation/OrbisToolbox-2.0/Debug.cpp @@ -3,7 +3,13 @@ void Debug::HandleAPI(OrbisNetId Sock, APIPacket* Packet) { + switch (Packet->Command) + { + default: + break; + + } } Debug::Debug() diff --git a/Playstation/OrbisToolbox-2.0/LncUtil.cpp b/Playstation/OrbisToolbox-2.0/LncUtil.cpp index 4f86f47..95e071d 100644 --- a/Playstation/OrbisToolbox-2.0/LncUtil.cpp +++ b/Playstation/OrbisToolbox-2.0/LncUtil.cpp @@ -83,7 +83,50 @@ int LncUtil::KillApp(int appId, int userId) } //static int ForceKillApp(int appId, int userId = -1); -//static int KillLocalProcess(int appId, int appLocalPid); + +int LncUtil::GetLocalProcessStatusList(LocalProcessStatus List[], unsigned int numEntries, unsigned int* outEntries) +{ + MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); + MonoClass* LocalProcessStatusClass = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil/LocalProcessStatus"); + + auto Array = Mono::New_Array(LocalProcessStatusClass, numEntries); + auto result = Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "GetLocalProcessStatusList", Array, numEntries, outEntries); + + for (int i = 0; i < *outEntries; i++) + { + List[i] = mono_array_get(Array, LocalProcessStatus, i); + } + + return result; +} + +int LncUtil::GetAppStatusListForShellUIReboot(AppStatusForShellUIReboot outStatusList[], unsigned int numEntries, unsigned int* outEntries) +{ + MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); + MonoClass* AppStatusForShellUIRebootClass = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil/AppStatusForShellUIReboot"); + + auto Array = Mono::New_Array(AppStatusForShellUIRebootClass, numEntries); + auto result = Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "GetAppStatusListForShellUIReboot", Array, numEntries, outEntries); + + for (int i = 0; i < *outEntries; i++) + { + outStatusList[i] = mono_array_get(Array, AppStatusForShellUIReboot, i); + } + + return result; +} + +int LncUtil::KillLocalProcess(int appId, int appLocalPid) +{ + MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); + return Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "KillLocalProcess", appId, appLocalPid); +} + +int LncUtil::ForceKillLocalProcess(int appId, int appLocalPid) +{ + MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); + return Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "ForceKillLocalProcess", appId, appLocalPid); +} void LncUtil::SystemShutdown(Boot flag) { diff --git a/Playstation/OrbisToolbox-2.0/LncUtil.h b/Playstation/OrbisToolbox-2.0/LncUtil.h index 7dc931d..883b603 100644 --- a/Playstation/OrbisToolbox-2.0/LncUtil.h +++ b/Playstation/OrbisToolbox-2.0/LncUtil.h @@ -49,6 +49,28 @@ public: char appType; }; + struct LocalProcessStatus + { + int appLocalPid; + char reserved[32]; + }; + + struct AppStatusForShellUIReboot + { + int appId; + int appType; + int appAttr; + int launchRequestAppId; + int userId; + int isActiveCdlg; + char path[1024]; + int isCoredumped; + int isPrxModuleLoadFailed; + int appLocalPid; + int crashReportMode; + char category[4]; + }; + static int GetAppStatus(AppStatus* Status); static int SuspendApp(int appId, Flag flag = Flag_None); static int ResumeApp(int appId, Flag flag = Flag_None); @@ -62,6 +84,9 @@ public: static int KillApp(int appId, int userId = -1); static int ForceKillApp(int appId, int userId = -1); static int KillLocalProcess(int appId, int appLocalPid); + static int ForceKillLocalProcess(int appId, int appLocalPid); + static int GetLocalProcessStatusList(LocalProcessStatus List[], unsigned int numEntries, unsigned int* outEntries); + static int GetAppStatusListForShellUIReboot(AppStatusForShellUIReboot outStatusList[], unsigned int numEntries, unsigned int* outEntries); static void SystemShutdown(Boot flag); static void SystemReboot(); diff --git a/Playstation/OrbisToolbox-2.0/Menu.cpp b/Playstation/OrbisToolbox-2.0/Menu.cpp index 205d425..bf4a7da 100644 --- a/Playstation/OrbisToolbox-2.0/Menu.cpp +++ b/Playstation/OrbisToolbox-2.0/Menu.cpp @@ -13,8 +13,11 @@ #include "NetWrapper.h" +#include + std::map* Menu::Options; bool Menu::Auto_Load_Settings; +int procId = 0; void Menu::Init() { @@ -214,6 +217,52 @@ void Menu::Init() NetWrapper::GetMacAddressInfo(SCE_NET_IF_NAME_PHYSICAL), NetWrapper::GetMacAddressInfo(SCE_NET_IF_NAME_WLAN0)); }); + Add_Option("id_orbis_load", []() -> void + { + int appId = LncUtil::GetAppId("NPXS20000"); + + const char* args[] = { + "--CUSTOM_ARGS", + NULL, + }; + + procId = sceSystemServiceAddLocalProcess(appId, "/data/Orbis Toolbox/TestLocalProcess.elf", 0, (const char**)&args); + + Notify("Local Process Test: Loaded!\nProcessId: %llX", procId); + }); + Add_Option("id_orbis_unload", []() -> void + { + int appId = LncUtil::GetAppId("NPXS20000"); + + auto result = LncUtil::ForceKillLocalProcess(appId, procId); + + Notify("Local Process Test: Un-Loaded!\nResult: %llx", result); + }); + Add_Option("id_orbis_listproc", []() -> void + { + ProcInfo Infos[200]; + auto count = KDriver::GetProcessList(200, (ProcInfo*)&Infos); + + for (int i = 0; i < count; i++) + { + klog("%i %s %s\n", Infos[i].PID, Infos[i].ProcName, Infos[i].TitleID); + } + }); + Add_Option("id_orbis_listlocalproc", []() -> void + { + LocalProcessStatus List[16]; + unsigned int actualCount = 0; + auto result = sceSystemServiceGetLocalProcessStatusList(List, 16, &actualCount); + + klog("result: %llx\nactualCount: %i\n", result, actualCount); + + for (int i = 0; i < actualCount; i++) + { + klog("appLocalPid: %llX\nTitleId: %s", List[i].appLocalPid, LncUtil::GetAppTitleId(List[i].appLocalPid)); + } + + + }); } void Menu::Term() diff --git a/Playstation/OrbisToolbox-2.0/Proc.cpp b/Playstation/OrbisToolbox-2.0/Proc.cpp index 6bfd163..5bec507 100644 --- a/Playstation/OrbisToolbox-2.0/Proc.cpp +++ b/Playstation/OrbisToolbox-2.0/Proc.cpp @@ -18,30 +18,6 @@ void Proc::HandleAPI(OrbisNetId Sock, APIPacket* Packet) break; - case API_PROC_ATTACH: - - break; - - case API_PROC_DETACH: - - break; - - case API_PROC_GET_CURRENT: - - break; - - case API_PROC_READ: - - break; - - case API_PROC_WRITE: - - break; - - case API_PROC_KILL: - - break; - case API_PROC_LOAD_ELF: break; @@ -49,34 +25,6 @@ void Proc::HandleAPI(OrbisNetId Sock, APIPacket* Packet) case API_PROC_CALL: break; - - case API_PROC_LOAD_SPRX: - - break; - - case API_PROC_UNLOAD_SPRX: - - break; - - case API_PROC_UNLOAD_SPRX_NAME: - - break; - - case API_PROC_RELOAD_SPRX_NAME: - - break; - - case API_PROC_RELOAD_SPRX_HANDLE: - - break; - - case API_PROC_DUMP_MODULE: - - break; - - case API_PROC_MODULE_LIST: - - break; } } diff --git a/Playstation/OrbisToolbox-2.0/System_Monitor.cpp b/Playstation/OrbisToolbox-2.0/System_Monitor.cpp index 9233843..178a95e 100644 --- a/Playstation/OrbisToolbox-2.0/System_Monitor.cpp +++ b/Playstation/OrbisToolbox-2.0/System_Monitor.cpp @@ -3,6 +3,7 @@ #include "Game_Overlay.h" int System_Monitor::Thread_Count = 0; +int System_Monitor::Busy_Core = 0; float System_Monitor::Usage[8] = { 0 }; float System_Monitor::Average_Usage; int System_Monitor::CPU_Temp; @@ -19,6 +20,8 @@ void System_Monitor::calc_usage(unsigned int idle_tid[8], thread_usages* cur, th if (cur->Thread_Count <= 0 || prev->Thread_Count <= 0) //Make sure our banks have threads return; + float CurrentMax = 0.0f; + //Calculate the Current time difference from the last bank to the current bank. float Current_Time_Total = ((prev->current_time.tv_sec + (prev->current_time.tv_nsec / 1000000000.0f)) - (cur->current_time.tv_sec + (cur->current_time.tv_nsec / 1000000000.0f))); @@ -67,6 +70,12 @@ void System_Monitor::calc_usage(unsigned int idle_tid[8], thread_usages* cur, th //Get inverse of idle percentage and express in percent. usage_out[i] = (1.0f - Idle_Usage) * 100.0f; + + if (usage_out[i] > CurrentMax) + { + CurrentMax = usage_out[i]; + Busy_Core = i; + } } } diff --git a/Playstation/OrbisToolbox-2.0/System_Monitor.h b/Playstation/OrbisToolbox-2.0/System_Monitor.h index 889d8e4..2273f22 100644 --- a/Playstation/OrbisToolbox-2.0/System_Monitor.h +++ b/Playstation/OrbisToolbox-2.0/System_Monitor.h @@ -13,6 +13,7 @@ public: }; static int Thread_Count; + static int Busy_Core; static float Usage[8]; static float Average_Usage; static int CPU_Temp; diff --git a/Playstation/OrbisToolbox-2.0/Target.cpp b/Playstation/OrbisToolbox-2.0/Target.cpp index fcd801a..abcee08 100644 --- a/Playstation/OrbisToolbox-2.0/Target.cpp +++ b/Playstation/OrbisToolbox-2.0/Target.cpp @@ -131,7 +131,9 @@ void Target::SendTargetInfo(OrbisNetId Sock) Packet->SOCTemp = System_Monitor::SOC_Temp; Packet->ThreadCount = System_Monitor::Thread_Count; Packet->AverageCPUUsage = System_Monitor::Average_Usage; - + Packet->BusyCore = System_Monitor::Busy_Core; + memcpy(&Packet->Ram, &System_Monitor::RAM, sizeof(MemoryInfo)); + memcpy(&Packet->VRam, &System_Monitor::VRAM, sizeof(MemoryInfo)); sceNetSend(Sock, Packet, sizeof(TargetInfoPacket), 0); @@ -166,4 +168,6 @@ void Target::SetSettings(OrbisNetId Sock) SendStatus(Sock, APIResults::API_OK); Config::SetSettingsNow = true; -} \ No newline at end of file +} + +//TODO: Get Target Settings. \ No newline at end of file diff --git a/Playstation/OrbisToolbox-2.0/Version.h b/Playstation/OrbisToolbox-2.0/Version.h index bd5c102..62fe041 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 146 -#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 196 +#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/orbis_toolbox.xml b/Playstation/OrbisToolbox-2.0/orbis_toolbox.xml index 6524f4a..5b3751f 100644 --- a/Playstation/OrbisToolbox-2.0/orbis_toolbox.xml +++ b/Playstation/OrbisToolbox-2.0/orbis_toolbox.xml @@ -194,6 +194,11 @@