Added a RAM hardware and sensor, fixed Issue 115.
1.1 --- a/GUI/HardwareTypeImage.cs Sun Jul 22 18:07:11 2012 +0000
1.2 +++ b/GUI/HardwareTypeImage.cs Mon Jul 23 21:54:35 2012 +0000
1.3 @@ -56,6 +56,9 @@
1.4 case HardwareType.TBalancer:
1.5 image = Utilities.EmbeddedResources.GetImage("bigng.png");
1.6 break;
1.7 + case HardwareType.RAM:
1.8 + image = Utilities.EmbeddedResources.GetImage("chip.png");
1.9 + break;
1.10 default:
1.11 image = new Bitmap(1, 1);
1.12 break;
2.1 --- a/GUI/MainForm.Designer.cs Sun Jul 22 18:07:11 2012 +0000
2.2 +++ b/GUI/MainForm.Designer.cs Mon Jul 23 21:54:35 2012 +0000
2.3 @@ -94,6 +94,7 @@
2.4 this.timer = new System.Windows.Forms.Timer(this.components);
2.5 this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv();
2.6 this.treeView = new Aga.Controls.Tree.TreeViewAdv();
2.7 + this.ramMenuItem = new System.Windows.Forms.MenuItem();
2.8 this.splitContainer.Panel1.SuspendLayout();
2.9 this.splitContainer.SuspendLayout();
2.10 this.SuspendLayout();
2.11 @@ -227,6 +228,7 @@
2.12 this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
2.13 this.mainboardMenuItem,
2.14 this.cpuMenuItem,
2.15 + this.ramMenuItem,
2.16 this.gpuMenuItem,
2.17 this.fanControllerMenuItem,
2.18 this.hddMenuItem});
2.19 @@ -244,17 +246,17 @@
2.20 //
2.21 // gpuMenuItem
2.22 //
2.23 - this.gpuMenuItem.Index = 2;
2.24 + this.gpuMenuItem.Index = 3;
2.25 this.gpuMenuItem.Text = "GPU";
2.26 //
2.27 // fanControllerMenuItem
2.28 //
2.29 - this.fanControllerMenuItem.Index = 3;
2.30 + this.fanControllerMenuItem.Index = 4;
2.31 this.fanControllerMenuItem.Text = "Fan Controllers";
2.32 //
2.33 // hddMenuItem
2.34 //
2.35 - this.hddMenuItem.Index = 4;
2.36 + this.hddMenuItem.Index = 5;
2.37 this.hddMenuItem.Text = "Hard Disk Drives";
2.38 //
2.39 // menuItem6
2.40 @@ -525,6 +527,11 @@
2.41 this.treeView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseMove);
2.42 this.treeView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseUp);
2.43 //
2.44 + // ramMenuItem
2.45 + //
2.46 + this.ramMenuItem.Index = 2;
2.47 + this.ramMenuItem.Text = "RAM";
2.48 + //
2.49 // MainForm
2.50 //
2.51 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
2.52 @@ -607,6 +614,7 @@
2.53 private System.Windows.Forms.MenuItem cpuMenuItem;
2.54 private System.Windows.Forms.MenuItem gpuMenuItem;
2.55 private System.Windows.Forms.MenuItem fanControllerMenuItem;
2.56 + private System.Windows.Forms.MenuItem ramMenuItem;
2.57 }
2.58 }
2.59
3.1 --- a/GUI/MainForm.cs Sun Jul 22 18:07:11 2012 +0000
3.2 +++ b/GUI/MainForm.cs Mon Jul 23 21:54:35 2012 +0000
3.3 @@ -54,6 +54,7 @@
3.4
3.5 private UserOption readMainboardSensors;
3.6 private UserOption readCpuSensors;
3.7 + private UserOption readRamSensors;
3.8 private UserOption readGpuSensors;
3.9 private UserOption readFanControllersSensors;
3.10 private UserOption readHddSensors;
3.11 @@ -226,6 +227,12 @@
3.12 computer.CPUEnabled = readCpuSensors.Value;
3.13 };
3.14
3.15 + readRamSensors = new UserOption("ramMenuItem", true,
3.16 + ramMenuItem, settings);
3.17 + readRamSensors.Changed += delegate(object sender, EventArgs e) {
3.18 + computer.RAMEnabled = readRamSensors.Value;
3.19 + };
3.20 +
3.21 readGpuSensors = new UserOption("gpuMenuItem", true,
3.22 gpuMenuItem, settings);
3.23 readGpuSensors.Changed += delegate(object sender, EventArgs e) {
4.1 --- a/Hardware/Computer.cs Sun Jul 22 18:07:11 2012 +0000
4.2 +++ b/Hardware/Computer.cs Mon Jul 23 21:54:35 2012 +0000
4.3 @@ -22,13 +22,16 @@
4.4 private readonly List<IGroup> groups = new List<IGroup>();
4.5 private readonly ISettings settings;
4.6
4.7 + private SMBIOS smbios;
4.8 +
4.9 private bool open;
4.10
4.11 private bool mainboardEnabled;
4.12 private bool cpuEnabled;
4.13 + private bool ramEnabled;
4.14 private bool gpuEnabled;
4.15 private bool fanControllerEnabled;
4.16 - private bool hddEnabled;
4.17 + private bool hddEnabled;
4.18
4.19 public Computer() {
4.20 this.settings = new Settings();
4.21 @@ -76,15 +79,20 @@
4.22 if (open)
4.23 return;
4.24
4.25 + this.smbios = new SMBIOS();
4.26 +
4.27 Ring0.Open();
4.28 Opcode.Open();
4.29
4.30 if (mainboardEnabled)
4.31 - Add(new Mainboard.MainboardGroup(settings));
4.32 + Add(new Mainboard.MainboardGroup(smbios, settings));
4.33
4.34 if (cpuEnabled)
4.35 Add(new CPU.CPUGroup(settings));
4.36
4.37 + if (ramEnabled)
4.38 + Add(new RAM.RAMGroup(smbios, settings));
4.39 +
4.40 if (gpuEnabled) {
4.41 Add(new ATI.ATIGroup(settings));
4.42 Add(new Nvidia.NvidiaGroup(settings));
4.43 @@ -108,7 +116,7 @@
4.44 set {
4.45 if (open && value != mainboardEnabled) {
4.46 if (value)
4.47 - Add(new Mainboard.MainboardGroup(settings));
4.48 + Add(new Mainboard.MainboardGroup(smbios, settings));
4.49 else
4.50 RemoveType<Mainboard.MainboardGroup>();
4.51 }
4.52 @@ -131,6 +139,21 @@
4.53 }
4.54 }
4.55
4.56 + public bool RAMEnabled {
4.57 + get { return ramEnabled; }
4.58 +
4.59 + [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
4.60 + set {
4.61 + if (open && value != ramEnabled) {
4.62 + if (value)
4.63 + Add(new RAM.RAMGroup(smbios, settings));
4.64 + else
4.65 + RemoveType<RAM.RAMGroup>();
4.66 + }
4.67 + ramEnabled = value;
4.68 + }
4.69 + }
4.70 +
4.71 public bool GPUEnabled {
4.72 get { return gpuEnabled; }
4.73
4.74 @@ -336,6 +359,8 @@
4.75 Opcode.Close();
4.76 Ring0.Close();
4.77
4.78 + this.smbios = null;
4.79 +
4.80 open = false;
4.81 }
4.82
5.1 --- a/Hardware/IComputer.cs Sun Jul 22 18:07:11 2012 +0000
5.2 +++ b/Hardware/IComputer.cs Mon Jul 23 21:54:35 2012 +0000
5.3 @@ -16,8 +16,14 @@
5.4
5.5 IHardware[] Hardware { get; }
5.6
5.7 + bool MainboardEnabled { get; }
5.8 + bool CPUEnabled { get; }
5.9 + bool RAMEnabled { get; }
5.10 + bool GPUEnabled { get; }
5.11 + bool FanControllerEnabled { get; }
5.12 bool HDDEnabled { get; }
5.13
5.14 +
5.15 string GetReport();
5.16
5.17 event HardwareEventHandler HardwareAdded;
6.1 --- a/Hardware/IHardware.cs Sun Jul 22 18:07:11 2012 +0000
6.2 +++ b/Hardware/IHardware.cs Mon Jul 23 21:54:35 2012 +0000
6.3 @@ -16,11 +16,12 @@
6.4 Mainboard,
6.5 SuperIO,
6.6 CPU,
6.7 + RAM,
6.8 GpuNvidia,
6.9 GpuAti,
6.10 TBalancer,
6.11 Heatmaster,
6.12 - HDD,
6.13 + HDD
6.14 }
6.15
6.16 public interface IHardware : IElement {
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/Hardware/Mainboard/Identification.cs Mon Jul 23 21:54:35 2012 +0000
7.3 @@ -0,0 +1,200 @@
7.4 +/*
7.5 +
7.6 + This Source Code Form is subject to the terms of the Mozilla Public
7.7 + License, v. 2.0. If a copy of the MPL was not distributed with this
7.8 + file, You can obtain one at http://mozilla.org/MPL/2.0/.
7.9 +
7.10 + Copyright (C) 2012 Michael Möller <mmoeller@openhardwaremonitor.org>
7.11 +
7.12 +*/
7.13 +
7.14 +namespace OpenHardwareMonitor.Hardware.Mainboard {
7.15 + internal class Identification {
7.16 +
7.17 + public static Manufacturer GetManufacturer(string name) {
7.18 + switch (name) {
7.19 + case "Alienware":
7.20 + return Manufacturer.Alienware;
7.21 + case "Apple Inc.":
7.22 + return Manufacturer.Apple;
7.23 + case "ASRock":
7.24 + return Manufacturer.ASRock;
7.25 + case "ASUSTeK Computer INC.":
7.26 + case "ASUSTeK COMPUTER INC.":
7.27 + return Manufacturer.ASUS;
7.28 + case "Dell Inc.":
7.29 + return Manufacturer.Dell;
7.30 + case "DFI":
7.31 + case "DFI Inc.":
7.32 + return Manufacturer.DFI;
7.33 + case "ECS":
7.34 + return Manufacturer.ECS;
7.35 + case "EPoX COMPUTER CO., LTD":
7.36 + return Manufacturer.EPoX;
7.37 + case "EVGA":
7.38 + return Manufacturer.EVGA;
7.39 + case "First International Computer, Inc.":
7.40 + return Manufacturer.FIC;
7.41 + case "FUJITSU":
7.42 + case "FUJITSU SIEMENS":
7.43 + return Manufacturer.Fujitsu;
7.44 + case "Gigabyte Technology Co., Ltd.":
7.45 + return Manufacturer.Gigabyte;
7.46 + case "Hewlett-Packard":
7.47 + return Manufacturer.HP;
7.48 + case "IBM":
7.49 + return Manufacturer.IBM;
7.50 + case "Intel":
7.51 + case "Intel Corp.":
7.52 + case "Intel Corporation":
7.53 + case "INTEL Corporation":
7.54 + return Manufacturer.Intel;
7.55 + case "Lenovo":
7.56 + case "LENOVO":
7.57 + return Manufacturer.Lenovo;
7.58 + case "Micro-Star International":
7.59 + case "MICRO-STAR INTERNATIONAL CO., LTD":
7.60 + case "MICRO-STAR INTERNATIONAL CO.,LTD":
7.61 + case "MSI":
7.62 + return Manufacturer.MSI;
7.63 + case "Shuttle":
7.64 + return Manufacturer.Shuttle;
7.65 + case "Supermicro":
7.66 + return Manufacturer.Supermicro;
7.67 + case "TOSHIBA":
7.68 + return Manufacturer.Toshiba;
7.69 + case "XFX":
7.70 + return Manufacturer.XFX;
7.71 + case "To be filled by O.E.M.":
7.72 + return Manufacturer.Unknown;
7.73 + default:
7.74 + return Manufacturer.Unknown;
7.75 + }
7.76 + }
7.77 +
7.78 + public static Model GetModel(string name) {
7.79 + switch (name) {
7.80 + case "880GMH/USB3":
7.81 + return Model._880GMH_USB3;
7.82 + case "ASRock AOD790GX/128M":
7.83 + return Model.AOD790GX_128M;
7.84 + case "P55 Deluxe":
7.85 + return Model.P55_Deluxe;
7.86 + case "Crosshair III Formula":
7.87 + return Model.Crosshair_III_Formula;
7.88 + case "M2N-SLI DELUXE":
7.89 + return Model.M2N_SLI_DELUXE;
7.90 + case "M4A79XTD EVO":
7.91 + return Model.M4A79XTD_EVO;
7.92 + case "P5W DH Deluxe":
7.93 + return Model.P5W_DH_Deluxe;
7.94 + case "P6T":
7.95 + return Model.P6T;
7.96 + case "P6X58D-E":
7.97 + return Model.P6X58D_E;
7.98 + case "P8P67":
7.99 + return Model.P8P67;
7.100 + case "P8P67 EVO":
7.101 + return Model.P8P67_EVO;
7.102 + case "P8P67 PRO":
7.103 + return Model.P8P67_PRO;
7.104 + case "P8P67-M PRO":
7.105 + return Model.P8P67_M_PRO;
7.106 + case "P8Z77-V":
7.107 + return Model.P8Z77_V;
7.108 + case "P9X79":
7.109 + return Model.P9X79;
7.110 + case "Rampage Extreme":
7.111 + return Model.Rampage_Extreme;
7.112 + case "Rampage II GENE":
7.113 + return Model.Rampage_II_GENE;
7.114 + case "LP BI P45-T2RS Elite":
7.115 + return Model.LP_BI_P45_T2RS_Elite;
7.116 + case "LP DK P55-T3eH9":
7.117 + return Model.LP_DK_P55_T3eH9;
7.118 + case "A890GXM-A":
7.119 + return Model.A890GXM_A;
7.120 + case "X58 SLI Classified":
7.121 + return Model.X58_SLI_Classified;
7.122 + case "965P-S3":
7.123 + return Model._965P_S3;
7.124 + case "EP45-DS3R":
7.125 + return Model.EP45_DS3R;
7.126 + case "EP45-UD3R":
7.127 + return Model.EP45_UD3R;
7.128 + case "EX58-EXTREME":
7.129 + return Model.EX58_EXTREME;
7.130 + case "EX58-UD3R":
7.131 + return Model.EX58_UD3R;
7.132 + case "G41M-Combo":
7.133 + return Model.G41M_Combo;
7.134 + case "G41MT-S2":
7.135 + return Model.G41MT_S2;
7.136 + case "G41MT-S2P":
7.137 + return Model.G41MT_S2P;
7.138 + case "GA-MA770T-UD3":
7.139 + return Model.GA_MA770T_UD3;
7.140 + case "GA-MA770T-UD3P":
7.141 + return Model.GA_MA770T_UD3P;
7.142 + case "GA-MA785GM-US2H":
7.143 + return Model.GA_MA785GM_US2H;
7.144 + case "GA-MA785GMT-UD2H":
7.145 + return Model.GA_MA785GMT_UD2H;
7.146 + case "GA-MA78LM-S2H":
7.147 + return Model.GA_MA78LM_S2H;
7.148 + case "GA-MA790X-UD3P":
7.149 + return Model.GA_MA790X_UD3P;
7.150 + case "H55-USB3":
7.151 + return Model.H55_USB3;
7.152 + case "H55N-USB3":
7.153 + return Model.H55N_USB3;
7.154 + case "H61M-DS2 REV 1.2":
7.155 + return Model.H61M_DS2_REV_1_2;
7.156 + case "H61M-USB3-B3 REV 2.0":
7.157 + return Model.H61M_USB3_B3_REV_2_0;
7.158 + case "H67A-UD3H-B3":
7.159 + return Model.H67A_UD3H_B3;
7.160 + case "H67A-USB3-B3":
7.161 + return Model.H67A_USB3_B3;
7.162 + case "P35-DS3":
7.163 + return Model.P35_DS3;
7.164 + case "P35-DS3L":
7.165 + return Model.P35_DS3L;
7.166 + case "P55-UD4":
7.167 + return Model.P55_UD4;
7.168 + case "P55A-UD3":
7.169 + return Model.P55A_UD3;
7.170 + case "P55M-UD4":
7.171 + return Model.P55M_UD4;
7.172 + case "P67A-UD3-B3":
7.173 + return Model.P67A_UD3_B3;
7.174 + case "P67A-UD3R-B3":
7.175 + return Model.P67A_UD3R_B3;
7.176 + case "P67A-UD4-B3":
7.177 + return Model.P67A_UD4_B3;
7.178 + case "P8Z68-V PRO":
7.179 + return Model.P8Z68_V_PRO;
7.180 + case "X38-DS5":
7.181 + return Model.X38_DS5;
7.182 + case "X58A-UD3R":
7.183 + return Model.X58A_UD3R;
7.184 + case "Z68A-D3H-B3":
7.185 + return Model.Z68A_D3H_B3;
7.186 + case "Z68AP-D3":
7.187 + return Model.Z68AP_D3;
7.188 + case "Z68X-UD3H-B3":
7.189 + return Model.Z68X_UD3H_B3;
7.190 + case "Z68X-UD7-B3":
7.191 + return Model.Z68X_UD7_B3;
7.192 + case "FH67":
7.193 + return Model.FH67;
7.194 + case "Base Board Product Name":
7.195 + case "To be filled by O.E.M.":
7.196 + return Model.Unknown;
7.197 + default:
7.198 + return Model.Unknown;
7.199 + }
7.200 + }
7.201 +
7.202 + }
7.203 +}
8.1 --- a/Hardware/Mainboard/Mainboard.cs Sun Jul 22 18:07:11 2012 +0000
8.2 +++ b/Hardware/Mainboard/Mainboard.cs Mon Jul 23 21:54:35 2012 +0000
8.3 @@ -4,7 +4,7 @@
8.4 License, v. 2.0. If a copy of the MPL was not distributed with this
8.5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
8.6
8.7 - Copyright (C) 2009-2011 Michael Möller <mmoeller@openhardwaremonitor.org>
8.8 + Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
8.9
8.10 */
8.11
8.12 @@ -22,19 +22,25 @@
8.13 private readonly LMSensors lmSensors;
8.14 private readonly Hardware[] superIOHardware;
8.15
8.16 - public Mainboard(ISettings settings) {
8.17 + public Mainboard(SMBIOS smbios, ISettings settings) {
8.18 this.settings = settings;
8.19 - this.smbios = new SMBIOS();
8.20 -
8.21 + this.smbios = smbios;
8.22 +
8.23 + Manufacturer manufacturer = smbios.Board == null ? Manufacturer.Unknown :
8.24 + Identification.GetManufacturer(smbios.Board.ManufacturerName);
8.25 +
8.26 + Model model = smbios.Board == null ? Model.Unknown :
8.27 + Identification.GetModel(smbios.Board.ProductName);
8.28 +
8.29 if (smbios.Board != null) {
8.30 if (!string.IsNullOrEmpty(smbios.Board.ProductName)) {
8.31 - if (smbios.Board.Manufacturer == Manufacturer.Unknown)
8.32 + if (manufacturer == Manufacturer.Unknown)
8.33 this.name = smbios.Board.ProductName;
8.34 else
8.35 - this.name = smbios.Board.Manufacturer + " " +
8.36 + this.name = manufacturer + " " +
8.37 smbios.Board.ProductName;
8.38 } else {
8.39 - this.name = smbios.Board.Manufacturer.ToString();
8.40 + this.name = manufacturer.ToString();
8.41 }
8.42 } else {
8.43 this.name = Manufacturer.Unknown.ToString();
8.44 @@ -55,10 +61,8 @@
8.45
8.46 superIOHardware = new Hardware[superIO.Length];
8.47 for (int i = 0; i < superIO.Length; i++)
8.48 - superIOHardware[i] = new SuperIOHardware(this, superIO[i],
8.49 - smbios.Board != null ? smbios.Board.Manufacturer :
8.50 - Manufacturer.Unknown, smbios.Board != null ? smbios.Board.Model :
8.51 - Model.Unknown, settings);
8.52 + superIOHardware[i] = new SuperIOHardware(this, superIO[i],
8.53 + manufacturer, model, settings);
8.54 }
8.55
8.56 public string Name {
9.1 --- a/Hardware/Mainboard/MainboardGroup.cs Sun Jul 22 18:07:11 2012 +0000
9.2 +++ b/Hardware/Mainboard/MainboardGroup.cs Mon Jul 23 21:54:35 2012 +0000
9.3 @@ -13,9 +13,9 @@
9.4
9.5 private readonly Mainboard[] mainboards;
9.6
9.7 - public MainboardGroup(ISettings settings) {
9.8 + public MainboardGroup(SMBIOS smbios, ISettings settings) {
9.9 mainboards = new Mainboard[1];
9.10 - mainboards[0] = new Mainboard(settings);
9.11 + mainboards[0] = new Mainboard(smbios, settings);
9.12 }
9.13
9.14 public void Close() {
10.1 --- a/Hardware/Mainboard/SMBIOS.cs Sun Jul 22 18:07:11 2012 +0000
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,533 +0,0 @@
10.4 -/*
10.5 -
10.6 - This Source Code Form is subject to the terms of the Mozilla Public
10.7 - License, v. 2.0. If a copy of the MPL was not distributed with this
10.8 - file, You can obtain one at http://mozilla.org/MPL/2.0/.
10.9 -
10.10 - Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
10.11 -
10.12 -*/
10.13 -
10.14 -using System;
10.15 -using System.Collections.Generic;
10.16 -using System.IO;
10.17 -using System.Management;
10.18 -using System.Text;
10.19 -
10.20 -namespace OpenHardwareMonitor.Hardware.Mainboard {
10.21 -
10.22 - internal class SMBIOS {
10.23 -
10.24 - private readonly byte[] raw;
10.25 - private readonly Structure[] table;
10.26 -
10.27 - private readonly Version version;
10.28 - private readonly BIOSInformation biosInformation;
10.29 - private readonly SystemInformation systemInformation;
10.30 - private readonly BaseBoardInformation baseBoardInformation;
10.31 -
10.32 - private static string ReadSysFS(string path) {
10.33 - try {
10.34 - if (File.Exists(path)) {
10.35 - using (StreamReader reader = new StreamReader(path))
10.36 - return reader.ReadLine();
10.37 - } else {
10.38 - return null;
10.39 - }
10.40 - } catch {
10.41 - return null;
10.42 - }
10.43 - }
10.44 -
10.45 - public SMBIOS() {
10.46 - int p = (int)Environment.OSVersion.Platform;
10.47 - if ((p == 4) || (p == 128)) {
10.48 - this.raw = null;
10.49 - this.table = null;
10.50 -
10.51 - string boardVendor = ReadSysFS("/sys/class/dmi/id/board_vendor");
10.52 - string boardName = ReadSysFS("/sys/class/dmi/id/board_name");
10.53 - string boardVersion = ReadSysFS("/sys/class/dmi/id/board_version");
10.54 - this.baseBoardInformation = new BaseBoardInformation(
10.55 - boardVendor, boardName, boardVersion, null);
10.56 -
10.57 - string systemVendor = ReadSysFS("/sys/class/dmi/id/sys_vendor");
10.58 - string productName = ReadSysFS("/sys/class/dmi/id/product_name");
10.59 - string productVersion = ReadSysFS("/sys/class/dmi/id/product_version");
10.60 - this.systemInformation = new SystemInformation(systemVendor,
10.61 - productName, productVersion, null, null);
10.62 -
10.63 - string biosVendor = ReadSysFS("/sys/class/dmi/id/bios_vendor");
10.64 - string biosVersion = ReadSysFS("/sys/class/dmi/id/bios_version");
10.65 - this.biosInformation = new BIOSInformation(biosVendor, biosVersion);
10.66 -
10.67 - } else {
10.68 - List<Structure> structureList = new List<Structure>();
10.69 -
10.70 - raw = null;
10.71 - byte majorVersion = 0;
10.72 - byte minorVersion = 0;
10.73 - try {
10.74 - ManagementObjectCollection collection;
10.75 - using (ManagementObjectSearcher searcher =
10.76 - new ManagementObjectSearcher("root\\WMI",
10.77 - "SELECT * FROM MSSMBios_RawSMBiosTables")) {
10.78 - collection = searcher.Get();
10.79 - }
10.80 -
10.81 - foreach (ManagementObject mo in collection) {
10.82 - raw = (byte[])mo["SMBiosData"];
10.83 - majorVersion = (byte)mo["SmbiosMajorVersion"];
10.84 - minorVersion = (byte)mo["SmbiosMinorVersion"];
10.85 - break;
10.86 - }
10.87 - } catch { }
10.88 -
10.89 - if (majorVersion > 0 || minorVersion > 0)
10.90 - version = new Version(majorVersion, minorVersion);
10.91 -
10.92 - if (raw != null && raw.Length > 0) {
10.93 - int offset = 0;
10.94 - byte type = raw[offset];
10.95 - while (offset + 4 < raw.Length && type != 127) {
10.96 -
10.97 - type = raw[offset];
10.98 - int length = raw[offset + 1];
10.99 - ushort handle = (ushort)((raw[offset + 2] << 8) | raw[offset + 3]);
10.100 -
10.101 - if (offset + length > raw.Length)
10.102 - break;
10.103 - byte[] data = new byte[length];
10.104 - Array.Copy(raw, offset, data, 0, length);
10.105 - offset += length;
10.106 -
10.107 - List<string> stringsList = new List<string>();
10.108 - if (offset < raw.Length && raw[offset] == 0)
10.109 - offset++;
10.110 -
10.111 - while (offset < raw.Length && raw[offset] != 0) {
10.112 - StringBuilder sb = new StringBuilder();
10.113 - while (offset < raw.Length && raw[offset] != 0) {
10.114 - sb.Append((char)raw[offset]); offset++;
10.115 - }
10.116 - offset++;
10.117 - stringsList.Add(sb.ToString());
10.118 - }
10.119 - offset++;
10.120 - switch (type) {
10.121 - case 0x00:
10.122 - this.biosInformation = new BIOSInformation(
10.123 - type, handle, data, stringsList.ToArray());
10.124 - structureList.Add(this.biosInformation); break;
10.125 - case 0x01:
10.126 - this.systemInformation = new SystemInformation(
10.127 - type, handle, data, stringsList.ToArray());
10.128 - structureList.Add(this.systemInformation); break;
10.129 - case 0x02: this.baseBoardInformation = new BaseBoardInformation(
10.130 - type, handle, data, stringsList.ToArray());
10.131 - structureList.Add(this.baseBoardInformation); break;
10.132 - default: structureList.Add(new Structure(
10.133 - type, handle, data, stringsList.ToArray())); break;
10.134 - }
10.135 - }
10.136 - }
10.137 -
10.138 - table = structureList.ToArray();
10.139 - }
10.140 - }
10.141 -
10.142 - public string GetReport() {
10.143 - StringBuilder r = new StringBuilder();
10.144 -
10.145 - if (version != null) {
10.146 - r.Append("SMBIOS Version: "); r.AppendLine(version.ToString(2));
10.147 - r.AppendLine();
10.148 - }
10.149 -
10.150 - if (BIOS != null) {
10.151 - r.Append("BIOS Vendor: "); r.AppendLine(BIOS.Vendor);
10.152 - r.Append("BIOS Version: "); r.AppendLine(BIOS.Version);
10.153 - r.AppendLine();
10.154 - }
10.155 -
10.156 - if (System != null) {
10.157 - r.Append("System Manufacturer: ");
10.158 - r.AppendLine(System.ManufacturerName);
10.159 - r.Append("System Name: ");
10.160 - r.AppendLine(System.ProductName);
10.161 - r.Append("System Version: ");
10.162 - r.AppendLine(System.Version);
10.163 - r.AppendLine();
10.164 - }
10.165 -
10.166 - if (Board != null) {
10.167 - r.Append("Mainboard Manufacturer: ");
10.168 - r.AppendLine(Board.ManufacturerName);
10.169 - r.Append("Mainboard Name: ");
10.170 - r.AppendLine(Board.ProductName);
10.171 - r.Append("Mainboard Version: ");
10.172 - r.AppendLine(Board.Version);
10.173 - r.AppendLine();
10.174 - }
10.175 -
10.176 - if (raw != null) {
10.177 - string base64 = Convert.ToBase64String(raw);
10.178 - r.AppendLine("SMBIOS Table");
10.179 - r.AppendLine();
10.180 -
10.181 - for (int i = 0; i < Math.Ceiling(base64.Length / 64.0); i++) {
10.182 - r.Append(" ");
10.183 - for (int j = 0; j < 0x40; j++) {
10.184 - int index = (i << 6) | j;
10.185 - if (index < base64.Length) {
10.186 - r.Append(base64[index]);
10.187 - }
10.188 - }
10.189 - r.AppendLine();
10.190 - }
10.191 - r.AppendLine();
10.192 - }
10.193 -
10.194 - return r.ToString();
10.195 - }
10.196 -
10.197 - public BIOSInformation BIOS {
10.198 - get { return biosInformation; }
10.199 - }
10.200 -
10.201 - public SystemInformation System {
10.202 - get { return systemInformation; }
10.203 - }
10.204 -
10.205 - public BaseBoardInformation Board {
10.206 - get { return baseBoardInformation; }
10.207 - }
10.208 -
10.209 - public class Structure {
10.210 - private readonly byte type;
10.211 - private readonly ushort handle;
10.212 -
10.213 - private readonly byte[] data;
10.214 - private readonly string[] strings;
10.215 -
10.216 - protected string GetString(int offset) {
10.217 - if (offset < data.Length && data[offset] > 0 &&
10.218 - data[offset] <= strings.Length)
10.219 - return strings[data[offset] - 1];
10.220 - else
10.221 - return "";
10.222 - }
10.223 -
10.224 - public Structure(byte type, ushort handle, byte[] data, string[] strings)
10.225 - {
10.226 - this.type = type;
10.227 - this.handle = handle;
10.228 - this.data = data;
10.229 - this.strings = strings;
10.230 - }
10.231 -
10.232 - public byte Type { get { return type; } }
10.233 -
10.234 - public ushort Handle { get { return handle; } }
10.235 - }
10.236 -
10.237 - public class BIOSInformation : Structure {
10.238 -
10.239 - private readonly string vendor;
10.240 - private readonly string version;
10.241 -
10.242 - public BIOSInformation(string vendor, string version)
10.243 - : base (0x00, 0, null, null)
10.244 - {
10.245 - this.vendor = vendor;
10.246 - this.version = version;
10.247 - }
10.248 -
10.249 - public BIOSInformation(byte type, ushort handle, byte[] data,
10.250 - string[] strings)
10.251 - : base(type, handle, data, strings)
10.252 - {
10.253 - this.vendor = GetString(0x04);
10.254 - this.version = GetString(0x05);
10.255 - }
10.256 -
10.257 - public string Vendor { get { return vendor; } }
10.258 -
10.259 - public string Version { get { return version; } }
10.260 - }
10.261 -
10.262 - public class SystemInformation : Structure {
10.263 -
10.264 - private readonly string manufacturerName;
10.265 - private readonly string productName;
10.266 - private readonly string version;
10.267 - private readonly string serialNumber;
10.268 - private readonly string family;
10.269 -
10.270 - public SystemInformation(string manufacturerName, string productName,
10.271 - string version, string serialNumber, string family)
10.272 - : base (0x01, 0, null, null)
10.273 - {
10.274 - this.manufacturerName = manufacturerName;
10.275 - this.productName = productName;
10.276 - this.version = version;
10.277 - this.serialNumber = serialNumber;
10.278 - this.family = family;
10.279 - }
10.280 -
10.281 - public SystemInformation(byte type, ushort handle, byte[] data,
10.282 - string[] strings)
10.283 - : base(type, handle, data, strings)
10.284 - {
10.285 - this.manufacturerName = GetString(0x04);
10.286 - this.productName = GetString(0x05);
10.287 - this.version = GetString(0x06);
10.288 - this.serialNumber = GetString(0x07);
10.289 - this.family = GetString(0x1A);
10.290 - }
10.291 -
10.292 - public string ManufacturerName { get { return manufacturerName; } }
10.293 -
10.294 - public string ProductName { get { return productName; } }
10.295 -
10.296 - public string Version { get { return version; } }
10.297 -
10.298 - public string SerialNumber { get { return serialNumber; } }
10.299 -
10.300 - public string Family { get { return family; } }
10.301 -
10.302 - }
10.303 -
10.304 - public class BaseBoardInformation : Structure {
10.305 -
10.306 - private readonly string manufacturerName;
10.307 - private readonly string productName;
10.308 - private readonly string version;
10.309 - private readonly string serialNumber;
10.310 - private readonly Manufacturer manufacturer;
10.311 - private readonly Model model;
10.312 -
10.313 - private static Manufacturer GetManufacturer(string name) {
10.314 - switch (name) {
10.315 - case "Alienware":
10.316 - return Manufacturer.Alienware;
10.317 - case "Apple Inc.":
10.318 - return Manufacturer.Apple;
10.319 - case "ASRock":
10.320 - return Manufacturer.ASRock;
10.321 - case "ASUSTeK Computer INC.":
10.322 - case "ASUSTeK COMPUTER INC.":
10.323 - return Manufacturer.ASUS;
10.324 - case "Dell Inc.":
10.325 - return Manufacturer.Dell;
10.326 - case "DFI":
10.327 - case "DFI Inc.":
10.328 - return Manufacturer.DFI;
10.329 - case "ECS":
10.330 - return Manufacturer.ECS;
10.331 - case "EPoX COMPUTER CO., LTD":
10.332 - return Manufacturer.EPoX;
10.333 - case "EVGA":
10.334 - return Manufacturer.EVGA;
10.335 - case "First International Computer, Inc.":
10.336 - return Manufacturer.FIC;
10.337 - case "FUJITSU":
10.338 - case "FUJITSU SIEMENS":
10.339 - return Manufacturer.Fujitsu;
10.340 - case "Gigabyte Technology Co., Ltd.":
10.341 - return Manufacturer.Gigabyte;
10.342 - case "Hewlett-Packard":
10.343 - return Manufacturer.HP;
10.344 - case "IBM":
10.345 - return Manufacturer.IBM;
10.346 - case "Intel":
10.347 - case "Intel Corp.":
10.348 - case "Intel Corporation":
10.349 - case "INTEL Corporation":
10.350 - return Manufacturer.Intel;
10.351 - case "Lenovo":
10.352 - case "LENOVO":
10.353 - return Manufacturer.Lenovo;
10.354 - case "Micro-Star International":
10.355 - case "MICRO-STAR INTERNATIONAL CO., LTD":
10.356 - case "MICRO-STAR INTERNATIONAL CO.,LTD":
10.357 - case "MSI":
10.358 - return Manufacturer.MSI;
10.359 - case "Shuttle":
10.360 - return Manufacturer.Shuttle;
10.361 - case "Supermicro":
10.362 - return Manufacturer.Supermicro;
10.363 - case "TOSHIBA":
10.364 - return Manufacturer.Toshiba;
10.365 - case "XFX":
10.366 - return Manufacturer.XFX;
10.367 - case "To be filled by O.E.M.":
10.368 - return Manufacturer.Unknown;
10.369 - default:
10.370 - return Manufacturer.Unknown;
10.371 - }
10.372 - }
10.373 -
10.374 - private static Model GetModel(string name) {
10.375 - switch (name) {
10.376 - case "880GMH/USB3":
10.377 - return Model._880GMH_USB3;
10.378 - case "ASRock AOD790GX/128M":
10.379 - return Model.AOD790GX_128M;
10.380 - case "P55 Deluxe":
10.381 - return Model.P55_Deluxe;
10.382 - case "Crosshair III Formula":
10.383 - return Model.Crosshair_III_Formula;
10.384 - case "M2N-SLI DELUXE":
10.385 - return Model.M2N_SLI_DELUXE;
10.386 - case "M4A79XTD EVO":
10.387 - return Model.M4A79XTD_EVO;
10.388 - case "P5W DH Deluxe":
10.389 - return Model.P5W_DH_Deluxe;
10.390 - case "P6T":
10.391 - return Model.P6T;
10.392 - case "P6X58D-E":
10.393 - return Model.P6X58D_E;
10.394 - case "P8P67":
10.395 - return Model.P8P67;
10.396 - case "P8P67 EVO":
10.397 - return Model.P8P67_EVO;
10.398 - case "P8P67 PRO":
10.399 - return Model.P8P67_PRO;
10.400 - case "P8P67-M PRO":
10.401 - return Model.P8P67_M_PRO;
10.402 - case "P8Z77-V":
10.403 - return Model.P8Z77_V;
10.404 - case "P9X79":
10.405 - return Model.P9X79;
10.406 - case "Rampage Extreme":
10.407 - return Model.Rampage_Extreme;
10.408 - case "Rampage II GENE":
10.409 - return Model.Rampage_II_GENE;
10.410 - case "LP BI P45-T2RS Elite":
10.411 - return Model.LP_BI_P45_T2RS_Elite;
10.412 - case "LP DK P55-T3eH9":
10.413 - return Model.LP_DK_P55_T3eH9;
10.414 - case "A890GXM-A":
10.415 - return Model.A890GXM_A;
10.416 - case "X58 SLI Classified":
10.417 - return Model.X58_SLI_Classified;
10.418 - case "965P-S3":
10.419 - return Model._965P_S3;
10.420 - case "EP45-DS3R":
10.421 - return Model.EP45_DS3R;
10.422 - case "EP45-UD3R":
10.423 - return Model.EP45_UD3R;
10.424 - case "EX58-EXTREME":
10.425 - return Model.EX58_EXTREME;
10.426 - case "EX58-UD3R":
10.427 - return Model.EX58_UD3R;
10.428 - case "G41M-Combo":
10.429 - return Model.G41M_Combo;
10.430 - case "G41MT-S2":
10.431 - return Model.G41MT_S2;
10.432 - case "G41MT-S2P":
10.433 - return Model.G41MT_S2P;
10.434 - case "GA-MA770T-UD3":
10.435 - return Model.GA_MA770T_UD3;
10.436 - case "GA-MA770T-UD3P":
10.437 - return Model.GA_MA770T_UD3P;
10.438 - case "GA-MA785GM-US2H":
10.439 - return Model.GA_MA785GM_US2H;
10.440 - case "GA-MA785GMT-UD2H":
10.441 - return Model.GA_MA785GMT_UD2H;
10.442 - case "GA-MA78LM-S2H":
10.443 - return Model.GA_MA78LM_S2H;
10.444 - case "GA-MA790X-UD3P":
10.445 - return Model.GA_MA790X_UD3P;
10.446 - case "H55-USB3":
10.447 - return Model.H55_USB3;
10.448 - case "H55N-USB3":
10.449 - return Model.H55N_USB3;
10.450 - case "H61M-DS2 REV 1.2":
10.451 - return Model.H61M_DS2_REV_1_2;
10.452 - case "H61M-USB3-B3 REV 2.0":
10.453 - return Model.H61M_USB3_B3_REV_2_0;
10.454 - case "H67A-UD3H-B3":
10.455 - return Model.H67A_UD3H_B3;
10.456 - case "H67A-USB3-B3":
10.457 - return Model.H67A_USB3_B3;
10.458 - case "P35-DS3":
10.459 - return Model.P35_DS3;
10.460 - case "P35-DS3L":
10.461 - return Model.P35_DS3L;
10.462 - case "P55-UD4":
10.463 - return Model.P55_UD4;
10.464 - case "P55A-UD3":
10.465 - return Model.P55A_UD3;
10.466 - case "P55M-UD4":
10.467 - return Model.P55M_UD4;
10.468 - case "P67A-UD3-B3":
10.469 - return Model.P67A_UD3_B3;
10.470 - case "P67A-UD3R-B3":
10.471 - return Model.P67A_UD3R_B3;
10.472 - case "P67A-UD4-B3":
10.473 - return Model.P67A_UD4_B3;
10.474 - case "P8Z68-V PRO":
10.475 - return Model.P8Z68_V_PRO;
10.476 - case "X38-DS5":
10.477 - return Model.X38_DS5;
10.478 - case "X58A-UD3R":
10.479 - return Model.X58A_UD3R;
10.480 - case "Z68A-D3H-B3":
10.481 - return Model.Z68A_D3H_B3;
10.482 - case "Z68AP-D3":
10.483 - return Model.Z68AP_D3;
10.484 - case "Z68X-UD3H-B3":
10.485 - return Model.Z68X_UD3H_B3;
10.486 - case "Z68X-UD7-B3":
10.487 - return Model.Z68X_UD7_B3;
10.488 - case "FH67":
10.489 - return Model.FH67;
10.490 - case "Base Board Product Name":
10.491 - case "To be filled by O.E.M.":
10.492 - return Model.Unknown;
10.493 - default:
10.494 - return Model.Unknown;
10.495 - }
10.496 - }
10.497 -
10.498 - public BaseBoardInformation(string manufacturerName, string productName,
10.499 - string version, string serialNumber)
10.500 - : base(0x02, 0, null, null)
10.501 - {
10.502 - this.manufacturerName = manufacturerName;
10.503 - this.manufacturer = GetManufacturer(manufacturerName);
10.504 - this.productName = productName;
10.505 - this.model = GetModel(productName);
10.506 - this.version = version;
10.507 - this.serialNumber = serialNumber;
10.508 - }
10.509 -
10.510 - public BaseBoardInformation(byte type, ushort handle, byte[] data,
10.511 - string[] strings)
10.512 - : base(type, handle, data, strings) {
10.513 -
10.514 - this.manufacturerName = GetString(0x04).Trim();
10.515 - this.manufacturer = GetManufacturer(this.manufacturerName);
10.516 - this.productName = GetString(0x05).Trim();
10.517 - this.model = GetModel(this.productName);
10.518 - this.version = GetString(0x06).Trim();
10.519 - this.serialNumber = GetString(0x07).Trim();
10.520 - }
10.521 -
10.522 - public string ManufacturerName { get { return manufacturerName; } }
10.523 -
10.524 - public string ProductName { get { return productName; } }
10.525 -
10.526 - public string Version { get { return version; } }
10.527 -
10.528 - public string SerialNumber { get { return serialNumber; } }
10.529 -
10.530 - public Manufacturer Manufacturer { get { return manufacturer; } }
10.531 -
10.532 - public Model Model { get { return model; } }
10.533 -
10.534 - }
10.535 - }
10.536 -}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/Hardware/RAM/GenericRAM.cs Mon Jul 23 21:54:35 2012 +0000
11.3 @@ -0,0 +1,47 @@
11.4 +/*
11.5 +
11.6 + This Source Code Form is subject to the terms of the Mozilla Public
11.7 + License, v. 2.0. If a copy of the MPL was not distributed with this
11.8 + file, You can obtain one at http://mozilla.org/MPL/2.0/.
11.9 +
11.10 + Copyright (C) 2012 Michael Möller <mmoeller@openhardwaremonitor.org>
11.11 +
11.12 +*/
11.13 +
11.14 +using Microsoft.VisualBasic.Devices;
11.15 +
11.16 +namespace OpenHardwareMonitor.Hardware.RAM {
11.17 + internal class GenericRAM : Hardware {
11.18 +
11.19 + private Sensor loadSensor;
11.20 + private Sensor availableMemory;
11.21 +
11.22 + private ComputerInfo computerInfo;
11.23 +
11.24 + public GenericRAM(string name, ISettings settings)
11.25 + : base(name, new Identifier("ram"), settings)
11.26 + {
11.27 + computerInfo = new ComputerInfo();
11.28 + loadSensor = new Sensor("Memory", 0, SensorType.Load, this, settings);
11.29 + ActivateSensor(loadSensor);
11.30 +
11.31 + availableMemory = new Sensor("Available Memory", 0, SensorType.Data, this, settings);
11.32 + ActivateSensor(availableMemory);
11.33 + }
11.34 +
11.35 + public override HardwareType HardwareType {
11.36 + get {
11.37 + return HardwareType.RAM;
11.38 + }
11.39 + }
11.40 +
11.41 + public override void Update() {
11.42 + loadSensor.Value = 100.0f -
11.43 + (100.0f * computerInfo.AvailablePhysicalMemory) /
11.44 + computerInfo.TotalPhysicalMemory;
11.45 +
11.46 + availableMemory.Value = (float)computerInfo.AvailablePhysicalMemory /
11.47 + (1024 * 1024 * 1024);
11.48 + }
11.49 + }
11.50 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/Hardware/RAM/RAMGroup.cs Mon Jul 23 21:54:35 2012 +0000
12.3 @@ -0,0 +1,42 @@
12.4 +/*
12.5 +
12.6 + This Source Code Form is subject to the terms of the Mozilla Public
12.7 + License, v. 2.0. If a copy of the MPL was not distributed with this
12.8 + file, You can obtain one at http://mozilla.org/MPL/2.0/.
12.9 +
12.10 + Copyright (C) 2012 Michael Möller <mmoeller@openhardwaremonitor.org>
12.11 +
12.12 +*/
12.13 +
12.14 +namespace OpenHardwareMonitor.Hardware.RAM {
12.15 + internal class RAMGroup : IGroup {
12.16 +
12.17 + private IHardware[] hardware;
12.18 +
12.19 + public RAMGroup(SMBIOS smbios, ISettings settings) {
12.20 + string name;
12.21 + if (smbios.MemoryDevices.Length > 0) {
12.22 + name = smbios.MemoryDevices[0].ManufacturerName + " " +
12.23 + smbios.MemoryDevices[0].PartNumber;
12.24 + } else {
12.25 + name = "Generic Memory";
12.26 + }
12.27 +
12.28 + hardware = new IHardware[] { new GenericRAM(name, settings) };
12.29 + }
12.30 +
12.31 + public string GetReport() {
12.32 + return null;
12.33 + }
12.34 +
12.35 + public IHardware[] Hardware {
12.36 + get {
12.37 + return hardware;
12.38 + }
12.39 + }
12.40 +
12.41 + public void Close() {
12.42 +
12.43 + }
12.44 + }
12.45 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/Hardware/SMBIOS.cs Mon Jul 23 21:54:35 2012 +0000
13.3 @@ -0,0 +1,388 @@
13.4 +/*
13.5 +
13.6 + This Source Code Form is subject to the terms of the Mozilla Public
13.7 + License, v. 2.0. If a copy of the MPL was not distributed with this
13.8 + file, You can obtain one at http://mozilla.org/MPL/2.0/.
13.9 +
13.10 + Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
13.11 +
13.12 +*/
13.13 +
13.14 +using System;
13.15 +using System.Collections.Generic;
13.16 +using System.IO;
13.17 +using System.Management;
13.18 +using System.Text;
13.19 +
13.20 +namespace OpenHardwareMonitor.Hardware {
13.21 +
13.22 + internal class SMBIOS {
13.23 +
13.24 + private readonly byte[] raw;
13.25 + private readonly Structure[] table;
13.26 +
13.27 + private readonly Version version;
13.28 + private readonly BIOSInformation biosInformation;
13.29 + private readonly SystemInformation systemInformation;
13.30 + private readonly BaseBoardInformation baseBoardInformation;
13.31 + private readonly MemoryDevice[] memoryDevices;
13.32 +
13.33 + private static string ReadSysFS(string path) {
13.34 + try {
13.35 + if (File.Exists(path)) {
13.36 + using (StreamReader reader = new StreamReader(path))
13.37 + return reader.ReadLine();
13.38 + } else {
13.39 + return null;
13.40 + }
13.41 + } catch {
13.42 + return null;
13.43 + }
13.44 + }
13.45 +
13.46 + public SMBIOS() {
13.47 + int p = (int)Environment.OSVersion.Platform;
13.48 + if ((p == 4) || (p == 128)) {
13.49 + this.raw = null;
13.50 + this.table = null;
13.51 +
13.52 + string boardVendor = ReadSysFS("/sys/class/dmi/id/board_vendor");
13.53 + string boardName = ReadSysFS("/sys/class/dmi/id/board_name");
13.54 + string boardVersion = ReadSysFS("/sys/class/dmi/id/board_version");
13.55 + this.baseBoardInformation = new BaseBoardInformation(
13.56 + boardVendor, boardName, boardVersion, null);
13.57 +
13.58 + string systemVendor = ReadSysFS("/sys/class/dmi/id/sys_vendor");
13.59 + string productName = ReadSysFS("/sys/class/dmi/id/product_name");
13.60 + string productVersion = ReadSysFS("/sys/class/dmi/id/product_version");
13.61 + this.systemInformation = new SystemInformation(systemVendor,
13.62 + productName, productVersion, null, null);
13.63 +
13.64 + string biosVendor = ReadSysFS("/sys/class/dmi/id/bios_vendor");
13.65 + string biosVersion = ReadSysFS("/sys/class/dmi/id/bios_version");
13.66 + this.biosInformation = new BIOSInformation(biosVendor, biosVersion);
13.67 +
13.68 + this.memoryDevices = new MemoryDevice[0];
13.69 + } else {
13.70 + List<Structure> structureList = new List<Structure>();
13.71 + List<MemoryDevice> memoryDeviceList = new List<MemoryDevice>();
13.72 +
13.73 + raw = null;
13.74 + byte majorVersion = 0;
13.75 + byte minorVersion = 0;
13.76 + try {
13.77 + ManagementObjectCollection collection;
13.78 + using (ManagementObjectSearcher searcher =
13.79 + new ManagementObjectSearcher("root\\WMI",
13.80 + "SELECT * FROM MSSMBios_RawSMBiosTables")) {
13.81 + collection = searcher.Get();
13.82 + }
13.83 +
13.84 + foreach (ManagementObject mo in collection) {
13.85 + raw = (byte[])mo["SMBiosData"];
13.86 + majorVersion = (byte)mo["SmbiosMajorVersion"];
13.87 + minorVersion = (byte)mo["SmbiosMinorVersion"];
13.88 + break;
13.89 + }
13.90 + } catch { }
13.91 +
13.92 + if (majorVersion > 0 || minorVersion > 0)
13.93 + version = new Version(majorVersion, minorVersion);
13.94 +
13.95 + if (raw != null && raw.Length > 0) {
13.96 + int offset = 0;
13.97 + byte type = raw[offset];
13.98 + while (offset + 4 < raw.Length && type != 127) {
13.99 +
13.100 + type = raw[offset];
13.101 + int length = raw[offset + 1];
13.102 + ushort handle = (ushort)((raw[offset + 2] << 8) | raw[offset + 3]);
13.103 +
13.104 + if (offset + length > raw.Length)
13.105 + break;
13.106 + byte[] data = new byte[length];
13.107 + Array.Copy(raw, offset, data, 0, length);
13.108 + offset += length;
13.109 +
13.110 + List<string> stringsList = new List<string>();
13.111 + if (offset < raw.Length && raw[offset] == 0)
13.112 + offset++;
13.113 +
13.114 + while (offset < raw.Length && raw[offset] != 0) {
13.115 + StringBuilder sb = new StringBuilder();
13.116 + while (offset < raw.Length && raw[offset] != 0) {
13.117 + sb.Append((char)raw[offset]); offset++;
13.118 + }
13.119 + offset++;
13.120 + stringsList.Add(sb.ToString());
13.121 + }
13.122 + offset++;
13.123 + switch (type) {
13.124 + case 0x00:
13.125 + this.biosInformation = new BIOSInformation(
13.126 + type, handle, data, stringsList.ToArray());
13.127 + structureList.Add(this.biosInformation); break;
13.128 + case 0x01:
13.129 + this.systemInformation = new SystemInformation(
13.130 + type, handle, data, stringsList.ToArray());
13.131 + structureList.Add(this.systemInformation); break;
13.132 + case 0x02: this.baseBoardInformation = new BaseBoardInformation(
13.133 + type, handle, data, stringsList.ToArray());
13.134 + structureList.Add(this.baseBoardInformation); break;
13.135 + case 0x11: MemoryDevice m = new MemoryDevice(
13.136 + type, handle, data, stringsList.ToArray());
13.137 + memoryDeviceList.Add(m);
13.138 + structureList.Add(m); break;
13.139 + default: structureList.Add(new Structure(
13.140 + type, handle, data, stringsList.ToArray())); break;
13.141 + }
13.142 + }
13.143 + }
13.144 +
13.145 + memoryDevices = memoryDeviceList.ToArray();
13.146 + table = structureList.ToArray();
13.147 + }
13.148 + }
13.149 +
13.150 + public string GetReport() {
13.151 + StringBuilder r = new StringBuilder();
13.152 +
13.153 + if (version != null) {
13.154 + r.Append("SMBIOS Version: "); r.AppendLine(version.ToString(2));
13.155 + r.AppendLine();
13.156 + }
13.157 +
13.158 + if (BIOS != null) {
13.159 + r.Append("BIOS Vendor: "); r.AppendLine(BIOS.Vendor);
13.160 + r.Append("BIOS Version: "); r.AppendLine(BIOS.Version);
13.161 + r.AppendLine();
13.162 + }
13.163 +
13.164 + if (System != null) {
13.165 + r.Append("System Manufacturer: ");
13.166 + r.AppendLine(System.ManufacturerName);
13.167 + r.Append("System Name: ");
13.168 + r.AppendLine(System.ProductName);
13.169 + r.Append("System Version: ");
13.170 + r.AppendLine(System.Version);
13.171 + r.AppendLine();
13.172 + }
13.173 +
13.174 + if (Board != null) {
13.175 + r.Append("Mainboard Manufacturer: ");
13.176 + r.AppendLine(Board.ManufacturerName);
13.177 + r.Append("Mainboard Name: ");
13.178 + r.AppendLine(Board.ProductName);
13.179 + r.Append("Mainboard Version: ");
13.180 + r.AppendLine(Board.Version);
13.181 + r.AppendLine();
13.182 + }
13.183 +
13.184 + for (int i = 0; i < MemoryDevices.Length; i++) {
13.185 + r.Append("Memory Device [" + i + "] Manufacturer: ");
13.186 + r.AppendLine(MemoryDevices[i].ManufacturerName);
13.187 + r.Append("Memory Device [" + i + "] Part Number: ");
13.188 + r.AppendLine(MemoryDevices[i].PartNumber);
13.189 + r.AppendLine();
13.190 + }
13.191 +
13.192 + if (raw != null) {
13.193 + string base64 = Convert.ToBase64String(raw);
13.194 + r.AppendLine("SMBIOS Table");
13.195 + r.AppendLine();
13.196 +
13.197 + for (int i = 0; i < Math.Ceiling(base64.Length / 64.0); i++) {
13.198 + r.Append(" ");
13.199 + for (int j = 0; j < 0x40; j++) {
13.200 + int index = (i << 6) | j;
13.201 + if (index < base64.Length) {
13.202 + r.Append(base64[index]);
13.203 + }
13.204 + }
13.205 + r.AppendLine();
13.206 + }
13.207 + r.AppendLine();
13.208 + }
13.209 +
13.210 + return r.ToString();
13.211 + }
13.212 +
13.213 + public BIOSInformation BIOS {
13.214 + get { return biosInformation; }
13.215 + }
13.216 +
13.217 + public SystemInformation System {
13.218 + get { return systemInformation; }
13.219 + }
13.220 +
13.221 + public BaseBoardInformation Board {
13.222 + get { return baseBoardInformation; }
13.223 + }
13.224 +
13.225 + public MemoryDevice[] MemoryDevices {
13.226 + get { return memoryDevices; }
13.227 + }
13.228 +
13.229 + public class Structure {
13.230 + private readonly byte type;
13.231 + private readonly ushort handle;
13.232 +
13.233 + private readonly byte[] data;
13.234 + private readonly string[] strings;
13.235 +
13.236 + protected string GetString(int offset) {
13.237 + if (offset < data.Length && data[offset] > 0 &&
13.238 + data[offset] <= strings.Length)
13.239 + return strings[data[offset] - 1];
13.240 + else
13.241 + return "";
13.242 + }
13.243 +
13.244 + public Structure(byte type, ushort handle, byte[] data, string[] strings)
13.245 + {
13.246 + this.type = type;
13.247 + this.handle = handle;
13.248 + this.data = data;
13.249 + this.strings = strings;
13.250 + }
13.251 +
13.252 + public byte Type { get { return type; } }
13.253 +
13.254 + public ushort Handle { get { return handle; } }
13.255 + }
13.256 +
13.257 + public class BIOSInformation : Structure {
13.258 +
13.259 + private readonly string vendor;
13.260 + private readonly string version;
13.261 +
13.262 + public BIOSInformation(string vendor, string version)
13.263 + : base (0x00, 0, null, null)
13.264 + {
13.265 + this.vendor = vendor;
13.266 + this.version = version;
13.267 + }
13.268 +
13.269 + public BIOSInformation(byte type, ushort handle, byte[] data,
13.270 + string[] strings)
13.271 + : base(type, handle, data, strings)
13.272 + {
13.273 + this.vendor = GetString(0x04);
13.274 + this.version = GetString(0x05);
13.275 + }
13.276 +
13.277 + public string Vendor { get { return vendor; } }
13.278 +
13.279 + public string Version { get { return version; } }
13.280 + }
13.281 +
13.282 + public class SystemInformation : Structure {
13.283 +
13.284 + private readonly string manufacturerName;
13.285 + private readonly string productName;
13.286 + private readonly string version;
13.287 + private readonly string serialNumber;
13.288 + private readonly string family;
13.289 +
13.290 + public SystemInformation(string manufacturerName, string productName,
13.291 + string version, string serialNumber, string family)
13.292 + : base (0x01, 0, null, null)
13.293 + {
13.294 + this.manufacturerName = manufacturerName;
13.295 + this.productName = productName;
13.296 + this.version = version;
13.297 + this.serialNumber = serialNumber;
13.298 + this.family = family;
13.299 + }
13.300 +
13.301 + public SystemInformation(byte type, ushort handle, byte[] data,
13.302 + string[] strings)
13.303 + : base(type, handle, data, strings)
13.304 + {
13.305 + this.manufacturerName = GetString(0x04);
13.306 + this.productName = GetString(0x05);
13.307 + this.version = GetString(0x06);
13.308 + this.serialNumber = GetString(0x07);
13.309 + this.family = GetString(0x1A);
13.310 + }
13.311 +
13.312 + public string ManufacturerName { get { return manufacturerName; } }
13.313 +
13.314 + public string ProductName { get { return productName; } }
13.315 +
13.316 + public string Version { get { return version; } }
13.317 +
13.318 + public string SerialNumber { get { return serialNumber; } }
13.319 +
13.320 + public string Family { get { return family; } }
13.321 +
13.322 + }
13.323 +
13.324 + public class BaseBoardInformation : Structure {
13.325 +
13.326 + private readonly string manufacturerName;
13.327 + private readonly string productName;
13.328 + private readonly string version;
13.329 + private readonly string serialNumber;
13.330 +
13.331 + public BaseBoardInformation(string manufacturerName, string productName,
13.332 + string version, string serialNumber)
13.333 + : base(0x02, 0, null, null)
13.334 + {
13.335 + this.manufacturerName = manufacturerName;
13.336 + this.productName = productName;
13.337 + this.version = version;
13.338 + this.serialNumber = serialNumber;
13.339 + }
13.340 +
13.341 + public BaseBoardInformation(byte type, ushort handle, byte[] data,
13.342 + string[] strings)
13.343 + : base(type, handle, data, strings) {
13.344 +
13.345 + this.manufacturerName = GetString(0x04).Trim();
13.346 + this.productName = GetString(0x05).Trim();
13.347 + this.version = GetString(0x06).Trim();
13.348 + this.serialNumber = GetString(0x07).Trim();
13.349 + }
13.350 +
13.351 + public string ManufacturerName { get { return manufacturerName; } }
13.352 +
13.353 + public string ProductName { get { return productName; } }
13.354 +
13.355 + public string Version { get { return version; } }
13.356 +
13.357 + public string SerialNumber { get { return serialNumber; } }
13.358 +
13.359 + }
13.360 +
13.361 + public class MemoryDevice : Structure {
13.362 +
13.363 + private readonly string manufacturerName;
13.364 + private readonly string serialNumber;
13.365 + private readonly string partNumber;
13.366 +
13.367 + public MemoryDevice(string manufacturerName, string serialNumber,
13.368 + string partNumber)
13.369 + : base(0x11, 0, null, null) {
13.370 + this.manufacturerName = manufacturerName;
13.371 + this.serialNumber = serialNumber;
13.372 + this.partNumber = partNumber;
13.373 + }
13.374 +
13.375 + public MemoryDevice(byte type, ushort handle, byte[] data,
13.376 + string[] strings)
13.377 + : base(type, handle, data, strings) {
13.378 + this.manufacturerName = GetString(0x17).Trim();
13.379 + this.serialNumber = GetString(0x18).Trim();
13.380 + this.partNumber = GetString(0x1A).Trim();
13.381 + }
13.382 +
13.383 + public string ManufacturerName { get { return manufacturerName; } }
13.384 +
13.385 + public string SerialNumber { get { return serialNumber; } }
13.386 +
13.387 + public string PartNumber { get { return partNumber; } }
13.388 +
13.389 + }
13.390 + }
13.391 +}
14.1 --- a/OpenHardwareMonitorLib.csproj Sun Jul 22 18:07:11 2012 +0000
14.2 +++ b/OpenHardwareMonitorLib.csproj Mon Jul 23 21:54:35 2012 +0000
14.3 @@ -52,6 +52,7 @@
14.4 <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
14.5 </PropertyGroup>
14.6 <ItemGroup>
14.7 + <Reference Include="Microsoft.VisualBasic" />
14.8 <Reference Include="System" />
14.9 <Reference Include="System.Management" />
14.10 </ItemGroup>
14.11 @@ -91,8 +92,11 @@
14.12 <Compile Include="Hardware\CPU\IntelCPU.cs" />
14.13 <Compile Include="Hardware\LPC\NCT677X.cs" />
14.14 <Compile Include="Hardware\Mainboard\GigabyteTAMG.cs" />
14.15 + <Compile Include="Hardware\Mainboard\Identification.cs" />
14.16 <Compile Include="Hardware\Opcode.cs" />
14.17 <Compile Include="Hardware\OperatingSystem.cs" />
14.18 + <Compile Include="Hardware\RAM\GenericRAM.cs" />
14.19 + <Compile Include="Hardware\RAM\RAMGroup.cs" />
14.20 <Compile Include="Hardware\Ring0.cs" />
14.21 <Compile Include="Hardware\KernelDriver.cs" />
14.22 <Compile Include="Hardware\Hardware.cs" />
14.23 @@ -120,7 +124,7 @@
14.24 <Compile Include="Hardware\Mainboard\MainboardGroup.cs" />
14.25 <Compile Include="Hardware\Mainboard\Manufacturer.cs" />
14.26 <Compile Include="Hardware\Mainboard\Model.cs" />
14.27 - <Compile Include="Hardware\Mainboard\SMBIOS.cs" />
14.28 + <Compile Include="Hardware\SMBIOS.cs" />
14.29 <Compile Include="Hardware\Mainboard\SuperIOHardware.cs" />
14.30 <Compile Include="Hardware\Nvidia\NVAPI.cs" />
14.31 <Compile Include="Hardware\Nvidia\NvidiaGPU.cs" />
15.1 --- a/Utilities/HttpServer.cs Sun Jul 22 18:07:11 2012 +0000
15.2 +++ b/Utilities/HttpServer.cs Mon Jul 23 21:54:35 2012 +0000
15.3 @@ -315,6 +315,8 @@
15.4 return "chip.png";
15.5 case HardwareType.TBalancer:
15.6 return "bigng.png";
15.7 + case HardwareType.RAM:
15.8 + return "chip.png";
15.9 default:
15.10 return "cpu.png";
15.11 }