From 0e0f82d28762ce7934f6ed7388c0961dae67565a Mon Sep 17 00:00:00 2001 From: Dylan Bickerstaff Date: Sun, 8 Mar 2020 21:33:19 -0400 Subject: [PATCH] Fixes 45 --- SuperGrate/Classes/Misc.cs | 14 +++++++++++--- SuperGrate/Classes/USMT.cs | 12 ++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/SuperGrate/Classes/Misc.cs b/SuperGrate/Classes/Misc.cs index b350c74..9a4b312 100644 --- a/SuperGrate/Classes/Misc.cs +++ b/SuperGrate/Classes/Misc.cs @@ -479,7 +479,7 @@ public static async void CancelRemoteProfileDelete(string Host) /// /// Host to get the architecture information from. /// CPU architecture. - public static Task GetRemoteArch(string Host) + public static Task GetRemoteArch(string Host) { Logger.Information("Reading OS Architecture..."); return Task.Run(() => { @@ -492,7 +492,9 @@ public static Task GetRemoteArch(string Host) ManagementObjectCollection collection = searcher.Get(); foreach (ManagementObject manObj in collection) { - string arch = (string)manObj["OSArchitecture"]; + string rawArch = (string)manObj["OSArchitecture"]; + OSArchitecture arch = OSArchitecture.X86; + if (rawArch.Contains("64")) arch = OSArchitecture.X64; Logger.Information("OS Architecture is: " + arch + "."); return arch; } @@ -501,7 +503,7 @@ public static Task GetRemoteArch(string Host) { Logger.Exception(e, "Failed to read the OS Architecture from host: " + Host + "."); } - return null; + return OSArchitecture.Unknown; }); } /// @@ -520,5 +522,11 @@ public static void MainMenuSetState(MainMenu Menu, bool Enabled, string[] Menus mi.Enabled = Enabled; } } + public enum OSArchitecture + { + Unknown = 0, + X86 = 1, + X64 = 2 + } } } \ No newline at end of file diff --git a/SuperGrate/Classes/USMT.cs b/SuperGrate/Classes/USMT.cs index b9f984a..61751c1 100644 --- a/SuperGrate/Classes/USMT.cs +++ b/SuperGrate/Classes/USMT.cs @@ -12,7 +12,7 @@ class USMT private static bool Failed = false; private static bool Running = false; private static string CurrentTarget = ""; - private static string DetectedArch = null; + private static Misc.OSArchitecture DetectedArch = Misc.OSArchitecture.Unknown; private static string PayloadPathLocal { get { @@ -32,11 +32,11 @@ private static string USMTPath { get { - if(DetectedArch == "64-bit") + if(DetectedArch == Misc.OSArchitecture.X64) { return Config.Settings["USMTPathX64"]; } - if(DetectedArch == "32-bit") + if(DetectedArch == Misc.OSArchitecture.X64) { return Config.Settings["USMTPathX86"]; } @@ -63,7 +63,7 @@ public static Task Do(USMTMode Mode, string[] IDs) } return Task.Run(async () => { DetectedArch = await Misc.GetRemoteArch(CurrentTarget); - if (Canceled || DetectedArch == null) return false; + if (Canceled || DetectedArch == Misc.OSArchitecture.Unknown) return false; Failed = !await CopyUSMT(); if (Canceled || Failed) return false; Logger.UpdateProgress(0); @@ -274,12 +274,12 @@ private static Task DownloadUSMTFromWeb() Directory.CreateDirectory(USMTPath); } string dlPath = Path.Combine(USMTPath, "USMT.zip"); - if (DetectedArch == "64-bit") + if (DetectedArch == Misc.OSArchitecture.X64) { success = await new Download("https://github.com/belowaverage-org/SuperGrate/raw/master/USMT/x64.zip", dlPath).Start(); if (!success) throw new Exception("Download failure."); } - else if (DetectedArch == "32-bit") + else if (DetectedArch == Misc.OSArchitecture.X86) { success = await new Download("https://github.com/belowaverage-org/SuperGrate/raw/master/USMT/x86.zip", dlPath).Start(); if (!success) throw new Exception("Download failure.");