Fixed 5th fan channel for IT87 chips. Added ADL status code to report.
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.SMBIOS {
45 public class SMBIOSGroup : IGroup {
47 private Structure[] table;
49 private BIOSInformation biosInformation = null;
51 private BaseBoardInformation baseBoardInformation = null;
53 public SMBIOSGroup() {
54 int p = (int)System.Environment.OSVersion.Platform;
55 if ((p == 4) || (p == 128))
58 ManagementObjectCollection collection = new ManagementObjectSearcher(
59 "root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
62 foreach (ManagementObject mo in collection) {
63 raw = (byte[])mo["SMBiosData"];
67 List<Structure> structureList = new List<Structure>();
68 if (raw != null && raw.Length > 0) {
70 byte type = raw[offset];
71 while (offset < raw.Length && type != 127) {
73 type = raw[offset]; offset++;
74 int length = raw[offset]; offset++;
75 ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]);
78 byte[] data = new byte[length];
79 Array.Copy(raw, offset - 4, data, 0, length); offset += length - 4;
81 List<string> stringsList = new List<string>();
84 while (raw[offset] != 0) {
85 StringBuilder sb = new StringBuilder();
86 while (raw[offset] != 0) {
87 sb.Append((char)raw[offset]); offset++;
90 stringsList.Add(sb.ToString());
95 this.biosInformation = new BIOSInformation(
96 type, handle, data, stringsList.ToArray());
97 structureList.Add(this.biosInformation); break;
98 case 0x02: this.baseBoardInformation = new BaseBoardInformation(
99 type, handle, data, stringsList.ToArray());
100 structureList.Add(this.baseBoardInformation); break;
101 default: structureList.Add(new Structure(
102 type, handle, data, stringsList.ToArray())); break;
106 table = structureList.ToArray();
109 public IHardware[] Hardware { get { return new IHardware[0]; } }
111 public string GetReport() {
112 StringBuilder r = new StringBuilder();
114 r.AppendLine("SMBIOS");
117 if (biosInformation != null) {
118 r.Append("BIOS Vendor: "); r.AppendLine(biosInformation.Vendor);
119 r.Append("BIOS Version: "); r.AppendLine(biosInformation.Version);
123 if (baseBoardInformation != null) {
124 r.Append("Mainboard Manufacturer: ");
125 r.AppendLine(baseBoardInformation.Manufacturer);
126 r.Append("Mainboard Name: ");
127 r.AppendLine(baseBoardInformation.ProductName);
134 public void Close() { }
136 public class Structure {
138 private ushort handle;
141 private string[] strings;
143 public Structure(byte type, ushort handle, byte[] data, string[] strings)
146 this.handle = handle;
148 this.strings = strings;
151 public byte Type { get { return type; } }
153 public ushort Handle { get { return handle; } }
156 public class BIOSInformation : Structure {
158 private string vendor = "";
159 private string version = "";
161 public BIOSInformation(byte type, ushort handle, byte[] data,
163 : base(type, handle, data, strings) {
165 if (data[0x04] > 0 && data[0x04] <= strings.Length)
166 vendor = strings[data[0x04] - 1];
168 if (data[0x05] > 0 && data[0x05] <= strings.Length)
169 version = strings[data[0x05] - 1];
172 public string Vendor { get { return vendor; } }
174 public string Version { get { return version; } }
177 public class BaseBoardInformation : Structure {
179 private string manufacturer = "";
180 private string productName = "";
182 public BaseBoardInformation(byte type, ushort handle, byte[] data,
184 : base(type, handle, data, strings) {
186 if (data[0x04] > 0 && data[0x04] <= strings.Length)
187 manufacturer = strings[data[0x04] - 1];
189 if (data[0x05] > 0 && data[0x05] <= strings.Length)
190 productName = strings[data[0x05] - 1];
193 public string Manufacturer { get { return manufacturer; } }
195 public string ProductName { get { return productName; } }