Fixed Issue 25.
1.1 --- a/Hardware/Mainboard/SMBIOS.cs Mon Apr 05 15:51:40 2010 +0000
1.2 +++ b/Hardware/Mainboard/SMBIOS.cs Mon Apr 05 21:31:21 2010 +0000
1.3 @@ -56,56 +56,59 @@
1.4
1.5 List<Structure> structureList = new List<Structure>();
1.6
1.7 + byte[] raw = null;
1.8 try {
1.9 ManagementObjectCollection collection = new ManagementObjectSearcher(
1.10 "root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
1.11 -
1.12 - byte[] raw = null;
1.13 +
1.14 foreach (ManagementObject mo in collection) {
1.15 raw = (byte[])mo["SMBiosData"];
1.16 break;
1.17 }
1.18 + } catch (NotImplementedException) { } catch (ManagementException) { }
1.19
1.20 - if (raw != null && raw.Length > 0) {
1.21 - int offset = 0;
1.22 - byte type = raw[offset];
1.23 - while (offset < raw.Length && type != 127) {
1.24 + if (raw != null && raw.Length > 0) {
1.25 + int offset = 0;
1.26 + byte type = raw[offset];
1.27 + while (offset + 4 < raw.Length && type != 127) {
1.28
1.29 - type = raw[offset]; offset++;
1.30 - int length = raw[offset]; offset++;
1.31 - ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]);
1.32 - offset += 2;
1.33 + type = raw[offset];
1.34 + int length = raw[offset + 1];
1.35 + ushort handle = (ushort)((raw[offset + 2] << 8) | raw[offset + 3]);
1.36
1.37 - byte[] data = new byte[length];
1.38 - Array.Copy(raw, offset - 4, data, 0, length); offset += length - 4;
1.39 + if (offset + length > raw.Length)
1.40 + break;
1.41 + byte[] data = new byte[length];
1.42 + Array.Copy(raw, offset, data, 0, length);
1.43 + offset += length;
1.44
1.45 - List<string> stringsList = new List<string>();
1.46 - if (raw[offset] == 0)
1.47 - offset++;
1.48 - while (raw[offset] != 0) {
1.49 - StringBuilder sb = new StringBuilder();
1.50 - while (raw[offset] != 0) {
1.51 - sb.Append((char)raw[offset]); offset++;
1.52 - }
1.53 - offset++;
1.54 - stringsList.Add(sb.ToString());
1.55 + List<string> stringsList = new List<string>();
1.56 + if (offset < raw.Length && raw[offset] == 0)
1.57 + offset++;
1.58 +
1.59 + while (offset < raw.Length && raw[offset] != 0) {
1.60 + StringBuilder sb = new StringBuilder();
1.61 + while (offset < raw.Length && raw[offset] != 0) {
1.62 + sb.Append((char)raw[offset]); offset++;
1.63 }
1.64 offset++;
1.65 - switch (type) {
1.66 - case 0x00:
1.67 - this.biosInformation = new BIOSInformation(
1.68 - type, handle, data, stringsList.ToArray());
1.69 - structureList.Add(this.biosInformation); break;
1.70 - case 0x02: this.baseBoardInformation = new BaseBoardInformation(
1.71 - type, handle, data, stringsList.ToArray());
1.72 - structureList.Add(this.baseBoardInformation); break;
1.73 - default: structureList.Add(new Structure(
1.74 - type, handle, data, stringsList.ToArray())); break;
1.75 - }
1.76 + stringsList.Add(sb.ToString());
1.77 + }
1.78 + offset++;
1.79 + switch (type) {
1.80 + case 0x00:
1.81 + this.biosInformation = new BIOSInformation(
1.82 + type, handle, data, stringsList.ToArray());
1.83 + structureList.Add(this.biosInformation); break;
1.84 + case 0x02: this.baseBoardInformation = new BaseBoardInformation(
1.85 + type, handle, data, stringsList.ToArray());
1.86 + structureList.Add(this.baseBoardInformation); break;
1.87 + default: structureList.Add(new Structure(
1.88 + type, handle, data, stringsList.ToArray())); break;
1.89 }
1.90 }
1.91 - } catch (NotImplementedException) { } catch (ManagementException) { }
1.92 -
1.93 + }
1.94 +
1.95 table = structureList.ToArray();
1.96 }
1.97
1.98 @@ -187,6 +190,8 @@
1.99
1.100 private string manufacturerName;
1.101 private string productName;
1.102 + private string version;
1.103 + private string serialNumber;
1.104 private Manufacturer manufacturer;
1.105
1.106 public BaseBoardInformation(byte type, ushort handle, byte[] data,
1.107 @@ -195,6 +200,8 @@
1.108
1.109 this.manufacturerName = GetString(0x04).Trim();
1.110 this.productName = GetString(0x05).Trim();
1.111 + this.version = GetString(0x06).Trim();
1.112 + this.serialNumber = GetString(0x07).Trim();
1.113
1.114 switch (manufacturerName) {
1.115 case "ASUSTeK Computer INC.":
1.116 @@ -220,7 +227,12 @@
1.117
1.118 public string ProductName { get { return productName; } }
1.119
1.120 + public string Version { get { return version; } }
1.121 +
1.122 + public string SerialNumber { get { return serialNumber; } }
1.123 +
1.124 public Manufacturer Manufacturer { get { return manufacturer; } }
1.125 +
1.126 }
1.127 }
1.128 }
2.1 --- a/Properties/AssemblyInfo.cs Mon Apr 05 15:51:40 2010 +0000
2.2 +++ b/Properties/AssemblyInfo.cs Mon Apr 05 21:31:21 2010 +0000
2.3 @@ -69,5 +69,5 @@
2.4 // You can specify all the values or you can default the Build and Revision Numbers
2.5 // by using the '*' as shown below:
2.6 // [assembly: AssemblyVersion("1.0.*")]
2.7 -[assembly: AssemblyVersion("0.1.28.0")]
2.8 -[assembly: AssemblyFileVersion("0.1.28.0")]
2.9 +[assembly: AssemblyVersion("0.1.29.0")]
2.10 +[assembly: AssemblyFileVersion("0.1.29.0")]