mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-30 13:57:38 +00:00
Added additional checks to SMBIOS parsing. New class HexStringArray is for debugging with report data.
This commit is contained in:
parent
7a48707225
commit
cb0a64e90c
@ -41,7 +41,7 @@ using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.LPC {
|
||||
public class F71882FG : IHardware {
|
||||
public class F71882 : IHardware {
|
||||
|
||||
private string name;
|
||||
private Image icon;
|
||||
@ -70,10 +70,10 @@ namespace OpenHardwareMonitor.Hardware.LPC {
|
||||
return WinRing0.ReadIoPortByte((ushort)(address + DATA_REGISTER_OFFSET));
|
||||
}
|
||||
|
||||
public F71882FG(ushort address) {
|
||||
public F71882(ushort address) {
|
||||
this.address = address;
|
||||
|
||||
this.name = "Fintek F71882FG";
|
||||
this.name = "Fintek F71882";
|
||||
|
||||
temperatures = new Sensor[3];
|
||||
for (int i = 0; i < temperatures.Length; i++)
|
@ -176,7 +176,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
|
||||
break;
|
||||
case Chip.F71882FG:
|
||||
if (vendorID == FINTEK_VENDOR_ID)
|
||||
hardware.Add(new F71882FG(address));
|
||||
hardware.Add(new F71882(address));
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
@ -144,6 +144,14 @@ namespace OpenHardwareMonitor.Hardware.SMBIOS {
|
||||
private byte[] data;
|
||||
private string[] strings;
|
||||
|
||||
protected string GetString(int offset) {
|
||||
if (offset < data.Length && data[offset] > 0 &&
|
||||
data[offset] <= strings.Length)
|
||||
return strings[data[offset] - 1];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
public Structure(byte type, ushort handle, byte[] data, string[] strings)
|
||||
{
|
||||
this.type = type;
|
||||
@ -159,18 +167,15 @@ namespace OpenHardwareMonitor.Hardware.SMBIOS {
|
||||
|
||||
public class BIOSInformation : Structure {
|
||||
|
||||
private string vendor = "";
|
||||
private string version = "";
|
||||
private string vendor;
|
||||
private string version;
|
||||
|
||||
public BIOSInformation(byte type, ushort handle, byte[] data,
|
||||
string[] strings)
|
||||
: base(type, handle, data, strings) {
|
||||
|
||||
if (data[0x04] > 0 && data[0x04] <= strings.Length)
|
||||
vendor = strings[data[0x04] - 1];
|
||||
|
||||
if (data[0x05] > 0 && data[0x05] <= strings.Length)
|
||||
version = strings[data[0x05] - 1];
|
||||
this.vendor = GetString(0x04);
|
||||
this.version = GetString(0x05);
|
||||
}
|
||||
|
||||
public string Vendor { get { return vendor; } }
|
||||
@ -180,18 +185,15 @@ namespace OpenHardwareMonitor.Hardware.SMBIOS {
|
||||
|
||||
public class BaseBoardInformation : Structure {
|
||||
|
||||
private string manufacturer = "";
|
||||
private string productName = "";
|
||||
private string manufacturer;
|
||||
private string productName;
|
||||
|
||||
public BaseBoardInformation(byte type, ushort handle, byte[] data,
|
||||
string[] strings)
|
||||
: base(type, handle, data, strings) {
|
||||
|
||||
if (data[0x04] > 0 && data[0x04] <= strings.Length)
|
||||
manufacturer = strings[data[0x04] - 1];
|
||||
|
||||
if (data[0x05] > 0 && data[0x05] <= strings.Length)
|
||||
productName = strings[data[0x05] - 1];
|
||||
this.manufacturer = GetString(0x04);
|
||||
this.productName = GetString(0x05);
|
||||
}
|
||||
|
||||
public string Manufacturer { get { return manufacturer; } }
|
||||
|
@ -62,7 +62,7 @@
|
||||
<Compile Include="Hardware\HDD\HDDGroup.cs" />
|
||||
<Compile Include="Hardware\HDD\SMART.cs" />
|
||||
<Compile Include="Hardware\LPC\Chip.cs" />
|
||||
<Compile Include="Hardware\LPC\F71882FG.cs" />
|
||||
<Compile Include="Hardware\LPC\F71882.cs" />
|
||||
<Compile Include="Hardware\SMBIOS\SMBIOSGroup.cs" />
|
||||
<Compile Include="Hardware\LPC\W83627DHG.cs" />
|
||||
<Compile Include="Hardware\ReportWriter.cs" />
|
||||
@ -94,6 +94,7 @@
|
||||
<Compile Include="Hardware\Nvidia\NVAPI.cs" />
|
||||
<Compile Include="Hardware\Nvidia\NvidiaGPU.cs" />
|
||||
<Compile Include="Hardware\Nvidia\NvidiaGroup.cs" />
|
||||
<Compile Include="Utilities\HexStringArray.cs" />
|
||||
<Compile Include="Utilities\PInvokeDelegateFactory.cs" />
|
||||
<Compile Include="GUI\PlotPanel.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
|
60
Utilities/HexStringArray.cs
Normal file
60
Utilities/HexStringArray.cs
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the License.
|
||||
|
||||
The Original Code is the Open Hardware Monitor code.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael Möller <m.moeller@gmx.ch>.
|
||||
Portions created by the Initial Developer are Copyright (C) 2009-2010
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Utilities {
|
||||
public class HexStringArray {
|
||||
|
||||
private byte[] array;
|
||||
|
||||
public HexStringArray(string input) {
|
||||
List<byte> list = new List<byte>();
|
||||
foreach (string str in input.Split(' ')) {
|
||||
if (str.Trim().Length > 0)
|
||||
list.Add(Convert.ToByte(str, 16));
|
||||
}
|
||||
array = list.ToArray();
|
||||
}
|
||||
|
||||
public byte this[int i] {
|
||||
get { return array[i]; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user