Added basic support for ITE IT8712F super I/O chips.
3 Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 The contents of this file are subject to the Mozilla Public License Version
6 1.1 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 for the specific language governing rights and limitations under the License.
15 The Original Code is the Open Hardware Monitor code.
17 The Initial Developer of the Original Code is
18 Michael Möller <m.moeller@gmx.ch>.
19 Portions created by the Initial Developer are Copyright (C) 2009-2010
20 the Initial Developer. All Rights Reserved.
24 Alternatively, the contents of this file may be used under the terms of
25 either the GNU General Public License Version 2 or later (the "GPL"), or
26 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 in which case the provisions of the GPL or the LGPL are applicable instead
28 of those above. If you wish to allow use of your version of this file only
29 under the terms of either the GPL or the LGPL, and not to allow others to
30 use your version of this file under the terms of the MPL, indicate your
31 decision by deleting the provisions above and replace them with the notice
32 and other provisions required by the GPL or the LGPL. If you do not delete
33 the provisions above, a recipient may use your version of this file under
34 the terms of any one of the MPL, the GPL or the LGPL.
39 using System.Collections.Generic;
40 using System.Management;
43 namespace OpenHardwareMonitor.Hardware.Mainboard {
47 private Structure[] table;
49 private BIOSInformation biosInformation = null;
50 private BaseBoardInformation baseBoardInformation = null;
53 int p = (int)System.Environment.OSVersion.Platform;
54 if ((p == 4) || (p == 128))
57 List<Structure> structureList = new List<Structure>();
61 ManagementObjectCollection collection = new ManagementObjectSearcher(
62 "root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
64 foreach (ManagementObject mo in collection) {
65 raw = (byte[])mo["SMBiosData"];
68 } catch (NotImplementedException) { } catch (ManagementException) { }
70 if (raw != null && raw.Length > 0) {
72 byte type = raw[offset];
73 while (offset + 4 < raw.Length && type != 127) {
76 int length = raw[offset + 1];
77 ushort handle = (ushort)((raw[offset + 2] << 8) | raw[offset + 3]);
79 if (offset + length > raw.Length)
81 byte[] data = new byte[length];
82 Array.Copy(raw, offset, data, 0, length);
85 List<string> stringsList = new List<string>();
86 if (offset < raw.Length && raw[offset] == 0)
89 while (offset < raw.Length && raw[offset] != 0) {
90 StringBuilder sb = new StringBuilder();
91 while (offset < raw.Length && raw[offset] != 0) {
92 sb.Append((char)raw[offset]); offset++;
95 stringsList.Add(sb.ToString());
100 this.biosInformation = new BIOSInformation(
101 type, handle, data, stringsList.ToArray());
102 structureList.Add(this.biosInformation); break;
103 case 0x02: this.baseBoardInformation = new BaseBoardInformation(
104 type, handle, data, stringsList.ToArray());
105 structureList.Add(this.baseBoardInformation); break;
106 default: structureList.Add(new Structure(
107 type, handle, data, stringsList.ToArray())); break;
112 table = structureList.ToArray();
115 public string GetReport() {
116 StringBuilder r = new StringBuilder();
118 if (biosInformation != null) {
119 r.Append("BIOS Vendor: "); r.AppendLine(biosInformation.Vendor);
120 r.Append("BIOS Version: "); r.AppendLine(biosInformation.Version);
124 if (baseBoardInformation != null) {
125 r.Append("Mainboard Manufacturer: ");
126 r.AppendLine(baseBoardInformation.ManufacturerName);
127 r.Append("Mainboard Name: ");
128 r.AppendLine(baseBoardInformation.ProductName);
135 public BIOSInformation BIOS {
136 get { return biosInformation; }
139 public BaseBoardInformation Board {
140 get { return baseBoardInformation; }
143 public class Structure {
145 private ushort handle;
148 private string[] strings;
150 protected string GetString(int offset) {
151 if (offset < data.Length && data[offset] > 0 &&
152 data[offset] <= strings.Length)
153 return strings[data[offset] - 1];
158 public Structure(byte type, ushort handle, byte[] data, string[] strings)
161 this.handle = handle;
163 this.strings = strings;
166 public byte Type { get { return type; } }
168 public ushort Handle { get { return handle; } }
171 public class BIOSInformation : Structure {
173 private string vendor;
174 private string version;
176 public BIOSInformation(byte type, ushort handle, byte[] data,
178 : base(type, handle, data, strings) {
180 this.vendor = GetString(0x04);
181 this.version = GetString(0x05);
184 public string Vendor { get { return vendor; } }
186 public string Version { get { return version; } }
189 public class BaseBoardInformation : Structure {
191 private string manufacturerName;
192 private string productName;
193 private string version;
194 private string serialNumber;
195 private Manufacturer manufacturer;
197 public BaseBoardInformation(byte type, ushort handle, byte[] data,
199 : base(type, handle, data, strings) {
201 this.manufacturerName = GetString(0x04).Trim();
202 this.productName = GetString(0x05).Trim();
203 this.version = GetString(0x06).Trim();
204 this.serialNumber = GetString(0x07).Trim();
206 switch (manufacturerName) {
207 case "ASUSTeK Computer INC.":
208 manufacturer = Manufacturer.ASUS; break;
211 manufacturer = Manufacturer.DFI; break;
212 case "EPoX COMPUTER CO., LTD":
213 manufacturer = Manufacturer.EPoX; break;
214 case "Gigabyte Technology Co., Ltd.":
215 manufacturer = Manufacturer.Gigabyte; break;
217 manufacturer = Manufacturer.IBM; break;
218 case "MICRO-STAR INTERNATIONAL CO., LTD":
219 case "MICRO-STAR INTERNATIONAL CO.,LTD":
220 manufacturer = Manufacturer.MSI; break;
222 manufacturer = Manufacturer.Unkown; break;
226 public string ManufacturerName { get { return manufacturerName; } }
228 public string ProductName { get { return productName; } }
230 public string Version { get { return version; } }
232 public string SerialNumber { get { return serialNumber; } }
234 public Manufacturer Manufacturer { get { return manufacturer; } }