From 4d6a755c115b8dc497166088f2fe6db6206f6323 Mon Sep 17 00:00:00 2001 From: Tianqian Zhu Date: Sat, 20 Apr 2024 01:46:30 +0800 Subject: [PATCH] Fix memory size calculation with extended size (#1315) According to the specification v.3.3.0, Chapter 7.18, Table 74, the Size row: > If the size is 32 GB-1 MB or greater, the > field value is 7FFFh and the actual size is stored in > the Extended Size field. Therefore the Extended Size should replace the value of Size if the latter equals 0x7FFF. The Extended Size should not be added to Size. Also, since Extended Size is DWORD, Size should not be ushort. --- LibreHardwareMonitorLib/Hardware/SMBios.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/LibreHardwareMonitorLib/Hardware/SMBios.cs b/LibreHardwareMonitorLib/Hardware/SMBios.cs index 9571668..71a7a0a 100644 --- a/LibreHardwareMonitorLib/Hardware/SMBios.cs +++ b/LibreHardwareMonitorLib/Hardware/SMBios.cs @@ -1094,10 +1094,9 @@ public class MemoryDevice : InformationBase ConfiguredSpeed = GetWord(0x20); ConfiguredVoltage = GetWord(0x26); Size = GetWord(0x0C); + if (Size == 0x7FFF) + Size = GetDword(0x1C); Type = (MemoryType)GetByte(0x12); - - if (GetWord(0x1C) > 0) - Size += GetWord(0x1C); } /// @@ -1126,9 +1125,11 @@ public class MemoryDevice : InformationBase public string SerialNumber { get; } /// - /// Gets the size of the memory device. If the value is 0, no memory device is installed in the socket. + /// Gets the size of the memory device. + /// If the value is 0, no memory device is installed in the socket. + /// If the value is 0xFFFF, the size is unknown. /// - public ushort Size { get; } + public uint Size { get; } /// /// Gets the value that identifies the maximum capable speed of the device, in mega transfers per second (MT/s).