Clean up libjbc, add sqlite library, App Start/Stop API commands added & Added more to lncutil temp class.
This commit is contained in:
@@ -9,3 +9,6 @@
|
||||
[submodule "External/ps4-libjbc"]
|
||||
path = External/ps4-libjbc
|
||||
url = https://github.com/OSM-Made/ps4-libjbc
|
||||
[submodule "External/LibSQLite-ps4"]
|
||||
path = External/LibSQLite-ps4
|
||||
url = https://github.com/bucanero/libSQLite-ps4
|
||||
|
||||
+1
Submodule External/LibSQLite-ps4 added at 0d55afbab1
Vendored
+1
-1
Submodule External/ps4-libjbc updated: e155da5ce3...513b6d78eb
@@ -15,17 +15,11 @@ extern "C"
|
||||
size_t data_size;
|
||||
};
|
||||
|
||||
struct ProcInfo
|
||||
{
|
||||
char ProcName[32];
|
||||
};
|
||||
|
||||
void jbc_run_as_root(void(*fn)(void* arg), void* arg, int cwd_mode);
|
||||
int jbc_mount_in_sandbox(const char* system_path, const char* mnt_name);
|
||||
int jbc_unmount_in_sandbox(const char* mnt_name);
|
||||
int jbc_set_proc_name(const char* New_Name);
|
||||
int jbc_get_proc_libraries(struct LibraryInfo* out, int maxCount);
|
||||
uint64_t jbc_get_proc_list(struct ProcInfo* out, int maxCount);
|
||||
|
||||
struct jbc_cred
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Common.h"
|
||||
#include "Apps.h"
|
||||
#include <orbis/SysCore.h>
|
||||
#include <orbis/SystemService.h>
|
||||
|
||||
void Apps::HandleAPI(OrbisNetId Sock, APIPacket* Packet)
|
||||
{
|
||||
@@ -17,6 +18,18 @@ void Apps::HandleAPI(OrbisNetId Sock, APIPacket* Packet)
|
||||
|
||||
SendAppStatus(Sock, titleId);
|
||||
|
||||
break;
|
||||
|
||||
case API_APPS_START:
|
||||
|
||||
StartApp(Sock, titleId);
|
||||
|
||||
break;
|
||||
|
||||
case API_APPS_STOP:
|
||||
|
||||
KillApp(Sock, titleId);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -64,6 +77,64 @@ void Apps::SendAppStatus(OrbisNetId Sock, const char* TitleId)
|
||||
}
|
||||
}
|
||||
|
||||
void Apps::StartApp(OrbisNetId Sock, const char* TitleId)
|
||||
{
|
||||
LaunchAppParam appParam;
|
||||
appParam.size = sizeof(LaunchAppParam);
|
||||
|
||||
if (auto res = sceUserServiceGetForegroundUser(&appParam.userId) != 0)
|
||||
{
|
||||
klog("sceUserServiceGetForegroundUser(): Failed with error %llX\n", res);
|
||||
|
||||
SockSendInt(Sock, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
auto res = LncUtil::sceLncUtilLaunchApp(TitleId, nullptr, &appParam);
|
||||
if (res <= 0)
|
||||
{
|
||||
klog("sceLncUtilLaunchApp() : Failed with error % llX\n", res);
|
||||
|
||||
SockSendInt(Sock, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
SockSendInt(Sock, res);
|
||||
}
|
||||
|
||||
void Apps::KillApp(OrbisNetId Sock, const char* TitleId)
|
||||
{
|
||||
int appId = 0;
|
||||
|
||||
// Get the list of running processes.
|
||||
std::vector<kinfo_proc> processList;
|
||||
GetProcessList(processList);
|
||||
|
||||
for (const auto& i : processList)
|
||||
{
|
||||
// Get the app info using the pid.
|
||||
OrbisAppInfo appInfo;
|
||||
sceKernelGetAppInfo(i.pid, &appInfo);
|
||||
|
||||
// Using the titleId match our desired app and return the appId from the appinfo.
|
||||
if (!strcmp(appInfo.TitleId, TitleId))
|
||||
{
|
||||
appId = appInfo.AppId;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (appId > 0 && sceSystemServiceKillApp(appId, -1, 0, 0) == 0)
|
||||
{
|
||||
SockSendInt(Sock, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
SockSendInt(Sock, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Apps::Apps()
|
||||
{
|
||||
|
||||
|
||||
@@ -12,4 +12,6 @@ public:
|
||||
|
||||
private:
|
||||
void SendAppStatus(OrbisNetId Sock, const char* TitleId);
|
||||
void StartApp(OrbisNetId Sock, const char* TitleId);
|
||||
void KillApp(OrbisNetId Sock, const char* TitleId);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
uint64_t LncUtil::LibraryBaseAddress = 0;
|
||||
int(*LncUtil::_sceLncUtilGetAppId)(const char*);
|
||||
int(*LncUtil::_GetAppStatusListForShellUIReboot)(AppStatusForShellUIReboot* outStatusList, unsigned int numEntries, unsigned int* outEntries);
|
||||
int(*LncUtil::_sceLncUtilLaunchApp)(const char* titleId, char* args, LaunchAppParam* appParam);
|
||||
|
||||
int LncUtil::Init()
|
||||
{
|
||||
@@ -44,7 +44,7 @@ int LncUtil::Init()
|
||||
|
||||
// Set up Functions.
|
||||
_sceLncUtilGetAppId = (decltype(_sceLncUtilGetAppId))(LibraryBaseAddress + 0x4E10);
|
||||
_GetAppStatusListForShellUIReboot = (decltype(_GetAppStatusListForShellUIReboot))(LibraryBaseAddress + 0x4FA0);
|
||||
_sceLncUtilLaunchApp = (decltype(_sceLncUtilLaunchApp))(LibraryBaseAddress + 0x4C10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -62,11 +62,11 @@ int LncUtil::sceLncUtilGetAppId(const char* TitleId)
|
||||
}
|
||||
}
|
||||
|
||||
int LncUtil::GetAppStatusListForShellUIReboot(AppStatusForShellUIReboot* outStatusList, unsigned int numEntries, unsigned int* outEntries)
|
||||
int LncUtil::sceLncUtilLaunchApp(const char* titleId, char* args, LaunchAppParam* appParam)
|
||||
{
|
||||
if ((uint64_t)_GetAppStatusListForShellUIReboot > 0x4FA0)
|
||||
if ((uint64_t)_sceLncUtilLaunchApp > 0x4C10)
|
||||
{
|
||||
return _GetAppStatusListForShellUIReboot(outStatusList, numEntries, outEntries);
|
||||
return _sceLncUtilLaunchApp(titleId, args, appParam);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -20,20 +20,24 @@ struct AppStatus
|
||||
char AppType;
|
||||
};
|
||||
|
||||
struct AppStatusForShellUIReboot
|
||||
enum Flag
|
||||
{
|
||||
int appId;
|
||||
char appType;
|
||||
char appAttr;
|
||||
int launchRequestAppId;
|
||||
int userId;
|
||||
int isActiveCdlg;
|
||||
char path[1024];
|
||||
int isCoredumped;
|
||||
int isPrxModuleLoadFailed;
|
||||
int appLocalPid;
|
||||
char crashReportMode;
|
||||
char category[4];
|
||||
Flag_None = 0,
|
||||
SkipLaunchCheck = 1,
|
||||
SkipResumeCheck = 1,
|
||||
SkipSystemUpdateCheck = 2,
|
||||
RebootPatchInstall = 4,
|
||||
VRMode = 8,
|
||||
NonVRMode = 16
|
||||
};
|
||||
|
||||
struct LaunchAppParam
|
||||
{
|
||||
unsigned int size; //0x00
|
||||
int userId; //0x04
|
||||
int appAttr; //0x08
|
||||
int enableCrashReport; //0x0C
|
||||
uint64_t checkFlag; //0x10
|
||||
};
|
||||
|
||||
class LncUtil
|
||||
@@ -41,10 +45,10 @@ class LncUtil
|
||||
public:
|
||||
static int Init();
|
||||
static int sceLncUtilGetAppId(const char* TitleId);
|
||||
static int GetAppStatusListForShellUIReboot(AppStatusForShellUIReboot* outStatusList, unsigned int numEntries, unsigned int* outEntries);
|
||||
static int sceLncUtilLaunchApp(const char* titleId, char* args, LaunchAppParam* appParam);
|
||||
|
||||
private:
|
||||
static uint64_t LibraryBaseAddress;
|
||||
static int(*_sceLncUtilGetAppId)(const char* titleId);
|
||||
static int(*_GetAppStatusListForShellUIReboot)(AppStatusForShellUIReboot* outStatusList, unsigned int numEntries, unsigned int* outEntries);
|
||||
static int(*_sceLncUtilLaunchApp)(const char* titleId, char* args, LaunchAppParam* appParam);
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
#define ORBISLIB_MAJOR 3
|
||||
#define ORBISLIB_MINOR 0
|
||||
#define ORBISLIB_BUILDVERSION 557
|
||||
#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 577
|
||||
#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
|
||||
|
||||
@@ -85,7 +85,7 @@ int main()
|
||||
sceApplicationInitialize();
|
||||
|
||||
// start up the API. NOTE: this is blocking.
|
||||
//API::Init();
|
||||
API::Init();
|
||||
|
||||
sceSystemServiceLoadExec("exit", 0);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrbisSuite
|
||||
@@ -20,7 +21,7 @@ namespace OrbisSuite
|
||||
|
||||
public AppState GetAppState(string TitleId)
|
||||
{
|
||||
if(TitleId.Length > 10)
|
||||
if (!Regex.IsMatch(TitleId, @"[a-zA-Z]{4}\d{5}"))
|
||||
{
|
||||
Console.WriteLine($"Invaild titleId format {TitleId}");
|
||||
return AppState.STATE_ERROR;
|
||||
@@ -48,5 +49,67 @@ namespace OrbisSuite
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool Start(string TitleId)
|
||||
{
|
||||
if (!Regex.IsMatch(TitleId, @"[a-zA-Z]{4}\d{5}"))
|
||||
{
|
||||
Console.WriteLine($"Invaild titleId format {TitleId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Target.Info.Details.IsAPIAvailable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
APIResults apiResult = API.CallLong(Target.Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_APP_START }, out Socket Sock);
|
||||
|
||||
if (apiResult != APIResults.API_OK)
|
||||
return false;
|
||||
|
||||
// Send the titleId of the app.
|
||||
var bytes = Encoding.ASCII.GetBytes(TitleId.PadRight(9, '\0')).Take(9).ToArray();
|
||||
Sock.Send(bytes);
|
||||
|
||||
// Get the state from API.
|
||||
var result = Sock.RecvInt32();
|
||||
|
||||
// close socket.
|
||||
Sock.Close();
|
||||
|
||||
return (result == 1);
|
||||
}
|
||||
|
||||
public bool Stop(string TitleId)
|
||||
{
|
||||
if (!Regex.IsMatch(TitleId, @"[a-zA-Z]{4}\d{5}"))
|
||||
{
|
||||
Console.WriteLine($"Invaild titleId format {TitleId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Target.Info.Details.IsAPIAvailable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
APIResults apiResult = API.CallLong(Target.Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_APP_STOP }, out Socket Sock);
|
||||
|
||||
if (apiResult != APIResults.API_OK)
|
||||
return false;
|
||||
|
||||
// Send the titleId of the app.
|
||||
var bytes = Encoding.ASCII.GetBytes(TitleId.PadRight(9, '\0')).Take(9).ToArray();
|
||||
Sock.Send(bytes);
|
||||
|
||||
// Get the state from API.
|
||||
var result = Sock.RecvInt32();
|
||||
|
||||
// close socket.
|
||||
Sock.Close();
|
||||
|
||||
return (result == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OrbisSuite.Common
|
||||
{
|
||||
Sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
|
||||
return Sock.EasyConnect(IPAddr, Port, 2000);
|
||||
return Sock.EasyConnect(IPAddr, Port, 4000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -122,7 +122,18 @@ namespace OrbisNeighborHood.Controls
|
||||
|
||||
private void StartStop_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Console.WriteLine($"{App.titleId} AppStatus: {AppState}");
|
||||
Task.Run(() =>
|
||||
{
|
||||
var currentTarget = OrbisLib.Instance.SelectedTarget;
|
||||
if (AppState == AppState.STATE_RUNNING || AppState == AppState.STATE_SUSPENDED)
|
||||
{
|
||||
currentTarget.Application.Stop(App.titleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentTarget.Application.Start(App.titleId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void Visibility_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -1 +1 @@
|
||||
1831
|
||||
1856
|
||||
|
||||
@@ -1 +1 @@
|
||||
Version 3.0.1831 Debug Build Saturday December 17 2022 2:37 PM
|
||||
Version 3.0.1856 Debug Build Saturday December 17 2022 6:19 PM
|
||||
|
||||
Reference in New Issue
Block a user