diff --git a/LibreHardwareMonitorLib/Hardware/SMBios.cs b/LibreHardwareMonitorLib/Hardware/SMBios.cs index 05dbb76..46da568 100644 --- a/LibreHardwareMonitorLib/Hardware/SMBios.cs +++ b/LibreHardwareMonitorLib/Hardware/SMBios.cs @@ -484,8 +484,8 @@ namespace LibreHardwareMonitor.Hardware /// Gets the byte. /// /// The offset. - /// . - protected int GetByte(int offset) + /// . + protected byte GetByte(int offset) { if (offset < _data.Length && offset >= 0) return _data[offset]; @@ -497,11 +497,43 @@ namespace LibreHardwareMonitor.Hardware /// Gets the word. /// /// The offset. - /// . - protected int GetWord(int offset) + /// . + protected ushort GetWord(int offset) { if (offset + 1 < _data.Length && offset >= 0) - return (_data[offset + 1] << 8) | _data[offset]; + { + return BitConverter.ToUInt16(_data, offset); + } + + return 0; + } + + /// + /// Gets the dword. + /// + /// The offset. + /// . + protected uint GetDword(int offset) + { + if (offset + 3 < _data.Length && offset >= 0) + { + return BitConverter.ToUInt32(_data, offset); + } + + return 0; + } + + /// + /// Gets the qword. + /// + /// The offset. + /// . + protected ulong GetQword(int offset) + { + if (offset + 7 < _data.Length && offset >= 0) + { + return BitConverter.ToUInt64(_data, offset); + } return 0; } @@ -568,7 +600,7 @@ namespace LibreHardwareMonitor.Hardware private ulong? GetSize() { int biosRomSize = GetByte(0x09); - int extendedBiosRomSize = GetWord(0x18); + ushort extendedBiosRomSize = GetWord(0x18); bool isExtendedBiosRomSize = biosRomSize == 0xFF && extendedBiosRomSize != 0; if (!isExtendedBiosRomSize) @@ -602,9 +634,7 @@ namespace LibreHardwareMonitor.Hardware { if (month > 12) { - int tmp = month; - month = day; - day = tmp; + (month, day) = (day, month); } return new DateTime(year < 100 ? 1900 + year : year, month, day); @@ -733,7 +763,7 @@ namespace LibreHardwareMonitor.Hardware /// /// Gets the number of power cords associated with the enclosure or chassis. /// - public int PowerCords { get; } + public byte PowerCords { get; } /// /// Gets the state of the enclosure’s power supply (or supplies) when last booted. @@ -744,7 +774,7 @@ namespace LibreHardwareMonitor.Hardware /// Gets the height of the enclosure, in 'U's. A U is a standard unit of measure for the height of a rack or rack-mountable component and is equal to 1.75 inches or 4.445 cm. A value of 0 /// indicates that the enclosure height is unspecified. /// - public int RackHeight { get; } + public byte RackHeight { get; } /// /// Gets the physical security status of the enclosure when last booted. @@ -831,6 +861,8 @@ namespace LibreHardwareMonitor.Hardware MaxSpeed = GetWord(0x14); CurrentSpeed = GetWord(0x16); Serial = GetString(0x20).Trim(); + Id = GetQword(0x08); + Handle = GetWord(0x02); ProcessorType = (ProcessorType)GetByte(0x05); Socket = (ProcessorSocket)GetByte(0x19); @@ -846,42 +878,53 @@ namespace LibreHardwareMonitor.Hardware /// /// Gets the value that represents the number of cores per processor socket. /// - public int CoreCount { get; } + public ushort CoreCount { get; } /// /// Gets the value that represents the number of enabled cores per processor socket. /// - public int CoreEnabled { get; } + public ushort CoreEnabled { get; } /// /// Gets the value that represents the current processor speed (in MHz). /// - public int CurrentSpeed { get; } + public ushort CurrentSpeed { get; } /// /// Gets the external Clock Frequency, in MHz. If the value is unknown, the field is set to 0. /// - public int ExternalClock { get; } + public ushort ExternalClock { get; } /// /// Gets /// public ProcessorFamily Family { get; } + /// + /// Gets the handle. + /// + /// The handle. + public ushort Handle { get; } + + /// + /// Gets the identifier. + /// + public ulong Id { get; } + /// /// Gets the L1 cache handle. /// - public int L1CacheHandle { get; } + public ushort L1CacheHandle { get; } /// /// Gets the L2 cache handle. /// - public int L2CacheHandle { get; } + public ushort L2CacheHandle { get; } /// /// Gets the L3 cache handle. /// - public int L3CacheHandle { get; } + public ushort L3CacheHandle { get; } /// /// Gets the string number of Processor Manufacturer. @@ -891,7 +934,7 @@ namespace LibreHardwareMonitor.Hardware /// /// Gets the value that represents the maximum processor speed (in MHz) supported by the system for this processor socket. /// - public int MaxSpeed { get; } + public ushort MaxSpeed { get; } /// /// Gets @@ -917,7 +960,7 @@ namespace LibreHardwareMonitor.Hardware /// /// Gets the value that represents the number of threads per processor socket. /// - public int ThreadCount { get; } + public ushort ThreadCount { get; } /// /// Gets the value that represents the string number describing the Processor. @@ -951,12 +994,12 @@ namespace LibreHardwareMonitor.Hardware /// /// Gets the handle. /// - public int Handle { get; } + public ushort Handle { get; } /// /// Gets the value that represents the installed cache size. /// - public int Size { get; } + public ushort Size { get; } /// /// Gets the cache designation. @@ -1027,12 +1070,12 @@ namespace LibreHardwareMonitor.Hardware /// /// Gets the size of the memory device. If the value is 0, no memory device is installed in the socket. /// - public int Size { get; } + public ushort Size { get; } /// /// Gets the value that identifies the maximum capable speed of the device, in mega transfers per second (MT/s). /// - public int Speed { get; } + public ushort Speed { get; } /// /// Gets the type of this memory device.