Add some temp wrappers & design UI for app control.

This commit is contained in:
Greg
2022-12-14 15:41:17 -07:00
parent 0e10531499
commit 3c757c8aba
37 changed files with 978 additions and 76 deletions
+1
View File
@@ -206,6 +206,7 @@ struct TargetInfoPacket
int ConsoleType;
int Attached;
int AttachedPid;
int ForegroundAccountId;
uint64_t FreeSpace;
uint64_t TotalSpace;
+3
View File
@@ -31,3 +31,6 @@
#include "Flash.h"
#include "APIPackets.h"
#include "LncUtil.h"
#include "ShellCoreUtil.h"
#include "SystemMonitor.h"
+61
View File
@@ -0,0 +1,61 @@
#include "Common.h"
#include "LncUtil.h"
uint64_t LncUtil::LibraryBaseAddress = 0;
int(*LncUtil::_sceLncUtilGetAppId)(const char*);
int LncUtil::Init()
{
// Load the prx or get its module handle.
char Buffer[0x200];
sprintf(Buffer, "/%s/common/lib/libSceSystemService.sprx", sceKernelGetFsSandboxRandomWord());
int libHandle = sceKernelLoadStartModule(Buffer, 0, nullptr, 0, nullptr, nullptr);
if (libHandle == 0) {
klog("Failed to load libSceSystemService Library.\n");
return -1;
}
// Get module info so we can find the base address.
OrbisKernelModuleInfo moduleInfo;
moduleInfo.size = sizeof(OrbisKernelModuleInfo);
if (sceKernelGetModuleInfo(libHandle, &moduleInfo) != 0)
{
klog("Failed to get libSceSystemService module info.\n");
return -1;
}
// Save base address for later.
LibraryBaseAddress = (uint64_t)moduleInfo.segmentInfo[0].address;
if (LibraryBaseAddress <= 0)
{
klog("Failed to get libSceSystemService base address.\n");
return -1;
}
// Init the lnc util library.
auto sceLncUtilInitialize = (int(*)())(LibraryBaseAddress + 0x4BF0);
if (sceLncUtilInitialize() != 0)
{
klog("Failed to call sceLncUtilInitialize().\n");
return -1;
}
// Set up Functions.
_sceLncUtilGetAppId = (decltype(_sceLncUtilGetAppId))(LibraryBaseAddress + 0x4E10);
return 0;
}
int LncUtil::sceLncUtilGetAppId(const char* TitleId)
{
if ((uint64_t)_sceLncUtilGetAppId > 0x4E10)
{
return _sceLncUtilGetAppId(TitleId);
}
else
{
klog("failed to resolve sceLncUtilGetAppId\n");
return -1;
}
}
+12
View File
@@ -0,0 +1,12 @@
#pragma once
class LncUtil
{
public:
static int Init();
static int sceLncUtilGetAppId(const char* TitleId);
private:
static uint64_t LibraryBaseAddress;
static int(*_sceLncUtilGetAppId)(const char* titleId);
};
@@ -67,11 +67,14 @@ del /s /q /f $(IntDir)\*.oelf</NMakeCleanCommandLine>
<ClCompile Include="Debug.cpp" />
<ClCompile Include="Flash.cpp" />
<ClCompile Include="GeneralIPC.cpp" />
<ClCompile Include="LncUtil.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="build.bat" />
<ClCompile Include="Proc.cpp" />
<ClCompile Include="ShellCoreUtil.cpp" />
<ClCompile Include="SocketListener.cpp" />
<ClCompile Include="System.cpp" />
<ClCompile Include="SystemMonitor.cpp" />
<ClCompile Include="Target.cpp" />
<ClCompile Include="Utilities.cpp" />
<ClCompile Include="Watchpoint.cpp" />
@@ -85,9 +88,12 @@ del /s /q /f $(IntDir)\*.oelf</NMakeCleanCommandLine>
<ClInclude Include="Debug.h" />
<ClInclude Include="Flash.h" />
<ClInclude Include="GeneralIPC.h" />
<ClInclude Include="LncUtil.h" />
<ClInclude Include="Proc.h" />
<ClInclude Include="ShellCoreUtil.h" />
<ClInclude Include="SocketListener.h" />
<ClInclude Include="System.h" />
<ClInclude Include="SystemMonitor.h" />
<ClInclude Include="Target.h" />
<ClInclude Include="Utilities.h" />
<ClInclude Include="Version.h" />
@@ -85,6 +85,15 @@
<ClCompile Include="GeneralIPC.cpp">
<Filter>Source Files\Utilities</Filter>
</ClCompile>
<ClCompile Include="LncUtil.cpp">
<Filter>Source Files\Utilities\PS Utils</Filter>
</ClCompile>
<ClCompile Include="ShellCoreUtil.cpp">
<Filter>Source Files\Utilities\PS Utils</Filter>
</ClCompile>
<ClCompile Include="SystemMonitor.cpp">
<Filter>Source Files\Utilities\PS Utils</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Common.h">
@@ -132,5 +141,14 @@
<ClInclude Include="GeneralIPC.h">
<Filter>Header Files\Utilities</Filter>
</ClInclude>
<ClInclude Include="LncUtil.h">
<Filter>Header Files\Utilities\PS Utils</Filter>
</ClInclude>
<ClInclude Include="ShellCoreUtil.h">
<Filter>Header Files\Utilities\PS Utils</Filter>
</ClInclude>
<ClInclude Include="SystemMonitor.h">
<Filter>Header Files\Utilities\PS Utils</Filter>
</ClInclude>
</ItemGroup>
</Project>
+53
View File
@@ -0,0 +1,53 @@
#include "Common.h"
#include "ShellCoreUtil.h"
uint64_t ShellCoreUtil::LibraryBaseAddress = 0;
int(*ShellCoreUtil::_sceShellCoreUtilGetFreeSizeOfUserPartition)(uint64_t* free, uint64_t* total);
int ShellCoreUtil::Init()
{
// Load the prx or get its module handle.
char Buffer[0x200];
sprintf(Buffer, "/%s/common/lib/libSceSystemService.sprx", sceKernelGetFsSandboxRandomWord());
int libHandle = sceKernelLoadStartModule(Buffer, 0, nullptr, 0, nullptr, nullptr);
if (libHandle == 0) {
klog("Failed to load libSceSystemService Library.\n");
return -1;
}
// Get module info so we can find the base address.
OrbisKernelModuleInfo moduleInfo;
moduleInfo.size = sizeof(OrbisKernelModuleInfo);
if (sceKernelGetModuleInfo(libHandle, &moduleInfo) != 0)
{
klog("Failed to get libSceSystemService module info.\n");
return -1;
}
// Save base address for later.
LibraryBaseAddress = (uint64_t)moduleInfo.segmentInfo[0].address;
if (LibraryBaseAddress <= 0)
{
klog("Failed to get libSceSystemService base address.\n");
return -1;
}
// Set up Functions.
_sceShellCoreUtilGetFreeSizeOfUserPartition = (decltype(_sceShellCoreUtilGetFreeSizeOfUserPartition))(LibraryBaseAddress + 0x105A0);
return 0;
}
int ShellCoreUtil::sceShellCoreUtilGetFreeSizeOfUserPartition(uint64_t* free, uint64_t* total)
{
if ((uint64_t)_sceShellCoreUtilGetFreeSizeOfUserPartition > 0x105A0)
{
return _sceShellCoreUtilGetFreeSizeOfUserPartition(free, total);
}
else
{
klog("failed to resolve sceShellCoreUtilGetFreeSizeOfUserPartition\n");
return -1;
}
}
+12
View File
@@ -0,0 +1,12 @@
#pragma once
class ShellCoreUtil
{
public:
static int Init();
static int sceShellCoreUtilGetFreeSizeOfUserPartition(uint64_t* free, uint64_t* total);
private:
static uint64_t LibraryBaseAddress;
static int(*_sceShellCoreUtilGetFreeSizeOfUserPartition)(uint64_t* free, uint64_t* total);
};
+189
View File
@@ -0,0 +1,189 @@
#include "Common.h"
#include "SystemMonitor.h"
int SystemMonitor::Thread_Count = 0;
int SystemMonitor::Busy_Core = 0;
float SystemMonitor::Usage[8] = { 0 };
float SystemMonitor::Average_Usage;
int SystemMonitor::CPU_Temp;
int SystemMonitor::SOC_Temp;
SystemMonitor::Memory SystemMonitor::RAM;
SystemMonitor::Memory SystemMonitor::VRAM;
bool SystemMonitor::Should_Run_Thread = true;
Proc_Stats SystemMonitor::Stat_Data[3072];
SystemMonitor::threadUsage SystemMonitor::gThread_Data[2];
void SystemMonitor::CalculateCpuUsage(unsigned int idle_tid[8], threadUsage* cur, threadUsage* prev, float usage_out[8])
{
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)));
//Here this could use to be improved but essetially what its doing is finding the thread information for the idle threads using their thread Index stored from before.
struct Data_s
{
Proc_Stats* Cur;
Proc_Stats* Prev;
}Data[8];
for (int i = 0; i < cur->Thread_Count; i++)
{
for (int j = 0; j < 8; j++)
{
if (idle_tid[j] == cur->Threads[i].td_tid)
Data[j].Cur = &cur->Threads[i];
}
}
for (int i = 0; i < prev->Thread_Count; i++)
{
for (int j = 0; j < 8; j++)
{
if (idle_tid[j] == prev->Threads[i].td_tid)
Data[j].Prev = &prev->Threads[i];
}
}
//Here we loop through each core to calculate the total usage time as its split into user/sustem
for (int i = 0; i < 8; i++)
{
float Prev_Usage_Time = (Data[i].Prev->system_cpu_usage_time.tv_sec + (Data[i].Prev->system_cpu_usage_time.tv_nsec / 1000000.0f));
Prev_Usage_Time += (Data[i].Prev->user_cpu_usage_time.tv_sec + (Data[i].Prev->user_cpu_usage_time.tv_nsec / 1000000.0f));
float Cur_Usage_Time = (Data[i].Cur->system_cpu_usage_time.tv_sec + (Data[i].Cur->system_cpu_usage_time.tv_nsec / 1000000.0f));
Cur_Usage_Time += (Data[i].Cur->user_cpu_usage_time.tv_sec + (Data[i].Cur->user_cpu_usage_time.tv_nsec / 1000000.0f));
//We calculate the usage using usage time difference between the two samples divided by the current time difference.
float Idle_Usage = ((Prev_Usage_Time - Cur_Usage_Time) / Current_Time_Total);
if (Idle_Usage > 1.0f)
Idle_Usage = 1.0f;
if (Idle_Usage < 0.0f)
Idle_Usage = 0.0f;
//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;
}
}
}
void SystemMonitor::Get_Page_Table_Stats(int vm, int type, int* Used, int* Free, int* Total)
{
int _Total = 0, _Free = 0;
if (get_page_table_stats(vm, type, &_Total, &_Free) == -1) {
klog("get_page_table_stats() Failed.\n");
return;
}
if (Used)
*Used = (_Total - _Free);
if (Free)
*Free = _Free;
if (Total)
*Total = _Total;
}
void* SystemMonitor::MonitorThread(void* args)
{
//klog("[System Monitor] Thread Started\n");
unsigned int Idle_Thread_ID[8];
int Thread_Count = 3072;
if (!sceKernelGetCpuUsage((Proc_Stats*)&Stat_Data, (int*)&Thread_Count) && Thread_Count > 0)
{
char Thread_Name[0x40];
int Core_Count = 0;
for (int i = 0; i < Thread_Count; i++)
{
if (!sceKernelGetThreadName(Stat_Data[i].td_tid, Thread_Name) && sscanf(Thread_Name, "SceIdleCpu%d", &Core_Count) == 1 && Core_Count <= 7)
{
//klog("[System Monitor][SceIdleCpu%d] -> %i\n", Core_Count, Stat_Data[i].td_tid);
Idle_Thread_ID[Core_Count] = Stat_Data[i].td_tid;
}
}
}
//klog("[System Monitor] Starting Monitor...\n");
int Current_Bank = 0;
while (Should_Run_Thread)
{
//grab thread data with max threads of 3072.
gThread_Data[Current_Bank].Thread_Count = 3072;
if (!sceKernelGetCpuUsage((Proc_Stats*)&gThread_Data[Current_Bank].Threads, &gThread_Data[Current_Bank].Thread_Count))
{
//Store the thread count.
SystemMonitor::Thread_Count = gThread_Data[Current_Bank].Thread_Count;
//klog("ThreadCount[%i] = %i\n", Current_Bank, gThread_Data[Current_Bank].Thread_Count);
//Set the current time.
sceKernelClockGettime(4, &gThread_Data[Current_Bank].current_time);
//flip to other bank.
Current_Bank = !Current_Bank;
//make sure bank has threads
if (gThread_Data[Current_Bank].Thread_Count <= 0)
continue;
//Calculate usage using thread data.
CalculateCpuUsage(Idle_Thread_ID, &gThread_Data[!Current_Bank], &gThread_Data[Current_Bank], Usage);
/*klog("CPU Utilization: %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%%\n",
Usage[0], Usage[1], Usage[2], Usage[3],
Usage[4], Usage[5], Usage[6], Usage[7]);*/
SystemMonitor::Average_Usage = ((Usage[0] + Usage[1] + Usage[2] + Usage[3] + Usage[4] + Usage[5] + Usage[6] + Usage[7]) / 8.0f);
}
// Die temperatures
sceKernelGetCpuTemperature(&CPU_Temp);
sceKernelGetSocSensorTemperature(0, &SOC_Temp);
// Ram Usage.
Get_Page_Table_Stats(1, 1, &RAM.Used, &RAM.Free, &RAM.Total);
RAM.Percentage = (((float)RAM.Used / (float)RAM.Total) * 100.0f);
// Video Ram Usage.
Get_Page_Table_Stats(1, 2, &VRAM.Used, &VRAM.Free, &VRAM.Total);
VRAM.Percentage = (((float)VRAM.Used / (float)VRAM.Total) * 100.0f);
sceKernelSleep(2);
}
Should_Run_Thread = true;
klog("[System Monitor] Thread Shutdown.\n");
void* res;
scePthreadExit(res);
return res;
}
void SystemMonitor::Init()
{
klog("[System Monitor] Starting System Monitor Thread...\n");
OrbisPthread* id;
scePthreadCreate(&id, nullptr, MonitorThread, NULL, "System Monitor Thread");
}
void SystemMonitor::Term()
{
Should_Run_Thread = false;
while (!Should_Run_Thread) { sceKernelUsleep(1000 * 10); }
}
+44
View File
@@ -0,0 +1,44 @@
#pragma once
#include "Common.h"
class SystemMonitor
{
public:
struct Memory
{
int Used;
int Free;
int Total;
float Percentage;
};
static int Thread_Count;
static int Busy_Core;
static float Usage[8];
static float Average_Usage;
static int CPU_Temp;
static int SOC_Temp;
static Memory RAM;
static Memory VRAM;
static void Init();
static void Term();
private:
struct threadUsage
{
OrbisKernelTimespec current_time; //0x00
int Thread_Count; //0x10
char padding0[0x4]; //0x14
Proc_Stats Threads[3072]; //0x18
};
static bool Should_Run_Thread;
static Proc_Stats Stat_Data[3072];
static threadUsage gThread_Data[2];
static void CalculateCpuUsage(unsigned int idle_tid[8], threadUsage* cur, threadUsage* prev, float usage_out[8]);
static void Get_Page_Table_Stats(int vm, int type, int* Used, int* Free, int* Total);
static void* MonitorThread(void* args);
};
+9 -26
View File
@@ -111,8 +111,8 @@ void Target::SendTargetInfo(OrbisNetId Sock)
ReadFlash(FLASH_MB_SERIAL, &Packet->MotherboardSerial, 14);
ReadFlash(FLASH_SERIAL, &Packet->Serial, 10);
ReadFlash(FLASH_MODEL, &Packet->Model, 14);
getMacAddress(SceNetIfName::SCE_NET_IF_NAME_ETH0, Packet->MACAdressLAN, 18);
getMacAddress(SceNetIfName::SCE_NET_IF_NAME_WLAN0, Packet->MACAdressWIFI, 18);
getMacAddress(SCE_NET_IF_NAME_ETH0, Packet->MACAdressLAN, 18);
getMacAddress(SCE_NET_IF_NAME_WLAN0, Packet->MACAdressWIFI, 18);
ReadFlash(FLASH_UART_FLAG, &Packet->UART, 1);
ReadFlash(FLASH_IDU_MODE, &Packet->IDUMode, 1);
GetIDPS(Packet->IDPS);
@@ -123,32 +123,15 @@ void Target::SendTargetInfo(OrbisNetId Sock)
Packet->Attached = false; // TODO: Add funcionality.
//Packet->CurrentProc
char Buffer[0x200];
sprintf(Buffer, "/%s/common/lib/libSceSystemService.sprx", sceKernelGetFsSandboxRandomWord());
int ModuleHandle = sceKernelLoadStartModule(Buffer, 0, nullptr, 0, nullptr, nullptr);
if (ModuleHandle == 0) {
klog("Failed to load libSceSystemService Library.\n");
return;
}
SceDbgModuleInfo infos;
sys_dynlib_get_info(ModuleHandle, &infos);
int(*sceShellCoreUtilGetFreeSizeOfUserPartition)(uint64_t * free, uint64_t * total) = (int(*)(uint64_t * free, uint64_t * total))((uint64_t)infos.segmentInfo[0].baseAddr + 0x105A0);
// Storage Stats.
uint64_t HDDFreeSpace, HDDTotalSpace;
auto res = sceShellCoreUtilGetFreeSizeOfUserPartition(&HDDFreeSpace, &HDDTotalSpace);
Packet->FreeSpace = HDDFreeSpace;
Packet->TotalSpace = HDDTotalSpace;
sceUserServiceGetForegroundUser(&Packet->ForegroundAccountId);
auto res = ShellCoreUtil::sceShellCoreUtilGetFreeSizeOfUserPartition(&Packet->FreeSpace, &Packet->TotalSpace);
// Perf Stats. TODO: Move from toolbox
/*Packet->CPUTemp = System_Monitor::CPU_Temp;
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));*/
/*Packet->ThreadCount = SystemMonitor::Thread_Count;
Packet->AverageCPUUsage = SystemMonitor::Average_Usage;
Packet->BusyCore = SystemMonitor::Busy_Core;
memcpy(&Packet->Ram, &SystemMonitor::RAM, sizeof(MemoryInfo));
memcpy(&Packet->VRam, &SystemMonitor::VRAM, sizeof(MemoryInfo));*/
sceNetSend(Sock, Packet, sizeof(TargetInfoPacket), 0);
+1 -2
View File
@@ -30,7 +30,6 @@ bool LoadModules()
_sceSysmoduleLoadModuleInternal(SCE_SYSMODULE_INTERNAL_NET);
_sceSysmoduleLoadModuleInternal(SCE_SYSMODULE_INTERNAL_HTTP);
_sceSysmoduleLoadModuleInternal(SCE_SYSMODULE_INTERNAL_BGFT);
_sceSysmoduleLoadModuleInternal(SCE_SYSMODULE_INTERNAL_APPINSTUTIL);
_sceSysmoduleLoadModuleInternal(0xA4);
return true;
@@ -162,7 +161,7 @@ bool CopySflash()
return false;
}
int getMacAddress(SceNetIfName ifName_Num, char* strOut, size_t len)
int getMacAddress(OrbisNetIfName ifName_Num, char* strOut, size_t len)
{
if (len < 18)
{
+1 -1
View File
@@ -26,7 +26,7 @@ int sys_dynlib_get_info(int moduleHandle, SceDbgModuleInfo* destModuleInfo);
int sys_dynlib_get_list(int* destModuleHandles, int max, int* count);
bool Jailbreak();
bool CopySflash();
int getMacAddress(SceNetIfName ifName_Num, char* strOut, size_t strlen);
int getMacAddress(OrbisNetIfName ifName_Num, char* strOut, size_t strlen);
// Networking
bool SockSendInt(OrbisNetId Sock, int val);
+11 -11
View File
@@ -1,11 +1,11 @@
#pragma once
#define ORBISLIB_MAJOR 3
#define ORBISLIB_MINOR 0
#define ORBISLIB_BUILDVERSION 359
#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 431
#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
+2 -2
View File
@@ -24,14 +24,14 @@ Rem Link the input ELF
ld.lld -m elf_x86_64 -pie --script "%OO_PS4_TOOLCHAIN%\link.x" --eh-frame-hdr -o "%outputElf%" "-L%OO_PS4_TOOLCHAIN%\\lib" "-L..\\..\\External\\GoldHEN_Plugins_SDK" %libraries% --verbose "%OO_PS4_TOOLCHAIN%\lib\crt1.o" %obj_files% "..\\..\\External\\ps4-libjbc\\jbc.o"
Rem Create the eboot
%OO_PS4_TOOLCHAIN%\bin\windows\create-fself.exe -in "%outputElf%" --out "%outputOelf%" --eboot "eboot.bin"
%OO_PS4_TOOLCHAIN%\bin\windows\create-fself.exe -in "%outputElf%" --out "%outputOelf%" --eboot "eboot.bin" --paid 0x3800000000010003
Rem Cleanup
copy "eboot.bin" %outputPath%\Playstation\Build\pkg\Daemons\ORBS30000\eboot.bin
del "eboot.bin"
REM Generate the script. Will overwrite any existing temp.txt
echo open 1.1.0.73 2121> temp.txt
echo open 1.1.0.13 2121> temp.txt
echo anonymous>> temp.txt
echo anonymous>> temp.txt
echo cd "/system/vsh/app/ORBS30000/">> temp.txt
+45 -30
View File
@@ -4,11 +4,7 @@
#include "GoldHEN.h"
#include <orbis/SystemService.h>
#include <orbis/SysCore.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <orbis/libkernel.h>
#include <orbis/Net.h>
#include "GeneralIPC.h"
@@ -41,12 +37,34 @@ int main()
return 0;
}
// TODO: Bug? This doesnt seem to work for some reason.
// Check GoldHEN SDK Version make sure we can run!
auto sdkVersion = sys_sdk_version();
if (sdkVersion < GOLDHEN_SDK_VERSION)
// Start up networking interface
if (sceNetInit() != 0)
{
Notify("Invalid GoldHEN SDK Version %d Orbis Toolbox supports %d+", sdkVersion, GOLDHEN_SDK_VERSION);
Notify("Failed to init Networking...");
sceSystemServiceLoadExec("exit", 0);
return 0;
}
// Start up user service.
if (sceUserServiceInitialize(nullptr) != 0)
{
Notify("Failed to init User Service...");
sceSystemServiceLoadExec("exit", 0);
return 0;
}
// Init temporary wrapper for lncutils.
if (LncUtil::Init() != 0)
{
Notify("Failed to init LncUtil...");
sceSystemServiceLoadExec("exit", 0);
return 0;
}
// Init temporary wrapper for shellcoreutils.
if (ShellCoreUtil::Init() != 0)
{
Notify("Failed to init ShellCoreUtil...");
sceSystemServiceLoadExec("exit", 0);
return 0;
}
@@ -59,6 +77,16 @@ int main()
return 0;
}
// TODO: Bug? This doesnt seem to work for some reason.
// Check GoldHEN SDK Version make sure we can run!
auto sdkVersion = sys_sdk_version();
if (sdkVersion < GOLDHEN_SDK_VERSION)
{
Notify("Invalid GoldHEN SDK Version %d Orbis Toolbox supports %d+", sdkVersion, GOLDHEN_SDK_VERSION);
sceSystemServiceLoadExec("exit", 0);
return 0;
}
// Copy back up of sflash so we can read it and not break things :)
CopySflash();
@@ -67,24 +95,9 @@ int main()
klog("\n%s\n\n", ORBISLIB_BUILDSTRING);
// #define KILLTHEMALL
#ifdef KILLTHEMALL
char Buffer[0x200];
sprintf(Buffer, "/%s/common/lib/libSceSystemService.sprx", sceKernelGetFsSandboxRandomWord());
int ModuleHandle = sceKernelLoadStartModule(Buffer, 0, nullptr, 0, nullptr, nullptr);
if (ModuleHandle == 0) {
klog("Failed to load libSceSystemService Library.\n");
return false;
}
SceDbgModuleInfo minfos;
sys_dynlib_get_info(ModuleHandle, &minfos);
void(*sceLncUtilInitialize)() = (void(*)())((uint64_t)minfos.segmentInfo[0].baseAddr + 0x4BF0);
int(*sceLncUtilGetAppId)(char* titleId) = (int(*)(char*))((uint64_t)minfos.segmentInfo[0].baseAddr + 0x4E10);
sceLncUtilInitialize();
sceSystemServiceKillApp(sceLncUtilGetAppId("NPXS20001"), -1, 0, 0);
// #define KILLSHELLUI
#ifdef KILLSHELLUI
sceSystemServiceKillApp(LncUtil::sceLncUtilGetAppId("NPXS20001"), -1, 0, 0);
#else
/*int hndl = sys_sdk_proc_prx_load("SceShellUI", "/user/data/Orbis Suite/OrbisLibGeneralHelper.sprx");
@@ -96,10 +109,12 @@ int main()
klog("path = %s\n", info.Path);
}*/
sceNetInit();
// Init a thread to monitor the system usage stats.
SystemMonitor::Init();
// start up the API.
API::Init();
#endif
while (true)
@@ -174,7 +174,7 @@ namespace OrbisSuite.Common
public float Percentage;
};
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi, Size = 260), Serializable]
[StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Ansi), Serializable]
public struct TargetInfoPacket
{
public int SDKVersion;
@@ -203,6 +203,7 @@ namespace OrbisSuite.Common
public int ConsoleType;
public int Attached;
public int AttachedPid;
public int ForegroundAccountId;
public ulong FreeSpace;
public ulong TotalSpace;
@@ -0,0 +1,213 @@
<UserControl x:Class="OrbisNeighborHood.Controls.AppPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OrbisNeighborHood.Controls"
xmlns:simpleControls="clr-namespace:SimpleUI.Controls;assembly=SimpleUI"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
mc:Ignorable="d"
Width="305" Height="210"
d:DesignWidth="305" d:DesignHeight="210">
<Border Width="305" Height="210"
CornerRadius="10"
Background="{DynamicResource WindowBar}" VerticalAlignment="Bottom">
<!-- Main View -->
<StackPanel Margin="5">
<!-- Application Name -->
<TextBlock Text="Super long application name that will overflow the text box."
TextTrimming="CharacterEllipsis"
Name="ApplicationNameElement"
Foreground="{DynamicResource Text}"
FontSize="16"
VerticalAlignment="Center"
Margin="0 0 0 5"/>
<!-- Application Image & Controls -->
<StackPanel Orientation="Horizontal">
<!-- Target Image -->
<Grid Margin="0 5 5 5"
Width="125"
Height="125">
<Rectangle Fill="#45494A"/>
<Image Name="IconImage"
Source="/OrbisNeighborHood;component/Images/DefaultTitleIcon.png"
RenderOptions.BitmapScalingMode="Fant"
RenderOptions.EdgeMode="Aliased"/>
<!-- Loading Image -->
<Image gif:ImageBehavior.AnimatedSource="pack://application:,,,/OrbisNeighborHood;component/Images/SpinningDualRing.gif"
RenderOptions.BitmapScalingMode="Fant"
RenderOptions.EdgeMode="Aliased"
Name="LoadingImage"
Opacity="0"
Margin="40"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
<!-- Target Details -->
<Grid VerticalAlignment="Center"
Height="125">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal"
Grid.Row="0">
<!-- TitleId -->
<simpleControls:SimpleTextField
FieldName="TitleId"
FieldText="CUSA00000"
Width="100"
Height="35"
Margin="0 0 5 0"/>
<!-- Version -->
<simpleControls:SimpleTextField
FieldName="Version"
FieldText="1.00"
Width="60"
Height="35"/>
</StackPanel>
<StackPanel Orientation="Horizontal"
Grid.Row="2">
<!-- Game Type -->
<simpleControls:SimpleTextField
FieldName="Type"
FieldText="Game (gd)"
Width="80"
Height="35"
Margin="0 0 5 0"/>
<!-- Size -->
<simpleControls:SimpleTextField
FieldName="Size"
FieldText="125.4 GB"
Width="80"
Height="35"/>
</StackPanel>
<!-- Install Date -->
<simpleControls:SimpleTextField
FieldName="Install Date"
FieldText="Dec 11, 2022 8:40 am"
Width="165"
Height="35"
Grid.Row="4"/>
</Grid>
</StackPanel>
<!-- Buttons -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- Start / Stop -->
<local:ImageButton x:Name="StartStop"
Width="35"
Height="35"
ToolTip="Start {Application Name}."
ImageSource="/OrbisNeighborHood;component/Images/Start.png"
ImageMargin="4"
Click="StartStop_Click"
Grid.Column="0"/>
<!-- Visibility -->
<local:ImageButton x:Name="Visibility"
Width="35"
Height="35"
ToolTip="Show / Hide {Application Name} from Home Menu."
ImageSource="/OrbisNeighborHood;component/Images/Visibility.png"
ImageMargin="4"
Click="Visibility_Click"
Grid.Column="2"/>
<!-- Change Icon -->
<local:ImageButton x:Name="ChangeIcon"
Width="35"
Height="35"
ToolTip="Change the icon of {Application Name}."
ImageSource="/OrbisNeighborHood;component/Images/ReplaceIcon.png"
ImageMargin="4"
Click="ChangeIcon_Click"
Grid.Column="4"/>
<!-- Unknown -->
<local:ImageButton x:Name="Unknown"
Width="35"
Height="35"
ToolTip="TBD"
ImageSource="/OrbisNeighborHood;component/Images/UnAvailable.png"
ImageMargin="4"
Click="Unknown_Click"
IsEnabled="False"
Grid.Column="6"/>
<!-- Unknown2 -->
<local:ImageButton x:Name="Unknown2"
Width="35"
Height="35"
ToolTip="TBD"
ImageSource="/OrbisNeighborHood;component/Images/UnAvailable.png"
ImageMargin="4"
Click="Unknown2_Click"
IsEnabled="False"
Grid.Column="8"/>
<!-- Unknown3 -->
<local:ImageButton x:Name="Unknown3"
Width="35"
Height="35"
ToolTip="TBD"
ImageSource="/OrbisNeighborHood;component/Images/UnAvailable.png"
ImageMargin="4"
Click="Unknown3_Click"
IsEnabled="False"
Grid.Column="10"/>
<!-- Delete -->
<local:ImageButton x:Name="Delete"
Width="35"
Height="35"
ToolTip="Delete {Application Name}."
ImageSource="/OrbisNeighborHood;component/Images/Delete.png"
ImageMargin="4"
Click="Delete_Click"
Grid.Column="12"/>
</Grid>
</StackPanel>
</Border>
</UserControl>
@@ -0,0 +1,77 @@
using SimpleUI.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace OrbisNeighborHood.Controls
{
/// <summary>
/// Interaction logic for AppPanel.xaml
/// </summary>
public partial class AppPanel : UserControl
{
public AppPanel(string Name, string TitleId)
{
InitializeComponent();
}
private void AppPanelElement_MouseDown(object sender, MouseButtonEventArgs e)
{
// Check if application running.
// Start this application.
// Stop this application.
}
#region Buttons
private void StartStop_Click(object sender, RoutedEventArgs e)
{
}
private void Visibility_Click(object sender, RoutedEventArgs e)
{
}
private void ChangeIcon_Click(object sender, RoutedEventArgs e)
{
}
private void Unknown_Click(object sender, RoutedEventArgs e)
{
}
private void Unknown2_Click(object sender, RoutedEventArgs e)
{
}
private void Unknown3_Click(object sender, RoutedEventArgs e)
{
}
private void Delete_Click(object sender, RoutedEventArgs e)
{
}
#endregion
}
}
@@ -9,6 +9,7 @@
mc:Ignorable="d"
Width="305" Height="210"
d:DesignHeight="210" d:DesignWidth="305">
<Border VerticalAlignment="Stretch"
CornerRadius="10"
Background="{DynamicResource WindowBar}">
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

@@ -0,0 +1,50 @@
<UserControl x:Class="OrbisNeighborHood.MVVM.View.AppListView"
x:Name="AppListElement"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OrbisNeighborHood.MVVM.View"
xmlns:controls="clr-namespace:OrbisNeighborHood.Controls"
xmlns:simpleControls="clr-namespace:SimpleUI.Controls;assembly=SimpleUI"
mc:Ignorable="d"
Background="Transparent"
d:DesignHeight="585" d:DesignWidth="700">
<StackPanel>
<TextBlock Text="{Binding ElementName=AppListElement, Path=TitleString}"
Foreground="{DynamicResource Text}"
FontSize="28"
HorizontalAlignment="Left"
Margin="30,10,0,10"/>
<Grid Margin="20 0 20 30">
<ListBox Width="660" Height="500"
Background="Transparent"
BorderBrush="Transparent"
x:Name="AppList">
<!-- Sets the List view to be a uniform grid starting top left with 2 columns. -->
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid VerticalAlignment="Top" Columns="2"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<!-- Remove Selection & Add Margin to all Items -->
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Margin" Value="0 0 0 20" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Grid>
</StackPanel>
</UserControl>
@@ -0,0 +1,95 @@
using OrbisNeighborHood.Controls;
using OrbisSuite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reflection.Emit;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static OrbisSuite.TargetStateChangedEvent;
namespace OrbisNeighborHood.MVVM.View
{
/// <summary>
/// Interaction logic for AppListView.xaml
/// </summary>
public partial class AppListView : UserControl
{
public AppListView()
{
InitializeComponent();
OrbisLib.Instance.Events.DBTouched += Events_DBTouched;
OrbisLib.Instance.Events.TargetStateChanged += Events_TargetStateChanged;
RefreshTargetInfo();
RefreshAppList();
}
#region Properties
public string TitleString
{
get { return (string)GetValue(TitleStringProperty); }
set
{
SetValue(TitleStringProperty, $"Applications ({value})");
}
}
public static readonly DependencyProperty TitleStringProperty =
DependencyProperty.Register("TitleString", typeof(string), typeof(AppListView), new PropertyMetadata(string.Empty));
#endregion
#region Events / Refresh Target
private void Events_TargetStateChanged(object? sender, TargetStateChangedEvent e)
{
Dispatcher.Invoke(() => { RefreshTargetInfo(); });
}
private void Events_DBTouched(object? sender, DBTouchedEvent e)
{
Dispatcher.Invoke(() => { RefreshTargetInfo(); });
}
private void RefreshTargetInfo()
{
var CurrentTarget = OrbisLib.Instance.SelectedTarget.Info;
if (CurrentTarget != null)
{
TitleString = CurrentTarget.IsDefault ? $"★{CurrentTarget.Name}" : CurrentTarget.Name;
}
}
#endregion
public void RefreshAppList()
{
AppList.Items.Clear();
if (OrbisLib.Instance.TargetManagement.TargetList == null)
return;
for(int i = 0; i < 9; i++)
{
var appPanel = new AppPanel("", "");
AppList.Items.Add(appPanel);
}
}
}
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrbisNeighborHood.MVVM.ViewModel
{
internal class AppListViewModel
{
}
}
@@ -14,6 +14,8 @@ namespace OrbisNeighborHood.MVVM.ViewModel
public RelayCommand TargetViewCommand { get; set; }
public RelayCommand AppListViewCommand { get; set; }
public RelayCommand SettingsViewCommand { get; set; }
// View Models
@@ -21,6 +23,8 @@ namespace OrbisNeighborHood.MVVM.ViewModel
public TargetViewModel TargetVM { get; set; }
public AppListViewModel AppListVM { get; set; }
public SettingsViewModel SettingsVM { get; set; }
@@ -55,6 +59,7 @@ namespace OrbisNeighborHood.MVVM.ViewModel
// MainViews
DashboardHomeVM = new DashboardViewModel();
TargetVM = new TargetViewModel();
AppListVM = new AppListViewModel();
SettingsVM = new SettingsViewModel();
// Sub Views
@@ -75,6 +80,11 @@ namespace OrbisNeighborHood.MVVM.ViewModel
CurrentView = TargetVM;
});
AppListViewCommand = new RelayCommand(o =>
{
CurrentView = AppListVM;
});
SettingsViewCommand = new RelayCommand(o =>
{
CurrentView = SettingsVM;
@@ -20,6 +20,7 @@
<Window.Resources>
<view:DashboardView x:Key="DashboardViewKey"/>
<view:TargetView x:Key="TargetViewKey"/>
<view:AppListView x:Key="AppListViewKey"/>
<view:SettingsView x:Key="SettingsViewKey"/>
<DataTemplate DataType="{x:Type viewModel:DashboardViewModel}">
@@ -30,6 +31,10 @@
<ContentControl Content="{StaticResource TargetViewKey}" />
</DataTemplate>
<DataTemplate DataType="{x:Type viewModel:AppListViewModel}">
<ContentControl Content="{StaticResource AppListViewKey}" />
</DataTemplate>
<DataTemplate DataType="{x:Type viewModel:SettingsViewModel}">
<ContentControl Content="{StaticResource SettingsViewKey}" />
</DataTemplate>
@@ -90,6 +95,11 @@
Height="50"
Command="{Binding TargetViewCommand}"/>
<controls:MenuButton ImagePath="/OrbisNeighborHood;component/Images/AppList.png"
Text="Applications"
Height="50"
Command="{Binding AppListViewCommand}"/>
<controls:MenuButton ImagePath="/OrbisNeighborHood;component/Images/Settings.png"
Text="Settings"
Height="50"
@@ -9,12 +9,14 @@
</PropertyGroup>
<ItemGroup>
<None Remove="Images\AppList.png" />
<None Remove="Images\Consoles\Fat.png" />
<None Remove="Images\Consoles\Pro.png" />
<None Remove="Images\Consoles\Slim.png" />
<None Remove="Images\Default.ico" />
<None Remove="Images\DefaultAppIcon.png" />
<None Remove="Images\DefaultTitleIcon.png" />
<None Remove="Images\Delete.png" />
<None Remove="Images\Home.png" />
<None Remove="Images\Icons\OrbisConsoleOutput.ico" />
<None Remove="Images\Icons\OrbisDebugger.ico" />
@@ -26,13 +28,19 @@
<None Remove="Images\Locate.png" />
<None Remove="Images\NotDefault.ico" />
<None Remove="Images\Plus.png" />
<None Remove="Images\ReplaceIcon.png" />
<None Remove="Images\Restart.png" />
<None Remove="Images\RestMode.png" />
<None Remove="Images\ReturnArrow.png" />
<None Remove="Images\Send.png" />
<None Remove="Images\Settings.png" />
<None Remove="Images\Shutdown.png" />
<None Remove="Images\SpinningDualRing.gif" />
<None Remove="Images\Start.png" />
<None Remove="Images\Stop.png" />
<None Remove="Images\Targets.png" />
<None Remove="Images\UnAvailable.png" />
<None Remove="Images\Visibility.png" />
<None Remove="Resources\BuildNumber.txt" />
<None Remove="Resources\BuildString.txt" />
</ItemGroup>
@@ -42,6 +50,9 @@
</ItemGroup>
<ItemGroup>
<Resource Include="Images\AppList.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Consoles\Fat.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
@@ -60,6 +71,9 @@
<Resource Include="Images\DefaultTitleIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Delete.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Icons\OrbisConsoleOutput.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
@@ -90,6 +104,9 @@
<Resource Include="Images\Plus.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\ReplaceIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Restart.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
@@ -108,9 +125,24 @@
<Resource Include="Images\Home.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\SpinningDualRing.gif">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Start.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Stop.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Targets.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\UnAvailable.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Visibility.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<EmbeddedResource Include="Resources\BuildNumber.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
@@ -119,6 +151,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="WpfAnimatedGif" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Libraries\OrbisLib\OrbisLib.csproj" />
</ItemGroup>
@@ -1 +1 @@
1446
1521
@@ -1 +1 @@
Version 3.0.1446 Debug Build Saturday December 10 2022 4:19 PM
Version 3.0.1521 Debug Build Wednesday December 14 2022 3:38 PM