Skip to content

Commit 7b4a32a

Browse files
committed
fixup! Add DIMM Temperature to LHM
1 parent b7dfcd6 commit 7b4a32a

9 files changed

Lines changed: 20 additions & 53 deletions

File tree

OpenHardwareMonitor/UI/MainForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public MainForm()
197197
}
198198
};
199199

200-
if (_startupManager.IsAdministrator())
200+
if (OperatingSystemHelper.IsAdministrator())
201201
{
202202
_readMainboardSensors = new UserOption("mainboardMenuItem", true, mainboardMenuItem, _settings);
203203
_readMainboardSensors.Changed += delegate { _computer.IsMotherboardEnabled = _readMainboardSensors.Value; };

OpenHardwareMonitor/UI/StartupManager.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@ public class StartupManager
1515
private bool _startup;
1616
private const string REGISTRY_RUN = @"Software\Microsoft\Windows\CurrentVersion\Run";
1717

18-
public bool IsAdministrator()
19-
{
20-
try
21-
{
22-
WindowsIdentity identity = WindowsIdentity.GetCurrent();
23-
WindowsPrincipal principal = new(identity);
24-
return principal.IsInRole(WindowsBuiltInRole.Administrator);
25-
}
26-
catch
27-
{
28-
return false;
29-
}
30-
}
31-
3218
public StartupManager()
3319
{
3420
if (OperatingSystemHelper.IsUnix)
@@ -38,7 +24,7 @@ public StartupManager()
3824
return;
3925
}
4026

41-
if (IsAdministrator())
27+
if (OperatingSystemHelper.IsAdministrator())
4228
{
4329
try
4430
{

OpenHardwareMonitorLib/Hardware/InpOut.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,9 @@ private static bool Extract(string filePath)
194194
if (stream != null)
195195
{
196196
using FileStream target = new(filePath, FileMode.Create);
197-
198-
stream.Position = 1; // Skip first byte.
199-
197+
//stream.Position = 1; // Skip first byte.
200198
using var gzipStream = new GZipStream(stream, CompressionMode.Decompress);
201-
202199
gzipStream.CopyTo(target);
203-
204200
requiredLength = target.Length;
205201
}
206202
}

OpenHardwareMonitorLib/Hardware/Memory/MemoryGroup.cs

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System.Collections.Generic;
2-
using System.Timers;
2+
using System.Threading.Tasks;
33
using RAMSPDToolkit.I2CSMBus;
44
using RAMSPDToolkit.SPD;
55
using RAMSPDToolkit.SPD.Enums;
@@ -13,19 +13,15 @@ internal class MemoryGroup : IGroup
1313
{
1414
//Retry 12x
1515
private const int RetryCount = 12;
16-
1716
//Retry every 2.5 seconds
18-
private const double RetryTime = 2500;
17+
private const int RetryTime = 2500;
1918
private static readonly object _lock = new();
2019

2120
private readonly List<Hardware> _hardware = [];
22-
private int _elapsedCounter;
23-
24-
private Timer _timer;
2521

2622
static MemoryGroup()
2723
{
28-
if (Ring0.IsOpen)
24+
if (OperatingSystemHelper.IsAdministrator() && Ring0.IsOpen)
2925
{
3026
//Assign implementation of IDriver
3127
DriverManager.Driver = new RAMSPDToolkitDriver(Ring0.KernelDriver);
@@ -38,30 +34,23 @@ public MemoryGroup(ISettings settings)
3834
_hardware.Add(new TotalMemory(settings));
3935
_hardware.Add(new VirtualMemory(settings));
4036

41-
//No RAM detected
42-
if (!DetectThermalSensors(out List<SPDAccessor> accessors))
37+
if (OperatingSystemHelper.IsAdministrator())
4338
{
44-
//Retry a couple of times
45-
//SMBus might not be detected right after boot
46-
_timer = new Timer(RetryTime);
47-
48-
_timer.Elapsed += (_, _) =>
39+
Task.Run(async () =>
4940
{
50-
if (_elapsedCounter++ >= RetryCount || DetectThermalSensors(out accessors))
41+
var _elapsedCounter = 0;
42+
while (true)
5143
{
52-
_timer.Stop();
53-
_timer = null;
54-
55-
if (accessors != null)
56-
AddDimms(accessors, settings);
44+
//SMBus might not be detected right after boot
45+
if (DetectThermalSensors(out var accessors) || _elapsedCounter++ >= RetryCount)
46+
{
47+
if (accessors != null)
48+
AddDimms(accessors, settings);
49+
break;
50+
}
51+
await Task.Delay(RetryTime);
5752
}
58-
};
59-
60-
_timer.Start();
61-
}
62-
else
63-
{
64-
AddDimms(accessors, settings);
53+
});
6554
}
6655
}
6756

OpenHardwareMonitorLib/Hardware/Ring0.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,9 @@ private static bool Extract(string filePath)
104104
if (stream != null)
105105
{
106106
using FileStream target = new(filePath, FileMode.Create);
107-
108-
stream.Position = 1; // Skip first byte.
109-
107+
//stream.Position = 1; // Skip first byte.
110108
using var gzipStream = new GZipStream(stream, CompressionMode.Decompress);
111-
112109
gzipStream.CopyTo(target);
113-
114110
requiredLength = target.Length;
115111
}
116112
}
-1 Bytes
Binary file not shown.
-1 Bytes
Binary file not shown.
-3.04 KB
Binary file not shown.
-2.73 KB
Binary file not shown.

0 commit comments

Comments
 (0)