Skip to content

Commit

Permalink
Display native and process architectures in DebugMessage
Browse files Browse the repository at this point in the history
This also gets rid of the Platform. Seems like it would always be Win32NT anyway.
  • Loading branch information
FailedShack committed Mar 22, 2021
1 parent 12b376e commit 2406004
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
6 changes: 5 additions & 1 deletion USBHelperLauncher/DebugMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Management;
Expand All @@ -15,6 +16,7 @@
using System.Threading.Tasks;
using USBHelperLauncher.Configuration;
using USBHelperLauncher.Utils;
using static USBHelperLauncher.Utils.WinUtil;

namespace USBHelperLauncher
{
Expand All @@ -37,6 +39,7 @@ public async Task<string> Build()
var hosts = Program.Hosts;
var locale = Program.Locale;
var av = new Dictionary<string, bool>();
IsWow64Process2(Process.GetCurrentProcess().Handle, out ImageFileMachine processMachine, out ImageFileMachine nativeMachine);
sb.Append('-', 13).Append(" USBHelperLauncher Debug Information ").Append('-', 13).AppendLine();
sb.AppendLine("Debug Time: " + now + " (UTC)");
sb.AppendLine("Session Length: " + (now - Program.SessionStart).ToString(@"hh\:mm\:ss"));
Expand All @@ -47,7 +50,8 @@ public async Task<string> Build()
sb.AppendLine("Helper Version: " + Program.HelperVersion);
sb.AppendLine(".NET Framework Version: " + Get45or451FromRegistry());
sb.AppendFormat("Operating System: {0} ({1}-bit)", info.OSFullName, Environment.Is64BitOperatingSystem ? 64 : 32).AppendLine();
sb.AppendLine("Platform: " + info.OSPlatform);
sb.AppendFormat("Native Architecture: {0}", Enum.GetName(typeof(ImageFileMachine), nativeMachine)).AppendLine();
sb.AppendFormat("Process Architecture: {0}", Enum.GetName(typeof(ImageFileMachine), processMachine)).AppendLine();
sb.AppendLine("Used Locale: " + locale.ChosenLocale);
sb.AppendLine("System Language: " + CultureInfo.CurrentUICulture.Name);
sb.AppendLine("Total Memory: " + info.TotalPhysicalMemory);
Expand Down
44 changes: 44 additions & 0 deletions USBHelperLauncher/Utils/WinUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,49 @@ public static void Delete(string keyContainer)
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}

// source: winnt.h
public enum ImageFileMachine
{
Unknown = 0,
I860 = 0x014D,
I386 = 0x014C,
R3000 = 0x0162,
R4000 = 0x0166,
R10000 = 0x0168,
WCEMIPSV2 = 0x0169,
ALPHA = 0x0184,
SH3 = 0x01A2,
SH3DSP = 0x01A3,
SH3E = 0x01A4,
SH4 = 0x01A6,
SH5 = 0x01A8,
ARM = 0x01C0,
THUMB = 0x01C2,
ARMNT = 0x01C4,
AM33 = 0x01D3,
POWERPC = 0x01F0,
POWERPCFP = 0x01F1,
IA64 = 0x0200,
MIPS16 = 0x0266,
ALPHA64 = 0x0284,
MIPSFPU = 0x0366,
MIPSFPU16 = 0x0466,
AXP64 = 0x0284,
TRICORE = 0x0520,
INFINEON = 0x0520,
CEF = 0x0CEF,
EBC = 0x0EBC,
AMD64 = 0x8664,
M32R = 0x9041,
AA64 = 0xAA64
}

[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool IsWow64Process2(
IntPtr process,
out ImageFileMachine processMachine,
out ImageFileMachine nativeMachine
);
}
}

0 comments on commit 2406004

Please sign in to comment.