diff --git a/LibreHardwareMonitorLib/Hardware/Battery/BatteryGroup.cs b/LibreHardwareMonitorLib/Hardware/Battery/BatteryGroup.cs index 45fa4fb..e29f8d0 100644 --- a/LibreHardwareMonitorLib/Hardware/Battery/BatteryGroup.cs +++ b/LibreHardwareMonitorLib/Hardware/Battery/BatteryGroup.cs @@ -28,6 +28,7 @@ internal class BatteryGroup : IGroup if (Software.OperatingSystem.IsUnix) return; +#if WINDOWS SetupDiDestroyDeviceInfoListSafeHandle hdev = PInvoke.SetupDiGetClassDevs(PInvoke.GUID_DEVICE_BATTERY, null, HWND.Null, @@ -129,11 +130,13 @@ internal class BatteryGroup : IGroup hdev.Dispose(); } +#endif } /// public IReadOnlyList Hardware => _hardware; +#if WINDOWS private static unsafe bool QueryStringFromBatteryInfo(SafeFileHandle battery, BATTERY_QUERY_INFORMATION bqi, out string value) { value = null; @@ -161,6 +164,7 @@ internal class BatteryGroup : IGroup return result; } +#endif /// public void Close() diff --git a/LibreHardwareMonitorLib/Hardware/Computer.cs b/LibreHardwareMonitorLib/Hardware/Computer.cs index bb87340..7a23d01 100644 --- a/LibreHardwareMonitorLib/Hardware/Computer.cs +++ b/LibreHardwareMonitorLib/Hardware/Computer.cs @@ -512,7 +512,9 @@ public class Computer : IComputer _smbios = new SMBios(); - Mutexes.Open(); + if (Software.OperatingSystem.IsWindows8OrGreater) + Mutexes.Open(); + OpCode.Open(); AddGroups(); diff --git a/LibreHardwareMonitorLib/Hardware/Cpu/IntelCpu.cs b/LibreHardwareMonitorLib/Hardware/Cpu/IntelCpu.cs index 1f32d1d..d7e13db 100644 --- a/LibreHardwareMonitorLib/Hardware/Cpu/IntelCpu.cs +++ b/LibreHardwareMonitorLib/Hardware/Cpu/IntelCpu.cs @@ -38,6 +38,9 @@ internal sealed class IntelCpu : GenericCpu public IntelCpu(int processorIndex, CpuId[][] cpuId, ISettings settings) : base(processorIndex, cpuId, settings) { + if (Software.OperatingSystem.IsUnix) + return; + _pawnModule = new IntelMsr(); uint eax; @@ -569,7 +572,7 @@ internal sealed class IntelCpu : GenericCpu float coreAvg = 0; uint eax; - for (int i = 0; i < _coreTemperatures.Length; i++) + for (int i = 0; i < _coreTemperatures?.Length; i++) { // if reading is valid if (_pawnModule.ReadMsr(IA32_THERM_STATUS_MSR, out eax, out _, _cpuId[i][0].Affinity) && (eax & 0x80000000) != 0) @@ -704,7 +707,7 @@ internal sealed class IntelCpu : GenericCpu _coreVoltage.Value = ((edx >> 32) & 0xFFFF) / (float)(1 << 13); } - for (int i = 0; i < _coreVIDs.Length; i++) + for (int i = 0; i < _coreVIDs?.Length; i++) { if (_pawnModule.ReadMsr(IA32_PERF_STATUS, out _, out edx, _cpuId[i][0].Affinity) && ((edx >> 32) & 0xFFFF) > 0) { diff --git a/LibreHardwareMonitorLib/Interop/PowerMonitor/Stm32PortFinder.cs b/LibreHardwareMonitorLib/Interop/PowerMonitor/Stm32PortFinder.cs index 715322a..eefef65 100644 --- a/LibreHardwareMonitorLib/Interop/PowerMonitor/Stm32PortFinder.cs +++ b/LibreHardwareMonitorLib/Interop/PowerMonitor/Stm32PortFinder.cs @@ -51,6 +51,7 @@ public static class Stm32PortFinder { var result = new List(); +#if WINDOWS //Setup SetupDiDestroyDeviceInfoListSafeHandle devInfo = PInvoke.SetupDiGetClassDevs(PInvoke.GUID_DEVCLASS_PORTS, null, HWND.Null, SETUP_DI_GET_CLASS_DEVS_FLAGS.DIGCF_PRESENT); @@ -102,8 +103,6 @@ public static class Stm32PortFinder devInfo.Dispose(); } - return result; - static string GetProperty(SafeHandle hDevInfo, SETUP_DI_REGISTRY_PROPERTY property, SP_DEVINFO_DATA devInfoData) { byte[] buffer = new byte[BufferSize]; @@ -116,6 +115,9 @@ public static class Stm32PortFinder return null; } +#endif + + return result; } private static string NormalizeString(string str) diff --git a/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj b/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj index 7fddd1c..2dab64c 100644 --- a/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj +++ b/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj @@ -2,7 +2,7 @@ net472;netstandard2.0;net8.0;net9.0;net10.0 x64;x86;ARM64 - win-x64;win-x86;win-arm64 + win-x64;win-x86;win-arm64;linux-x64;linux-arm64 LibreHardwareMonitorLib LibreHardwareMonitor true @@ -38,6 +38,14 @@ ..\bin\Release\$(Platform)\ + + $(DefineConstants);WINDOWS + + + + $(DefineConstants);LINUX + +