aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Ui.Common/SystemInfo/WindowsSystemInfo.cs
diff options
context:
space:
mode:
authorIsaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com>2024-02-11 02:09:18 +0000
committerGitHub <noreply@github.com>2024-02-11 03:09:18 +0100
commitf06d22d6f01e657ebbc0c8ef082739cd468e47b5 (patch)
treec10a566438d3801b33c1d7b4eff73ea62b2f1a63 /src/Ryujinx.Ui.Common/SystemInfo/WindowsSystemInfo.cs
parent84d6e8d121a1b329d26cc0e462aadd1108d99a04 (diff)
Infra: Capitalisation Consistency (#6296)
* Rename Ryujinx.UI.Common * Rename Ryujinx.UI.LocaleGenerator * Update in Files AboutWindow * Configuration State * Rename projects * Ryujinx/UI * Fix build * Main remaining inconsistencies * HLE.UI Namespace * HLE.UI Files * Namespace * Ryujinx.UI.Common.Configuration.UI * Ryujinx.UI.Common,Configuration.UI Files * More instances
Diffstat (limited to 'src/Ryujinx.Ui.Common/SystemInfo/WindowsSystemInfo.cs')
-rw-r--r--src/Ryujinx.Ui.Common/SystemInfo/WindowsSystemInfo.cs87
1 files changed, 0 insertions, 87 deletions
diff --git a/src/Ryujinx.Ui.Common/SystemInfo/WindowsSystemInfo.cs b/src/Ryujinx.Ui.Common/SystemInfo/WindowsSystemInfo.cs
deleted file mode 100644
index 9bb0fbf7..00000000
--- a/src/Ryujinx.Ui.Common/SystemInfo/WindowsSystemInfo.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using Ryujinx.Common.Logging;
-using System;
-using System.Management;
-using System.Runtime.InteropServices;
-using System.Runtime.Versioning;
-
-namespace Ryujinx.Ui.Common.SystemInfo
-{
- [SupportedOSPlatform("windows")]
- partial class WindowsSystemInfo : SystemInfo
- {
- internal WindowsSystemInfo()
- {
- CpuName = $"{GetCpuidCpuName() ?? GetCpuNameWMI()} ; {LogicalCoreCount} logical"; // WMI is very slow
- (RamTotal, RamAvailable) = GetMemoryStats();
- }
-
- private static (ulong Total, ulong Available) GetMemoryStats()
- {
- MemoryStatusEx memStatus = new();
- if (GlobalMemoryStatusEx(ref memStatus))
- {
- return (memStatus.TotalPhys, memStatus.AvailPhys); // Bytes
- }
-
- Logger.Error?.Print(LogClass.Application, $"GlobalMemoryStatusEx failed. Error {Marshal.GetLastWin32Error():X}");
-
- return (0, 0);
- }
-
- private static string GetCpuNameWMI()
- {
- ManagementObjectCollection cpuObjs = GetWMIObjects("root\\CIMV2", "SELECT * FROM Win32_Processor");
-
- if (cpuObjs != null)
- {
- foreach (var cpuObj in cpuObjs)
- {
- return cpuObj["Name"].ToString().Trim();
- }
- }
-
- return Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER").Trim();
- }
-
- [StructLayout(LayoutKind.Sequential)]
- private struct MemoryStatusEx
- {
- public uint Length;
- public uint MemoryLoad;
- public ulong TotalPhys;
- public ulong AvailPhys;
- public ulong TotalPageFile;
- public ulong AvailPageFile;
- public ulong TotalVirtual;
- public ulong AvailVirtual;
- public ulong AvailExtendedVirtual;
-
- public MemoryStatusEx()
- {
- Length = (uint)Marshal.SizeOf<MemoryStatusEx>();
- }
- }
-
- [LibraryImport("kernel32.dll", SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static partial bool GlobalMemoryStatusEx(ref MemoryStatusEx lpBuffer);
-
- private static ManagementObjectCollection GetWMIObjects(string scope, string query)
- {
- try
- {
- return new ManagementObjectSearcher(scope, query).Get();
- }
- catch (PlatformNotSupportedException ex)
- {
- Logger.Error?.Print(LogClass.Application, $"WMI isn't available : {ex.Message}");
- }
- catch (COMException ex)
- {
- Logger.Error?.Print(LogClass.Application, $"WMI isn't available : {ex.Message}");
- }
-
- return null;
- }
- }
-}