diff --git a/Orbis Suite 3.0.sln b/Orbis Suite 3.0.sln index 16d46e5..8ee958c 100644 --- a/Orbis Suite 3.0.sln +++ b/Orbis Suite 3.0.sln @@ -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} diff --git a/Windows/Libraries/OrbisLib/Classes/DispatcherClient.cs b/Windows/Libraries/OrbisLib/Classes/DispatcherClient.cs deleted file mode 100644 index a877c07..0000000 --- a/Windows/Libraries/OrbisLib/Classes/DispatcherClient.cs +++ /dev/null @@ -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; - } - } - } -} \ No newline at end of file diff --git a/Windows/Libraries/OrbisLib/Classes/EventTypes.cs b/Windows/Libraries/OrbisLib/Classes/EventTypes.cs deleted file mode 100644 index d8eca3f..0000000 --- a/Windows/Libraries/OrbisLib/Classes/EventTypes.cs +++ /dev/null @@ -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; - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Events.cs b/Windows/Libraries/OrbisLib/Classes/Events.cs deleted file mode 100644 index 2dfe77b..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Events.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace OrbisSuite -{ - public class Events - { - /// - /// The DBTouched Event gets invoked when the Database used to store target specific info is changed. - /// - public event EventHandler? DBTouched; - - /// - /// Even is fired when ever the state of the target changes. - /// - public event EventHandler? TargetStateChanged; - - /// - /// Will Fire the event for when the Database has been updated. - /// - internal void FireDBTouched() - { - DBTouched?.Invoke(null, new DBTouchedEvent()); - } - - /// - /// Will Fire the event for Target Availability. - /// - /// - /// - 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)); - } - - /// - /// Will Fire the event for Target API Availability. - /// - /// - /// - 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)); - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/TMDB.cs b/Windows/Libraries/OrbisLib/Classes/TMDB.cs deleted file mode 100644 index 698b3fb..0000000 --- a/Windows/Libraries/OrbisLib/Classes/TMDB.cs +++ /dev/null @@ -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; } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Target/Application.cs b/Windows/Libraries/OrbisLib/Classes/Target/Application.cs deleted file mode 100644 index 374d6df..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Target/Application.cs +++ /dev/null @@ -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 GetAppList() - { - var AppList = new List(); - - // 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); - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Target/Debug.cs b/Windows/Libraries/OrbisLib/Classes/Target/Debug.cs deleted file mode 100644 index 0309ea8..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Target/Debug.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace OrbisSuite -{ - public class Debug - { - private Target Target; - - public Debug(Target Target) - { - this.Target = Target; - } - - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Target/FTP.cs b/Windows/Libraries/OrbisLib/Classes/Target/FTP.cs deleted file mode 100644 index 93ec583..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Target/FTP.cs +++ /dev/null @@ -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 GetDir(string Dir) - { - var ftpItems = new List(); - 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; - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Target/Payload.cs b/Windows/Libraries/OrbisLib/Classes/Target/Payload.cs deleted file mode 100644 index a27e3d9..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Target/Payload.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Net.Sockets; - -namespace OrbisSuite -{ - public class Payload - { - private Target Target; - - public Payload(Target Target) - { - this.Target = Target; - } - - /// - /// Sends Custom Payloads to Playstation 4 Console - /// - /// PlayStation 4 IP address - /// Byte array of payload - /// Port used to recieve payload default value is 9020 - 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; - } - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Target/Process/Extension.cs b/Windows/Libraries/OrbisLib/Classes/Target/Process/Extension.cs deleted file mode 100644 index 4ed2dcc..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Target/Process/Extension.cs +++ /dev/null @@ -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; - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Target/Process/Memory.cs b/Windows/Libraries/OrbisLib/Classes/Target/Process/Memory.cs deleted file mode 100644 index 797790c..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Target/Process/Memory.cs +++ /dev/null @@ -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); - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Target/Process/Process.cs b/Windows/Libraries/OrbisLib/Classes/Target/Process/Process.cs deleted file mode 100644 index 0f2265d..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Target/Process/Process.cs +++ /dev/null @@ -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 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); - } - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Target/Target.cs b/Windows/Libraries/OrbisLib/Classes/Target/Target.cs deleted file mode 100644 index cf21811..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Target/Target.cs +++ /dev/null @@ -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; - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Target/TargetEventTypes.cs b/Windows/Libraries/OrbisLib/Classes/Target/TargetEventTypes.cs deleted file mode 100644 index 8eace72..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Target/TargetEventTypes.cs +++ /dev/null @@ -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; - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Target/TargetEvents.cs b/Windows/Libraries/OrbisLib/Classes/Target/TargetEvents.cs deleted file mode 100644 index fdbe32b..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Target/TargetEvents.cs +++ /dev/null @@ -1,129 +0,0 @@ -namespace OrbisSuite -{ - public class TargetEvents - { - private Target Target; - - public event EventHandler Print; - public event EventHandler ProcIntercept; - public event EventHandler ProcContinue; - public event EventHandler ProcDie; - public event EventHandler ProcAttach; - public event EventHandler ProcDetach; - public event EventHandler TargetSuspend; - public event EventHandler TargetResume; - public event EventHandler TargetShutdown; - public event EventHandler TargetNewTitle; - - public TargetEvents(Target Target) - { - this.Target = Target; - } - - /// - /// Event that should be fired when we recieve a print from the remote target. - /// - /// The sending Target Address. - /// - /// - internal void RaiseProcPrintEvent(string SenderIPAddress, string Sender, string Data) - { - if (SenderIPAddress.Equals(Target.Info.IPAddress)) - Print?.Invoke(null, new PrintEvent(Sender, Data)); - } - - /// - /// Fires an event for when the Target's proccess were attached to has reached an intercepted state. - /// - /// The sending Target Address. - internal void RaiseProcInterceptEvent(string IPAddr) - { - if (IPAddr.Equals(Target.Info.IPAddress)) - { - ProcIntercept?.Invoke(null, new ProcInterceptEvent()); - } - } - - /// - /// Fires an event when a procees on the Target has gotten the signal to continue execution. - /// - /// The sending Target Address. - internal void RaiseProcContinueEvent(string IPAddr) - { - if (IPAddr.Equals(Target.Info.IPAddress)) - ProcContinue?.Invoke(null, new ProcContinueEvent()); - } - - /// - /// Fires an event for when a proccess is going to be shutting down on the Target. - /// - /// The sending Target Address. - internal void RaiseProcDieEvent(string IPAddr) - { - if (IPAddr.Equals(Target.Info.IPAddress)) - ProcDie?.Invoke(null, new ProcDieEvent()); - } - - /// - /// Fires an event for when the OrbisLib API attaches to a process. - /// - /// The sending Target Address. - /// The name of the process were attaching to. - internal void RaiseProcAttachEvent(string IPAddr, string NewProcName) - { - if (IPAddr.Equals(Target.Info.IPAddress)) - ProcAttach?.Invoke(null, new ProcAttachEvent(NewProcName)); - } - - /// - /// Fires an event for when the OrbisLib API detaches to a process. - /// - /// The sending Target Address. - internal void RaiseProcDetachEvent(string IPAddr) - { - if (IPAddr.Equals(Target.Info.IPAddress)) - ProcDetach?.Invoke(null, new ProcDetachEvent()); - } - - /// - /// Fires event for when Target is entering the suspended state. - /// - /// The sending Target Address. - internal void RaiseTargetSuspendEvent(string IPAddr) - { - if (IPAddr.Equals(Target.Info.IPAddress)) - TargetSuspend?.Invoke(null, new TargetSuspendEvent()); - } - - /// - /// Fires event for when the Target is resuming from a suspended state. - /// - /// The sending Target Address. - internal void RaiseTargetResumeEvent(string IPAddr) - { - if (IPAddr.Equals(Target.Info.IPAddress)) - TargetResume?.Invoke(null, new TargetResumeEvent()); - } - - /// - /// Fires an event for when the Target is shutting down. - /// - /// The sending Target Address. - internal void RaiseTargetShutdownEvent(string IPAddr) - { - if (IPAddr.Equals(Target.Info.IPAddress)) - TargetShutdown?.Invoke(null, new TargetShutdownEvent()); - } - - /// - /// Fires an event for when we change the current game on the Target. - /// - /// The sending Target Address. - /// The next title index our Target will be running. - internal void RaiseTargetNewTitleEvent(string IPAddr, string TitleID) - { - if (IPAddr.Equals(Target.Info.IPAddress)) - TargetNewTitle?.Invoke(null, new TargetNewTitleEvent(TitleID)); - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/TargetManagement.cs b/Windows/Libraries/OrbisLib/Classes/TargetManagement.cs deleted file mode 100644 index 3ebb6db..0000000 --- a/Windows/Libraries/OrbisLib/Classes/TargetManagement.cs +++ /dev/null @@ -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? 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; - } - } -} diff --git a/Windows/Libraries/OrbisLib/Classes/Utilities.cs b/Windows/Libraries/OrbisLib/Classes/Utilities.cs deleted file mode 100644 index 44edbbd..0000000 --- a/Windows/Libraries/OrbisLib/Classes/Utilities.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Runtime.InteropServices; -using System.Text; - -namespace OrbisSuite -{ - public class Utilities - { - /// - /// Will convert byte array to a string and ensure a null terminator is set. - /// - /// Bytes to convert. - /// Returns a string form of the input bytes. - 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; - } - } - - /// - /// Will censor a part of an input string with the desired sensor char. - /// - /// The string we would like to censor. - /// The character we would like to use as the sensor. - /// The allowed number of characters starting from 0. - /// Returns the censored string. - 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 ""; - } - } -} diff --git a/Windows/Libraries/OrbisLib/Common/API/API.cs b/Windows/Libraries/OrbisLib/Common/API/API.cs deleted file mode 100644 index 519d615..0000000 --- a/Windows/Libraries/OrbisLib/Common/API/API.cs +++ /dev/null @@ -1,158 +0,0 @@ -using System.Net.Sockets; - -namespace OrbisSuite.Common -{ - public static class API - { - /// - /// Connects to the API. - /// - /// Address we would like to connnect to. - /// The socket we have connected on. - /// Returns true if we successfully connected. - 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); - } - - /// - /// Short API Call used when you only need to send the initial packet and no additional data. - /// - /// Address to send to. - /// The initial Packet Data. - /// Returns the result of the action. - 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; - } - - /// - /// Long API Call used for when we need to send more than just the initial packet. - /// - /// Address to send to. - /// The initial Packet Data. - /// The soucket out used for sending more data. - /// Returns the result of the action. - 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; - } - - /// - /// Sends additional data if required. - /// - /// The packet type. - /// The socket instance were using. - /// Any Packet structure. - /// Returns the result of the action. - public static APIResults SendNextPacket(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; - } - - /// - /// - /// - /// - /// - /// - 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; - } - - /// - /// Completes the call and gets our final result. - /// - /// The socket used to communicate witht the API. - /// Returns the result of the action. - public static APIResults CompleteCall(Socket Sock) - { - try - { - var Results = (APIResults)Sock.RecvInt32(); - - Sock.Close(); - - return Results; - } - catch - { - - } - - return APIResults.API_ERROR_GENERAL; - } - } -} diff --git a/Windows/Libraries/OrbisLib/Common/API/APIPackets.cs b/Windows/Libraries/OrbisLib/Common/API/APIPackets.cs deleted file mode 100644 index 4a9f942..0000000 --- a/Windows/Libraries/OrbisLib/Common/API/APIPackets.cs +++ /dev/null @@ -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 -} diff --git a/Windows/Libraries/OrbisLib/Common/Config.cs b/Windows/Libraries/OrbisLib/Common/Config.cs deleted file mode 100644 index 2f7b2d9..0000000 --- a/Windows/Libraries/OrbisLib/Common/Config.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace OrbisSuite.Common -{ - public class Config - { - /// - /// The prort that is used to interact with the Target Console. - /// - public static readonly int APIPort = 6900; - - /// - /// Port used to communicate events to the host machine from the Target Console. - /// - public static readonly int EventPort = 6901; - - /// - /// The Port used to recieve debug logs from the Target Console. - /// - public static readonly int DebugPort = 6902; - - /// - /// The default port for FTP. - /// - public static readonly int FTPPort = 2121; - - /// - /// - /// - public static readonly int DispatcherPort = 6919; - - /// - /// - /// - public static readonly int DispatcherClientPort = 6920; - - /// - /// Name of the data base used to store the user data / Target List. - /// - public static readonly string DataBaseName = "OrbisSuiteUserData.db"; - - /// - /// The Path to the Orbis Suite data. - /// - public static readonly string OrbisPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)}\Orbis Suite"; - - /// - /// Path of the data base used to store the user data / Target List. - /// - public static readonly string DataBasePath = $@"{OrbisPath}\{DataBaseName}"; - - /// - /// Maximum number of targets we can store. - /// - public static readonly int MaxTargets = 20; - - /// - /// The version of the packets used to communicate with the Target Console. - /// - public static readonly int PacketVersion = 2; - } -} diff --git a/Windows/Libraries/OrbisLib/Common/DataBase/SavedTargets.cs b/Windows/Libraries/OrbisLib/Common/DataBase/SavedTargets.cs deleted file mode 100644 index b0f8ccc..0000000 --- a/Windows/Libraries/OrbisLib/Common/DataBase/SavedTargets.cs +++ /dev/null @@ -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 - { - /// - /// Returns a list of the Targets saved. - /// - public static List? Targets - { - get - { - return TargetInfo.GetTargetList(); - } - } - - /// - /// Returns a count of all the Targets currently saved. - /// - public static int TargetCount - { - get - { - if(Targets == null) - return 0; - - return Targets.Count; - } - } - - /// - /// Returns the target that is the current Default Target. - /// - public static TargetInfo? DefaultTarget - { - get - { - return TargetInfo.FindDefaultTarget(); - } - } - - /// - /// Updates extended information about the Target. *Requires the Target to be on and the API running. - /// - /// The name of the target to update. - /// Returns weather or not the action was successful or not. - 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(); - } - } -} diff --git a/Windows/Libraries/OrbisLib/Common/DataBase/Settings.cs b/Windows/Libraries/OrbisLib/Common/DataBase/Settings.cs deleted file mode 100644 index ac82086..0000000 --- a/Windows/Libraries/OrbisLib/Common/DataBase/Settings.cs +++ /dev/null @@ -1,116 +0,0 @@ -using SQLite; - -namespace OrbisSuite.Common.Database -{ - /// - /// Used to get/set the settings of Orbis Suite. - /// - [Table("Settings")] - public class Settings - { - [PrimaryKey, AutoIncrement, NotNull] - public int Id { get; set; } - - /// - /// The API port that OrbisLib communicates on. - /// - [NotNull] - public int APIPort { get; set; } = 6900; - - /// - /// The port that will be used to access the targets file system using ftp - /// - [NotNull] - public int FTPPort { get; set; } = 2121; - - /// - /// The port of a klog server that will be used to print console output similar to UART. - /// - [NotNull] - public int KlogPort { get; set; } = 3232; - - /// - /// The serial COM port we will listen to for UART output. - /// - [NotNull] - public string? COMPort { get; set; } = "-"; - - /// - /// Starts the Orbis Suite taskbar app when windows boots. - /// - [NotNull] - public bool StartOnBoot { get; set; } = false; - - /// - /// Choose which theme will be used across Orbis Suite. - /// - [NotNull] - public int Theme { get; set; } = 0; - - /// - /// Enables the accent colours to cycle through all colours of the rainbow. - /// - [NotNull] - public bool RainbowColours { get; set; } = false; - - /// - /// When viewd from the target details choose to censor the Target identifier. - /// - [NotNull] - public bool CensorIDPS { get; set; } = false; - - /// - /// When viewd from the target details choose to censor the Target identifier. - /// - [NotNull] - public bool CensorPSID { get; set; } = false; - - /// - /// SHow timestamps on the console output. - /// - [NotNull] - public bool ShowTimestamps { get; set; } = false; - - /// - /// Word wrap the console output window. - /// - [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(); - - // Try to pull the entries of the settings - var list = db.Table(); - 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(); - } - } -} diff --git a/Windows/Libraries/OrbisLib/Common/Database/TargetDetails.cs b/Windows/Libraries/OrbisLib/Common/Database/TargetDetails.cs deleted file mode 100644 index 87e72c6..0000000 --- a/Windows/Libraries/OrbisLib/Common/Database/TargetDetails.cs +++ /dev/null @@ -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; } - - /// - /// Will be true if a tcp connection can be achieved on the saved IP Address. - /// - [NotNull] - [Column("Available")] - public bool IsAvailable { get; set; } = false; - - /// - /// Will be true if the Orbis Suite API is running on the target. - /// - [NotNull] - [Column("APIAvailable")] - public bool IsAPIAvailable { get; set; } = false; - - /// - /// The power/API status of the target. - /// - public TargetStatusType Status - { - get - { - if (IsAPIAvailable) - return TargetStatusType.APIAvailable; - else if (IsAvailable) - return TargetStatusType.Online; - else - return TargetStatusType.Offline; - } - } - - /// - /// The SDK Version of the software installed on the target. - /// - [NotNull] - public string SDKVersion { get; set; } = "-"; - - /// - /// The full software version installed on the target. - /// - [NotNull] - public string SoftwareVersion { get; set; } = "-"; - - /// - /// The software version first installed on the target when sold. - /// - [NotNull] - public string FactorySoftwareVersion { get; set; } = "-"; - - /// - /// The current big game titleId running on the target. - /// - [NotNull] - public string CurrentTitleID { get; set; } = "-"; - - /// - /// The name of the target as set on the target. - /// - [NotNull] - public string ConsoleName { get; set; } = "-"; - - /// - /// The serial number of the targets motherboard. - /// - [NotNull] - public string MotherboardSerial { get; set; } = "-"; - - /// - /// The seraial number of the target. - /// - [NotNull] - public string Serial { get; set; } = "-"; - - /// - /// The model number of the target. - /// - [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; - } - } - } - - /// - /// The MAC address of the target LAN adapter. - /// - [NotNull] - public string MACAddressLAN { get; set; } = "-"; - - /// - /// The MAC address of the target WIFI adapter. - /// - [NotNull] - public string MACAddressWIFI { get; set; } = "-"; - - /// - /// Will be true if the UART flag is set in the targets flash. - /// - [NotNull] - public bool UART { get; set; } = false; - - /// - /// Will return true if the IDUMode flag is set int he targets flash. - /// - [NotNull] - public bool IDUMode { get; set; } = false; - - /// - /// A unique string used to identify the target. - /// - [NotNull] - public string IDPS { get; set; } = "-"; - - /// - /// A unique string used to identify the target. - /// - [NotNull] - public string PSID { get; set; } = "-"; - - /// - /// The console type like Retail/TestKit/Devkit. - /// - [NotNull] - public ConsoleType ConsoleType { get; set; } = 0; - - /// - /// Will be true if the Orbis Suite Debugger is attached to a process. - /// - [NotNull] - [Column("Attached")] - public bool IsAttached { get; set; } = false; - - /// - /// The current processId being debugged by the OrbisSuite Debugger. - /// - [NotNull] - public int CurrentProcessId { get; set; } = 0; - - - /// - /// The current foreground account identifier. - /// - [NotNull] - public int ForegroundAccountId { get; set; } = 0; - - /// - /// The used space on the targets hard disk. - /// - [NotNull] - public long HDDUsedSpace { get; set; } = 0; - - /// - /// The free space on the targets hard disk. - /// - [NotNull] - public long HDDFreeSpace { get; set; } = 0; - - /// - /// The usable size of the targets hard disk. - /// - [NotNull] - public long HDDTotalSpace { get; set; } = 0; - - /// - /// The current temperature of the CPU. - /// - public int CPUTemp { get; set; } = 0; - - /// - /// The current tempurature of the SOC. - /// - public int SOCTemp { get; set; } = 0; - - /// - /// The current thread count. - /// - public int ThreadCount { get; set; } = 0; - - /// - /// The current average cpu usage. - /// - public float AverageCPUUsage { get; set; } = 0.0f; - - /// - /// The current core that is the most busy. - /// - public int BusyCore { get; set; } = 0; - - /// - /// The current system ram usage. - /// - public int RamUsage { get; set; } = 0; - - /// - /// The current video ram usage. - /// - public int VRamUsage { get; set; } = 0; - - /// - /// Shows the Title number of the games on the home screen of this target. - /// - [NotNull] - public bool ShowTitleId { get; set; } = false; - - /// - /// Shows the devkit information display panel that will show some information about the target like the IP Address. - /// - [NotNull] - public bool ShowDevkitPanel { get; set; } = false; - - /// - /// Shows a shortcut on the Home screen that can be used to quickly access the Orbis Toolbox menu. - /// - [NotNull] - public bool ShowToolboxShortcut { get; set; } = false; - - /// - /// Shows the '★APP_HOME' on the home screen that can be used to quickly launch home brew to debug it with out a pkg. - /// - [NotNull] - public bool ShowAppHome { get; set; } = false; - - /// - /// Saves the current information about the target to the database. - /// - /// Returns true if any rows were effected. - public bool Save() - { - var db = new SQLiteConnection(Config.DataBasePath); - - // Create the table if it doesn't exist already. - db.CreateTable(); - - var result = db.Update(this); - db.Close(); - return (result <= 0); - } - } -} diff --git a/Windows/Libraries/OrbisLib/Common/Database/TargetInfo.cs b/Windows/Libraries/OrbisLib/Common/Database/TargetInfo.cs deleted file mode 100644 index 0eff349..0000000 --- a/Windows/Libraries/OrbisLib/Common/Database/TargetInfo.cs +++ /dev/null @@ -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 -{ - /// - /// Information about the targets saved. - /// - [Table("Targets")] - public class TargetInfo - { - [PrimaryKey, AutoIncrement, NotNull] - public int Id { get; set; } - - /// - /// Weather or not this is our default target to be selected on start up. - /// - [NotNull] - [Column("DefaultTarget")] - public bool IsDefault { get; set; } = false; - - /// - /// The name given to the target. - /// - [NotNull, Unique] - [Column("TargetName")] - public string Name { get; set; } = "-"; - - /// - /// The IP Address as a string. - /// - [NotNull, Unique] - public string IPAddress { get; set; } = "-"; - - /// - /// The port used to send payloads to the saved IP Address. - /// - [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(); - - _details = db.Find(x => x.TargetId == Id); - if (_details == null) - { - _details = new TargetDetails(); - _details.TargetId = Id; - db.Insert(_details); - db.Close(); - } - else - { - db.Close(); - } - } - - return _details; - } - } - - /// - /// Remove the default tag from the other row. - /// - private void CheckDefault() - { - var defaultTarget = FindDefaultTarget(); - if (IsDefault && defaultTarget != null && defaultTarget.Id != Id) - { - defaultTarget.IsDefault = false; - defaultTarget.Save(); - } - } - - /// - /// Saves the current information about the target to the database. - /// - /// Returns true if any rows were effected. - 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(); - - var result = db.Update(this); - db.Close(); - return (result > 0); - } - - public TargetInfo Clone() - { - return (TargetInfo)this.MemberwiseClone(); - } - - /// - /// Adds a this Target to the data base. - /// - /// Returns true if a row was added to the database. - 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(); - - var result = db.Insert(this); - db.Close(); - return (result > 0); - } - catch (Exception ex) - { - return false; - } - } - - /// - /// Removes this current Target from the database. - /// - /// Returns true if a row was removed from the database. - 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 GetTargetList() - { - var db = new SQLiteConnection(Config.DataBasePath); - - // Create the table if it doesn't exist already. - db.CreateTable(); - - var result = db.Table().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(); - - var result = db.Find(x => x.IsDefault == true); - db.Close(); - return result; - } - - /// - /// Find a saved Target by a specific value using a predicate. - /// - /// The predicate of the columns we want to match on. - /// Returns the first object that matches the predicate. - public static TargetInfo FindTarget(Expression> predicate) - { - var db = new SQLiteConnection(Config.DataBasePath); - - // Create the table if it doesn't exist already. - db.CreateTable(); - - var result = db.Find(predicate); - db.Close(); - return result; - } - - /// - /// Find weahter or not a Target by specific value exists by using a predicate. - /// - /// The predicate of the columns we want to match on. - /// Returns true if we found a match. - public static bool DoesTargetExist(Expression> predicate) - { - var db = new SQLiteConnection(Config.DataBasePath); - - // Create the table if it doesn't exist already. - db.CreateTable(); - - var result = db.Find(predicate); - db.Close(); - return (result != null); - } - } -} diff --git a/Windows/Libraries/OrbisLib/Common/Database/TargetSettings.cs b/Windows/Libraries/OrbisLib/Common/Database/TargetSettings.cs deleted file mode 100644 index c691b8a..0000000 --- a/Windows/Libraries/OrbisLib/Common/Database/TargetSettings.cs +++ /dev/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 - { - - } -} diff --git a/Windows/Libraries/OrbisLib/Common/Database/Types/ConsoleModelType.cs b/Windows/Libraries/OrbisLib/Common/Database/Types/ConsoleModelType.cs deleted file mode 100644 index 7a320e2..0000000 --- a/Windows/Libraries/OrbisLib/Common/Database/Types/ConsoleModelType.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace OrbisSuite.Common.Database -{ - /// - /// The model revision type based on its model number. - /// - public enum ConsoleModelType - { - Unknown, - Fat, - Slim, - Pro - }; -} diff --git a/Windows/Libraries/OrbisLib/Common/Database/Types/ConsoleType.cs b/Windows/Libraries/OrbisLib/Common/Database/Types/ConsoleType.cs deleted file mode 100644 index 574b4a6..0000000 --- a/Windows/Libraries/OrbisLib/Common/Database/Types/ConsoleType.cs +++ /dev/null @@ -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, - }; -} diff --git a/Windows/Libraries/OrbisLib/Common/Database/Types/TargetStatusType.cs b/Windows/Libraries/OrbisLib/Common/Database/Types/TargetStatusType.cs deleted file mode 100644 index c9a2a1a..0000000 --- a/Windows/Libraries/OrbisLib/Common/Database/Types/TargetStatusType.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace OrbisSuite.Common.Database -{ - /// - /// The current status of the Target & the Orbis Suite API. - /// - public enum TargetStatusType - { - None, - Offline, - Online, - APIAvailable - }; -} diff --git a/Windows/Libraries/OrbisLib/Common/Dispatcher/DispatcherPackets.cs b/Windows/Libraries/OrbisLib/Common/Dispatcher/DispatcherPackets.cs deleted file mode 100644 index c4875ec..0000000 --- a/Windows/Libraries/OrbisLib/Common/Dispatcher/DispatcherPackets.cs +++ /dev/null @@ -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, - }; - - /// - /// The event the packet is firing for. - /// - public PacketType Type { get; set; } - - /// - /// The Target's IP Address which the Event belongs to. - /// - public string? SenderIPAddress { get; set; } - - /// - /// Name of the process that the event was triggered for. - /// - 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(); - } - } -} diff --git a/Windows/Libraries/OrbisLib/Common/Helpers/Helper.cs b/Windows/Libraries/OrbisLib/Common/Helpers/Helper.cs deleted file mode 100644 index 0b03174..0000000 --- a/Windows/Libraries/OrbisLib/Common/Helpers/Helper.cs +++ /dev/null @@ -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 - { - /// - /// Convert an object to a byte array - /// - /// The Object to convert. - /// - public static byte[] ObjectToByteArray(Object obj) - { - BinaryFormatter bf = new BinaryFormatter(); - using (var ms = new MemoryStream()) - { - bf.Serialize(ms, obj); - return ms.ToArray(); - } - } - - /// - /// Convert a byte array to an Object - /// - /// The array to convert. - /// - 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); - } - } - - /// - /// Sends an object and its size to the socket. - /// - /// - /// The object we would like to send. (Must be serializable.) - 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); - } - - /// - /// Recieve an object from a socket. - /// - /// - /// Returns the object we would like to receive. - public static object RecvObject(this Socket s) - { - var ObjectSize = s.RecvInt32(); - - var ObjectData = new byte[ObjectSize]; - s.Receive(ObjectData); - - return ByteArrayToObject(ObjectData); - } - - /// - /// Sends an int32 over socket. - /// - /// - /// - public static void SendInt32(this Socket s, int Data) - { - s.Send(BitConverter.GetBytes(Data)); - } - - - /// - /// Receives an int32 over sockets. - /// - /// - /// - public static int RecvInt32(this Socket s) - { - var Data = new byte[sizeof(int)]; - s.Receive(Data); - return BitConverter.ToInt32(Data, 0); - } - - /// - /// Easily connect to a socket and handle the time out. - /// - /// - /// The address we would like to connect to. - /// The port of the socket we would like to connect to. - /// The time we would like to wait for connection. - /// - 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; - } - - /// - /// Tests the availability of a tcp host. - /// - /// Host Address. - /// Host Port. - /// - 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; - } - - /// - /// Attempts to ping a host. - /// - /// Host Address - /// - 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; - } - - /// - /// - /// - /// - /// - 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; - } - - /// - /// - /// - /// - /// - public static void BytestoStruct(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); - } - } -} diff --git a/Windows/Libraries/OrbisLib/Common/Helpers/Listener.cs b/Windows/Libraries/OrbisLib/Common/Helpers/Listener.cs deleted file mode 100644 index a5aaab1..0000000 --- a/Windows/Libraries/OrbisLib/Common/Helpers/Listener.cs +++ /dev/null @@ -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; - } -} diff --git a/Windows/Libraries/OrbisLib/Dialog/AddTarget.xaml b/Windows/Libraries/OrbisLib/Dialog/AddTarget.xaml deleted file mode 100644 index 4d49dce..0000000 --- a/Windows/Libraries/OrbisLib/Dialog/AddTarget.xaml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Windows/Libraries/OrbisLib/Dialog/AddTarget.xaml.cs b/Windows/Libraries/OrbisLib/Dialog/AddTarget.xaml.cs deleted file mode 100644 index d49f5cb..0000000 --- a/Windows/Libraries/OrbisLib/Dialog/AddTarget.xaml.cs +++ /dev/null @@ -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 -{ - /// - /// Interaction logic for AddTarget.xaml - /// - 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; - } - } -} diff --git a/Windows/Libraries/OrbisLib/Dialog/Dialog.cs b/Windows/Libraries/OrbisLib/Dialog/Dialog.cs deleted file mode 100644 index bd570a3..0000000 --- a/Windows/Libraries/OrbisLib/Dialog/Dialog.cs +++ /dev/null @@ -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; - }*/ - } -} diff --git a/Windows/Libraries/OrbisLib/OrbisLib.cs b/Windows/Libraries/OrbisLib/OrbisLib.cs deleted file mode 100644 index ec6a661..0000000 --- a/Windows/Libraries/OrbisLib/OrbisLib.cs +++ /dev/null @@ -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 Internal_Targets = new Dictionary(); - public Dictionary 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(); - } - } -} \ No newline at end of file diff --git a/Windows/Libraries/OrbisLib/OrbisLib.csproj b/Windows/Libraries/OrbisLib/OrbisLib.csproj deleted file mode 100644 index ff7020d..0000000 --- a/Windows/Libraries/OrbisLib/OrbisLib.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - net6.0-windows - enable - annotations - OrbisSuite - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - true - - - - - - - - - - - - - - - - - ..\..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\SimpleUI.dll - - - - - - - - diff --git a/Windows/OrbisLibraryManager/Controls/CurrentTargetDisplay.xaml.cs b/Windows/OrbisLibraryManager/Controls/CurrentTargetDisplay.xaml.cs index 711bc36..6a80a48 100644 --- a/Windows/OrbisLibraryManager/Controls/CurrentTargetDisplay.xaml.cs +++ b/Windows/OrbisLibraryManager/Controls/CurrentTargetDisplay.xaml.cs @@ -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 diff --git a/Windows/OrbisLibraryManager/OrbisLibraryManager.csproj b/Windows/OrbisLibraryManager/OrbisLibraryManager.csproj index 4f76ce2..efbd63a 100644 --- a/Windows/OrbisLibraryManager/OrbisLibraryManager.csproj +++ b/Windows/OrbisLibraryManager/OrbisLibraryManager.csproj @@ -33,24 +33,24 @@ - + + + + + + + - ..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\Microsoft.Expression.Drawing.dll + ..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\Microsoft.Expression.Drawing.dll - ..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\SimpleUI.dll + ..\..\External\SimpleUI\SimpleUI\bin\Debug\net6.0-windows\SimpleUI.dll - - - - - - PreserveNewest diff --git a/Windows/OrbisLibraryManager/OrbisLibraryManager.xaml.cs b/Windows/OrbisLibraryManager/OrbisLibraryManager.xaml.cs index 2e9d419..da00918 100644 --- a/Windows/OrbisLibraryManager/OrbisLibraryManager.xaml.cs +++ b/Windows/OrbisLibraryManager/OrbisLibraryManager.xaml.cs @@ -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(); } } } diff --git a/Windows/OrbisNeighborHood/Resources/BuildNumber.txt b/Windows/OrbisNeighborHood/Resources/BuildNumber.txt index b6ac305..a9a6e2f 100644 --- a/Windows/OrbisNeighborHood/Resources/BuildNumber.txt +++ b/Windows/OrbisNeighborHood/Resources/BuildNumber.txt @@ -1 +1 @@ -2047 +2049 diff --git a/Windows/OrbisNeighborHood/Resources/BuildString.txt b/Windows/OrbisNeighborHood/Resources/BuildString.txt index f585909..40b354b 100644 --- a/Windows/OrbisNeighborHood/Resources/BuildString.txt +++ b/Windows/OrbisNeighborHood/Resources/BuildString.txt @@ -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