Fixed Issue 25.

This commit is contained in:
Michael Möller
2010-04-05 21:31:21 +00:00
parent 772fa1b94c
commit 1f2f9d6843
2 changed files with 49 additions and 37 deletions

View File

@@ -56,35 +56,39 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
List<Structure> structureList = new List<Structure>(); List<Structure> structureList = new List<Structure>();
byte[] raw = null;
try { try {
ManagementObjectCollection collection = new ManagementObjectSearcher( ManagementObjectCollection collection = new ManagementObjectSearcher(
"root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get(); "root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
byte[] raw = null;
foreach (ManagementObject mo in collection) { foreach (ManagementObject mo in collection) {
raw = (byte[])mo["SMBiosData"]; raw = (byte[])mo["SMBiosData"];
break; break;
} }
} catch (NotImplementedException) { } catch (ManagementException) { }
if (raw != null && raw.Length > 0) { if (raw != null && raw.Length > 0) {
int offset = 0; int offset = 0;
byte type = raw[offset]; byte type = raw[offset];
while (offset < raw.Length && type != 127) { while (offset + 4 < raw.Length && type != 127) {
type = raw[offset]; offset++; type = raw[offset];
int length = raw[offset]; offset++; int length = raw[offset + 1];
ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]); ushort handle = (ushort)((raw[offset + 2] << 8) | raw[offset + 3]);
offset += 2;
if (offset + length > raw.Length)
break;
byte[] data = new byte[length]; byte[] data = new byte[length];
Array.Copy(raw, offset - 4, data, 0, length); offset += length - 4; Array.Copy(raw, offset, data, 0, length);
offset += length;
List<string> stringsList = new List<string>(); List<string> stringsList = new List<string>();
if (raw[offset] == 0) if (offset < raw.Length && raw[offset] == 0)
offset++; offset++;
while (raw[offset] != 0) {
while (offset < raw.Length && raw[offset] != 0) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
while (raw[offset] != 0) { while (offset < raw.Length && raw[offset] != 0) {
sb.Append((char)raw[offset]); offset++; sb.Append((char)raw[offset]); offset++;
} }
offset++; offset++;
@@ -104,7 +108,6 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
} }
} }
} }
} catch (NotImplementedException) { } catch (ManagementException) { }
table = structureList.ToArray(); table = structureList.ToArray();
} }
@@ -187,6 +190,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
private string manufacturerName; private string manufacturerName;
private string productName; private string productName;
private string version;
private string serialNumber;
private Manufacturer manufacturer; private Manufacturer manufacturer;
public BaseBoardInformation(byte type, ushort handle, byte[] data, public BaseBoardInformation(byte type, ushort handle, byte[] data,
@@ -195,6 +200,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
this.manufacturerName = GetString(0x04).Trim(); this.manufacturerName = GetString(0x04).Trim();
this.productName = GetString(0x05).Trim(); this.productName = GetString(0x05).Trim();
this.version = GetString(0x06).Trim();
this.serialNumber = GetString(0x07).Trim();
switch (manufacturerName) { switch (manufacturerName) {
case "ASUSTeK Computer INC.": case "ASUSTeK Computer INC.":
@@ -220,7 +227,12 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
public string ProductName { get { return productName; } } public string ProductName { get { return productName; } }
public string Version { get { return version; } }
public string SerialNumber { get { return serialNumber; } }
public Manufacturer Manufacturer { get { return manufacturer; } } public Manufacturer Manufacturer { get { return manufacturer; } }
} }
} }
} }

View File

@@ -69,5 +69,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.28.0")] [assembly: AssemblyVersion("0.1.29.0")]
[assembly: AssemblyFileVersion("0.1.28.0")] [assembly: AssemblyFileVersion("0.1.29.0")]