Suspend/Resume apps & some more button icons.

This commit is contained in:
Greg
2022-12-18 22:37:15 -07:00
parent 241396f9ff
commit 12e01180fe
18 changed files with 258 additions and 96 deletions
+50 -26
View File
@@ -48,6 +48,18 @@ void Apps::HandleAPI(OrbisNetId Sock, APIPacket* Packet)
KillApp(Sock, titleId);
break;
case API_APPS_SUSPEND:
SuspendApp(Sock, titleId);
break;
case API_APPS_RESUME:
ResumeApp(Sock, titleId);
break;
}
}
@@ -77,21 +89,17 @@ void Apps::GetAppInfoString(OrbisNetId Sock, const char* TitleId)
char KeyValue[50];
sceNetRecv(Sock, KeyValue, sizeof(KeyValue), 0);
klog("TitleId: %s\n", TitleId);
klog("Key: %s\n", KeyValue);
// Look up the key for that titleId in the app.db.
char OutStr[200];
memset(OutStr, 0, sizeof(OutStr));
AppDatabase::GetAppInfoString(TitleId, OutStr, sizeof(OutStr), KeyValue);
klog("OutStr: %s\n", OutStr);
// Send back the result.
sceNetSend(Sock, OutStr, sizeof(OutStr), 0);
}
void Apps::SendAppStatus(OrbisNetId Sock, const char* TitleId)
// TODO: Currently cant get the appId of child processes like the Web Browser since it is a child of the ShellUI.
int Apps::GetAppId(const char* TitleId)
{
int appId = 0;
@@ -114,6 +122,13 @@ void Apps::SendAppStatus(OrbisNetId Sock, const char* TitleId)
}
}
return appId;
}
void Apps::SendAppStatus(OrbisNetId Sock, const char* TitleId)
{
auto appId = GetAppId(TitleId);
// If we have no appId that means the process is not running.
if (appId <= 0)
{
@@ -161,26 +176,7 @@ void Apps::StartApp(OrbisNetId Sock, const char* TitleId)
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;
}
}
auto appId = GetAppId(TitleId);
if (appId > 0 && sceSystemServiceKillApp(appId, -1, 0, 0) == 0)
{
@@ -192,6 +188,34 @@ void Apps::KillApp(OrbisNetId Sock, const char* TitleId)
}
}
void Apps::SuspendApp(OrbisNetId Sock, const char* TitleId)
{
auto appId = GetAppId(TitleId);
if (appId > 0 && LncUtil::sceLncUtilSuspendApp(appId, 0) == 0)
{
SockSendInt(Sock, 1);
}
else
{
SockSendInt(Sock, 0);
}
}
void Apps::ResumeApp(OrbisNetId Sock, const char* TitleId)
{
auto appId = GetAppId(TitleId);
if (appId > 0 && LncUtil::sceLncUtilResumeApp(appId, 0) == 0)
{
SockSendInt(Sock, 1);
}
else
{
SockSendInt(Sock, 0);
}
}
Apps::Apps()
{
+3
View File
@@ -13,7 +13,10 @@ public:
private:
void GetAppsList(OrbisNetId Sock);
void GetAppInfoString(OrbisNetId Sock, const char* TitleId);
int GetAppId(const char* TitleId);
void SendAppStatus(OrbisNetId Sock, const char* TitleId);
void StartApp(OrbisNetId Sock, const char* TitleId);
void KillApp(OrbisNetId Sock, const char* TitleId);
void SuspendApp(OrbisNetId Sock, const char* TitleId);
void ResumeApp(OrbisNetId Sock, const char* TitleId);
};
+26 -6
View File
@@ -4,6 +4,8 @@
uint64_t LncUtil::LibraryBaseAddress = 0;
int(*LncUtil::_sceLncUtilGetAppId)(const char*);
int(*LncUtil::_sceLncUtilLaunchApp)(const char* titleId, char* args, LaunchAppParam* appParam);
int(*LncUtil::_sceLncUtilSuspendApp)(int AppId, int Flag);
int(*LncUtil::_sceLncUtilResumeApp)(int AppId, int Flag);
int LncUtil::Init()
{
@@ -45,6 +47,8 @@ int LncUtil::Init()
// Set up Functions.
_sceLncUtilGetAppId = (decltype(_sceLncUtilGetAppId))(LibraryBaseAddress + 0x4E10);
_sceLncUtilLaunchApp = (decltype(_sceLncUtilLaunchApp))(LibraryBaseAddress + 0x4C10);
_sceLncUtilSuspendApp = (decltype(_sceLncUtilSuspendApp))(LibraryBaseAddress + 0x4F20);
_sceLncUtilResumeApp = (decltype(_sceLncUtilResumeApp))(LibraryBaseAddress + 0x4F40);
return 0;
}
@@ -70,17 +74,33 @@ int LncUtil::sceLncUtilLaunchApp(const char* titleId, char* args, LaunchAppParam
}
else
{
klog("failed to resolve sceLncUtilGetAppId\n");
klog("failed to resolve sceLncUtilLaunchApp\n");
return -1;
}
}
/*int SuspensceLncUtilSuspendAppdApp(int AppId, int Flag)
int LncUtil::sceLncUtilSuspendApp(int AppId, int Flag)
{
if ((uint64_t)_sceLncUtilSuspendApp > 0x4F20)
{
return _sceLncUtilSuspendApp(AppId, Flag);
}
else
{
klog("failed to resolve sceLncUtilSuspendApp\n");
return -1;
}
}
int sceLncUtilResumeApp(int AppId, int Flag)
int LncUtil::sceLncUtilResumeApp(int AppId, int Flag)
{
}*/
if ((uint64_t)_sceLncUtilResumeApp > 0x4F40)
{
return _sceLncUtilResumeApp(AppId, Flag);
}
else
{
klog("failed to resolve sceLncUtilResumeApp\n");
return -1;
}
}
+4
View File
@@ -46,9 +46,13 @@ public:
static int Init();
static int sceLncUtilGetAppId(const char* TitleId);
static int sceLncUtilLaunchApp(const char* titleId, char* args, LaunchAppParam* appParam);
static int sceLncUtilSuspendApp(int AppId, int Flag);
static int sceLncUtilResumeApp(int AppId, int Flag);
private:
static uint64_t LibraryBaseAddress;
static int(*_sceLncUtilGetAppId)(const char* titleId);
static int(*_sceLncUtilLaunchApp)(const char* titleId, char* args, LaunchAppParam* appParam);
static int(*_sceLncUtilSuspendApp)(int AppId, int Flag);
static int(*_sceLncUtilResumeApp)(int AppId, int Flag);
};
+11 -11
View File
@@ -1,11 +1,11 @@
#pragma once
#define ORBISLIB_MAJOR 3
#define ORBISLIB_MINOR 0
#define ORBISLIB_BUILDVERSION 635
#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 636
#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
@@ -188,7 +188,69 @@ namespace OrbisSuite
return false;
}
APIResults apiResult = API.CallLong(Target.Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_APPS_STOP }, out Socket Sock);
var apiResult = API.CallLong(Target.Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_APPS_STOP }, out Socket Sock);
if (apiResult != APIResults.API_OK)
return false;
// Send the titleId of the app.
var bytes = Encoding.ASCII.GetBytes(TitleId.PadRight(10, '\0')).Take(10).ToArray();
Sock.Send(bytes);
// Get the state from API.
var result = Sock.RecvInt32();
// close socket.
Sock.Close();
return (result == 1);
}
public bool Suspend(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;
}
var apiResult = API.CallLong(Target.Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_APPS_SUSPEND }, out Socket Sock);
if (apiResult != APIResults.API_OK)
return false;
// Send the titleId of the app.
var bytes = Encoding.ASCII.GetBytes(TitleId.PadRight(10, '\0')).Take(10).ToArray();
Sock.Send(bytes);
// Get the state from API.
var result = Sock.RecvInt32();
// close socket.
Sock.Close();
return (result == 1);
}
public bool Resume(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;
}
var apiResult = API.CallLong(Target.Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_APPS_RESUME }, out Socket Sock);
if (apiResult != APIResults.API_OK)
return false;
+1 -1
View File
@@ -14,7 +14,7 @@ namespace OrbisSuite.Common
{
Sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
return Sock.EasyConnect(IPAddr, Port, 4000);
return Sock.EasyConnect(IPAddr, Port, -1);
}
/// <summary>
@@ -149,6 +149,17 @@
Click="StartStop_Click"
Grid.Column="0"/>
<!-- Suspend / Resume -->
<local:ImageButton x:Name="SuspendResume"
Width="35"
Height="35"
ToolTip="Suspend {Application Name}."
ImageSource="/OrbisNeighborHood;component/Images/UnAvailable.png"
ImageMargin="4"
Click="SuspendResume_Click"
IsEnabled="False"
Grid.Column="2"/>
<!-- Visibility -->
<local:ImageButton x:Name="Visibility"
Width="35"
@@ -157,7 +168,7 @@
ImageSource="/OrbisNeighborHood;component/Images/Visibility.png"
ImageMargin="4"
Click="Visibility_Click"
Grid.Column="2"/>
Grid.Column="4"/>
<!-- Change Icon -->
<local:ImageButton x:Name="ChangeIcon"
@@ -167,39 +178,26 @@
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"
<!-- OpenStore -->
<local:ImageButton x:Name="OpenStore"
Width="35"
Height="35"
ToolTip="TBD"
ImageSource="/OrbisNeighborHood;component/Images/UnAvailable.png"
ToolTip="Open in Playstation store."
ImageSource="/OrbisNeighborHood;component/Images/Store.png"
ImageMargin="4"
Click="Unknown2_Click"
IsEnabled="False"
Click="OpenStore_Click"
Grid.Column="8"/>
<!-- Unknown3 -->
<local:ImageButton x:Name="Unknown3"
<!-- More Info -->
<local:ImageButton x:Name="MoreInfo"
Width="35"
Height="35"
ToolTip="TBD"
ImageSource="/OrbisNeighborHood;component/Images/UnAvailable.png"
ToolTip="See more info about {Application Name}."
ImageSource="/OrbisNeighborHood;component/Images/Info.png"
ImageMargin="4"
Click="Unknown3_Click"
IsEnabled="False"
Click="MoreInfo_Click"
Grid.Column="10"/>
<!-- Delete -->
@@ -62,7 +62,9 @@ namespace OrbisNeighborHood.Controls
StartStop.ToolTip = $"Start {App.TitleName}.";
Visibility.ToolTip = $"Hide {App.TitleName} from Home Menu.";
ChangeIcon.ToolTip = $"Change the icon of {App.TitleName}.";
// 3 more TBD here.
SuspendResume.ToolTip = $"Not available while {App.TitleName} is not running.";
// TODO: One TBD.
MoreInfo.ToolTip = $"See more info about {App.TitleName}.";
Delete.ToolTip = $"Delete {App.TitleName}.";
}
@@ -80,13 +82,35 @@ namespace OrbisNeighborHood.Controls
// App status.
if (AppState == AppState.STATE_RUNNING || AppState == AppState.STATE_SUSPENDED)
{
Dispatcher.Invoke(() => StartStop.ToolTip = $"Stop {App.TitleName}.");
Dispatcher.Invoke(() => StartStop.ImageSource = "/OrbisNeighborHood;component/Images/Stop.png");
Dispatcher.Invoke(() =>
{
StartStop.ToolTip = $"Stop {App.TitleName}.";
StartStop.ImageSource = "/OrbisNeighborHood;component/Images/Stop.png";
SuspendResume.IsEnabled = true;
if (AppState == AppState.STATE_SUSPENDED)
{
SuspendResume.ToolTip = $"Resume {App.TitleName}.";
SuspendResume.ImageSource = "/OrbisNeighborHood;component/Images/Start.png";
}
else
{
SuspendResume.ToolTip = $"Suspend {App.TitleName}.";
SuspendResume.ImageSource = "/OrbisNeighborHood;component/Images/Suspend.png";
}
});
}
else
{
Dispatcher.Invoke(() => StartStop.ToolTip = $"Start {App.TitleName}.");
Dispatcher.Invoke(() => StartStop.ImageSource = "/OrbisNeighborHood;component/Images/Start.png");
Dispatcher.Invoke(() =>
{
StartStop.ToolTip = $"Start {App.TitleName}.";
StartStop.ImageSource = "/OrbisNeighborHood;component/Images/Start.png";
SuspendResume.ToolTip = $"Not available while {App.TitleName} is not running.";
SuspendResume.ImageSource = "/OrbisNeighborHood;component/Images/UnAvailable.png";
SuspendResume.IsEnabled = false;
});
}
// App Visibility.
@@ -121,6 +145,22 @@ namespace OrbisNeighborHood.Controls
});
}
private void SuspendResume_Click(object sender, RoutedEventArgs e)
{
Task.Run(() =>
{
var currentTarget = OrbisLib.Instance.SelectedTarget;
if (AppState == AppState.STATE_SUSPENDED)
{
currentTarget.Application.Resume(App.TitleId);
}
else
{
currentTarget.Application.Suspend(App.TitleId);
}
});
}
private void Visibility_Click(object sender, RoutedEventArgs e)
{
@@ -131,17 +171,12 @@ namespace OrbisNeighborHood.Controls
}
private void Unknown_Click(object sender, RoutedEventArgs e)
private void OpenStore_Click(object sender, RoutedEventArgs e)
{
}
private void Unknown2_Click(object sender, RoutedEventArgs e)
{
}
private void Unknown3_Click(object sender, RoutedEventArgs e)
private void MoreInfo_Click(object sender, RoutedEventArgs e)
{
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

@@ -37,6 +37,8 @@ namespace OrbisNeighborHood.MVVM.View
"NPXS20112",
"NPXS20133",
"NPXS20132",
"CUSA02012", // Media Player
"NPXS20979", // Playstation Store
// Destiny? lol
"CUSA00219",
@@ -191,13 +193,10 @@ namespace OrbisNeighborHood.MVVM.View
var appList = currentTarget.Application.GetAppList();
foreach (var app in appList)
Parallel.ForEach(appList, app =>
{
Parallel.Invoke(() =>
{
AddApp(appCachePath, app);
});
}
AddApp(appCachePath, app);
});
}
private async Task CheckAppDatabase()
@@ -224,24 +223,26 @@ namespace OrbisNeighborHood.MVVM.View
var appList = currentTarget.Application.GetAppList();
// Check for deletions.
foreach (var app in AppList.Items.Cast<AppPanel>().ToList())
Parallel.ForEach(AppList.Items.Cast<AppPanel>().ToList(), app =>
{
if (appList.Find(x => x.TitleId == app.App.TitleId) == null)
{
Dispatcher.Invoke(() => AppList.Items.Remove(app));
}
}
});
// Check for new apps / updates.
foreach (var app in appList)
Parallel.ForEach(appList, app =>
{
Parallel.Invoke(() =>
var currentAppList = AppList.Items.Cast<AppPanel>().ToList();
if (currentAppList.Find(x => x.App.TitleId == app.TitleId) == null)
{
AddApp(appCachePath, app);
});
}
}
});
await Task.Delay(1000);
await Task.Delay(2000);
}
catch (Exception ex)
{
@@ -25,6 +25,7 @@
<None Remove="Images\Icons\OrbisPeeknPoke.ico" />
<None Remove="Images\Icons\OrbisTargetSettings.ico" />
<None Remove="Images\Icons\OrbisTaskbarApp.ico" />
<None Remove="Images\Info.png" />
<None Remove="Images\Locate.png" />
<None Remove="Images\NotDefault.ico" />
<None Remove="Images\Plus.png" />
@@ -38,6 +39,8 @@
<None Remove="Images\SpinningDualRing.gif" />
<None Remove="Images\Start.png" />
<None Remove="Images\Stop.png" />
<None Remove="Images\Store.png" />
<None Remove="Images\Suspend.png" />
<None Remove="Images\Targets.png" />
<None Remove="Images\UnAvailable.png" />
<None Remove="Images\Visibility.png" />
@@ -49,6 +52,12 @@
<Content Include="OrbisNeighborhood.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Store.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\AppList.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -95,6 +104,9 @@
<Resource Include="Images\Icons\OrbisTaskbarApp.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Info.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Locate.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
@@ -134,6 +146,9 @@
<Resource Include="Images\Stop.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Suspend.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Targets.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
@@ -1 +1 @@
1956
1976
@@ -1 +1 @@
Version 3.0.1956 Debug Build Sunday December 18 2022 7:40 PM
Version 3.0.1976 Debug Build Sunday December 18 2022 10:33 PM