Remove OrbisLib and Convert final project to OrbisLib2.

This commit is contained in:
Greg
2022-12-23 10:44:24 -07:00
parent 40d4941d3a
commit 64a385ef3b
41 changed files with 26 additions and 3721 deletions
-20
View File
@@ -21,8 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrbisNeighborHood", "Window
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Installer", "Installer", "{6046C772-BE17-4BC8-A362-AD8C77F9178E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrbisLib", "Windows\Libraries\OrbisLib\OrbisLib.csproj", "{6AE42BFE-1833-4804-96EB-38D323B6C28E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrbisSuiteService", "Windows\OrbisSuiteService\OrbisSuiteService.csproj", "{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OrbisSuite", "Playstation\OrbisSuite\OrbisSuite.vcxproj", "{228AA300-11F5-49B1-A6B5-4986635C6D0B}"
@@ -37,7 +35,6 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "BootstrapperSetup", "Window
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "DummyInstaller", "Windows\Installer\DummyInstaller\DummyInstaller.wixproj", "{A37095E9-80BD-4A6B-AF8B-33D278CF92F3}"
ProjectSection(ProjectDependencies) = postProject
{6AE42BFE-1833-4804-96EB-38D323B6C28E} = {6AE42BFE-1833-4804-96EB-38D323B6C28E}
{81B068F7-776C-429F-BB7B-5563F75F1A39} = {81B068F7-776C-429F-BB7B-5563F75F1A39}
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF} = {D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}
EndProjectSection
@@ -80,22 +77,6 @@ Global
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Release|x64.Build.0 = Release|Any CPU
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Release|x86.ActiveCfg = Release|Any CPU
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Release|x86.Build.0 = Release|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|Win32.ActiveCfg = Debug|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|Win32.Build.0 = Debug|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|x64.ActiveCfg = Debug|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|x64.Build.0 = Debug|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|x86.ActiveCfg = Debug|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|x86.Build.0 = Debug|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|Any CPU.Build.0 = Release|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|Win32.ActiveCfg = Release|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|Win32.Build.0 = Release|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|x64.ActiveCfg = Release|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|x64.Build.0 = Release|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|x86.ActiveCfg = Release|Any CPU
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|x86.Build.0 = Release|Any CPU
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Debug|Win32.ActiveCfg = Debug|Any CPU
@@ -264,7 +245,6 @@ Global
{72E29C1E-8723-4885-A5ED-BD3A929D81B6} = {8F0E1457-FB1E-47A4-9DA8-74A6B757CAA4}
{81B068F7-776C-429F-BB7B-5563F75F1A39} = {8F0E1457-FB1E-47A4-9DA8-74A6B757CAA4}
{6046C772-BE17-4BC8-A362-AD8C77F9178E} = {8F0E1457-FB1E-47A4-9DA8-74A6B757CAA4}
{6AE42BFE-1833-4804-96EB-38D323B6C28E} = {72E29C1E-8723-4885-A5ED-BD3A929D81B6}
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF} = {8F0E1457-FB1E-47A4-9DA8-74A6B757CAA4}
{228AA300-11F5-49B1-A6B5-4986635C6D0B} = {8E8E4C8D-E3E1-4CB9-BD78-7ADAB2F2CF45}
{57244F52-BA7C-4D89-9C38-D80AD9727721} = {8E8E4C8D-E3E1-4CB9-BD78-7ADAB2F2CF45}
@@ -1,104 +0,0 @@
using OrbisSuite.Common;
using OrbisSuite.Common.Dispatcher;
using System.Net.Sockets;
using System.Text;
using TinyIpc.Messaging;
namespace OrbisSuite
{
public class DispatcherClient
{
private OrbisLib PS4;
private TinyMessageBus _ServiceMessageBus;
public DispatcherClient(OrbisLib PS4)
{
this.PS4 = PS4;
_ServiceMessageBus = new TinyMessageBus("OrbisSuite");
_ServiceMessageBus.MessageReceived += _ServiceMessageBus_MessageReceived; ;
}
private void _ServiceMessageBus_MessageReceived(object? sender, TinyMessageReceivedEventArgs e)
{
var Packet = (ForwardPacket)Helpers.ByteArrayToObject(e.Message.ToArray());
switch (Packet.Type)
{
default:
Console.WriteLine("Invalid Packet...");
break;
// Debugging
case ForwardPacket.PacketType.Print:
PS4.DefaultTarget.Events.RaiseProcPrintEvent(Packet.SenderIPAddress, Packet.Print.Sender, Packet.Print.Data);
PS4.SelectedTarget.Events.RaiseProcPrintEvent(Packet.SenderIPAddress, Packet.Print.Sender, Packet.Print.Data);
break;
case ForwardPacket.PacketType.SerialCom:
Console.Write(Encoding.UTF8.GetString(Packet.SerialCom.Data));
break;
case ForwardPacket.PacketType.Intercept:
PS4.DefaultTarget.Events.RaiseProcInterceptEvent(Packet.SenderIPAddress);
PS4.SelectedTarget.Events.RaiseProcInterceptEvent(Packet.SenderIPAddress);
break;
case ForwardPacket.PacketType.Continue:
PS4.DefaultTarget.Events.RaiseProcContinueEvent(Packet.SenderIPAddress);
PS4.SelectedTarget.Events.RaiseProcContinueEvent(Packet.SenderIPAddress);
break;
// Process States
case ForwardPacket.PacketType.ProcessDie:
PS4.DefaultTarget.Events.RaiseProcDieEvent(Packet.SenderIPAddress);
PS4.SelectedTarget.Events.RaiseProcDieEvent(Packet.SenderIPAddress);
break;
case ForwardPacket.PacketType.ProcessAttach:
PS4.DefaultTarget.Events.RaiseProcAttachEvent(Packet.SenderIPAddress, Packet.ProcessName);
PS4.SelectedTarget.Events.RaiseProcAttachEvent(Packet.SenderIPAddress, Packet.ProcessName);
break;
case ForwardPacket.PacketType.ProcessDetach:
PS4.DefaultTarget.Events.RaiseProcDetachEvent(Packet.SenderIPAddress);
PS4.SelectedTarget.Events.RaiseProcDetachEvent(Packet.SenderIPAddress);
break;
// Target State
case ForwardPacket.PacketType.TargetSuspend:
PS4.DefaultTarget.Events.RaiseTargetSuspendEvent(Packet.SenderIPAddress);
PS4.SelectedTarget.Events.RaiseTargetSuspendEvent(Packet.SenderIPAddress);
break;
case ForwardPacket.PacketType.TargetResume:
PS4.DefaultTarget.Events.RaiseTargetResumeEvent(Packet.SenderIPAddress);
PS4.SelectedTarget.Events.RaiseTargetResumeEvent(Packet.SenderIPAddress);
break;
case ForwardPacket.PacketType.TargetShutdown:
PS4.DefaultTarget.Events.RaiseTargetShutdownEvent(Packet.SenderIPAddress);
PS4.SelectedTarget.Events.RaiseTargetShutdownEvent(Packet.SenderIPAddress);
break;
case ForwardPacket.PacketType.TargetNewTitle:
PS4.DefaultTarget.Events.RaiseTargetNewTitleEvent(Packet.SenderIPAddress, Packet.TitleChange.TitleID);
PS4.SelectedTarget.Events.RaiseTargetNewTitleEvent(Packet.SenderIPAddress, Packet.TitleChange.TitleID);
break;
case ForwardPacket.PacketType.TargetAvailability:
PS4.Events.FireTargetAvailability(Packet.TargetAvailability.Available, Packet.TargetAvailability.Name);
break;
case ForwardPacket.PacketType.TargetAPIAvailability:
PS4.Events.FireTargetAPIAvailability(Packet.TargetAvailability.Available, Packet.TargetAvailability.Name);
break;
// Misc
case ForwardPacket.PacketType.DBTouched:
PS4.Events.FireDBTouched();
break;
}
}
}
}
@@ -1,29 +0,0 @@
namespace OrbisSuite
{
public class DBTouchedEvent : EventArgs
{
public DBTouchedEvent() { }
}
public class TargetStateChangedEvent : EventArgs
{
public enum TargetState
{
None,
Available,
UnAvailable,
APIAvailable,
APIUnAvailable,
};
public TargetState State { get; private set; }
public string Name { get; private set; }
public TargetStateChangedEvent(string Name, TargetState State)
{
this.Name = Name;
this.State = State;
}
}
}
@@ -1,49 +0,0 @@
namespace OrbisSuite
{
public class Events
{
/// <summary>
/// The DBTouched Event gets invoked when the Database used to store target specific info is changed.
/// </summary>
public event EventHandler<DBTouchedEvent>? DBTouched;
/// <summary>
/// Even is fired when ever the state of the target changes.
/// </summary>
public event EventHandler<TargetStateChangedEvent>? TargetStateChanged;
/// <summary>
/// Will Fire the event for when the Database has been updated.
/// </summary>
internal void FireDBTouched()
{
DBTouched?.Invoke(null, new DBTouchedEvent());
}
/// <summary>
/// Will Fire the event for Target Availability.
/// </summary>
/// <param name="Available"></param>
/// <param name="TargetName"></param>
internal void FireTargetAvailability(bool Available, string TargetName)
{
if (Available)
TargetStateChanged?.Invoke(null, new TargetStateChangedEvent(TargetName, TargetStateChangedEvent.TargetState.Available));
else
TargetStateChanged?.Invoke(null, new TargetStateChangedEvent(TargetName, TargetStateChangedEvent.TargetState.UnAvailable));
}
/// <summary>
/// Will Fire the event for Target API Availability.
/// </summary>
/// <param name="Available"></param>
/// <param name="TargetName"></param>
internal void FireTargetAPIAvailability(bool Available, string TargetName)
{
if (Available)
TargetStateChanged?.Invoke(null, new TargetStateChangedEvent(TargetName, TargetStateChangedEvent.TargetState.APIAvailable));
else
TargetStateChanged?.Invoke(null, new TargetStateChangedEvent(TargetName, TargetStateChangedEvent.TargetState.APIUnAvailable));
}
}
}
-166
View File
@@ -1,166 +0,0 @@
using System.Net;
using System.Text;
using System.Json;
using System.Text.RegularExpressions;
using System.Security.Cryptography;
namespace OrbisSuite
{
public class TMDB
{
private string Internal_TitleID = "";
public string TitleID
{
get
{
return Internal_TitleID;
}
set
{
Internal_TitleID = value.Contains("_00") ? value : value + "_00";
//Update the url for the new TitleID
tmdbUrl = GetUrl();
//Download the Json document and parse the data.
ParseJson();
}
}
public string tmdbUrl { get; private set; }
public JsonValue Data { get; private set; }
//Json Data
public int Revision { get; private set; }
public int PatchRevision { get; private set; }
public int FormatVersion { get; private set; }
public string NPTitleID { get; private set; }
public string Console { get; private set; }
public string[] Names { get; private set; } = new string[20];
public string[] Icons { get; private set; } = new string[20];
public int ParentalLevel { get; private set; }
public string Pronunciation { get; private set; }
public string ContentID { get; private set; }
public string BackgroundImage { get; private set; }
public string BGM { get; private set; }
public string Category { get; private set; }
public int PSVR { get; private set; }
public int NEOEnable { get; private set; }
private string GetUrl()
{
//TitleID format must follow CUSAXXXXX_00 format.
if (!Regex.IsMatch(TitleID, @"CUSA\d{5}_00"))
{
throw new Exception("TitleID format incorrect!! Format must follow CUSAXXXXX_00.");
}
//tmdb Key for PS3 and PS4 credits to https://github.com/Tustin
byte[] tmdb_key = { 0xF5, 0xDE, 0x66, 0xD2, 0x68, 0x0E, 0x25, 0x5B, 0x2D, 0xF7, 0x9E, 0x74, 0xF8, 0x90, 0xEB, 0xF3, 0x49, 0x26, 0x2F, 0x61, 0x8B, 0xCA, 0xE2, 0xA9,
0xAC, 0xCD, 0xEE, 0x51, 0x56, 0xCE, 0x8D, 0xF2, 0xCD, 0xF2, 0xD4, 0x8C, 0x71, 0x17, 0x3C, 0xDC, 0x25, 0x94, 0x46, 0x5B, 0x87, 0x40, 0x5D, 0x19,
0x7C, 0xF1, 0xAE, 0xD3, 0xB7, 0xE9, 0x67, 0x1E, 0xEB, 0x56, 0xCA, 0x67, 0x53, 0xC2, 0xE6, 0xB0,
};
//Make a new Hmac sha1 digest with the key tmdb_key
HMACSHA1 Digest = new HMACSHA1(tmdb_key);
//Compute new digest using the data of the TitleID
Digest.ComputeHash(Encoding.UTF8.GetBytes(TitleID));
//return the url for the json using the TitleID and generated Digest.
return $"https://tmdb.np.dl.playstation.net/tmdb2/{TitleID}_{BitConverter.ToString(Digest.Hash).Replace("-", "")}/{TitleID}.json";
}
private void ParseJson()
{
//Download the Json file.
WebClient webClient = new WebClient();
Data = JsonValue.Parse(webClient.DownloadString(tmdbUrl));
//Parse the data.
if (Data.ContainsKey("revision"))
Revision = Data["revision"];
if (Data.ContainsKey("patchRevision"))
PatchRevision = Data["patchRevision"];
if (Data.ContainsKey("formatVersion"))
FormatVersion = Data["formatVersion"];
if (Data.ContainsKey("npTitleId"))
NPTitleID = Data["npTitleId"];
if (Data.ContainsKey("console"))
Console = Data["console"];
if (Data.ContainsKey("names"))
{
JsonValue jNames = Data["names"];
for (int i = 0; i < jNames.Count; i++)
{
JsonValue Temp = jNames[i];
if (Temp.ContainsKey("name"))
{
Regex rgx = new Regex(@"[^0-9a-zA-Z +.:']");
Names[i] = rgx.Replace(Temp["name"], "");
}
}
}
if (Data.ContainsKey("icons"))
{
JsonValue jIcons = Data["icons"];
for (int i = 0; i < jIcons.Count; i++)
{
JsonValue Temp = jIcons[i];
if (Temp.ContainsKey("icon") && Temp.ContainsKey("type"))
{
Icons[i] = Temp["icon"];
//Icons[i].Size = Temp["type"];
}
}
}
if (Data.ContainsKey("parentalLevel"))
ParentalLevel = Data["parentalLevel"];
if (Data.ContainsKey("pronunciation"))
Pronunciation = Data["pronunciation"];
if (Data.ContainsKey("contentId"))
ContentID = Data["contentId"];
if (Data.ContainsKey("backgroundImage"))
BackgroundImage = Data["backgroundImage"];
if (Data.ContainsKey("bgm"))
BGM = Data["bgm"];
if (Data.ContainsKey("category"))
Category = Data["category"];
if (Data.ContainsKey("psVr"))
PSVR = Data["psVr"];
if (Data.ContainsKey("neoEnable"))
NEOEnable = Data["neoEnable"];
}
public TMDB(string TitleID)
{
//Store TitleID Locally.
this.TitleID = TitleID;
}
}
public class Icons
{
public string Url { get; set; }
public string Size { get; set; }
}
}
@@ -1,271 +0,0 @@
using OrbisSuite.Common;
using OrbisSuite.Common.Database;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace OrbisSuite
{
public record AppInfo(string TitleId, string ContentId, string TitleName, string MetaDataPath, DateTime LastAccessTime,
int Visible, int SortPriority, int DisplayLocation, bool CanRemove, string Category, int ContentSize, DateTime InstallDate, string UICategory);
public class Application
{
private Target Target;
public Application(Target Target)
{
this.Target = Target;
}
public List<AppInfo> GetAppList()
{
var AppList = new List<AppInfo>();
// Check to see the API is online.
if (!Target.Info.Details.IsAPIAvailable)
{
return AppList;
}
// Make the initial request.
APIResults apiResult = API.CallLong(Target.Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_APPS_GET_LIST }, out Socket Sock);
// Make sure the request was sucessful.
if (apiResult != APIResults.API_OK)
return AppList;
// Get the number of apps installed.
int Count = Sock.RecvInt32();
// Itterate through the count to recieve all the apps details.
for (int i = 0; i < Count; i++)
{
// Recieve the bytes of the struct.
var Packet = new AppInfoPacket();
var RawPacket = new byte[Marshal.SizeOf(Packet)];
var bytes = Sock.Receive(RawPacket);
if (bytes <= 0)
break;
// Convert the recieved bytes to a struct.
Helpers.BytestoStruct(RawPacket, ref Packet);
// Try to parse the date time strings.
if (!DateTime.TryParse(Packet.LastAccessTime, out DateTime LastAccessTime))
LastAccessTime = DateTime.MinValue;
if (!DateTime.TryParse(Packet.LastAccessTime, out DateTime InstallDate))
InstallDate = DateTime.MinValue;
// For some reason there is garbage after the string so this stops that :)
var firstNullIndex = Array.FindIndex(Packet.TitleName, b => b == 0);
string titleName = Encoding.UTF8.GetString(Packet.TitleName, 0, firstNullIndex);
// Add the entry to the list.
AppList.Add(new AppInfo(Packet.TitleId, Packet.ContentId, titleName, Packet.MetaDataPath, LastAccessTime, Packet.Visible,
Packet.SortPriority, Packet.DispLocation, Packet.CanRemove == 1, Packet.Category, Packet.ContentSize, InstallDate, Packet.UICategory));
}
// close socket.
Sock.Close();
return AppList;
}
public string GetAppInfoString(string TitleId, string Key)
{
if (!Regex.IsMatch(TitleId, @"[a-zA-Z]{4}\d{5}"))
{
Console.WriteLine($"Invaild titleId format {TitleId}");
return string.Empty;
}
if (!Target.Info.Details.IsAPIAvailable)
{
return string.Empty;
}
var apiResult = API.CallLong(Target.Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_APPS_GET_INFO_STR }, out Socket Sock);
if (apiResult != APIResults.API_OK)
return string.Empty;
// Send the titleId of the app.
Sock.Send(Encoding.ASCII.GetBytes(TitleId.PadRight(10, '\0')).Take(10).ToArray());
// Send the bytes of the key string.
Sock.Send(Encoding.ASCII.GetBytes(Key.PadRight(50, '\0')));
var resultBuffer = new byte[200];
Sock.Receive(resultBuffer);
// close socket.
Sock.Close();
return Encoding.ASCII.GetString(resultBuffer);
}
public AppState GetAppState(string TitleId)
{
if (!Regex.IsMatch(TitleId, @"[a-zA-Z]{4}\d{5}"))
{
Console.WriteLine($"Invaild titleId format {TitleId}");
return AppState.STATE_ERROR;
}
if (!Target.Info.Details.IsAPIAvailable)
{
return AppState.STATE_NOT_RUNNING;
}
APIResults apiResult = API.CallLong(Target.Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_APPS_STATUS }, out Socket Sock);
if (apiResult != APIResults.API_OK)
return AppState.STATE_ERROR;
// 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 = (AppState)Sock.RecvInt32();
// close socket.
Sock.Close();
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_APPS_START }, 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 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;
}
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;
// 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);
}
}
}
@@ -1,13 +0,0 @@
namespace OrbisSuite
{
public class Debug
{
private Target Target;
public Debug(Target Target)
{
this.Target = Target;
}
}
}
@@ -1,87 +0,0 @@
using Limilabs.FTP.Client;
using OrbisSuite.Common;
using System.Data.Entity.Core.Mapping;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
namespace OrbisSuite
{
public class FTP
{
private Target Target;
public FTP(Target Target)
{
this.Target = Target;
}
public bool DownloadFile(string RemoteFilePath, string LocalFilePath)
{
using (Ftp ftp = new Ftp())
{
try
{
ftp.Connect(Target.Info.IPAddress, Config.FTPPort);
ftp.Login("anonymous", "anonymous");
ftp.Download(RemoteFilePath, LocalFilePath);
ftp.Close();
}
catch (Exception ex)
{
if(ex.Message.Contains("The requested address is not valid in its context.") || ex.Message.Contains("File not found."))
{
File.Delete(LocalFilePath);
Console.WriteLine(ex.Message);
return false;
}
else if(ex.Message.Contains("No connection could be made because the target machine actively refused it.") ||
ex.Message.Contains("A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."))
{
Console.WriteLine(ex.Message);
return false;
}
else
{
Console.WriteLine(ex.Message);
throw;
}
}
}
return true;
}
public void SendFile(string RemoteFilePath, string LocalFilePath)
{
using (Ftp ftp = new Ftp())
{
ftp.Connect(Target.Info.IPAddress, Config.FTPPort);
ftp.Login("anonymous", "anonymous");
ftp.Upload(RemoteFilePath, LocalFilePath);
ftp.Close();
}
}
public List<FtpItem> GetDir(string Dir)
{
var ftpItems = new List<FtpItem>();
using (Ftp ftp = new Ftp())
{
ftp.Connect(Target.Info.IPAddress, Config.FTPPort);
ftp.Login("anonymous", "anonymous");
ftp.ChangeFolder(Dir);
ftpItems = ftp.GetList();
ftp.Close();
}
return ftpItems;
}
}
}
@@ -1,58 +0,0 @@
using System.Net.Sockets;
namespace OrbisSuite
{
public class Payload
{
private Target Target;
public Payload(Target Target)
{
this.Target = Target;
}
/// <summary>
/// Sends Custom Payloads to Playstation 4 Console
/// </summary>
/// <param name="IP">PlayStation 4 IP address</param>
/// <param name="PayloadBuffer">Byte array of payload</param>
/// <param name="Port">Port used to recieve payload default value is 9020</param>
public bool InjectPayload(byte[] PayloadBuffer)
{
try
{
Socket socket;
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.ReceiveTimeout = 1000;
socket.SendTimeout = 1000;
IAsyncResult result = socket.BeginConnect(Target.Info.IPAddress, Target.Info.PayloadPort, null, null);
result.AsyncWaitHandle.WaitOne(3000, true);
if (!socket.Connected)
{
Console.WriteLine("Failed to connect to socket.");
socket.Close();
return false;
}
// we have connected
socket.EndConnect(result);
//Send Payload
socket.Send(PayloadBuffer);
socket.Close();
return true;
}
catch
{
Console.WriteLine("Failed to load Payload");
return false;
}
}
}
}
@@ -1,14 +0,0 @@
namespace OrbisSuite
{
public class Extension
{
private Target Target;
private Memory Memory;
public Extension(Target Target, Memory Memory)
{
this.Target = Target;
this.Memory = Memory;
}
}
}
@@ -1,17 +0,0 @@
namespace OrbisSuite
{
public class Memory
{
private Target Target;
private Process Process;
public Extension Ext;
public Memory(Target Target, Process Process)
{
this.Target = Target;
this.Process = Process;
Ext = new Extension(Target, this);
}
}
}
@@ -1,78 +0,0 @@
using OrbisSuite.Common;
using OrbisSuite.Common.Database;
using System.Net.Sockets;
using System.Runtime.InteropServices;
namespace OrbisSuite
{
public class ProcessInfo
{
public Int32 PID;
public bool Attached;
public string Name;
public string TitleID;
public UInt64 TextSegmentBase;
public UInt64 TextSegmentLen;
public UInt64 DataSegmentBase;
public UInt64 DataSegmentLen;
public ProcessInfo(Int32 PID, string Name, string TitleID)
{
this.PID = PID;
this.Name = Name;
this.TitleID = TitleID;
}
public ProcessInfo()
{
this.Attached = false;
}
}
public class Process
{
private OrbisLib PS4;
private Target Target;
public Memory Memory;
public Process(OrbisLib PS4, Target Target)
{
this.PS4 = PS4;
this.Target = Target;
Memory = new Memory(Target, this);
}
public IEnumerable<ProcessInfo> List
{
get
{
if (!Target.Info.Details.IsAPIAvailable)
{
yield break;
}
if (API.CallLong(Target.Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_PROC_GET_LIST }, out Socket Sock) != APIResults.API_OK)
{
Sock.Close();
yield break;
}
var ProcCount = Sock.RecvInt32();
for (var i = 0; i < ProcCount; i++)
{
var Packet = new ProcPacket();
var RawPacket = new byte[Marshal.SizeOf(Packet)];
Sock.Receive(RawPacket);
Helpers.BytestoStruct(RawPacket, ref Packet);
yield return new ProcessInfo(Packet.ProcessID, Packet.Name, Packet.TitleID);
}
API.CompleteCall(Sock);
}
}
}
}
@@ -1,200 +0,0 @@
using OrbisSuite.Common;
using OrbisSuite.Common.Database;
using System.Net.Sockets;
namespace OrbisSuite
{
public class Target
{
public bool Active = false;
public TargetInfo Info;
private OrbisLib PS4;
public TargetEvents Events;
public Debug Debug;
public Payload Payload;
public Process Process;
public FTP FTP;
public Application Application;
public Target(OrbisLib PS4)
{
Active = false;
Info = new TargetInfo();
this.PS4 = PS4;
Events = new TargetEvents(this);
Debug = new Debug(this);
Payload = new Payload(this);
Process = new Process(PS4, this);
FTP = new FTP(this);
Application = new Application(this);
}
public Target(OrbisLib PS4, TargetInfo TargetInfo)
{
Active = true;
Info = TargetInfo;
this.PS4 = PS4;
Events = new TargetEvents(this);
Debug = new Debug(this);
Payload = new Payload(this);
Process = new Process(PS4, this);
FTP = new FTP(this);
Application = new Application(this);
}
public APIResults Shutdown()
{
if (!Info.Details.IsAPIAvailable)
{
Console.WriteLine($"Attempted to call '{System.Reflection.MethodBase.GetCurrentMethod().Name}' but API not Available on target '{Info.Name}'.");
return APIResults.API_ERROR_NOT_CONNECTED;
}
return API.Call(Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_TARGET_SHUTDOWN });
}
public APIResults Reboot()
{
if (!Info.Details.IsAPIAvailable)
{
Console.WriteLine($"Attempted to call '{System.Reflection.MethodBase.GetCurrentMethod().Name}' but API not Available on target '{Info.Name}'.");
return APIResults.API_ERROR_NOT_CONNECTED;
}
return API.Call(Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_TARGET_REBOOT });
}
public APIResults Suspend()
{
if (!Info.Details.IsAPIAvailable)
{
Console.WriteLine($"Attempted to call '{System.Reflection.MethodBase.GetCurrentMethod().Name}' but API not Available on target '{Info.Name}'.");
return APIResults.API_ERROR_NOT_CONNECTED;
}
return API.Call(Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_TARGET_RESTMODE });
}
public APIResults Notify(string Message)
{
if (!Info.Details.IsAPIAvailable)
{
Console.WriteLine($"Attempted to call '{System.Reflection.MethodBase.GetCurrentMethod().Name}' but API not Available on target '{Info.Name}'.");
return APIResults.API_ERROR_NOT_CONNECTED;
}
APIResults Result = API.CallLong(Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_TARGET_NOTIFY }, out Socket Sock);
if (Result != APIResults.API_OK)
return Result;
Result = API.SendNextPacket(Sock, new TargetNotifyPacket() { Message = Message });
Sock.Close();
return Result;
}
public APIResults Notify(string IconURI, string Message)
{
if (!Info.Details.IsAPIAvailable)
{
Console.WriteLine($"Attempted to call '{System.Reflection.MethodBase.GetCurrentMethod().Name}' but API not Available on target '{Info.Name}'.");
return APIResults.API_ERROR_NOT_CONNECTED;
}
APIResults Result = API.CallLong(Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_TARGET_NOTIFY }, out Socket Sock);
if (Result != APIResults.API_OK)
return Result;
Result = API.SendNextPacket(Sock, new TargetNotifyPacket() { IconURI = IconURI, Message = Message });
Sock.Close();
return Result;
}
public APIResults Buzzer(BuzzerType Type)
{
if (!Info.Details.IsAPIAvailable)
{
Console.WriteLine($"Attempted to call '{System.Reflection.MethodBase.GetCurrentMethod().Name}' but API not Available on target '{Info.Name}'.");
return APIResults.API_ERROR_NOT_CONNECTED;
}
APIResults Result = API.CallLong(Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_TARGET_BUZZER }, out Socket Sock);
if (Result != APIResults.API_OK)
return Result;
Result = API.SendInt32(Sock, (int)Type);
Sock.Close();
return Result;
}
public APIResults SetLED(ConsoleLEDColours Colour)
{
if (!Info.Details.IsAPIAvailable)
{
Console.WriteLine($"Attempted to call '{System.Reflection.MethodBase.GetCurrentMethod().Name}' but API not Available on target '{Info.Name}'.");
return APIResults.API_ERROR_NOT_CONNECTED;
}
APIResults Result = API.CallLong(Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_TARGET_SET_LED }, out Socket Sock);
if (Result != APIResults.API_OK)
return Result;
Result = API.SendInt32(Sock, (int)Colour);
Sock.Close();
return Result;
}
/*public APIResults DumpProcess(string ProcName, int Length, byte[] Out)
{
IntPtr ptr = Marshal.AllocHGlobal(Length);
UInt64 RealLength = 0;
API_ERRORS Result = Imports.Target.DumpProcess(Info.IPAddr, ProcName, out RealLength, ptr);
Marshal.Copy(ptr, Out, 0, Length);
//free unmanageed memory.
Marshal.FreeHGlobal(ptr);
return Result;
}*/
public APIResults SetSettings(bool ShowDebugTitleIdLabel, bool ShowDevkitPanel, bool ShowDebugSettings, bool ShowAppHome)
{
if (!Info.Details.IsAPIAvailable)
{
Console.WriteLine($"Attempted to call '{System.Reflection.MethodBase.GetCurrentMethod().Name}' but API not Available on target '{Info.Name}'.");
return APIResults.API_ERROR_NOT_CONNECTED;
}
APIResults Result = API.CallLong(Info.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_TARGET_SET_SETTINGS }, out Socket Sock);
if (Result != APIResults.API_OK)
return Result;
Result = API.SendNextPacket(Sock, new TargetSettingsPacket()
{
ShowDebugTitleIdLabel = Convert.ToInt32(ShowDebugTitleIdLabel),
ShowDevkitPanel = Convert.ToInt32(ShowDevkitPanel),
ShowDebugSettings = Convert.ToInt32(ShowDebugSettings),
ShowAppHome = Convert.ToInt32(ShowAppHome)
});
Sock.Close();
return Result;
}
}
}
@@ -1,72 +0,0 @@
namespace OrbisSuite
{
public class PrintEvent : EventArgs
{
public string Sender { get; private set; }
public string Data { get; private set; }
public PrintEvent(string Sender, string Data)
{
this.Sender = Sender;
this.Data = Data;
}
}
public class ProcInterceptEvent : EventArgs
{
public ProcInterceptEvent()
{
}
}
public class ProcContinueEvent : EventArgs
{
public ProcContinueEvent() { }
}
public class ProcDieEvent : EventArgs
{
public ProcDieEvent() { }
}
public class ProcAttachEvent : EventArgs
{
public string NewProcName { get; private set; }
public ProcAttachEvent(string NewProcName)
{
this.NewProcName = NewProcName;
}
}
public class ProcDetachEvent : EventArgs
{
public ProcDetachEvent() { }
}
public class TargetSuspendEvent : EventArgs
{
public TargetSuspendEvent() { }
}
public class TargetResumeEvent : EventArgs
{
public TargetResumeEvent() { }
}
public class TargetShutdownEvent : EventArgs
{
public TargetShutdownEvent() { }
}
public class TargetNewTitleEvent : EventArgs
{
public string TitleID { get; private set; }
public TargetNewTitleEvent(string TitleID)
{
this.TitleID = TitleID;
}
}
}
@@ -1,129 +0,0 @@
namespace OrbisSuite
{
public class TargetEvents
{
private Target Target;
public event EventHandler<PrintEvent> Print;
public event EventHandler<ProcInterceptEvent> ProcIntercept;
public event EventHandler<ProcContinueEvent> ProcContinue;
public event EventHandler<ProcDieEvent> ProcDie;
public event EventHandler<ProcAttachEvent> ProcAttach;
public event EventHandler<ProcDetachEvent> ProcDetach;
public event EventHandler<TargetSuspendEvent> TargetSuspend;
public event EventHandler<TargetResumeEvent> TargetResume;
public event EventHandler<TargetShutdownEvent> TargetShutdown;
public event EventHandler<TargetNewTitleEvent> TargetNewTitle;
public TargetEvents(Target Target)
{
this.Target = Target;
}
/// <summary>
/// Event that should be fired when we recieve a print from the remote target.
/// </summary>
/// <param name="SenderIPAddress">The sending Target Address.</param>
/// <param name="Sender"></param>
/// <param name="Data"></param>
internal void RaiseProcPrintEvent(string SenderIPAddress, string Sender, string Data)
{
if (SenderIPAddress.Equals(Target.Info.IPAddress))
Print?.Invoke(null, new PrintEvent(Sender, Data));
}
/// <summary>
/// Fires an event for when the Target's proccess were attached to has reached an intercepted state.
/// </summary>
/// <param name="IPAddr">The sending Target Address.</param>
internal void RaiseProcInterceptEvent(string IPAddr)
{
if (IPAddr.Equals(Target.Info.IPAddress))
{
ProcIntercept?.Invoke(null, new ProcInterceptEvent());
}
}
/// <summary>
/// Fires an event when a procees on the Target has gotten the signal to continue execution.
/// </summary>
/// <param name="IPAddr">The sending Target Address.</param>
internal void RaiseProcContinueEvent(string IPAddr)
{
if (IPAddr.Equals(Target.Info.IPAddress))
ProcContinue?.Invoke(null, new ProcContinueEvent());
}
/// <summary>
/// Fires an event for when a proccess is going to be shutting down on the Target.
/// </summary>
/// <param name="IPAddr">The sending Target Address.</param>
internal void RaiseProcDieEvent(string IPAddr)
{
if (IPAddr.Equals(Target.Info.IPAddress))
ProcDie?.Invoke(null, new ProcDieEvent());
}
/// <summary>
/// Fires an event for when the OrbisLib API attaches to a process.
/// </summary>
/// <param name="IPAddr">The sending Target Address.</param>
/// <param name="NewProcName">The name of the process were attaching to.</param>
internal void RaiseProcAttachEvent(string IPAddr, string NewProcName)
{
if (IPAddr.Equals(Target.Info.IPAddress))
ProcAttach?.Invoke(null, new ProcAttachEvent(NewProcName));
}
/// <summary>
/// Fires an event for when the OrbisLib API detaches to a process.
/// </summary>
/// <param name="IPAddr">The sending Target Address.</param>
internal void RaiseProcDetachEvent(string IPAddr)
{
if (IPAddr.Equals(Target.Info.IPAddress))
ProcDetach?.Invoke(null, new ProcDetachEvent());
}
/// <summary>
/// Fires event for when Target is entering the suspended state.
/// </summary>
/// <param name="IPAddr">The sending Target Address.</param>
internal void RaiseTargetSuspendEvent(string IPAddr)
{
if (IPAddr.Equals(Target.Info.IPAddress))
TargetSuspend?.Invoke(null, new TargetSuspendEvent());
}
/// <summary>
/// Fires event for when the Target is resuming from a suspended state.
/// </summary>
/// <param name="IPAddr">The sending Target Address.</param>
internal void RaiseTargetResumeEvent(string IPAddr)
{
if (IPAddr.Equals(Target.Info.IPAddress))
TargetResume?.Invoke(null, new TargetResumeEvent());
}
/// <summary>
/// Fires an event for when the Target is shutting down.
/// </summary>
/// <param name="IPAddr">The sending Target Address.</param>
internal void RaiseTargetShutdownEvent(string IPAddr)
{
if (IPAddr.Equals(Target.Info.IPAddress))
TargetShutdown?.Invoke(null, new TargetShutdownEvent());
}
/// <summary>
/// Fires an event for when we change the current game on the Target.
/// </summary>
/// <param name="IPAddr">The sending Target Address.</param>
/// <param name="TitleID">The next title index our Target will be running.</param>
internal void RaiseTargetNewTitleEvent(string IPAddr, string TitleID)
{
if (IPAddr.Equals(Target.Info.IPAddress))
TargetNewTitle?.Invoke(null, new TargetNewTitleEvent(TitleID));
}
}
}
@@ -1,63 +0,0 @@
using OrbisSuite.Common.Database;
namespace OrbisSuite
{
public class TargetManagement
{
OrbisLib PS4;
public TargetManagement(OrbisLib PS4)
{
this.PS4 = PS4;
}
public TargetInfo? DefaultTarget
{
get
{
return SavedTargets.DefaultTarget;
}
}
public List<TargetInfo>? TargetList
{
get
{
return SavedTargets.Targets;
}
}
public bool DoesDefaultTargetExist()
{
return (DefaultTarget != null);
}
public bool GetTarget(string TargetName, out TargetInfo Out)
{
Out = TargetInfo.FindTarget(x => x.Name == TargetName);
return (Out != null);
}
public bool DeleteTarget(string TargetName)
{
var Target = TargetInfo.FindTarget(x => x.Name == TargetName);
return Target.Remove();
}
public bool NewTarget(bool Default, string TargetName, string IPAddress, int PayloadPort)
{
return new TargetInfo { IsDefault = Default, Name = TargetName, IPAddress = IPAddress, PayloadPort = PayloadPort }.Add();
}
public int GetTargetCount()
{
return SavedTargets.TargetCount;
}
public void SetSelected(string TargetName)
{
TargetInfo Info;
if (GetTarget(TargetName, out Info))
PS4.SelectedTarget.Info = Info;
}
}
}
@@ -1,75 +0,0 @@
using System.Runtime.InteropServices;
using System.Text;
namespace OrbisSuite
{
public class Utilities
{
/// <summary>
/// Will convert byte array to a string and ensure a null terminator is set.
/// </summary>
/// <param name="bIn">Bytes to convert.</param>
/// <returns>Returns a string form of the input bytes.</returns>
public static string CleanByteToString(byte[] bIn)
{
try
{
if (bIn.Length <= 0)
return string.Empty;
string Out = Encoding.Default.GetString(bIn);
return Out.Substring(0, Out.IndexOf('\0'));
}
catch
{
return string.Empty;
}
}
/// <summary>
/// Will censor a part of an input string with the desired sensor char.
/// </summary>
/// <param name="In">The string we would like to censor.</param>
/// <param name="CensorChar">The character we would like to use as the sensor.</param>
/// <param name="AllowedCount">The allowed number of characters starting from 0.</param>
/// <returns>Returns the censored string.</returns>
public static string CensorString(string In, char CensorChar, int AllowedCount)
{
try
{
string Out = In.Substring(0, AllowedCount);
Out += new string(CensorChar, In.Length - AllowedCount);
return Out;
}
catch
{
return string.Empty;
}
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool SetDllDirectory(string lpPathName);
public static string BytesToString(long numberOfBytes)
{
string[] typeStrings = new string[]
{
"{0} B",
"{0:f1} KB",
"{0:f1} MB",
"{0:f1} GB"
};
double num = numberOfBytes;
for (int i = 0; i < 4; i++)
{
if (num <= 10240.0 || i >= 3)
{
return string.Format(typeStrings[i], num);
}
num /= 1024.0;
}
return "";
}
}
}
@@ -1,158 +0,0 @@
using System.Net.Sockets;
namespace OrbisSuite.Common
{
public static class API
{
/// <summary>
/// Connects to the API.
/// </summary>
/// <param name="IPAddr">Address we would like to connnect to.</param>
/// <param name="Sock">The socket we have connected on.</param>
/// <returns>Returns true if we successfully connected.</returns>
public static bool Connect(string IPAddr, int Port, out Socket Sock)
{
Sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
return Sock.EasyConnect(IPAddr, Port, -1);
}
/// <summary>
/// Short API Call used when you only need to send the initial packet and no additional data.
/// </summary>
/// <param name="IPAddr">Address to send to.</param>
/// <param name="Packet">The initial Packet Data.</param>
/// <returns>Returns the result of the action.</returns>
public static APIResults Call(string IPAddr, int Port, APIPacket Packet)
{
try
{
if (Connect(IPAddr, Port, out Socket Sock))
{
// Send Inital Packet.
Sock.Send(Helpers.StructtoBytes(Packet));
// Get API Response.
var Result = (APIResults)Sock.RecvInt32();
// Clean up.
Sock.Close();
return Result;
}
else
return APIResults.API_ERROR_COULDNT_CONNECT;
}
catch
{
}
return APIResults.API_ERROR_GENERAL;
}
/// <summary>
/// Long API Call used for when we need to send more than just the initial packet.
/// </summary>
/// <param name="IPAddr">Address to send to.</param>
/// <param name="Packet">The initial Packet Data.</param>
/// <param name="Sock">The soucket out used for sending more data.</param>
/// <returns>Returns the result of the action.</returns>
public static APIResults CallLong(string IPAddr, int Port, APIPacket Packet, out Socket Sock)
{
Sock = null;
try
{
if (Connect(IPAddr, Port, out Sock))
{
// Send Inital Packet.
Sock.Send(Helpers.StructtoBytes(Packet));
// Get API Response.
return (APIResults)Sock.RecvInt32();
}
else
return APIResults.API_ERROR_COULDNT_CONNECT;
}
catch (Exception ex)
{
}
return APIResults.API_ERROR_GENERAL;
}
/// <summary>
/// Sends additional data if required.
/// </summary>
/// <typeparam name="T">The packet type.</typeparam>
/// <param name="Sock">The socket instance were using.</param>
/// <param name="Packet">Any Packet structure.</param>
/// <returns>Returns the result of the action.</returns>
public static APIResults SendNextPacket<T>(Socket Sock, T Packet)
{
try
{
// Send Next Packet.
Sock.Send(Helpers.StructtoBytes(Packet));
// Get API Response.
return (APIResults)Sock.RecvInt32();
}
catch
{
}
return APIResults.API_ERROR_GENERAL;
}
/// <summary>
///
/// </summary>
/// <param name="Sock"></param>
/// <param name="Value"></param>
/// <returns></returns>
public static APIResults SendInt32(Socket Sock, int Value)
{
try
{
// Send Next Packet.
Sock.Send(BitConverter.GetBytes(Value));
// Get API Response.
return (APIResults)Sock.RecvInt32();
}
catch
{
}
return APIResults.API_ERROR_GENERAL;
}
/// <summary>
/// Completes the call and gets our final result.
/// </summary>
/// <param name="Sock">The socket used to communicate witht the API.</param>
/// <returns>Returns the result of the action.</returns>
public static APIResults CompleteCall(Socket Sock)
{
try
{
var Results = (APIResults)Sock.RecvInt32();
Sock.Close();
return Results;
}
catch
{
}
return APIResults.API_ERROR_GENERAL;
}
}
}
@@ -1,355 +0,0 @@
using System.Runtime.InteropServices;
using System.Text;
namespace OrbisSuite.Common
{
public enum APICommands : int
{
/* ####### Proc functions ####### */
PROC_START = 1,
API_PROC_GET_LIST,
API_PROC_LOAD_ELF,
API_PROC_CALL, /* RPC Call. */
PROC_END,
/* ############################## */
/* ####### Apps functions ####### */
APP_START,
API_APPS_GET_LIST,
API_APPS_GET_INFO_STR,
API_APPS_STATUS,
API_APPS_START,
API_APPS_STOP,
API_APPS_SUSPEND,
API_APPS_RESUME,
API_APPS_DELETE,
APP_END,
/* ############################## */
/* ##### Debugger functions ##### */
DBG_START,
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,
API_DBG_STEP,
API_DBG_STEP_OVER,
API_DBG_STEP_OUT,
API_DBG_GET_CALLSTACK,
API_DBG_GET_REG,
API_DBG_SET_REG,
API_DBG_GET_FREG,
API_DBG_SET_FREG,
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,
API_DBG_THREAD_RESUME,
/* Breakpoint functions */
API_DBG_BREAKPOINT_GETFREE,
API_DBG_BREAKPOINT_SET,
API_DBG_BREAKPOINT_UPDATE,
API_DBG_BREAKPOINT_REMOVE,
API_DBG_BREAKPOINT_GETINFO,
API_DBG_BREAKPOINT_LIST,
/* Watchpoint functions */
API_DBG_WATCHPOINT_SET,
API_DBG_WATCHPOINT_UPDATE,
API_DBG_WATCHPOINT_REMOVE,
API_DBG_WATCHPOINT_GETINFO,
API_DBG_WATCHPOINT_LIST,
DBG_END,
/* ############################## */
/* ###### Kernel functions ###### */
KERN_START,
API_KERN_BASE,
API_KERN_READ,
API_KERN_WRITE,
KERN_END,
/* ############################## */
/* ###### Target functions ###### */
TARGET_START,
API_TARGET_INFO,
API_TARGET_RESTMODE,
API_TARGET_SHUTDOWN,
API_TARGET_REBOOT,
API_TARGET_NOTIFY,
API_TARGET_BUZZER,
API_TARGET_SET_LED,
API_TARGET_DUMP_PROC,
API_TARGET_SET_SETTINGS,
API_TARGET_GETFILE,
TARGET_END,
/* ############################## */
}
public enum APIResults : int
{
API_OK = 1,
API_ERROR_COULDNT_CONNECT,
API_ERROR_NOT_CONNECTED,
API_ERROR_NOT_ATTACHED,
API_ERROR_LOST_PROC,
API_ERROR_GENERAL,
API_ERROR_INVALID_ADDRESS,
//Debugger
API_ERROR_PROC_RUNNING,
API_ERROR_DEBUG_TO_ATTACHED,
}
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi, Size = 40), Serializable]
public struct APIPacket
{
public int PacketVersion;
public APICommands Command;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string ProcName;
}
#region Process
[StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Ansi)]
public struct ProcPacket
{
public int ProcessID;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string Name;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string TitleID;
}
#endregion
#region Apps
public enum AppState
{
STATE_ERROR = -1,
STATE_NOT_RUNNING,
STATE_RUNNING,
STATE_SUSPENDED,
};
[StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Ansi), Serializable]
public struct AppInfoPacket
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string TitleId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public string ContentId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 200)]
public byte[] TitleName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public string MetaDataPath;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public string LastAccessTime;
public int Visible;
public int SortPriority;
public int DispLocation;
public char CanRemove;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string Category;
public int ContentSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public string InstallDate;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string UICategory;
};
#endregion
#region Debug
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
public struct LibraryPacket
{
public Int64 Handle;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string Path;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
public SegmentInfo[] Segments;
}
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
public struct ProcRWPacket
{
public UInt64 Address;
public UInt64 Length;
}
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
public struct ProcSPRXPacket
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string Name;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string Path;
public int ModuleHandle;
public int Flags;
}
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
public struct ProcBreakpointPacket
{
public int Index;
public UInt64 Address;
public int Enable;
}
#endregion
#region Kernel
#endregion
#region Target
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
public struct SegmentInfo
{
public UInt64 baseAddr;
public uint size;
public int prot;
}
public enum ConsoleTypes
{
UNK,
DIAG, //0x80
DEVKIT, //0x81
TESTKIT, //0x82
RETAIL, //0x83 -> 0x8F
KRATOS, //0xA0 IMPOSSIBLE??
};
public enum ConsoleLEDColours
{
white,
white_Blinking,
Blue_Blinking,
};
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi), Serializable]
public struct MemoryInfo
{
public int Used;
public int Free;
public int Total;
public float Percentage;
};
[StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Ansi), Serializable]
public struct TargetInfoPacket
{
public int SDKVersion;
public int SoftwareVersion;
public int FactorySoftwareVersion;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string CurrentTitleID;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public string ConsoleName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
public string MotherboardSerial;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string Serial;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
public string Model;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 18)]
public string MACAddressLAN;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 18)]
public string MACAddressWIFI;
public int UART;
public int IDUMode;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] IDPS;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] PSID;
public int ConsoleType;
public int Attached;
public int AttachedPid;
public int ForegroundAccountId;
public ulong FreeSpace;
public ulong TotalSpace;
public int CPUTemp;
public int SOCTemp;
public int ThreadCount;
public float AverageCPUUsage;
public int BusyCore;
public MemoryInfo Ram;
public MemoryInfo VRam;
}
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
public struct TargetNotifyPacket
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
public string IconURI;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
public string Message;
}
public enum BuzzerType
{
RingOnce = 1,
RingThree,
LongRing,
ThreeLongRing,
ThreeLongDoubleBeeps,
}
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
public struct TargetSettingsPacket
{
public int AutoLoadSettings;
public int ShowDebugTitleIdLabel;
public int ShowDevkitPanel;
public int ShowDebugSettings;
public int ShowAppHome;
public int ShowBuildOverlay;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string GameOverlayLocation;
public int ShowCPUUsage;
public int ShowThreadCount;
public int Showram;
public int Showvram;
public int ShowCPUTemp;
public int ShowSOCTemp;
};
#endregion
}
@@ -1,60 +0,0 @@
namespace OrbisSuite.Common
{
public class Config
{
/// <summary>
/// The prort that is used to interact with the Target Console.
/// </summary>
public static readonly int APIPort = 6900;
/// <summary>
/// Port used to communicate events to the host machine from the Target Console.
/// </summary>
public static readonly int EventPort = 6901;
/// <summary>
/// The Port used to recieve debug logs from the Target Console.
/// </summary>
public static readonly int DebugPort = 6902;
/// <summary>
/// The default port for FTP.
/// </summary>
public static readonly int FTPPort = 2121;
/// <summary>
///
/// </summary>
public static readonly int DispatcherPort = 6919;
/// <summary>
///
/// </summary>
public static readonly int DispatcherClientPort = 6920;
/// <summary>
/// Name of the data base used to store the user data / Target List.
/// </summary>
public static readonly string DataBaseName = "OrbisSuiteUserData.db";
/// <summary>
/// The Path to the Orbis Suite data.
/// </summary>
public static readonly string OrbisPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)}\Orbis Suite";
/// <summary>
/// Path of the data base used to store the user data / Target List.
/// </summary>
public static readonly string DataBasePath = $@"{OrbisPath}\{DataBaseName}";
/// <summary>
/// Maximum number of targets we can store.
/// </summary>
public static readonly int MaxTargets = 20;
/// <summary>
/// The version of the packets used to communicate with the Target Console.
/// </summary>
public static readonly int PacketVersion = 2;
}
}
@@ -1,124 +0,0 @@
using OrbisSuite.Common.Database;
using OrbisSuite.Common.Database.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace OrbisSuite.Common.Database
{
public static class SavedTargets
{
/// <summary>
/// Returns a list of the Targets saved.
/// </summary>
public static List<TargetInfo>? Targets
{
get
{
return TargetInfo.GetTargetList();
}
}
/// <summary>
/// Returns a count of all the Targets currently saved.
/// </summary>
public static int TargetCount
{
get
{
if(Targets == null)
return 0;
return Targets.Count;
}
}
/// <summary>
/// Returns the target that is the current Default Target.
/// </summary>
public static TargetInfo? DefaultTarget
{
get
{
return TargetInfo.FindDefaultTarget();
}
}
/// <summary>
/// Updates extended information about the Target. *Requires the Target to be on and the API running.
/// </summary>
/// <param name="TargetName">The name of the target to update.</param>
/// <returns>Returns weather or not the action was successful or not.</returns>
public static bool UpdateTargetInfo(string TargetName)
{
var Target = TargetInfo.FindTarget(x => x.Name == TargetName);
if (Target == null)
{
Console.WriteLine($"Couldn't Find Target \"{TargetName}\".");
return false;
}
if (API.CallLong(Target.IPAddress, Settings.CreateInstance().APIPort, new APIPacket() { PacketVersion = Config.PacketVersion, Command = APICommands.API_TARGET_INFO }, out Socket Sock) != APIResults.API_OK)
{
Sock.Close();
return false;
}
var Packet = new TargetInfoPacket();
var RawPacket = new byte[Marshal.SizeOf(Packet)];
var bytes = Sock.Receive(RawPacket);
if (bytes <= 0)
return false;
Helpers.BytestoStruct(RawPacket, ref Packet);
API.CompleteCall(Sock);
if (Packet.ConsoleName == null || Packet.ConsoleName == string.Empty)
return false;
Target.Details.SDKVersion = $"{((Packet.SDKVersion >> 24) & 0xFF).ToString("X1")}.{((Packet.SDKVersion >> 12) & 0xFFF).ToString("X3")}.{(Packet.SDKVersion & 0xFFF).ToString("X3")}";
Target.Details.SoftwareVersion = $"{((Packet.SoftwareVersion >> 24) & 0xFF).ToString("X1")}.{((Packet.SoftwareVersion >> 16) & 0xFF).ToString("X2")}";
Target.Details.FactorySoftwareVersion = $"{((Packet.FactorySoftwareVersion >> 24) & 0xFF).ToString("X1")}.{((Packet.FactorySoftwareVersion >> 12) & 0xFFF).ToString("X3")}.{(Packet.FactorySoftwareVersion & 0xFFF).ToString("X3")}";
Target.Details.CurrentTitleID = Packet.CurrentTitleID;
Target.Details.ConsoleName = Packet.ConsoleName;
Target.Details.MotherboardSerial = Packet.MotherboardSerial;
Target.Details.Serial = Packet.Serial;
Target.Details.Model = Packet.Model;
Target.Details.MACAddressLAN = Packet.MACAddressLAN.ToUpper();
Target.Details.MACAddressWIFI = Packet.MACAddressWIFI.ToUpper();
Target.Details.UART = Packet.UART > 0;
Target.Details.IDUMode = Packet.IDUMode > 0;
Target.Details.IDPS = BitConverter.ToString(Packet.IDPS).Replace("-", string.Empty);
Target.Details.PSID = BitConverter.ToString(Packet.PSID).Replace("-", string.Empty);
Target.Details.ConsoleType = (ConsoleType)Packet.ConsoleType;
// Debugging.
Target.Details.IsAttached = Packet.Attached > 0;
// TODO: Implement this into the API.
Target.Details.CurrentProcessId = 0;// TODO: Update this to process Id Packet.CurrentProc;
// Storage.
Target.Details.HDDUsedSpace = (long)(Packet.TotalSpace - Packet.FreeSpace);
Target.Details.HDDFreeSpace = (long)Packet.FreeSpace;
Target.Details.HDDTotalSpace = (long)Packet.TotalSpace;
// Perf Stats.
Target.Details.CPUTemp = Packet.CPUTemp;
Target.Details.SOCTemp = Packet.SOCTemp;
Target.Details.ThreadCount = Packet.ThreadCount;
Target.Details.AverageCPUUsage = Packet.AverageCPUUsage;
Target.Details.BusyCore = Packet.BusyCore;
Target.Details.RamUsage = Packet.Ram.Used;
Target.Details.VRamUsage = Packet.VRam.Used;
return Target.Details.Save();
}
}
}
@@ -1,116 +0,0 @@
using SQLite;
namespace OrbisSuite.Common.Database
{
/// <summary>
/// Used to get/set the settings of Orbis Suite.
/// </summary>
[Table("Settings")]
public class Settings
{
[PrimaryKey, AutoIncrement, NotNull]
public int Id { get; set; }
/// <summary>
/// The API port that OrbisLib communicates on.
/// </summary>
[NotNull]
public int APIPort { get; set; } = 6900;
/// <summary>
/// The port that will be used to access the targets file system using ftp
/// </summary>
[NotNull]
public int FTPPort { get; set; } = 2121;
/// <summary>
/// The port of a klog server that will be used to print console output similar to UART.
/// </summary>
[NotNull]
public int KlogPort { get; set; } = 3232;
/// <summary>
/// The serial COM port we will listen to for UART output.
/// </summary>
[NotNull]
public string? COMPort { get; set; } = "-";
/// <summary>
/// Starts the Orbis Suite taskbar app when windows boots.
/// </summary>
[NotNull]
public bool StartOnBoot { get; set; } = false;
/// <summary>
/// Choose which theme will be used across Orbis Suite.
/// </summary>
[NotNull]
public int Theme { get; set; } = 0;
/// <summary>
/// Enables the accent colours to cycle through all colours of the rainbow.
/// </summary>
[NotNull]
public bool RainbowColours { get; set; } = false;
/// <summary>
/// When viewd from the target details choose to censor the Target identifier.
/// </summary>
[NotNull]
public bool CensorIDPS { get; set; } = false;
/// <summary>
/// When viewd from the target details choose to censor the Target identifier.
/// </summary>
[NotNull]
public bool CensorPSID { get; set; } = false;
/// <summary>
/// SHow timestamps on the console output.
/// </summary>
[NotNull]
public bool ShowTimestamps { get; set; } = false;
/// <summary>
/// Word wrap the console output window.
/// </summary>
[NotNull]
public bool WordWrap { get; set; } = false;
public static Settings CreateInstance()
{
var db = new SQLiteConnection(Config.DataBasePath);
// Create the table if it doesn't exist already.
db.CreateTable<Settings>();
// Try to pull the entries of the settings
var list = db.Table<Settings>();
if(list.Count() > 0)
{
var instance = list.First();
db.Close();
return instance;
}
else
{
// Create settings entry since it doesn't exist.
var instance = new Settings();
var result = db.Insert(instance);
db.Close();
if (result > 0)
return instance;
else
throw new Exception("Failed to create settings row into database.");
}
}
public void Save()
{
var db = new SQLiteConnection(Config.DataBasePath, SQLiteOpenFlags.ReadWrite);
db.Update(this);
db.Close();
}
}
}
@@ -1,287 +0,0 @@
using OrbisSuite.Common.Database.Types;
using SQLite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace OrbisSuite.Common.Database
{
[Table("TargetInfo")]
public class TargetDetails
{
[PrimaryKey, AutoIncrement, NotNull]
public int Id { get; set; }
[NotNull]
public int TargetId { get; set; }
/// <summary>
/// Will be true if a tcp connection can be achieved on the saved IP Address.
/// </summary>
[NotNull]
[Column("Available")]
public bool IsAvailable { get; set; } = false;
/// <summary>
/// Will be true if the Orbis Suite API is running on the target.
/// </summary>
[NotNull]
[Column("APIAvailable")]
public bool IsAPIAvailable { get; set; } = false;
/// <summary>
/// The power/API status of the target.
/// </summary>
public TargetStatusType Status
{
get
{
if (IsAPIAvailable)
return TargetStatusType.APIAvailable;
else if (IsAvailable)
return TargetStatusType.Online;
else
return TargetStatusType.Offline;
}
}
/// <summary>
/// The SDK Version of the software installed on the target.
/// </summary>
[NotNull]
public string SDKVersion { get; set; } = "-";
/// <summary>
/// The full software version installed on the target.
/// </summary>
[NotNull]
public string SoftwareVersion { get; set; } = "-";
/// <summary>
/// The software version first installed on the target when sold.
/// </summary>
[NotNull]
public string FactorySoftwareVersion { get; set; } = "-";
/// <summary>
/// The current big game titleId running on the target.
/// </summary>
[NotNull]
public string CurrentTitleID { get; set; } = "-";
/// <summary>
/// The name of the target as set on the target.
/// </summary>
[NotNull]
public string ConsoleName { get; set; } = "-";
/// <summary>
/// The serial number of the targets motherboard.
/// </summary>
[NotNull]
public string MotherboardSerial { get; set; } = "-";
/// <summary>
/// The seraial number of the target.
/// </summary>
[NotNull]
public string Serial { get; set; } = "-";
/// <summary>
/// The model number of the target.
/// </summary>
[NotNull]
public string Model { get; set; } = "-";
public ConsoleModelType ModelType
{
get
{
// ConsoleModel
// CUH-1XXXX Fat
// CUH-2XXXX Slim
// CUH-7XXXX Pro
if (Model == null || !Regex.Match(Model, @"CUH-\d{1}\w{4}").Success)
return ConsoleModelType.Fat;
switch (char.IsDigit(Model[4]) ? int.Parse(Model[4].ToString()) : 0)
{
case 1:
return ConsoleModelType.Fat;
case 2:
return ConsoleModelType.Slim;
case 7:
return ConsoleModelType.Pro;
default:
return ConsoleModelType.Fat;
}
}
}
/// <summary>
/// The MAC address of the target LAN adapter.
/// </summary>
[NotNull]
public string MACAddressLAN { get; set; } = "-";
/// <summary>
/// The MAC address of the target WIFI adapter.
/// </summary>
[NotNull]
public string MACAddressWIFI { get; set; } = "-";
/// <summary>
/// Will be true if the UART flag is set in the targets flash.
/// </summary>
[NotNull]
public bool UART { get; set; } = false;
/// <summary>
/// Will return true if the IDUMode flag is set int he targets flash.
/// </summary>
[NotNull]
public bool IDUMode { get; set; } = false;
/// <summary>
/// A unique string used to identify the target.
/// </summary>
[NotNull]
public string IDPS { get; set; } = "-";
/// <summary>
/// A unique string used to identify the target.
/// </summary>
[NotNull]
public string PSID { get; set; } = "-";
/// <summary>
/// The console type like Retail/TestKit/Devkit.
/// </summary>
[NotNull]
public ConsoleType ConsoleType { get; set; } = 0;
/// <summary>
/// Will be true if the Orbis Suite Debugger is attached to a process.
/// </summary>
[NotNull]
[Column("Attached")]
public bool IsAttached { get; set; } = false;
/// <summary>
/// The current processId being debugged by the OrbisSuite Debugger.
/// </summary>
[NotNull]
public int CurrentProcessId { get; set; } = 0;
/// <summary>
/// The current foreground account identifier.
/// </summary>
[NotNull]
public int ForegroundAccountId { get; set; } = 0;
/// <summary>
/// The used space on the targets hard disk.
/// </summary>
[NotNull]
public long HDDUsedSpace { get; set; } = 0;
/// <summary>
/// The free space on the targets hard disk.
/// </summary>
[NotNull]
public long HDDFreeSpace { get; set; } = 0;
/// <summary>
/// The usable size of the targets hard disk.
/// </summary>
[NotNull]
public long HDDTotalSpace { get; set; } = 0;
/// <summary>
/// The current temperature of the CPU.
/// </summary>
public int CPUTemp { get; set; } = 0;
/// <summary>
/// The current tempurature of the SOC.
/// </summary>
public int SOCTemp { get; set; } = 0;
/// <summary>
/// The current thread count.
/// </summary>
public int ThreadCount { get; set; } = 0;
/// <summary>
/// The current average cpu usage.
/// </summary>
public float AverageCPUUsage { get; set; } = 0.0f;
/// <summary>
/// The current core that is the most busy.
/// </summary>
public int BusyCore { get; set; } = 0;
/// <summary>
/// The current system ram usage.
/// </summary>
public int RamUsage { get; set; } = 0;
/// <summary>
/// The current video ram usage.
/// </summary>
public int VRamUsage { get; set; } = 0;
/// <summary>
/// Shows the Title number of the games on the home screen of this target.
/// </summary>
[NotNull]
public bool ShowTitleId { get; set; } = false;
/// <summary>
/// Shows the devkit information display panel that will show some information about the target like the IP Address.
/// </summary>
[NotNull]
public bool ShowDevkitPanel { get; set; } = false;
/// <summary>
/// Shows a shortcut on the Home screen that can be used to quickly access the Orbis Toolbox menu.
/// </summary>
[NotNull]
public bool ShowToolboxShortcut { get; set; } = false;
/// <summary>
/// Shows the '★APP_HOME' on the home screen that can be used to quickly launch home brew to debug it with out a pkg.
/// </summary>
[NotNull]
public bool ShowAppHome { get; set; } = false;
/// <summary>
/// Saves the current information about the target to the database.
/// </summary>
/// <returns>Returns true if any rows were effected.</returns>
public bool Save()
{
var db = new SQLiteConnection(Config.DataBasePath);
// Create the table if it doesn't exist already.
db.CreateTable<TargetDetails>();
var result = db.Update(this);
db.Close();
return (result <= 0);
}
}
}
@@ -1,228 +0,0 @@
using OrbisSuite.Common.Database.Types;
using SQLite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace OrbisSuite.Common.Database
{
/// <summary>
/// Information about the targets saved.
/// </summary>
[Table("Targets")]
public class TargetInfo
{
[PrimaryKey, AutoIncrement, NotNull]
public int Id { get; set; }
/// <summary>
/// Weather or not this is our default target to be selected on start up.
/// </summary>
[NotNull]
[Column("DefaultTarget")]
public bool IsDefault { get; set; } = false;
/// <summary>
/// The name given to the target.
/// </summary>
[NotNull, Unique]
[Column("TargetName")]
public string Name { get; set; } = "-";
/// <summary>
/// The IP Address as a string.
/// </summary>
[NotNull, Unique]
public string IPAddress { get; set; } = "-";
/// <summary>
/// The port used to send payloads to the saved IP Address.
/// </summary>
[NotNull]
public int PayloadPort { get; set; } = 9020;
private TargetDetails _details;
public TargetDetails Details
{
get
{
if( _details == null )
{
var db = new SQLiteConnection(Config.DataBasePath);
// Create the table if it doesn't exist already.
db.CreateTable<TargetDetails>();
_details = db.Find<TargetDetails>(x => x.TargetId == Id);
if (_details == null)
{
_details = new TargetDetails();
_details.TargetId = Id;
db.Insert(_details);
db.Close();
}
else
{
db.Close();
}
}
return _details;
}
}
/// <summary>
/// Remove the default tag from the other row.
/// </summary>
private void CheckDefault()
{
var defaultTarget = FindDefaultTarget();
if (IsDefault && defaultTarget != null && defaultTarget.Id != Id)
{
defaultTarget.IsDefault = false;
defaultTarget.Save();
}
}
/// <summary>
/// Saves the current information about the target to the database.
/// </summary>
/// <returns>Returns true if any rows were effected.</returns>
public bool Save()
{
if (Name == string.Empty || Name == "-")
return false;
if (IPAddress == string.Empty || IPAddress == "-")
return false;
CheckDefault();
var db = new SQLiteConnection(Config.DataBasePath);
// Create the table if it doesn't exist already.
db.CreateTable<TargetInfo>();
var result = db.Update(this);
db.Close();
return (result > 0);
}
public TargetInfo Clone()
{
return (TargetInfo)this.MemberwiseClone();
}
/// <summary>
/// Adds a this Target to the data base.
/// </summary>
/// <returns>Returns true if a row was added to the database.</returns>
public bool Add()
{
try
{
if (Name == string.Empty || Name == "-")
return false;
if (IPAddress == string.Empty || IPAddress == "-")
return false;
CheckDefault();
var db = new SQLiteConnection(Config.DataBasePath);
// Create the table if it doesn't exist already.
db.CreateTable<TargetInfo>();
var result = db.Insert(this);
db.Close();
return (result > 0);
}
catch (Exception ex)
{
return false;
}
}
/// <summary>
/// Removes this current Target from the database.
/// </summary>
/// <returns>Returns true if a row was removed from the database.</returns>
public bool Remove()
{
var db = new SQLiteConnection(Config.DataBasePath);
var result = db.Delete(Details);
if (result <= 0)
{
Console.WriteLine("Failed to delete child db TargetDetails Details.");
return false;
}
result = db.Delete(this);
db.Close();
return (result > 0);
}
public static List<TargetInfo> GetTargetList()
{
var db = new SQLiteConnection(Config.DataBasePath);
// Create the table if it doesn't exist already.
db.CreateTable<TargetInfo>();
var result = db.Table<TargetInfo>().ToList();
db.Close();
return result;
}
public static TargetInfo FindDefaultTarget()
{
var db = new SQLiteConnection(Config.DataBasePath);
// Create the table if it doesn't exist already.
db.CreateTable<TargetInfo>();
var result = db.Find<TargetInfo>(x => x.IsDefault == true);
db.Close();
return result;
}
/// <summary>
/// Find a saved Target by a specific value using a predicate.
/// </summary>
/// <param name="predicate">The predicate of the columns we want to match on.</param>
/// <returns>Returns the first object that matches the predicate.</returns>
public static TargetInfo FindTarget(Expression<Func<TargetInfo, bool>> predicate)
{
var db = new SQLiteConnection(Config.DataBasePath);
// Create the table if it doesn't exist already.
db.CreateTable<TargetInfo>();
var result = db.Find(predicate);
db.Close();
return result;
}
/// <summary>
/// Find weahter or not a Target by specific value exists by using a predicate.
/// </summary>
/// <param name="predicate">The predicate of the columns we want to match on.</param>
/// <returns>Returns true if we found a match.</returns>
public static bool DoesTargetExist(Expression<Func<TargetInfo, bool>> predicate)
{
var db = new SQLiteConnection(Config.DataBasePath);
// Create the table if it doesn't exist already.
db.CreateTable<TargetInfo>();
var result = db.Find(predicate);
db.Close();
return (result != null);
}
}
}
@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrbisSuite.Common.Database
{
internal class TargetSettings : TargetInfo
{
}
}
@@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrbisSuite.Common.Database
{
/// <summary>
/// The model revision type based on its model number.
/// </summary>
public enum ConsoleModelType
{
Unknown,
Fat,
Slim,
Pro
};
}
@@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrbisSuite.Common.Database.Types
{
public enum ConsoleType
{
None,
Diag,
Devkit,
Testkit,
Retail,
Kratos,
};
}
@@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrbisSuite.Common.Database
{
/// <summary>
/// The current status of the Target & the Orbis Suite API.
/// </summary>
public enum TargetStatusType
{
None,
Offline,
Online,
APIAvailable
};
}
@@ -1,134 +0,0 @@
namespace OrbisSuite.Common.Dispatcher
{
[Serializable]
public class DispatcherClientPacket
{
public enum PacketType
{
None,
NewClient,
RemoveClient,
HeartBeat
};
public PacketType Type { get; set; }
public string? ClientName { get; set; }
public int Port { get; set; }
public DispatcherClientPacket() { }
public DispatcherClientPacket(PacketType Type, string ClientName, int Port)
{
this.Type = Type;
this.ClientName = ClientName;
this.Port = Port;
}
}
[Serializable]
public class TitleChange
{
public string? TitleID { get; set; }
}
[Serializable]
public class Print
{
public string? Sender { get; set; }
public string? Data { get; set; }
}
[Serializable]
public class SerialCom
{
public byte[]? Data { get; set; }
}
[Serializable]
public class Break
{
public int Reason { get; set; }
//Regiseters
}
[Serializable]
public class TargetAvailability
{
public bool Available { get; set; }
public string? Name { get; set; }
}
[Serializable]
public class ForwardPacket
{
public enum PacketType
{
None,
// Debugging
Print,
SerialCom,
Intercept,
Continue,
// Process States
ProcessDie,
ProcessAttach,
ProcessDetach,
// Target State
TargetSuspend,
TargetResume,
TargetShutdown,
TargetNewTitle,
TargetAvailability,
TargetAPIAvailability,
// Misc
DBTouched,
};
/// <summary>
/// The event the packet is firing for.
/// </summary>
public PacketType Type { get; set; }
/// <summary>
/// The Target's IP Address which the Event belongs to.
/// </summary>
public string? SenderIPAddress { get; set; }
/// <summary>
/// Name of the process that the event was triggered for.
/// </summary>
public string? ProcessName { get; set; }
public TitleChange? TitleChange { get; set; }
public Print? Print { get; set; }
public SerialCom? SerialCom { get; set; }
public Break? Break { get; set; }
public TargetAvailability? TargetAvailability { get; set; }
public TargetAvailability? TargetAPIAvailability { get; set; }
public ForwardPacket(PacketType Type, string SenderIPAddress)
{
this.Type = Type;
this.SenderIPAddress = SenderIPAddress;
//TODO: Maybe add logic to the getter/setter so that it will create these...
TitleChange = new TitleChange();
Print = new Print();
SerialCom = new SerialCom();
Break = new Break();
TargetAvailability = new TargetAvailability();
TargetAPIAvailability = new TargetAvailability();
}
}
}
@@ -1,212 +0,0 @@
using System.IO;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
namespace OrbisSuite.Common
{
public static class Helpers
{
/// <summary>
/// Convert an object to a byte array
/// </summary>
/// <param name="obj">The Object to convert.</param>
/// <returns></returns>
public static byte[] ObjectToByteArray(Object obj)
{
BinaryFormatter bf = new BinaryFormatter();
using (var ms = new MemoryStream())
{
bf.Serialize(ms, obj);
return ms.ToArray();
}
}
/// <summary>
/// Convert a byte array to an Object
/// </summary>
/// <param name="arrBytes">The array to convert.</param>
/// <returns></returns>
public static Object ByteArrayToObject(byte[] arrBytes)
{
using (var memStream = new MemoryStream())
{
var binForm = new BinaryFormatter();
memStream.Write(arrBytes, 0, arrBytes.Length);
memStream.Seek(0, SeekOrigin.Begin);
return binForm.Deserialize(memStream);
}
}
/// <summary>
/// Sends an object and its size to the socket.
/// </summary>
/// <param name="s"></param>
/// <param name="obj">The object we would like to send. (Must be serializable.)</param>
public static void SendObject(this Socket s, object obj)
{
var Data = ObjectToByteArray(obj);
s.Send(BitConverter.GetBytes(Data.Length), sizeof(int), SocketFlags.None);
s.Send(Data);
}
/// <summary>
/// Recieve an object from a socket.
/// </summary>
/// <param name="s"></param>
/// <returns>Returns the object we would like to receive.</returns>
public static object RecvObject(this Socket s)
{
var ObjectSize = s.RecvInt32();
var ObjectData = new byte[ObjectSize];
s.Receive(ObjectData);
return ByteArrayToObject(ObjectData);
}
/// <summary>
/// Sends an int32 over socket.
/// </summary>
/// <param name="s"></param>
/// <param name="Data"></param>
public static void SendInt32(this Socket s, int Data)
{
s.Send(BitConverter.GetBytes(Data));
}
/// <summary>
/// Receives an int32 over sockets.
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static int RecvInt32(this Socket s)
{
var Data = new byte[sizeof(int)];
s.Receive(Data);
return BitConverter.ToInt32(Data, 0);
}
/// <summary>
/// Easily connect to a socket and handle the time out.
/// </summary>
/// <param name="s"></param>
/// <param name="IPAddress">The address we would like to connect to.</param>
/// <param name="Port">The port of the socket we would like to connect to.</param>
/// <param name="TimeOut">The time we would like to wait for connection.</param>
/// <returns></returns>
public static bool EasyConnect(this Socket s, string IPAddress, int Port, int TimeOut)
{
s.ReceiveTimeout = s.SendTimeout = TimeOut;
var result = s.BeginConnect(IPAddress, Port, null, null);
result.AsyncWaitHandle.WaitOne(3000, true);
if (!s.Connected)
{
Console.WriteLine("Failed to connect to socket.");
s.Close();
return false;
}
// we have connected
s.EndConnect(result);
return true;
}
/// <summary>
/// Tests the availability of a tcp host.
/// </summary>
/// <param name="Host">Host Address.</param>
/// <param name="Port">Host Port.</param>
/// <returns></returns>
public static bool TestTcpConnection(string Host, int Port)
{
try
{
var client = new TcpClient();
var result = client.BeginConnect(Host, Port, null, null);
var success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(1));
if (!success)
{
return false;
}
client.EndConnect(result);
return true;
}
catch
{
}
return false;
}
/// <summary>
/// Attempts to ping a host.
/// </summary>
/// <param name="Host">Host Address</param>
/// <returns></returns>
public static bool PingHost(string Host)
{
try
{
var pingSender = new Ping();
var options = new PingOptions();
options.DontFragment = true;
var reply = pingSender.Send(Host, 120, Encoding.ASCII.GetBytes("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), options);
return (reply.Status == IPStatus.Success);
}
catch
{
}
return false;
}
/// <summary>
///
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static byte[] StructtoBytes(object str)
{
int size = Marshal.SizeOf(str);
byte[] arr = new byte[size];
IntPtr ptr = Marshal.AllocHGlobal(size);
Marshal.StructureToPtr(str, ptr, true);
Marshal.Copy(ptr, arr, 0, size);
Marshal.FreeHGlobal(ptr);
return arr;
}
/// <summary>
///
/// </summary>
/// <param name="arr"></param>
/// <param name="str"></param>
public static void BytestoStruct<T>(byte[] arr, ref T str)
{
int size = Marshal.SizeOf(str);
IntPtr ptr = Marshal.AllocHGlobal(size);
Marshal.Copy(arr, 0, ptr, size);
str = (T)Marshal.PtrToStructure(ptr, str.GetType());
Marshal.FreeHGlobal(ptr);
}
}
}
@@ -1,84 +0,0 @@
using System.Net;
using System.Net.Sockets;
namespace OrbisSuite.Common
{
public class Listener
{
private Socket s_Listener;
public bool Listening
{
get;
private set;
}
public int Port
{
get;
private set;
}
public Listener(int Port)
{
this.Port = Port;
}
public void Start()
{
//Make sure we have not started before.
if (Listening)
return;
//Create Socket to listen on.
s_Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
//Bind Socket to Port and Listen with a backlog of 100.
s_Listener.Bind(new IPEndPoint(0, Port));
s_Listener.Listen(1000);
//Call BeginAccept with our call back so on every accept of a new socket connection the call back is called.
s_Listener.BeginAccept(CallBack, null);
Listening = true;
}
public void Stop()
{
if (!Listening)
return;
//Clean up for next connection.
s_Listener.Close();
s_Listener.Dispose();
Listening = false;
}
/*
Call back to handle all of our incoming connections and call our event.
*/
void CallBack(IAsyncResult ar)
{
try
{
//Complete the Accept of the incoming Connection and call the event if registered.
Socket s_Client = s_Listener.EndAccept(ar);
if (SocketAccepted != null)
{
SocketAccepted(s_Client);
}
//Begin Accepting other Connections again with our call back.
s_Listener.BeginAccept(CallBack, null);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public delegate void SocketAcceptedHandler(Socket e);
public event SocketAcceptedHandler SocketAccepted;
}
}
@@ -1,56 +0,0 @@
<simpleDialogs:SimpleDialog
x:Class="OrbisSuite.Dialog.AddTargetDialog"
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:OrbisSuite.Dialog"
xmlns:simpleControls="clr-namespace:SimpleUI.Controls;assembly=SimpleUI"
xmlns:simpleDialogs="clr-namespace:SimpleUI.Dialogs;assembly=SimpleUI"
mc:Ignorable="d"
Width="300" Height="400"
d:DesignHeight="400" d:DesignWidth="300">
<Border Background="{DynamicResource WindowBar}"
Margin="10 10 10 5"
CornerRadius="10">
<StackPanel>
<simpleControls:SimpleTextField FieldName="TargetName" Height="30"
Margin="10"
IsReadOnly="False"/>
<simpleControls:SimpleTextField FieldName="IP Address" Height="30"
Margin="10 0 10 10"/>
<simpleControls:SimpleComboBox Height="30" Margin="10 0 10 10" SelectedValuePath="Content">
<ComboBoxItem Content="5.05"/>
<ComboBoxItem Content="6.72"/>
<ComboBoxItem Content="7.02"/>
<ComboBoxItem Content="7.55"/>
<ComboBoxItem Content="9.00"/>
</simpleControls:SimpleComboBox>
<StackPanel Orientation="Horizontal" Margin="0 0 0 10">
<simpleControls:SimpleTextField FieldName="Payload Port"
Width="120"
Height="30"
Margin="10 0 7.5 0"/>
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="{DynamicResource Text}"
Text="Default Target"
VerticalAlignment="Center"
Margin="0 0 7.5 0"/>
<simpleControls:SimpleSwitch Height="15"
HorizontalAlignment="Center"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</simpleDialogs:SimpleDialog>
@@ -1,43 +0,0 @@
using SimpleUI.Dialogs;
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 OrbisSuite.Dialog
{
/// <summary>
/// Interaction logic for AddTarget.xaml
/// </summary>
public partial class AddTargetDialog : SimpleDialog
{
public AddTargetDialog(Window Owner, WindowStartupLocation StartPosition)
: base(Owner, "Save", "Cancel", "Add Target", StartPosition)
{
InitializeComponent();
}
public static SimpleDialogResult ShowDialog(Window Owner, WindowStartupLocation StartPosition)
{
var dlg = new AddTargetDialog(Owner, StartPosition);
dlg.ShowDialog();
if(dlg.Result == SimpleDialogResult.Button1)
{
Console.WriteLine("Save");
}
return dlg.Result;
}
}
}
-101
View File
@@ -1,101 +0,0 @@
using SimpleUI.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace OrbisSuite.Dialog
{
public class Dialogs
{
internal OrbisLib PS4;
public Dialogs(OrbisLib PS4)
{
this.PS4 = PS4;
}
// TODO: Port these to WPF.
public SimpleDialogResult AddTarget(Window Owner, WindowStartupLocation startPosition = WindowStartupLocation.CenterOwner)
{
return AddTargetDialog.ShowDialog(Owner, startPosition);
}
/*public System.Windows.Forms.DialogResult EditTarget(string TargetName, FormStartPosition startPosition = FormStartPosition.CenterParent)
{
EditTarget EditTarget = new EditTarget(PS4, TargetName);
EditTarget.StartPosition = startPosition;
System.Windows.Forms.DialogResult Result = EditTarget.ShowDialog();
EditTarget.Close();
return Result;
}
public System.Windows.Forms.DialogResult TargetDetails(string TargetName, FormStartPosition startPosition = FormStartPosition.CenterParent)
{
TargetDetails TargetDetails = new TargetDetails(PS4, TargetName);
TargetDetails.StartPosition = startPosition;
System.Windows.Forms.DialogResult Result = TargetDetails.ShowDialog();
TargetDetails.Close();
return Result;
}
public System.Windows.Forms.DialogResult About(FormStartPosition startPosition = FormStartPosition.CenterParent)
{
About About = new About();
About.StartPosition = startPosition;
System.Windows.Forms.DialogResult Result = About.ShowDialog();
About.Close();
return Result;
}
public System.Windows.Forms.DialogResult Settings(FormStartPosition startPosition = FormStartPosition.CenterParent)
{
Settings Settings = new Settings(PS4);
Settings.CreateInstance().StartPosition = startPosition;
DialogResult Result = Settings.CreateInstance().ShowDialog();
if (Result == DialogResult.OK)
Settings.CreateInstance().SaveSettings();
Settings.CreateInstance().Close();
return Result;
}
public System.Windows.Forms.DialogResult SelectProcess(string TargetName, FormStartPosition startPosition = FormStartPosition.CenterParent)
{
SelectProcess SelectProcess = new SelectProcess(PS4, TargetName);
SelectProcess.StartPosition = startPosition;
DialogResult Result = SelectProcess.ShowDialog();
if (Result == DialogResult.OK)
SelectProcess.AttachtoSelected();
SelectProcess.Close();
return Result;
}
public DialogResult SelectTarget(FormStartPosition startPosition = FormStartPosition.CenterParent)
{
SelectTarget SelectTarget = new SelectTarget(PS4);
SelectTarget.StartPosition = startPosition;
DialogResult Result = SelectTarget.ShowDialog();
if (Result == DialogResult.OK)
SelectTarget.SelectCurrentTarget();
SelectTarget.Close();
return Result;
}
public DialogResult GameDetails(string TitleID, FormStartPosition startPosition = FormStartPosition.CenterParent)
{
GameDetails GameDetails = new GameDetails(PS4, TitleID);
GameDetails.StartPosition = startPosition;
DialogResult Result = GameDetails.ShowDialog();
GameDetails.Close();
return Result;
}*/
}
}
-170
View File
@@ -1,170 +0,0 @@
using OrbisSuite.Common.Database;
using OrbisSuite.Dialog;
using System.IO;
namespace OrbisSuite
{
public class OrbisLib
{
internal string OrbisLib_Dir;
internal DispatcherClient Client;
#region Internal Class Defines
private Target Internal_DefaultTarget;
public Target DefaultTarget
{
get
{
//initialize the variable to start.
if (Internal_DefaultTarget == null)
Internal_DefaultTarget = new Target(this);
if (TargetManagement.TargetList == null)
{
Internal_DefaultTarget.Active = false;
return Internal_DefaultTarget;
}
var target = TargetInfo.FindDefaultTarget();
if(target != null)
{
Internal_DefaultTarget.Info = target;
Internal_DefaultTarget.Active = true;
}
else
{
Internal_DefaultTarget.Active = false;
}
//Return the instanced version of the default target.
return Internal_DefaultTarget;
}
}
private Target internal_SelectedTarget;
public Target SelectedTarget
{
get
{
//initialize the variable to start.
if (internal_SelectedTarget == null)
internal_SelectedTarget = new Target(this);
if (TargetManagement.TargetList == null)
return internal_SelectedTarget;
TargetInfo targetInfo = TargetInfo.FindTarget(x => x.Name == internal_SelectedTarget.Info.Name);
if (targetInfo != null)
{
internal_SelectedTarget.Info = targetInfo;
internal_SelectedTarget.Active = true;
}
else if (DefaultTarget.Active)
{
internal_SelectedTarget.Info = DefaultTarget.Info;
internal_SelectedTarget.Active = true;
}
else
internal_SelectedTarget.Active = false;
return internal_SelectedTarget;
}
}
private Dictionary<string, Target> Internal_Targets = new Dictionary<string, Target>();
public Dictionary<string, Target> Targets
{
get
{
//Updates the dictionary every time its referenced to make sure its up to date.
//Need to test and see if the overhead on this is too much.
try
{
if(TargetManagement.TargetList == null)
return Internal_Targets;
foreach (TargetInfo TargetInfo in TargetManagement.TargetList)
{
if (Internal_Targets.ContainsKey(TargetInfo.Name))
Internal_Targets[TargetInfo.Name].Info = TargetInfo;
else
Internal_Targets.Add(TargetInfo.Name, new Target(this, TargetInfo));
}
}
catch
{
Console.WriteLine("Failed to get Target.");
}
return Internal_Targets;
}
}
private Events Internal_Events;
public Events Events
{
get { return Internal_Events ?? (Internal_Events = new Events()); }
}
private TargetManagement Internal_TargetManagement;
public TargetManagement TargetManagement
{
get { return Internal_TargetManagement ?? (Internal_TargetManagement = new TargetManagement(this)); }
}
private Dialogs Internal_Dialogs;
public Dialogs Dialogs
{
get { return Internal_Dialogs ?? (Internal_Dialogs = new Dialogs(this)); }
}
#endregion
private OrbisLib()
{
try
{
OrbisLib_Dir = (Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Orbis Suite\\");
if (!Directory.Exists(OrbisLib_Dir))
{
//DarkMessageBox.ShowError("In order to use the functionality of the OrbisLib.dll you need to first install Orbis Suite on this machine.", "Orbis Suite not Installed.", DarkDialogButton.Ok, System.Windows.Forms.FormStartPosition.CenterScreen);
throw new System.Exception("Orbis Suite not Installed.");
}
Utilities.SetDllDirectory(OrbisLib_Dir);
// Set up selected target as default target initially.
//internal_SelectedTarget = new Target(this);
//SelectedTarget.Info = DefaultTarget.Info;
// Set up classes
Client = new DispatcherClient(this);
}
catch
{
}
}
private static OrbisLib? _Instance;
public static OrbisLib Instance
{
get
{
if(_Instance == null)
_Instance = new OrbisLib();
return _Instance;
}
}
public static void Init()
{
//_Instance = new OrbisLib();
}
}
}
@@ -1,34 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>annotations</Nullable>
<RootNamespace>OrbisSuite</RootNamespace>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Ftp.dll" Version="2.0.22269.922" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
<PackageReference Include="System.Data.SQLite" Version="1.0.115.5" />
<PackageReference Include="System.Json" Version="4.7.1" />
<PackageReference Include="TinyIpc" Version="4.1.1" />
</ItemGroup>
<ItemGroup>
<Reference Include="SimpleUI">
<HintPath>..\..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\SimpleUI.dll</HintPath>
</Reference>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy /y $(ProjectDir)$(OutDir)$(ProjectName).dll $(SolutionDir)Windows\Executables\" />
</Target>
</Project>
@@ -1,21 +1,14 @@
using OrbisSuite;
using OrbisSuite.Common.Database;
using OrbisLib2.Common.Database.Types;
using OrbisLib2.General;
using OrbisLib2.Targets;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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;
namespace OrbisLibraryManager.Controls
{
@@ -28,8 +21,8 @@ namespace OrbisLibraryManager.Controls
{
InitializeComponent();
OrbisLib.Instance.Events.DBTouched += Events_DBTouched;
OrbisLib.Instance.Events.TargetStateChanged += Events_TargetStateChanged;
Events.DBTouched += Events_DBTouched;
Events.TargetStateChanged += Events_TargetStateChanged;
RefreshTarget();
}
@@ -45,11 +38,11 @@ namespace OrbisLibraryManager.Controls
private void RefreshTarget()
{
var CurrentTarget = OrbisLib.Instance.SelectedTarget.Info;
var CurrentTarget = TargetManager.SelectedTarget;
if (CurrentTarget != null)
{
switch (CurrentTarget.Details.Status)
switch (CurrentTarget.Info.Status)
{
case TargetStatusType.Offline:
CurrentTargetState.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));
@@ -74,7 +67,7 @@ namespace OrbisLibraryManager.Controls
CurrentTargetName.Text = CurrentTarget.IsDefault ? $"★{CurrentTarget.Name}" : CurrentTarget.Name;
if (CurrentTarget.Details.CurrentTitleID == null || !Regex.IsMatch(CurrentTarget.Details.CurrentTitleID, @"CUSA\d{5}"))
if (CurrentTarget.Info.CurrentTitleID == null || !Regex.IsMatch(CurrentTarget.Info.CurrentTitleID, @"CUSA\d{5}"))
{
CurrentTargetTitleName.Text = "Unknown Title";
CurrentTargetTitleId.Text = "-";
@@ -82,7 +75,7 @@ namespace OrbisLibraryManager.Controls
}
else
{
var Title = new TMDB(CurrentTarget.Details.CurrentTitleID);
var Title = new TMDB(CurrentTarget.Info.CurrentTitleID);
Regex rgx = new Regex(@"[^0-9a-zA-Z +.:']");
CurrentTargetTitleName.Text = Title.Names.First();
CurrentTargetTitleId.Text = Title.NPTitleID;
@@ -94,11 +87,11 @@ namespace OrbisLibraryManager.Controls
private void CurrentTargetTitleImage_MouseDown(object sender, MouseButtonEventArgs e)
{
var CurrentTarget = OrbisLib.Instance.SelectedTarget.Info;
var CurrentTarget = TargetManager.SelectedTarget;
if (CurrentTarget != null && CurrentTarget.Details.CurrentTitleID != null && Regex.IsMatch(CurrentTarget.Details.CurrentTitleID, @"CUSA\d{5}"))
if (CurrentTarget != null && CurrentTarget.Info.CurrentTitleID != null && Regex.IsMatch(CurrentTarget.Info.CurrentTitleID, @"CUSA\d{5}"))
{
var Title = new TMDB(CurrentTarget.Details.CurrentTitleID);
var Title = new TMDB(CurrentTarget.Info.CurrentTitleID);
var url = $"https://store.playstation.com/product/{Title.ContentID}/";
System.Diagnostics.Process.Start(new ProcessStartInfo
@@ -33,24 +33,24 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Libraries\OrbisLib\OrbisLib.csproj" />
<Folder Include="Core\" />
<Folder Include="MVVM\ViewModel\" />
<Folder Include="MVVM\View\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Libraries\OrbisLib2\OrbisLib2.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Expression.Drawing">
<HintPath>..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\Microsoft.Expression.Drawing.dll</HintPath>
<HintPath>..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\Microsoft.Expression.Drawing.dll</HintPath>
</Reference>
<Reference Include="SimpleUI">
<HintPath>..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\SimpleUI.dll</HintPath>
<HintPath>..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\SimpleUI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Core\" />
<Folder Include="MVVM\ViewModel\" />
<Folder Include="MVVM\View\" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\DefaultTitleIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -1,18 +1,5 @@
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;
using OrbisLib2.Common.Dispatcher;
using SimpleUI.Controls;
namespace OrbisLibraryManager
{
@@ -24,6 +11,7 @@ namespace OrbisLibraryManager
public MainWindow()
{
InitializeComponent();
DispatcherClient.Subscribe();
}
}
}
@@ -1 +1 @@
2047
2049
@@ -1 +1 @@
Version 3.0.2047 Debug Build Friday December 23 2022 10:35 AM
Version 3.0.2049 Debug Build Friday December 23 2022 10:43 AM