mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-09-02 07:15:31 +00:00
Fixed some Code Analysis warnings.
This commit is contained in:
@@ -41,6 +41,7 @@ using System.Collections.Generic;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace OpenHardwareMonitor.Collections {
|
namespace OpenHardwareMonitor.Collections {
|
||||||
|
|
||||||
public class ListSet<T> : IEnumerable<T> {
|
public class ListSet<T> : IEnumerable<T> {
|
||||||
|
|
||||||
private List<T> list = new List<T>();
|
private List<T> list = new List<T>();
|
||||||
|
@@ -66,5 +66,9 @@ namespace OpenHardwareMonitor.Collections {
|
|||||||
public static implicit operator ReadOnlyArray<T>(T[] array) {
|
public static implicit operator ReadOnlyArray<T>(T[] array) {
|
||||||
return new ReadOnlyArray<T>(array);
|
return new ReadOnlyArray<T>(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T[] ToArray() {
|
||||||
|
return (T[])array.Clone();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -159,7 +159,7 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
|
|
||||||
protected override void InsertItem(int index, Node item) {
|
protected override void InsertItem(int index, Node item) {
|
||||||
if (item == null)
|
if (item == null)
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException("item");
|
||||||
|
|
||||||
if (item.parent != owner) {
|
if (item.parent != owner) {
|
||||||
if (item.parent != null)
|
if (item.parent != null)
|
||||||
@@ -189,7 +189,7 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
|
|
||||||
protected override void SetItem(int index, Node item) {
|
protected override void SetItem(int index, Node item) {
|
||||||
if (item == null)
|
if (item == null)
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException("item");
|
||||||
|
|
||||||
RemoveAt(index);
|
RemoveAt(index);
|
||||||
InsertItem(index, item);
|
InsertItem(index, item);
|
||||||
|
@@ -156,7 +156,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
private static ADL_Adapter_AdapterInfo_GetDelegate
|
private static ADL_Adapter_AdapterInfo_GetDelegate
|
||||||
_ADL_Adapter_AdapterInfo_Get;
|
_ADL_Adapter_AdapterInfo_Get;
|
||||||
|
|
||||||
public static ADL_Main_Control_DestroyDelegate
|
public static ADL_Main_Control_DestroyDelegate
|
||||||
ADL_Main_Control_Destroy;
|
ADL_Main_Control_Destroy;
|
||||||
public static ADL_Adapter_NumberOfAdapters_GetDelegate
|
public static ADL_Adapter_NumberOfAdapters_GetDelegate
|
||||||
ADL_Adapter_NumberOfAdapters_Get;
|
ADL_Adapter_NumberOfAdapters_Get;
|
||||||
|
@@ -104,7 +104,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
report.Append("AdapterID: 0x");
|
report.Append("AdapterID: 0x");
|
||||||
report.AppendLine(adapterID.ToString("X", CultureInfo.InvariantCulture));
|
report.AppendLine(adapterID.ToString("X", CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
if (adapterID != 0 && adapterInfo[i].UDID != "" &&
|
if (adapterID != 0 && !string.IsNullOrEmpty(adapterInfo[i].UDID) &&
|
||||||
(adapterInfo[i].VendorID == ADL.ATI_VENDOR_ID1 ||
|
(adapterInfo[i].VendorID == ADL.ATI_VENDOR_ID1 ||
|
||||||
adapterInfo[i].VendorID == ADL.ATI_VENDOR_ID2)) {
|
adapterInfo[i].VendorID == ADL.ATI_VENDOR_ID2)) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
@@ -48,13 +48,13 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
|
|
||||||
private CPUID[][][] threads;
|
private CPUID[][][] threads;
|
||||||
|
|
||||||
private CPUID[][] GetProcessorThreads() {
|
private static CPUID[][] GetProcessorThreads() {
|
||||||
|
|
||||||
List<CPUID> threads = new List<CPUID>();
|
List<CPUID> threads = new List<CPUID>();
|
||||||
for (int i = 0; i < 32; i++) {
|
for (int i = 0; i < 32; i++) {
|
||||||
try {
|
try {
|
||||||
threads.Add(new CPUID(i));
|
threads.Add(new CPUID(i));
|
||||||
} catch (ArgumentException) { }
|
} catch (ArgumentOutOfRangeException) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
SortedDictionary<uint, List<CPUID>> processors =
|
SortedDictionary<uint, List<CPUID>> processors =
|
||||||
@@ -78,7 +78,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
return processorThreads;
|
return processorThreads;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CPUID[][] GroupThreadsByCore(CPUID[] threads) {
|
private static CPUID[][] GroupThreadsByCore(CPUID[] threads) {
|
||||||
|
|
||||||
SortedDictionary<uint, List<CPUID>> cores =
|
SortedDictionary<uint, List<CPUID>> cores =
|
||||||
new SortedDictionary<uint, List<CPUID>>();
|
new SortedDictionary<uint, List<CPUID>>();
|
||||||
@@ -151,7 +151,9 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AppendCpuidData(StringBuilder r, uint[,] data, uint offset) {
|
private static void AppendCpuidData(StringBuilder r, uint[,] data,
|
||||||
|
uint offset)
|
||||||
|
{
|
||||||
for (int i = 0; i < data.GetLength(0); i++) {
|
for (int i = 0; i < data.GetLength(0); i++) {
|
||||||
r.Append(" ");
|
r.Append(" ");
|
||||||
r.Append((i + offset).ToString("X8", CultureInfo.InvariantCulture));
|
r.Append((i + offset).ToString("X8", CultureInfo.InvariantCulture));
|
||||||
|
@@ -75,14 +75,14 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
public static uint CPUID_0 = 0;
|
public static uint CPUID_0 = 0;
|
||||||
public static uint CPUID_EXT = 0x80000000;
|
public static uint CPUID_EXT = 0x80000000;
|
||||||
|
|
||||||
private void AppendRegister(StringBuilder b, uint value) {
|
private static void AppendRegister(StringBuilder b, uint value) {
|
||||||
b.Append((char)((value) & 0xff));
|
b.Append((char)((value) & 0xff));
|
||||||
b.Append((char)((value >> 8) & 0xff));
|
b.Append((char)((value >> 8) & 0xff));
|
||||||
b.Append((char)((value >> 16) & 0xff));
|
b.Append((char)((value >> 16) & 0xff));
|
||||||
b.Append((char)((value >> 24) & 0xff));
|
b.Append((char)((value >> 24) & 0xff));
|
||||||
}
|
}
|
||||||
|
|
||||||
private uint NextLog2(long x) {
|
private static uint NextLog2(long x) {
|
||||||
if (x <= 0)
|
if (x <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
uint eax, ebx, ecx, edx;
|
uint eax, ebx, ecx, edx;
|
||||||
|
|
||||||
if (thread >= 32)
|
if (thread >= 32)
|
||||||
throw new ArgumentException();
|
throw new ArgumentOutOfRangeException("thread");
|
||||||
UIntPtr mask = (UIntPtr)(1L << thread);
|
UIntPtr mask = (UIntPtr)(1L << thread);
|
||||||
|
|
||||||
if (WinRing0.CpuidTx(CPUID_0, 0,
|
if (WinRing0.CpuidTx(CPUID_0, 0,
|
||||||
@@ -139,10 +139,10 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new ArgumentException();
|
throw new ArgumentOutOfRangeException("thread");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ArgumentException();
|
throw new ArgumentOutOfRangeException("thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
maxCpuid = Math.Min(maxCpuid, 1024);
|
maxCpuid = Math.Min(maxCpuid, 1024);
|
||||||
|
@@ -62,12 +62,6 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
SystemProcessorPerformanceInformation = 8
|
SystemProcessorPerformanceInformation = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("ntdll.dll")]
|
|
||||||
private static extern int NtQuerySystemInformation(
|
|
||||||
SystemInformationClass informationClass,
|
|
||||||
[Out] SystemProcessorPerformanceInformation[] informations,
|
|
||||||
int structSize, out IntPtr returnLength);
|
|
||||||
|
|
||||||
private CPUID[][] cpuid;
|
private CPUID[][] cpuid;
|
||||||
|
|
||||||
private long systemTime;
|
private long systemTime;
|
||||||
@@ -78,16 +72,17 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
|
|
||||||
private bool available = false;
|
private bool available = false;
|
||||||
|
|
||||||
private long[] GetIdleTimes() {
|
private static long[] GetIdleTimes() {
|
||||||
SystemProcessorPerformanceInformation[] informations = new
|
SystemProcessorPerformanceInformation[] informations = new
|
||||||
SystemProcessorPerformanceInformation[64];
|
SystemProcessorPerformanceInformation[64];
|
||||||
|
|
||||||
int size = Marshal.SizeOf(typeof(SystemProcessorPerformanceInformation));
|
int size = Marshal.SizeOf(typeof(SystemProcessorPerformanceInformation));
|
||||||
|
|
||||||
IntPtr returnLength;
|
IntPtr returnLength;
|
||||||
NtQuerySystemInformation(
|
if (NativeMethods.NtQuerySystemInformation(
|
||||||
SystemInformationClass.SystemProcessorPerformanceInformation,
|
SystemInformationClass.SystemProcessorPerformanceInformation,
|
||||||
informations, informations.Length * size, out returnLength);
|
informations, informations.Length * size, out returnLength) != 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
long[] result = new long[(int)returnLength / size];
|
long[] result = new long[(int)returnLength / size];
|
||||||
|
|
||||||
@@ -127,10 +122,13 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
if (this.idleTimes == null)
|
if (this.idleTimes == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long localSystemTime = DateTime.Now.Ticks;
|
long newSystemTime = DateTime.Now.Ticks;
|
||||||
long[] localIdleTimes = GetIdleTimes();
|
long[] newIdleTimes = GetIdleTimes();
|
||||||
|
|
||||||
if (localSystemTime - this.systemTime < 10000)
|
if (newSystemTime - this.systemTime < 10000)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (newIdleTimes == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float total = 0;
|
float total = 0;
|
||||||
@@ -139,29 +137,37 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
float value = 0;
|
float value = 0;
|
||||||
for (int j = 0; j < cpuid[i].Length; j++) {
|
for (int j = 0; j < cpuid[i].Length; j++) {
|
||||||
long index = cpuid[i][j].Thread;
|
long index = cpuid[i][j].Thread;
|
||||||
if (index < localIdleTimes.Length) {
|
if (index < newIdleTimes.Length) {
|
||||||
long delta = localIdleTimes[index] - this.idleTimes[index];
|
long delta = newIdleTimes[index] - this.idleTimes[index];
|
||||||
value += delta;
|
value += delta;
|
||||||
total += delta;
|
total += delta;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
value = 1.0f - value / (cpuid[i].Length *
|
value = 1.0f - value / (cpuid[i].Length *
|
||||||
(localSystemTime - this.systemTime));
|
(newSystemTime - this.systemTime));
|
||||||
value = value < 0 ? 0 : value;
|
value = value < 0 ? 0 : value;
|
||||||
coreLoads[i] = value * 100;
|
coreLoads[i] = value * 100;
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
total = 1.0f - total / (count * (localSystemTime - this.systemTime));
|
total = 1.0f - total / (count * (newSystemTime - this.systemTime));
|
||||||
total = total < 0 ? 0 : total;
|
total = total < 0 ? 0 : total;
|
||||||
} else {
|
} else {
|
||||||
total = 0;
|
total = 0;
|
||||||
}
|
}
|
||||||
this.totalLoad = total * 100;
|
this.totalLoad = total * 100;
|
||||||
|
|
||||||
this.systemTime = localSystemTime;
|
this.systemTime = newSystemTime;
|
||||||
this.idleTimes = localIdleTimes;
|
this.idleTimes = newIdleTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class NativeMethods {
|
||||||
|
|
||||||
|
[DllImport("ntdll.dll")]
|
||||||
|
public static extern int NtQuerySystemInformation(
|
||||||
|
SystemInformationClass informationClass,
|
||||||
|
[Out] SystemProcessorPerformanceInformation[] informations,
|
||||||
|
int structSize, out IntPtr returnLength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -253,7 +253,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
get { return HardwareType.CPU; }
|
get { return HardwareType.CPU; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AppendMSRData(StringBuilder r, uint msr, int thread) {
|
private static void AppendMSRData(StringBuilder r, uint msr, int thread) {
|
||||||
uint eax, edx;
|
uint eax, edx;
|
||||||
if (WinRing0.RdmsrTx(msr, out eax, out edx, (UIntPtr)(1L << thread))) {
|
if (WinRing0.RdmsrTx(msr, out eax, out edx, (UIntPtr)(1L << thread))) {
|
||||||
r.Append(" ");
|
r.Append(" ");
|
||||||
@@ -298,7 +298,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
return r.ToString();
|
return r.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private double EstimateMaxClock(double timeWindow) {
|
private static double EstimateMaxClock(double timeWindow) {
|
||||||
long ticks = (long)(timeWindow * Stopwatch.Frequency);
|
long ticks = (long)(timeWindow * Stopwatch.Frequency);
|
||||||
uint lsbBegin, msbBegin, lsbEnd, msbEnd;
|
uint lsbBegin, msbBegin, lsbEnd, msbEnd;
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
else
|
else
|
||||||
maxClock = estimatedMaxClock;
|
maxClock = estimatedMaxClock;
|
||||||
|
|
||||||
double busClock = 0;
|
double newBusClock = 0;
|
||||||
uint eax, edx;
|
uint eax, edx;
|
||||||
for (int i = 0; i < coreClocks.Length; i++) {
|
for (int i = 0; i < coreClocks.Length; i++) {
|
||||||
System.Threading.Thread.Sleep(1);
|
System.Threading.Thread.Sleep(1);
|
||||||
@@ -369,7 +369,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
uint nehalemMultiplier = eax & 0xff;
|
uint nehalemMultiplier = eax & 0xff;
|
||||||
coreClocks[i].Value =
|
coreClocks[i].Value =
|
||||||
(float)(nehalemMultiplier * maxClock / maxNehalemMultiplier);
|
(float)(nehalemMultiplier * maxClock / maxNehalemMultiplier);
|
||||||
busClock = (float)(maxClock / maxNehalemMultiplier);
|
newBusClock = (float)(maxClock / maxNehalemMultiplier);
|
||||||
} else { // Core 2
|
} else { // Core 2
|
||||||
uint multiplier = (eax >> 8) & 0x1f;
|
uint multiplier = (eax >> 8) & 0x1f;
|
||||||
uint maxMultiplier = (edx >> 8) & 0x1f;
|
uint maxMultiplier = (edx >> 8) & 0x1f;
|
||||||
@@ -378,7 +378,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
uint maxFactor = (maxMultiplier << 1) | ((edx >> 14) & 1);
|
uint maxFactor = (maxMultiplier << 1) | ((edx >> 14) & 1);
|
||||||
if (maxFactor > 0) {
|
if (maxFactor > 0) {
|
||||||
coreClocks[i].Value = (float)(factor * maxClock / maxFactor);
|
coreClocks[i].Value = (float)(factor * maxClock / maxFactor);
|
||||||
busClock = (float)(2 * maxClock / maxFactor);
|
newBusClock = (float)(2 * maxClock / maxFactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // Intel Pentium 4
|
} else { // Intel Pentium 4
|
||||||
@@ -386,8 +386,8 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
|||||||
coreClocks[i].Value = (float)maxClock;
|
coreClocks[i].Value = (float)maxClock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (busClock > 0) {
|
if (newBusClock > 0) {
|
||||||
this.busClock.Value = (float)busClock;
|
this.busClock.Value = (float)newBusClock;
|
||||||
ActivateSensor(this.busClock);
|
ActivateSensor(this.busClock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,9 @@ using System.IO;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Security;
|
||||||
|
using System.Security.Permissions;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenHardwareMonitor.Hardware {
|
namespace OpenHardwareMonitor.Hardware {
|
||||||
|
|
||||||
@@ -86,10 +89,13 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
HardwareRemoved(hardware);
|
HardwareRemoved(hardware);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||||
public void Open() {
|
public void Open() {
|
||||||
if (open)
|
if (open)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
WinRing0.Open();
|
||||||
|
|
||||||
Add(new Mainboard.MainboardGroup(settings));
|
Add(new Mainboard.MainboardGroup(settings));
|
||||||
Add(new CPU.CPUGroup(settings));
|
Add(new CPU.CPUGroup(settings));
|
||||||
Add(new ATI.ATIGroup(settings));
|
Add(new ATI.ATIGroup(settings));
|
||||||
@@ -101,9 +107,11 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
|
|
||||||
open = true;
|
open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HDDEnabled {
|
public bool HDDEnabled {
|
||||||
get { return hddEnabled; }
|
get { return hddEnabled; }
|
||||||
|
|
||||||
|
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||||
set {
|
set {
|
||||||
if (open && value && !hddEnabled) {
|
if (open && value && !hddEnabled) {
|
||||||
Add(new HDD.HDDGroup(settings));
|
Add(new HDD.HDDGroup(settings));
|
||||||
@@ -129,7 +137,7 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NewSection(TextWriter writer) {
|
private static void NewSection(TextWriter writer) {
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
writer.Write("----------");
|
writer.Write("----------");
|
||||||
writer.WriteLine();
|
writer.WriteLine();
|
||||||
@@ -186,7 +194,7 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
|
|
||||||
private void ReportHardware(IHardware hardware, TextWriter w) {
|
private void ReportHardware(IHardware hardware, TextWriter w) {
|
||||||
string hardwareReport = hardware.GetReport();
|
string hardwareReport = hardware.GetReport();
|
||||||
if (hardwareReport != null && hardwareReport != "") {
|
if (!string.IsNullOrEmpty(hardwareReport)) {
|
||||||
NewSection(w);
|
NewSection(w);
|
||||||
w.Write(hardwareReport);
|
w.Write(hardwareReport);
|
||||||
}
|
}
|
||||||
@@ -237,7 +245,7 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
|
|
||||||
foreach (IGroup group in groups) {
|
foreach (IGroup group in groups) {
|
||||||
string report = group.GetReport();
|
string report = group.GetReport();
|
||||||
if (report != null && report != "") {
|
if (!string.IsNullOrEmpty(report)) {
|
||||||
NewSection(w);
|
NewSection(w);
|
||||||
w.Write(report);
|
w.Write(report);
|
||||||
}
|
}
|
||||||
@@ -259,6 +267,8 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
group.Close();
|
group.Close();
|
||||||
groups.Clear();
|
groups.Clear();
|
||||||
|
|
||||||
|
WinRing0.Close();
|
||||||
|
|
||||||
open = false;
|
open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,8 +276,9 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
public event HardwareEventHandler HardwareRemoved;
|
public event HardwareEventHandler HardwareRemoved;
|
||||||
|
|
||||||
public void Accept(IVisitor visitor) {
|
public void Accept(IVisitor visitor) {
|
||||||
if (visitor != null)
|
if (visitor == null)
|
||||||
visitor.VisitComputer(this);
|
throw new ArgumentNullException("visitor");
|
||||||
|
visitor.VisitComputer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Traverse(IVisitor visitor) {
|
public void Traverse(IVisitor visitor) {
|
||||||
|
@@ -117,8 +117,9 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
#pragma warning restore 67
|
#pragma warning restore 67
|
||||||
|
|
||||||
public void Accept(IVisitor visitor) {
|
public void Accept(IVisitor visitor) {
|
||||||
if (visitor != null)
|
if (visitor == null)
|
||||||
visitor.VisitHardware(this);
|
throw new ArgumentNullException("visitor");
|
||||||
|
visitor.VisitHardware(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Traverse(IVisitor visitor) { }
|
public void Traverse(IVisitor visitor) { }
|
||||||
|
@@ -232,37 +232,10 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
|
|
||||||
private const int MAX_DRIVE_ATTRIBUTES = 512;
|
private const int MAX_DRIVE_ATTRIBUTES = 512;
|
||||||
|
|
||||||
private const string KERNEL = "kernel32.dll";
|
private SMART() { }
|
||||||
|
|
||||||
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
|
||||||
private static extern IntPtr CreateFile(string fileName,
|
|
||||||
AccessMode desiredAccess, ShareMode shareMode, IntPtr securityAttributes,
|
|
||||||
CreationMode creationDisposition, FileAttribute flagsAndAttributes,
|
|
||||||
IntPtr templateFilehandle);
|
|
||||||
|
|
||||||
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
|
||||||
public static extern int CloseHandle(IntPtr handle);
|
|
||||||
|
|
||||||
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
|
||||||
private static extern bool DeviceIoControl(IntPtr handle,
|
|
||||||
DriveCommand command, ref DriveCommandParameter parameter,
|
|
||||||
int parameterSize, out DriveSmartReadResult result, int resultSize,
|
|
||||||
out uint bytesReturned, IntPtr overlapped);
|
|
||||||
|
|
||||||
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
|
||||||
private static extern bool DeviceIoControl(IntPtr handle,
|
|
||||||
DriveCommand command, ref DriveCommandParameter parameter,
|
|
||||||
int parameterSize, out DriveCommandResult result, int resultSize,
|
|
||||||
out uint bytesReturned, IntPtr overlapped);
|
|
||||||
|
|
||||||
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
|
||||||
private static extern bool DeviceIoControl(IntPtr handle,
|
|
||||||
DriveCommand command, ref DriveCommandParameter parameter,
|
|
||||||
int parameterSize, out DriveIdentifyResult result, int resultSize,
|
|
||||||
out uint bytesReturned, IntPtr overlapped);
|
|
||||||
|
|
||||||
public static IntPtr OpenPhysicalDrive(int driveNumber) {
|
public static IntPtr OpenPhysicalDrive(int driveNumber) {
|
||||||
return CreateFile(@"\\.\PhysicalDrive" + driveNumber,
|
return NativeMethods.CreateFile(@"\\.\PhysicalDrive" + driveNumber,
|
||||||
AccessMode.Read | AccessMode.Write, ShareMode.Read | ShareMode.Write,
|
AccessMode.Read | AccessMode.Write, ShareMode.Read | ShareMode.Write,
|
||||||
IntPtr.Zero, CreationMode.OpenExisting, FileAttribute.Device,
|
IntPtr.Zero, CreationMode.OpenExisting, FileAttribute.Device,
|
||||||
IntPtr.Zero);
|
IntPtr.Zero);
|
||||||
@@ -279,8 +252,8 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
parameter.Registers.LBAHigh = SMART_LBA_HI;
|
parameter.Registers.LBAHigh = SMART_LBA_HI;
|
||||||
parameter.Registers.Command = SMART_CMD;
|
parameter.Registers.Command = SMART_CMD;
|
||||||
|
|
||||||
return DeviceIoControl(handle, DriveCommand.SendDriveCommand,
|
return NativeMethods.DeviceIoControl(handle, DriveCommand.SendDriveCommand,
|
||||||
ref parameter, Marshal.SizeOf(parameter), out result,
|
ref parameter, Marshal.SizeOf(typeof(DriveCommandParameter)), out result,
|
||||||
Marshal.SizeOf(typeof(DriveCommandResult)), out bytesReturned,
|
Marshal.SizeOf(typeof(DriveCommandResult)), out bytesReturned,
|
||||||
IntPtr.Zero);
|
IntPtr.Zero);
|
||||||
}
|
}
|
||||||
@@ -296,10 +269,10 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
parameter.Registers.LBAHigh = SMART_LBA_HI;
|
parameter.Registers.LBAHigh = SMART_LBA_HI;
|
||||||
parameter.Registers.Command = SMART_CMD;
|
parameter.Registers.Command = SMART_CMD;
|
||||||
|
|
||||||
bool valid = DeviceIoControl(handle, DriveCommand.ReceiveDriveData,
|
bool valid = NativeMethods.DeviceIoControl(handle,
|
||||||
ref parameter, Marshal.SizeOf(parameter), out result,
|
DriveCommand.ReceiveDriveData, ref parameter, Marshal.SizeOf(parameter),
|
||||||
Marshal.SizeOf(typeof(DriveSmartReadResult)), out bytesReturned,
|
out result, Marshal.SizeOf(typeof(DriveSmartReadResult)),
|
||||||
IntPtr.Zero);
|
out bytesReturned, IntPtr.Zero);
|
||||||
|
|
||||||
if (!valid)
|
if (!valid)
|
||||||
return null;
|
return null;
|
||||||
@@ -315,10 +288,10 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
parameter.DriveNumber = (byte)driveNumber;
|
parameter.DriveNumber = (byte)driveNumber;
|
||||||
parameter.Registers.Command = ID_CMD;
|
parameter.Registers.Command = ID_CMD;
|
||||||
|
|
||||||
bool valid = DeviceIoControl(handle, DriveCommand.ReceiveDriveData,
|
bool valid = NativeMethods.DeviceIoControl(handle,
|
||||||
ref parameter, Marshal.SizeOf(parameter), out result,
|
DriveCommand.ReceiveDriveData, ref parameter, Marshal.SizeOf(parameter),
|
||||||
Marshal.SizeOf(typeof(DriveIdentifyResult)), out bytesReturned,
|
out result, Marshal.SizeOf(typeof(DriveIdentifyResult)),
|
||||||
IntPtr.Zero);
|
out bytesReturned, IntPtr.Zero);
|
||||||
|
|
||||||
if (!valid)
|
if (!valid)
|
||||||
return null;
|
return null;
|
||||||
@@ -335,5 +308,43 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int CloseHandle(IntPtr handle) {
|
||||||
|
return NativeMethods.CloseHandle(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class NativeMethods {
|
||||||
|
private const string KERNEL = "kernel32.dll";
|
||||||
|
|
||||||
|
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi,
|
||||||
|
CharSet = CharSet.Unicode)]
|
||||||
|
public static extern IntPtr CreateFile(string fileName,
|
||||||
|
AccessMode desiredAccess, ShareMode shareMode, IntPtr securityAttributes,
|
||||||
|
CreationMode creationDisposition, FileAttribute flagsAndAttributes,
|
||||||
|
IntPtr templateFilehandle);
|
||||||
|
|
||||||
|
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
public static extern int CloseHandle(IntPtr handle);
|
||||||
|
|
||||||
|
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
[return: MarshalAsAttribute(UnmanagedType.Bool)]
|
||||||
|
public static extern bool DeviceIoControl(IntPtr handle,
|
||||||
|
DriveCommand command, ref DriveCommandParameter parameter,
|
||||||
|
int parameterSize, out DriveSmartReadResult result, int resultSize,
|
||||||
|
out uint bytesReturned, IntPtr overlapped);
|
||||||
|
|
||||||
|
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
[return: MarshalAsAttribute(UnmanagedType.Bool)]
|
||||||
|
public static extern bool DeviceIoControl(IntPtr handle,
|
||||||
|
DriveCommand command, ref DriveCommandParameter parameter,
|
||||||
|
int parameterSize, out DriveCommandResult result, int resultSize,
|
||||||
|
out uint bytesReturned, IntPtr overlapped);
|
||||||
|
|
||||||
|
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
[return: MarshalAsAttribute(UnmanagedType.Bool)]
|
||||||
|
public static extern bool DeviceIoControl(IntPtr handle,
|
||||||
|
DriveCommand command, ref DriveCommandParameter parameter,
|
||||||
|
int parameterSize, out DriveIdentifyResult result, int resultSize,
|
||||||
|
out uint bytesReturned, IntPtr overlapped);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -80,8 +80,9 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
public abstract void Update();
|
public abstract void Update();
|
||||||
|
|
||||||
public void Accept(IVisitor visitor) {
|
public void Accept(IVisitor visitor) {
|
||||||
if (visitor != null)
|
if (visitor == null)
|
||||||
visitor.VisitHardware(this);
|
throw new ArgumentNullException("visitor");
|
||||||
|
visitor.VisitHardware(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Traverse(IVisitor visitor) {
|
public void Traverse(IVisitor visitor) {
|
||||||
|
@@ -46,7 +46,7 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
|
|
||||||
IHardware[] Hardware { get; }
|
IHardware[] Hardware { get; }
|
||||||
|
|
||||||
bool HDDEnabled { get; set; }
|
bool HDDEnabled { get; }
|
||||||
|
|
||||||
string GetReport();
|
string GetReport();
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
|
|
||||||
private static char SEPARATOR = '/';
|
private static char SEPARATOR = '/';
|
||||||
|
|
||||||
private void CheckIdentifiers(string[] identifiers) {
|
private static void CheckIdentifiers(string[] identifiers) {
|
||||||
foreach (string s in identifiers)
|
foreach (string s in identifiers)
|
||||||
if (s.Contains(" ") || s.Contains(SEPARATOR.ToString()))
|
if (s.Contains(" ") || s.Contains(SEPARATOR.ToString()))
|
||||||
throw new ArgumentException("Invalid identifier");
|
throw new ArgumentException("Invalid identifier");
|
||||||
|
@@ -25,7 +25,39 @@ namespace OpenHardwareMonitor.Hardware.LPC {
|
|||||||
F71869 = 0x0814,
|
F71869 = 0x0814,
|
||||||
F71882 = 0x0541,
|
F71882 = 0x0541,
|
||||||
F71889ED = 0x0909,
|
F71889ED = 0x0909,
|
||||||
F71889F = 0x0723
|
F71889F = 0x0723
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class ChipName {
|
||||||
|
|
||||||
|
private ChipName() { }
|
||||||
|
|
||||||
|
public static string GetName(Chip chip) {
|
||||||
|
switch (chip) {
|
||||||
|
case Chip.F71858: return "Fintek F71858";
|
||||||
|
case Chip.F71862: return "Fintek F71862";
|
||||||
|
case Chip.F71869: return "Fintek F71869";
|
||||||
|
case Chip.F71882: return "Fintek F71882";
|
||||||
|
case Chip.F71889ED: return "Fintek F71889ED";
|
||||||
|
case Chip.F71889F: return "Fintek F71889F";
|
||||||
|
case Chip.IT8712F: return "ITE IT8712F";
|
||||||
|
case Chip.IT8716F: return "ITE IT8716F";
|
||||||
|
case Chip.IT8718F: return "ITE IT8718F";
|
||||||
|
case Chip.IT8720F: return "ITE IT8720F";
|
||||||
|
case Chip.IT8726F: return "ITE IT8726F";
|
||||||
|
case Chip.W83627DHG: return "Winbond W83627DHG";
|
||||||
|
case Chip.W83627DHGP: return "Winbond W83627DHG-P";
|
||||||
|
case Chip.W83627EHF: return "Winbond W83627EHF";
|
||||||
|
case Chip.W83627HF: return "Winbond W83627HF";
|
||||||
|
case Chip.W83627THF: return "Winbond W83627THF";
|
||||||
|
case Chip.W83667HG: return "Winbond W83667HG";
|
||||||
|
case Chip.W83667HGB: return "Winbond W83667HG-B";
|
||||||
|
case Chip.W83687THF: return "Winbond W83687THF";
|
||||||
|
case Chip.Unknown: return "Unkown";
|
||||||
|
default: return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -51,9 +51,8 @@ namespace OpenHardwareMonitor.Hardware.LPC {
|
|||||||
foreach (string path in devicePaths) {
|
foreach (string path in devicePaths) {
|
||||||
string name = null;
|
string name = null;
|
||||||
try {
|
try {
|
||||||
StreamReader reader = new StreamReader(path + "/device/name");
|
using (StreamReader reader = new StreamReader(path + "/device/name"))
|
||||||
name = reader.ReadLine();
|
name = reader.ReadLine();
|
||||||
reader.Close();
|
|
||||||
} catch (IOException) { }
|
} catch (IOException) { }
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "f71858fg":
|
case "f71858fg":
|
||||||
|
@@ -47,8 +47,6 @@ namespace OpenHardwareMonitor.Hardware.LPC {
|
|||||||
private List<ISuperIO> superIOs = new List<ISuperIO>();
|
private List<ISuperIO> superIOs = new List<ISuperIO>();
|
||||||
private StringBuilder report = new StringBuilder();
|
private StringBuilder report = new StringBuilder();
|
||||||
|
|
||||||
private Chip chip = Chip.Unknown;
|
|
||||||
|
|
||||||
// I/O Ports
|
// I/O Ports
|
||||||
private ushort[] REGISTER_PORTS = new ushort[] { 0x2e, 0x4e };
|
private ushort[] REGISTER_PORTS = new ushort[] { 0x2e, 0x4e };
|
||||||
private ushort[] VALUE_PORTS = new ushort[] { 0x2f, 0x4f };
|
private ushort[] VALUE_PORTS = new ushort[] { 0x2f, 0x4f };
|
||||||
@@ -121,261 +119,290 @@ namespace OpenHardwareMonitor.Hardware.LPC {
|
|||||||
WinRing0.WriteIoPortByte(registerPort, 0xAA);
|
WinRing0.WriteIoPortByte(registerPort, 0xAA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ReportUnknownChip(string type, int chip) {
|
||||||
|
report.Append("Chip ID: Unknown ");
|
||||||
|
report.Append(type);
|
||||||
|
report.Append(" with ID 0x");
|
||||||
|
report.Append(chip.ToString("X", CultureInfo.InvariantCulture));
|
||||||
|
report.Append(" at 0x");
|
||||||
|
report.Append(registerPort.ToString("X", CultureInfo.InvariantCulture));
|
||||||
|
report.Append("/0x");
|
||||||
|
report.AppendLine(valuePort.ToString("X", CultureInfo.InvariantCulture));
|
||||||
|
report.AppendLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool DetectWinbondFintek() {
|
||||||
|
WinbondFintekEnter();
|
||||||
|
|
||||||
|
byte logicalDeviceNumber;
|
||||||
|
byte id = ReadByte(CHIP_ID_REGISTER);
|
||||||
|
byte revision = ReadByte(CHIP_REVISION_REGISTER);
|
||||||
|
Chip chip = Chip.Unknown;
|
||||||
|
logicalDeviceNumber = 0;
|
||||||
|
switch (id) {
|
||||||
|
case 0x05:
|
||||||
|
switch (revision) {
|
||||||
|
case 0x07:
|
||||||
|
chip = Chip.F71858;
|
||||||
|
logicalDeviceNumber = F71858_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
case 0x41:
|
||||||
|
chip = Chip.F71882;
|
||||||
|
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0x06:
|
||||||
|
switch (revision) {
|
||||||
|
case 0x01:
|
||||||
|
chip = Chip.F71862;
|
||||||
|
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0x07:
|
||||||
|
switch (revision) {
|
||||||
|
case 0x23:
|
||||||
|
chip = Chip.F71889F;
|
||||||
|
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0x08:
|
||||||
|
switch (revision) {
|
||||||
|
case 0x14:
|
||||||
|
chip = Chip.F71869;
|
||||||
|
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0x09:
|
||||||
|
switch (revision) {
|
||||||
|
case 0x09:
|
||||||
|
chip = Chip.F71889ED;
|
||||||
|
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0x52:
|
||||||
|
switch (revision) {
|
||||||
|
case 0x17:
|
||||||
|
case 0x3A:
|
||||||
|
case 0x41:
|
||||||
|
chip = Chip.W83627HF;
|
||||||
|
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0x82:
|
||||||
|
switch (revision & 0xF0) {
|
||||||
|
case 0x80:
|
||||||
|
chip = Chip.W83627THF;
|
||||||
|
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0x85:
|
||||||
|
switch (revision) {
|
||||||
|
case 0x41:
|
||||||
|
chip = Chip.W83687THF;
|
||||||
|
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0x88:
|
||||||
|
switch (revision & 0xF0) {
|
||||||
|
case 0x50:
|
||||||
|
case 0x60:
|
||||||
|
chip = Chip.W83627EHF;
|
||||||
|
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0xA0:
|
||||||
|
switch (revision & 0xF0) {
|
||||||
|
case 0x20:
|
||||||
|
chip = Chip.W83627DHG;
|
||||||
|
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0xA5:
|
||||||
|
switch (revision & 0xF0) {
|
||||||
|
case 0x10:
|
||||||
|
chip = Chip.W83667HG;
|
||||||
|
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0xB0:
|
||||||
|
switch (revision & 0xF0) {
|
||||||
|
case 0x70:
|
||||||
|
chip = Chip.W83627DHGP;
|
||||||
|
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
case 0xB3:
|
||||||
|
switch (revision & 0xF0) {
|
||||||
|
case 0x50:
|
||||||
|
chip = Chip.W83667HGB;
|
||||||
|
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
if (chip == Chip.Unknown) {
|
||||||
|
if (id != 0 && id != 0xff) {
|
||||||
|
WinbondFintekExit();
|
||||||
|
|
||||||
|
ReportUnknownChip("Winbond / Fintek", ((id << 8) | revision));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
Select(logicalDeviceNumber);
|
||||||
|
ushort address = ReadWord(BASE_ADDRESS_REGISTER);
|
||||||
|
Thread.Sleep(1);
|
||||||
|
ushort verify = ReadWord(BASE_ADDRESS_REGISTER);
|
||||||
|
|
||||||
|
ushort vendorID = ReadWord(FINTEK_VENDOR_ID_REGISTER);
|
||||||
|
|
||||||
|
WinbondFintekExit();
|
||||||
|
|
||||||
|
if (address != verify) {
|
||||||
|
report.Append("Chip ID: 0x");
|
||||||
|
report.AppendLine(chip.ToString("X"));
|
||||||
|
report.Append("Chip revision: 0x");
|
||||||
|
report.AppendLine(revision.ToString("X",
|
||||||
|
CultureInfo.InvariantCulture));
|
||||||
|
report.AppendLine("Error: Address verification failed");
|
||||||
|
report.AppendLine();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// some Fintek chips have address register offset 0x05 added already
|
||||||
|
if ((address & 0x07) == 0x05)
|
||||||
|
address &= 0xFFF8;
|
||||||
|
|
||||||
|
if (address < 0x100 || (address & 0xF007) != 0) {
|
||||||
|
report.Append("Chip ID: 0x");
|
||||||
|
report.AppendLine(chip.ToString("X"));
|
||||||
|
report.Append("Chip revision: 0x");
|
||||||
|
report.AppendLine(revision.ToString("X",
|
||||||
|
CultureInfo.InvariantCulture));
|
||||||
|
report.Append("Error: Invalid address 0x");
|
||||||
|
report.AppendLine(address.ToString("X",
|
||||||
|
CultureInfo.InvariantCulture));
|
||||||
|
report.AppendLine();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (chip) {
|
||||||
|
case Chip.W83627DHG:
|
||||||
|
case Chip.W83627DHGP:
|
||||||
|
case Chip.W83627EHF:
|
||||||
|
case Chip.W83627HF:
|
||||||
|
case Chip.W83627THF:
|
||||||
|
case Chip.W83667HG:
|
||||||
|
case Chip.W83667HGB:
|
||||||
|
case Chip.W83687THF:
|
||||||
|
superIOs.Add(new W836XX(chip, revision, address));
|
||||||
|
break;
|
||||||
|
case Chip.F71858:
|
||||||
|
case Chip.F71862:
|
||||||
|
case Chip.F71869:
|
||||||
|
case Chip.F71882:
|
||||||
|
case Chip.F71889ED:
|
||||||
|
case Chip.F71889F:
|
||||||
|
if (vendorID != FINTEK_VENDOR_ID) {
|
||||||
|
report.Append("Chip ID: 0x");
|
||||||
|
report.AppendLine(chip.ToString("X"));
|
||||||
|
report.Append("Chip revision: 0x");
|
||||||
|
report.AppendLine(revision.ToString("X",
|
||||||
|
CultureInfo.InvariantCulture));
|
||||||
|
report.Append("Error: Invalid vendor ID 0x");
|
||||||
|
report.AppendLine(vendorID.ToString("X",
|
||||||
|
CultureInfo.InvariantCulture));
|
||||||
|
report.AppendLine();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
superIOs.Add(new F718XX(chip, address));
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool DetectIT87() {
|
||||||
|
IT87Enter();
|
||||||
|
|
||||||
|
ushort chipID = ReadWord(CHIP_ID_REGISTER);
|
||||||
|
Chip chip;
|
||||||
|
switch (chipID) {
|
||||||
|
case 0x8712: chip = Chip.IT8712F; break;
|
||||||
|
case 0x8716: chip = Chip.IT8716F; break;
|
||||||
|
case 0x8718: chip = Chip.IT8718F; break;
|
||||||
|
case 0x8720: chip = Chip.IT8720F; break;
|
||||||
|
case 0x8726: chip = Chip.IT8726F; break;
|
||||||
|
default: chip = Chip.Unknown; break;
|
||||||
|
}
|
||||||
|
if (chip == Chip.Unknown) {
|
||||||
|
if (chipID != 0 && chipID != 0xffff) {
|
||||||
|
IT87Exit();
|
||||||
|
|
||||||
|
ReportUnknownChip("ITE", chipID);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Select(IT87_ENVIRONMENT_CONTROLLER_LDN);
|
||||||
|
ushort address = ReadWord(BASE_ADDRESS_REGISTER);
|
||||||
|
Thread.Sleep(1);
|
||||||
|
ushort verify = ReadWord(BASE_ADDRESS_REGISTER);
|
||||||
|
|
||||||
|
byte version = (byte)(ReadByte(IT87_CHIP_VERSION_REGISTER) & 0x0F);
|
||||||
|
|
||||||
|
IT87Exit();
|
||||||
|
|
||||||
|
if (address != verify || address < 0x100 || (address & 0xF007) != 0) {
|
||||||
|
report.Append("Chip ID: 0x");
|
||||||
|
report.AppendLine(chip.ToString("X"));
|
||||||
|
report.Append("Error: Invalid address 0x");
|
||||||
|
report.AppendLine(address.ToString("X",
|
||||||
|
CultureInfo.InvariantCulture));
|
||||||
|
report.AppendLine();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
superIOs.Add(new IT87XX(chip, address, version));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool DetectSMSC() {
|
||||||
|
SMSCEnter();
|
||||||
|
|
||||||
|
ushort chipID = ReadWord(CHIP_ID_REGISTER);
|
||||||
|
Chip chip;
|
||||||
|
switch (chipID) {
|
||||||
|
default: chip = Chip.Unknown; break;
|
||||||
|
}
|
||||||
|
if (chip == Chip.Unknown) {
|
||||||
|
if (chipID != 0 && chipID != 0xffff) {
|
||||||
|
SMSCExit();
|
||||||
|
|
||||||
|
ReportUnknownChip("SMSC", chipID);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SMSCExit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void Detect() {
|
private void Detect() {
|
||||||
|
|
||||||
for (int i = 0; i < REGISTER_PORTS.Length; i++) {
|
for (int i = 0; i < REGISTER_PORTS.Length; i++) {
|
||||||
registerPort = REGISTER_PORTS[i];
|
registerPort = REGISTER_PORTS[i];
|
||||||
valuePort = VALUE_PORTS[i];
|
valuePort = VALUE_PORTS[i];
|
||||||
|
|
||||||
WinbondFintekEnter();
|
if (DetectWinbondFintek()) continue;
|
||||||
|
|
||||||
byte logicalDeviceNumber;
|
if (DetectIT87()) continue;
|
||||||
byte id = ReadByte(CHIP_ID_REGISTER);
|
|
||||||
byte revision = ReadByte(CHIP_REVISION_REGISTER);
|
|
||||||
chip = Chip.Unknown;
|
|
||||||
logicalDeviceNumber = 0;
|
|
||||||
switch (id) {
|
|
||||||
case 0x05:
|
|
||||||
switch (revision) {
|
|
||||||
case 0x07:
|
|
||||||
chip = Chip.F71858;
|
|
||||||
logicalDeviceNumber = F71858_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
case 0x41:
|
|
||||||
chip = Chip.F71882;
|
|
||||||
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0x06:
|
|
||||||
switch (revision) {
|
|
||||||
case 0x01:
|
|
||||||
chip = Chip.F71862;
|
|
||||||
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0x07:
|
|
||||||
switch (revision) {
|
|
||||||
case 0x23:
|
|
||||||
chip = Chip.F71889F;
|
|
||||||
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0x08:
|
|
||||||
switch (revision) {
|
|
||||||
case 0x14:
|
|
||||||
chip = Chip.F71869;
|
|
||||||
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0x09:
|
|
||||||
switch (revision) {
|
|
||||||
case 0x09:
|
|
||||||
chip = Chip.F71889ED;
|
|
||||||
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0x52:
|
|
||||||
switch (revision) {
|
|
||||||
case 0x17:
|
|
||||||
case 0x3A:
|
|
||||||
case 0x41:
|
|
||||||
chip = Chip.W83627HF;
|
|
||||||
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0x82:
|
|
||||||
switch (revision & 0xF0) {
|
|
||||||
case 0x80:
|
|
||||||
chip = Chip.W83627THF;
|
|
||||||
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0x85:
|
|
||||||
switch (revision) {
|
|
||||||
case 0x41:
|
|
||||||
chip = Chip.W83687THF;
|
|
||||||
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0x88:
|
|
||||||
switch (revision & 0xF0) {
|
|
||||||
case 0x50:
|
|
||||||
case 0x60:
|
|
||||||
chip = Chip.W83627EHF;
|
|
||||||
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0xA0:
|
|
||||||
switch (revision & 0xF0) {
|
|
||||||
case 0x20:
|
|
||||||
chip = Chip.W83627DHG;
|
|
||||||
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0xA5:
|
|
||||||
switch (revision & 0xF0) {
|
|
||||||
case 0x10:
|
|
||||||
chip = Chip.W83667HG;
|
|
||||||
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0xB0:
|
|
||||||
switch (revision & 0xF0) {
|
|
||||||
case 0x70:
|
|
||||||
chip = Chip.W83627DHGP;
|
|
||||||
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
case 0xB3:
|
|
||||||
switch (revision & 0xF0) {
|
|
||||||
case 0x50:
|
|
||||||
chip = Chip.W83667HGB;
|
|
||||||
logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
|
|
||||||
break;
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
if (chip == Chip.Unknown) {
|
|
||||||
if (id != 0 && id != 0xff) {
|
|
||||||
WinbondFintekExit();
|
|
||||||
|
|
||||||
report.Append("Chip ID: Unknown Winbond / Fintek with ID 0x");
|
if (DetectSMSC()) continue;
|
||||||
report.AppendLine(((id << 8) | revision).ToString("X",
|
|
||||||
CultureInfo.InvariantCulture));
|
|
||||||
report.AppendLine();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Select(logicalDeviceNumber);
|
|
||||||
ushort address = ReadWord(BASE_ADDRESS_REGISTER);
|
|
||||||
Thread.Sleep(1);
|
|
||||||
ushort verify = ReadWord(BASE_ADDRESS_REGISTER);
|
|
||||||
|
|
||||||
ushort vendorID = ReadWord(FINTEK_VENDOR_ID_REGISTER);
|
|
||||||
|
|
||||||
WinbondFintekExit();
|
|
||||||
|
|
||||||
if (address != verify) {
|
|
||||||
report.Append("Chip ID: 0x");
|
|
||||||
report.AppendLine(chip.ToString("X"));
|
|
||||||
report.Append("Chip revision: 0x");
|
|
||||||
report.AppendLine(revision.ToString("X", CultureInfo.InvariantCulture));
|
|
||||||
report.AppendLine("Error: Address verification failed");
|
|
||||||
report.AppendLine();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// some Fintek chips have address register offset 0x05 added already
|
|
||||||
if ((address & 0x07) == 0x05)
|
|
||||||
address &= 0xFFF8;
|
|
||||||
|
|
||||||
if (address < 0x100 || (address & 0xF007) != 0) {
|
|
||||||
report.Append("Chip ID: 0x");
|
|
||||||
report.AppendLine(chip.ToString("X"));
|
|
||||||
report.Append("Chip revision: 0x");
|
|
||||||
report.AppendLine(revision.ToString("X", CultureInfo.InvariantCulture));
|
|
||||||
report.Append("Error: Invalid address 0x");
|
|
||||||
report.AppendLine(address.ToString("X", CultureInfo.InvariantCulture));
|
|
||||||
report.AppendLine();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (chip) {
|
|
||||||
case Chip.W83627DHG:
|
|
||||||
case Chip.W83627DHGP:
|
|
||||||
case Chip.W83627EHF:
|
|
||||||
case Chip.W83627HF:
|
|
||||||
case Chip.W83627THF:
|
|
||||||
case Chip.W83667HG:
|
|
||||||
case Chip.W83667HGB:
|
|
||||||
case Chip.W83687THF:
|
|
||||||
superIOs.Add(new W836XX(chip, revision, address));
|
|
||||||
break;
|
|
||||||
case Chip.F71858:
|
|
||||||
case Chip.F71862:
|
|
||||||
case Chip.F71869:
|
|
||||||
case Chip.F71882:
|
|
||||||
case Chip.F71889ED:
|
|
||||||
case Chip.F71889F:
|
|
||||||
if (vendorID != FINTEK_VENDOR_ID) {
|
|
||||||
report.Append("Chip ID: 0x");
|
|
||||||
report.AppendLine(chip.ToString("X"));
|
|
||||||
report.Append("Chip revision: 0x");
|
|
||||||
report.AppendLine(revision.ToString("X", CultureInfo.InvariantCulture));
|
|
||||||
report.Append("Error: Invalid vendor ID 0x");
|
|
||||||
report.AppendLine(vendorID.ToString("X", CultureInfo.InvariantCulture));
|
|
||||||
report.AppendLine();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
superIOs.Add(new F718XX(chip, address));
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IT87Enter();
|
|
||||||
|
|
||||||
ushort chipID = ReadWord(CHIP_ID_REGISTER);
|
|
||||||
switch (chipID) {
|
|
||||||
case 0x8712: chip = Chip.IT8712F; break;
|
|
||||||
case 0x8716: chip = Chip.IT8716F; break;
|
|
||||||
case 0x8718: chip = Chip.IT8718F; break;
|
|
||||||
case 0x8720: chip = Chip.IT8720F; break;
|
|
||||||
case 0x8726: chip = Chip.IT8726F; break;
|
|
||||||
default: chip = Chip.Unknown; break;
|
|
||||||
}
|
|
||||||
if (chip == Chip.Unknown) {
|
|
||||||
if (chipID != 0 && chipID != 0xffff) {
|
|
||||||
IT87Exit();
|
|
||||||
|
|
||||||
report.Append("Chip ID: Unknown ITE with ID 0x");
|
|
||||||
report.AppendLine(chipID.ToString("X", CultureInfo.InvariantCulture));
|
|
||||||
report.AppendLine();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Select(IT87_ENVIRONMENT_CONTROLLER_LDN);
|
|
||||||
ushort address = ReadWord(BASE_ADDRESS_REGISTER);
|
|
||||||
Thread.Sleep(1);
|
|
||||||
ushort verify = ReadWord(BASE_ADDRESS_REGISTER);
|
|
||||||
|
|
||||||
byte version = (byte)(ReadByte(IT87_CHIP_VERSION_REGISTER) & 0x0F);
|
|
||||||
|
|
||||||
IT87Exit();
|
|
||||||
|
|
||||||
if (address != verify || address < 0x100 || (address & 0xF007) != 0) {
|
|
||||||
report.Append("Chip ID: 0x");
|
|
||||||
report.AppendLine(chip.ToString("X"));
|
|
||||||
report.Append("Error: Invalid address 0x");
|
|
||||||
report.AppendLine(address.ToString("X", CultureInfo.InvariantCulture));
|
|
||||||
report.AppendLine();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
superIOs.Add(new IT87XX(chip, address, version));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SMSCEnter();
|
|
||||||
|
|
||||||
chipID = ReadWord(CHIP_ID_REGISTER);
|
|
||||||
switch (chipID) {
|
|
||||||
default: chip = Chip.Unknown; break;
|
|
||||||
}
|
|
||||||
if (chip == Chip.Unknown) {
|
|
||||||
if (chipID != 0 && chipID != 0xffff) {
|
|
||||||
SMSCExit();
|
|
||||||
|
|
||||||
report.Append("Chip ID: Unknown SMSC with ID 0x");
|
|
||||||
report.AppendLine(chipID.ToString("X", CultureInfo.InvariantCulture));
|
|
||||||
report.AppendLine();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SMSCExit();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -178,7 +178,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
|
|||||||
return vendorId == WINBOND_VENDOR_ID;
|
return vendorId == WINBOND_VENDOR_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ulong SetBit(ulong target, int bit, int value) {
|
private static ulong SetBit(ulong target, int bit, int value) {
|
||||||
if ((value & 1) != value)
|
if ((value & 1) != value)
|
||||||
throw new ArgumentException("Value must be one bit only.");
|
throw new ArgumentException("Value must be one bit only.");
|
||||||
|
|
||||||
|
@@ -53,8 +53,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
this.smbios = new SMBIOS();
|
this.smbios = new SMBIOS();
|
||||||
|
|
||||||
if (smbios.Board != null) {
|
if (smbios.Board != null) {
|
||||||
if (smbios.Board.ProductName != null
|
if (!string.IsNullOrEmpty(smbios.Board.ProductName)) {
|
||||||
&& smbios.Board.ProductName != "") {
|
|
||||||
if (smbios.Board.Manufacturer == Manufacturer.Unknown)
|
if (smbios.Board.Manufacturer == Manufacturer.Unknown)
|
||||||
this.name = smbios.Board.ProductName;
|
this.name = smbios.Board.ProductName;
|
||||||
else
|
else
|
||||||
@@ -131,8 +130,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
#pragma warning restore 67
|
#pragma warning restore 67
|
||||||
|
|
||||||
public void Accept(IVisitor visitor) {
|
public void Accept(IVisitor visitor) {
|
||||||
if (visitor != null)
|
if (visitor == null)
|
||||||
visitor.VisitHardware(this);
|
throw new ArgumentNullException("visitor");
|
||||||
|
visitor.VisitHardware(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Traverse(IVisitor visitor) {
|
public void Traverse(IVisitor visitor) {
|
||||||
|
@@ -51,7 +51,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
private BIOSInformation biosInformation = null;
|
private BIOSInformation biosInformation = null;
|
||||||
private BaseBoardInformation baseBoardInformation = null;
|
private BaseBoardInformation baseBoardInformation = null;
|
||||||
|
|
||||||
private string ReadSysFS(string path) {
|
private static string ReadSysFS(string path) {
|
||||||
try {
|
try {
|
||||||
if (File.Exists(path)) {
|
if (File.Exists(path)) {
|
||||||
using (StreamReader reader = new StreamReader(path))
|
using (StreamReader reader = new StreamReader(path))
|
||||||
@@ -85,9 +85,12 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
|
|
||||||
raw = null;
|
raw = null;
|
||||||
try {
|
try {
|
||||||
ManagementObjectCollection collection =
|
ManagementObjectCollection collection;
|
||||||
|
using (ManagementObjectSearcher searcher =
|
||||||
new ManagementObjectSearcher("root\\WMI",
|
new ManagementObjectSearcher("root\\WMI",
|
||||||
"SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
|
"SELECT SMBiosData FROM MSSMBios_RawSMBiosTables")) {
|
||||||
|
collection = searcher.Get();
|
||||||
|
}
|
||||||
|
|
||||||
foreach (ManagementObject mo in collection) {
|
foreach (ManagementObject mo in collection) {
|
||||||
raw = (byte[])mo["SMBiosData"];
|
raw = (byte[])mo["SMBiosData"];
|
||||||
@@ -144,17 +147,19 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
public string GetReport() {
|
public string GetReport() {
|
||||||
StringBuilder r = new StringBuilder();
|
StringBuilder r = new StringBuilder();
|
||||||
|
|
||||||
if (biosInformation != null) {
|
if (BIOS != null) {
|
||||||
r.Append("BIOS Vendor: "); r.AppendLine(biosInformation.Vendor);
|
r.Append("BIOS Vendor: "); r.AppendLine(BIOS.Vendor);
|
||||||
r.Append("BIOS Version: "); r.AppendLine(biosInformation.Version);
|
r.Append("BIOS Version: "); r.AppendLine(BIOS.Version);
|
||||||
r.AppendLine();
|
r.AppendLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseBoardInformation != null) {
|
if (Board != null) {
|
||||||
r.Append("Mainboard Manufacturer: ");
|
r.Append("Mainboard Manufacturer: ");
|
||||||
r.AppendLine(baseBoardInformation.ManufacturerName);
|
r.AppendLine(Board.ManufacturerName);
|
||||||
r.Append("Mainboard Name: ");
|
r.Append("Mainboard Name: ");
|
||||||
r.AppendLine(baseBoardInformation.ProductName);
|
r.AppendLine(Board.ProductName);
|
||||||
|
r.Append("Mainboard Version: ");
|
||||||
|
r.AppendLine(Board.Version);
|
||||||
r.AppendLine();
|
r.AppendLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,10 +254,10 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
private Manufacturer manufacturer;
|
private Manufacturer manufacturer;
|
||||||
private Model model;
|
private Model model;
|
||||||
|
|
||||||
private void SetManufacturerName(string manufacturerName) {
|
private void SetManufacturerName(string name) {
|
||||||
this.manufacturerName = manufacturerName;
|
this.manufacturerName = name;
|
||||||
|
|
||||||
switch (manufacturerName) {
|
switch (name) {
|
||||||
case "ASRock":
|
case "ASRock":
|
||||||
manufacturer = Manufacturer.ASRock; break;
|
manufacturer = Manufacturer.ASRock; break;
|
||||||
case "ASUSTeK Computer INC.":
|
case "ASUSTeK Computer INC.":
|
||||||
@@ -286,10 +291,10 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetProductName(string productName) {
|
private void SetProductName(string name) {
|
||||||
this.productName = productName;
|
this.productName = name;
|
||||||
|
|
||||||
switch (productName) {
|
switch (name) {
|
||||||
case "880GMH/USB3":
|
case "880GMH/USB3":
|
||||||
model = Model._880GMH_USB3; break;
|
model = Model._880GMH_USB3; break;
|
||||||
case "Crosshair III Formula":
|
case "Crosshair III Formula":
|
||||||
|
@@ -44,39 +44,18 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
internal class SuperIOHardware : Hardware {
|
internal class SuperIOHardware : Hardware {
|
||||||
|
|
||||||
private ISuperIO superIO;
|
private ISuperIO superIO;
|
||||||
protected readonly string name;
|
private string name;
|
||||||
|
|
||||||
private List<Sensor> voltages = new List<Sensor>();
|
private List<Sensor> voltages = new List<Sensor>();
|
||||||
private List<Sensor> temperatures = new List<Sensor>();
|
private List<Sensor> temperatures = new List<Sensor>();
|
||||||
private List<Sensor> fans = new List<Sensor>();
|
private List<Sensor> fans = new List<Sensor>();
|
||||||
|
|
||||||
|
|
||||||
public SuperIOHardware(ISuperIO superIO, Manufacturer manufacturer,
|
public SuperIOHardware(ISuperIO superIO, Manufacturer manufacturer,
|
||||||
Model model, ISettings settings)
|
Model model, ISettings settings)
|
||||||
{
|
{
|
||||||
this.superIO = superIO;
|
this.superIO = superIO;
|
||||||
|
this.name = ChipName.GetName(superIO.Chip);
|
||||||
switch (superIO.Chip) {
|
|
||||||
case Chip.F71858: name = "Fintek F71858"; break;
|
|
||||||
case Chip.F71862: name = "Fintek F71862"; break;
|
|
||||||
case Chip.F71869: name = "Fintek F71869"; break;
|
|
||||||
case Chip.F71882: name = "Fintek F71882"; break;
|
|
||||||
case Chip.F71889ED: name = "Fintek F71889ED"; break;
|
|
||||||
case Chip.F71889F: name = "Fintek F71889F"; break;
|
|
||||||
case Chip.IT8712F: this.name = "ITE IT8712F"; break;
|
|
||||||
case Chip.IT8716F: this.name = "ITE IT8716F"; break;
|
|
||||||
case Chip.IT8718F: this.name = "ITE IT8718F"; break;
|
|
||||||
case Chip.IT8720F: this.name = "ITE IT8720F"; break;
|
|
||||||
case Chip.IT8726F: this.name = "ITE IT8726F"; break;
|
|
||||||
case Chip.W83627DHG: this.name = "Winbond W83627DHG"; break;
|
|
||||||
case Chip.W83627DHGP: this.name = "Winbond W83627DHG-P"; break;
|
|
||||||
case Chip.W83627EHF: this.name = "Winbond W83627EHF"; break;
|
|
||||||
case Chip.W83627HF: this.name = "Winbond W83627HF"; break;
|
|
||||||
case Chip.W83627THF: this.name = "Winbond W83627THF"; break;
|
|
||||||
case Chip.W83667HG: this.name = "Winbond W83667HG"; break;
|
|
||||||
case Chip.W83667HGB: this.name = "Winbond W83667HG-B"; break;
|
|
||||||
case Chip.W83687THF: this.name = "Winbond W83687THF"; break;
|
|
||||||
case Chip.Unknown: this.name = "Unkown"; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Voltage> v = new List<Voltage>();
|
List<Voltage> v = new List<Voltage>();
|
||||||
List<Temperature> t = new List<Temperature>();
|
List<Temperature> t = new List<Temperature>();
|
||||||
@@ -483,7 +462,6 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
v.Add(new Voltage("Standby +3.3V", 7, 34, 34, 0));
|
v.Add(new Voltage("Standby +3.3V", 7, 34, 34, 0));
|
||||||
v.Add(new Voltage("VBAT", 8, 34, 34, 0));
|
v.Add(new Voltage("VBAT", 8, 34, 34, 0));
|
||||||
t.Add(new Temperature("CPU", 0));
|
t.Add(new Temperature("CPU", 0));
|
||||||
t.Add(new Temperature("Auxiliary", 1, true));
|
|
||||||
t.Add(new Temperature("Motherboard", 2));
|
t.Add(new Temperature("Motherboard", 2));
|
||||||
f.Add(new Fan("Chassis Fan #1", 0));
|
f.Add(new Fan("Chassis Fan #1", 0));
|
||||||
f.Add(new Fan("CPU Fan", 1));
|
f.Add(new Fan("CPU Fan", 1));
|
||||||
@@ -673,15 +651,10 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
private class Temperature {
|
private class Temperature {
|
||||||
public readonly string Name;
|
public readonly string Name;
|
||||||
public readonly int Index;
|
public readonly int Index;
|
||||||
public readonly bool Hidden;
|
|
||||||
|
|
||||||
public Temperature(string name, int index) :
|
public Temperature(string name, int index) {
|
||||||
this(name, index, false) { }
|
|
||||||
|
|
||||||
public Temperature(string name, int index, bool hidden) {
|
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.Index = index;
|
this.Index = index;
|
||||||
this.Hidden = hidden;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -310,7 +310,9 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
|||||||
public static readonly NvAPI_GPU_GetMemoryInfoDelegate
|
public static readonly NvAPI_GPU_GetMemoryInfoDelegate
|
||||||
NvAPI_GPU_GetMemoryInfo;
|
NvAPI_GPU_GetMemoryInfo;
|
||||||
public static readonly NvAPI_GetDisplayDriverVersionDelegate
|
public static readonly NvAPI_GetDisplayDriverVersionDelegate
|
||||||
NvAPI_GetDisplayDriverVersion;
|
NvAPI_GetDisplayDriverVersion;
|
||||||
|
|
||||||
|
private NVAPI() { }
|
||||||
|
|
||||||
public static NvStatus NvAPI_GPU_GetFullName(NvPhysicalGpuHandle gpuHandle,
|
public static NvStatus NvAPI_GPU_GetFullName(NvPhysicalGpuHandle gpuHandle,
|
||||||
out string name) {
|
out string name) {
|
||||||
|
@@ -239,7 +239,8 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
|||||||
r.Append("Driver Version: ");
|
r.Append("Driver Version: ");
|
||||||
r.Append(driverVersion.DriverVersion / 100);
|
r.Append(driverVersion.DriverVersion / 100);
|
||||||
r.Append(".");
|
r.Append(".");
|
||||||
r.Append((driverVersion.DriverVersion % 100).ToString("00", CultureInfo.InvariantCulture));
|
r.Append((driverVersion.DriverVersion % 100).ToString("00",
|
||||||
|
CultureInfo.InvariantCulture));
|
||||||
r.AppendLine();
|
r.AppendLine();
|
||||||
r.Append("Driver Branch: ");
|
r.Append("Driver Branch: ");
|
||||||
r.AppendLine(driverVersion.BuildBranch);
|
r.AppendLine(driverVersion.BuildBranch);
|
||||||
|
@@ -45,25 +45,15 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
|
|
||||||
internal sealed class PInvokeDelegateFactory {
|
internal sealed class PInvokeDelegateFactory {
|
||||||
|
|
||||||
private static AssemblyBuilder assemblyBuilder;
|
private static ModuleBuilder moduleBuilder =
|
||||||
private static ModuleBuilder moduleBuilder;
|
AppDomain.CurrentDomain.DefineDynamicAssembly(
|
||||||
|
new AssemblyName("PInvokeDelegateFactoryInternalAssembly"),
|
||||||
|
AssemblyBuilderAccess.Run).DefineDynamicModule(
|
||||||
|
"PInvokeDelegateFactoryInternalModule");
|
||||||
|
|
||||||
private static IDictionary<DllImportAttribute, Type> wrapperTypes =
|
private static IDictionary<DllImportAttribute, Type> wrapperTypes =
|
||||||
new Dictionary<DllImportAttribute, Type>();
|
new Dictionary<DllImportAttribute, Type>();
|
||||||
|
|
||||||
static PInvokeDelegateFactory() {
|
|
||||||
|
|
||||||
AssemblyName assemblyName = new AssemblyName();
|
|
||||||
assemblyName.Name = "PInvokeDelegateFactoryInternalAssembly";
|
|
||||||
|
|
||||||
assemblyBuilder =
|
|
||||||
AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName,
|
|
||||||
AssemblyBuilderAccess.Run);
|
|
||||||
|
|
||||||
moduleBuilder = assemblyBuilder.DefineDynamicModule(
|
|
||||||
"PInvokeDelegateFactoryInternalModule");
|
|
||||||
}
|
|
||||||
|
|
||||||
private PInvokeDelegateFactory() { }
|
private PInvokeDelegateFactory() { }
|
||||||
|
|
||||||
public static void CreateDelegate<T>(DllImportAttribute dllImportAttribute,
|
public static void CreateDelegate<T>(DllImportAttribute dllImportAttribute,
|
||||||
|
@@ -41,7 +41,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace OpenHardwareMonitor.Hardware {
|
namespace OpenHardwareMonitor.Hardware {
|
||||||
|
|
||||||
public struct ParameterDescription {
|
internal struct ParameterDescription {
|
||||||
private string name;
|
private string name;
|
||||||
private string description;
|
private string description;
|
||||||
private float defaultValue;
|
private float defaultValue;
|
||||||
@@ -60,7 +60,7 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
public float DefaultValue { get { return defaultValue; } }
|
public float DefaultValue { get { return defaultValue; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Parameter : IParameter {
|
internal class Parameter : IParameter {
|
||||||
private ISensor sensor;
|
private ISensor sensor;
|
||||||
private ParameterDescription description;
|
private ParameterDescription description;
|
||||||
private float value;
|
private float value;
|
||||||
@@ -129,8 +129,9 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Accept(IVisitor visitor) {
|
public void Accept(IVisitor visitor) {
|
||||||
if (visitor != null)
|
if (visitor == null)
|
||||||
visitor.VisitParameter(this);
|
throw new ArgumentNullException("visitor");
|
||||||
|
visitor.VisitParameter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Traverse(IVisitor visitor) { }
|
public void Traverse(IVisitor visitor) { }
|
||||||
|
@@ -51,9 +51,9 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
private SensorType sensorType;
|
private SensorType sensorType;
|
||||||
private IHardware hardware;
|
private IHardware hardware;
|
||||||
private ReadOnlyArray<IParameter> parameters;
|
private ReadOnlyArray<IParameter> parameters;
|
||||||
private float? value;
|
private float? currentValue;
|
||||||
private float? min;
|
private float? minValue;
|
||||||
private float? max;
|
private float? maxValue;
|
||||||
private Queue<SensorValue> values =
|
private Queue<SensorValue> values =
|
||||||
new Queue<SensorValue>(MAX_MINUTES * 15);
|
new Queue<SensorValue>(MAX_MINUTES * 15);
|
||||||
private ISettings settings;
|
private ISettings settings;
|
||||||
@@ -114,7 +114,7 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if (value != "")
|
if (!string.IsNullOrEmpty(value))
|
||||||
name = value;
|
name = value;
|
||||||
else
|
else
|
||||||
name = defaultName;
|
name = defaultName;
|
||||||
@@ -136,7 +136,7 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
|
|
||||||
public float? Value {
|
public float? Value {
|
||||||
get {
|
get {
|
||||||
return value;
|
return currentValue;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
while (values.Count > 0 &&
|
while (values.Count > 0 &&
|
||||||
@@ -153,23 +153,23 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.value = value;
|
this.currentValue = value;
|
||||||
if (min > value || !min.HasValue)
|
if (minValue > value || !minValue.HasValue)
|
||||||
min = value;
|
minValue = value;
|
||||||
if (max < value || !max.HasValue)
|
if (maxValue < value || !maxValue.HasValue)
|
||||||
max = value;
|
maxValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float? Min { get { return min; } }
|
public float? Min { get { return minValue; } }
|
||||||
public float? Max { get { return max; } }
|
public float? Max { get { return maxValue; } }
|
||||||
|
|
||||||
public void ResetMin() {
|
public void ResetMin() {
|
||||||
min = null;
|
minValue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetMax() {
|
public void ResetMax() {
|
||||||
max = null;
|
maxValue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<SensorValue> Values {
|
public IEnumerable<SensorValue> Values {
|
||||||
@@ -177,8 +177,9 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Accept(IVisitor visitor) {
|
public void Accept(IVisitor visitor) {
|
||||||
if (visitor != null)
|
if (visitor == null)
|
||||||
visitor.VisitSensor(this);
|
throw new ArgumentNullException("visitor");
|
||||||
|
visitor.VisitSensor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Traverse(IVisitor visitor) {
|
public void Traverse(IVisitor visitor) {
|
||||||
|
@@ -45,14 +45,20 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
private SensorEventHandler handler;
|
private SensorEventHandler handler;
|
||||||
|
|
||||||
public SensorVisitor(SensorEventHandler handler) {
|
public SensorVisitor(SensorEventHandler handler) {
|
||||||
|
if (handler == null)
|
||||||
|
throw new ArgumentNullException("handler");
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitComputer(IComputer computer) {
|
public void VisitComputer(IComputer computer) {
|
||||||
|
if (computer == null)
|
||||||
|
throw new ArgumentNullException("computer");
|
||||||
computer.Traverse(this);
|
computer.Traverse(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisitHardware(IHardware hardware) {
|
public void VisitHardware(IHardware hardware) {
|
||||||
|
if (hardware == null)
|
||||||
|
throw new ArgumentNullException("hardware");
|
||||||
hardware.Traverse(this);
|
hardware.Traverse(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -128,18 +128,44 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
|||||||
public delegate FT_STATUS FT_ReadDelegate(FT_HANDLE handle,
|
public delegate FT_STATUS FT_ReadDelegate(FT_HANDLE handle,
|
||||||
[Out] byte[] buffer, uint bytesToRead, out uint bytesReturned);
|
[Out] byte[] buffer, uint bytesToRead, out uint bytesReturned);
|
||||||
|
|
||||||
public static FT_CreateDeviceInfoListDelegate FT_CreateDeviceInfoList;
|
public static readonly FT_CreateDeviceInfoListDelegate
|
||||||
public static FT_GetDeviceInfoListDelegate FT_GetDeviceInfoList;
|
FT_CreateDeviceInfoList = CreateDelegate<
|
||||||
public static FT_OpenDelegate FT_Open;
|
FT_CreateDeviceInfoListDelegate>("FT_CreateDeviceInfoList");
|
||||||
public static FT_CloseDelegate FT_Close;
|
public static readonly FT_GetDeviceInfoListDelegate
|
||||||
public static FT_SetBaudRateDelegate FT_SetBaudRate;
|
FT_GetDeviceInfoList = CreateDelegate<
|
||||||
public static FT_SetDataCharacteristicsDelegate FT_SetDataCharacteristics;
|
FT_GetDeviceInfoListDelegate>("FT_GetDeviceInfoList");
|
||||||
public static FT_SetFlowControlDelegate FT_SetFlowControl;
|
public static readonly FT_OpenDelegate
|
||||||
public static FT_SetTimeoutsDelegate FT_SetTimeouts;
|
FT_Open = CreateDelegate<
|
||||||
public static FT_WriteDelegate FT_Write;
|
FT_OpenDelegate>("FT_Open");
|
||||||
public static FT_PurgeDelegate FT_Purge;
|
public static readonly FT_CloseDelegate
|
||||||
public static FT_GetStatusDelegate FT_GetStatus;
|
FT_Close = CreateDelegate<
|
||||||
public static FT_ReadDelegate FT_Read;
|
FT_CloseDelegate>("FT_Close");
|
||||||
|
public static readonly FT_SetBaudRateDelegate
|
||||||
|
FT_SetBaudRate = CreateDelegate<
|
||||||
|
FT_SetBaudRateDelegate>("FT_SetBaudRate");
|
||||||
|
public static readonly FT_SetDataCharacteristicsDelegate
|
||||||
|
FT_SetDataCharacteristics = CreateDelegate<
|
||||||
|
FT_SetDataCharacteristicsDelegate>("FT_SetDataCharacteristics");
|
||||||
|
public static readonly FT_SetFlowControlDelegate
|
||||||
|
FT_SetFlowControl = CreateDelegate<
|
||||||
|
FT_SetFlowControlDelegate>("FT_SetFlowControl");
|
||||||
|
public static readonly FT_SetTimeoutsDelegate
|
||||||
|
FT_SetTimeouts = CreateDelegate<
|
||||||
|
FT_SetTimeoutsDelegate>("FT_SetTimeouts");
|
||||||
|
public static readonly FT_WriteDelegate
|
||||||
|
FT_Write = CreateDelegate<
|
||||||
|
FT_WriteDelegate>("FT_Write");
|
||||||
|
public static readonly FT_PurgeDelegate
|
||||||
|
FT_Purge = CreateDelegate<
|
||||||
|
FT_PurgeDelegate>("FT_Purge");
|
||||||
|
public static readonly FT_GetStatusDelegate
|
||||||
|
FT_GetStatus = CreateDelegate<
|
||||||
|
FT_GetStatusDelegate>("FT_GetStatus");
|
||||||
|
public static readonly FT_ReadDelegate
|
||||||
|
FT_Read = CreateDelegate<
|
||||||
|
FT_ReadDelegate>("FT_Read");
|
||||||
|
|
||||||
|
private FTD2XX() { }
|
||||||
|
|
||||||
public static FT_STATUS Write(FT_HANDLE handle, byte[] buffer) {
|
public static FT_STATUS Write(FT_HANDLE handle, byte[] buffer) {
|
||||||
uint bytesWritten;
|
uint bytesWritten;
|
||||||
@@ -168,40 +194,27 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
|||||||
uint bytesReturned;
|
uint bytesReturned;
|
||||||
FT_STATUS status = FT_Read(handle, buffer, 1, out bytesReturned);
|
FT_STATUS status = FT_Read(handle, buffer, 1, out bytesReturned);
|
||||||
if (status != FT_STATUS.FT_OK || bytesReturned != 1)
|
if (status != FT_STATUS.FT_OK || bytesReturned != 1)
|
||||||
throw new Exception();
|
throw new InvalidOperationException();
|
||||||
return buffer[0];
|
return buffer[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string dllName;
|
private static string GetDllName() {
|
||||||
|
int p = (int)System.Environment.OSVersion.Platform;
|
||||||
|
if ((p == 4) || (p == 128))
|
||||||
|
return "libftd2xx.so";
|
||||||
|
else
|
||||||
|
return "ftd2xx.dll";
|
||||||
|
}
|
||||||
|
|
||||||
private static void GetDelegate<T>(string entryPoint, out T newDelegate)
|
private static T CreateDelegate<T>(string entryPoint)
|
||||||
where T : class {
|
where T : class {
|
||||||
DllImportAttribute attribute = new DllImportAttribute(dllName);
|
DllImportAttribute attribute = new DllImportAttribute(GetDllName());
|
||||||
attribute.CallingConvention = CallingConvention.StdCall;
|
attribute.CallingConvention = CallingConvention.StdCall;
|
||||||
attribute.PreserveSig = true;
|
attribute.PreserveSig = true;
|
||||||
attribute.EntryPoint = entryPoint;
|
attribute.EntryPoint = entryPoint;
|
||||||
|
T newDelegate;
|
||||||
PInvokeDelegateFactory.CreateDelegate(attribute, out newDelegate);
|
PInvokeDelegateFactory.CreateDelegate(attribute, out newDelegate);
|
||||||
}
|
return newDelegate;
|
||||||
|
|
||||||
static FTD2XX() {
|
|
||||||
int p = (int)System.Environment.OSVersion.Platform;
|
|
||||||
if ((p == 4) || (p == 128))
|
|
||||||
dllName = "libftd2xx.so";
|
|
||||||
else
|
|
||||||
dllName = "ftd2xx.dll";
|
|
||||||
|
|
||||||
GetDelegate("FT_CreateDeviceInfoList", out FT_CreateDeviceInfoList);
|
|
||||||
GetDelegate("FT_GetDeviceInfoList", out FT_GetDeviceInfoList);
|
|
||||||
GetDelegate("FT_Open", out FT_Open);
|
|
||||||
GetDelegate("FT_Close", out FT_Close);
|
|
||||||
GetDelegate("FT_SetBaudRate", out FT_SetBaudRate);
|
|
||||||
GetDelegate("FT_SetDataCharacteristics", out FT_SetDataCharacteristics);
|
|
||||||
GetDelegate("FT_SetFlowControl", out FT_SetFlowControl);
|
|
||||||
GetDelegate("FT_SetTimeouts", out FT_SetTimeouts);
|
|
||||||
GetDelegate("FT_Write", out FT_Write);
|
|
||||||
GetDelegate("FT_Purge", out FT_Purge);
|
|
||||||
GetDelegate("FT_GetStatus", out FT_GetStatus);
|
|
||||||
GetDelegate("FT_Read", out FT_Read);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -161,8 +161,6 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
float maxRPM = 20.0f * data[offset + 44 + 2 * i];
|
|
||||||
|
|
||||||
if (miniNGFans[number * 2 + i] == null)
|
if (miniNGFans[number * 2 + i] == null)
|
||||||
miniNGFans[number * 2 + i] =
|
miniNGFans[number * 2 + i] =
|
||||||
new Sensor("miniNG #" + (number + 1) + " Fan Channel " + (i + 1),
|
new Sensor("miniNG #" + (number + 1) + " Fan Channel " + (i + 1),
|
||||||
@@ -376,8 +374,9 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
|||||||
public event SensorEventHandler SensorRemoved;
|
public event SensorEventHandler SensorRemoved;
|
||||||
|
|
||||||
public void Accept(IVisitor visitor) {
|
public void Accept(IVisitor visitor) {
|
||||||
if (visitor != null)
|
if (visitor == null)
|
||||||
visitor.VisitHardware(this);
|
throw new ArgumentNullException("visitor");
|
||||||
|
visitor.VisitHardware(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Traverse(IVisitor visitor) { }
|
public void Traverse(IVisitor visitor) { }
|
||||||
|
@@ -44,6 +44,8 @@ using System.Threading;
|
|||||||
namespace OpenHardwareMonitor.Hardware {
|
namespace OpenHardwareMonitor.Hardware {
|
||||||
|
|
||||||
internal class WinRing0 {
|
internal class WinRing0 {
|
||||||
|
|
||||||
|
private WinRing0() { }
|
||||||
|
|
||||||
public enum OlsDllStatus{
|
public enum OlsDllStatus{
|
||||||
OLS_DLL_NO_ERROR = 0,
|
OLS_DLL_NO_ERROR = 0,
|
||||||
@@ -56,7 +58,7 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static bool available = false;
|
private static bool available = false;
|
||||||
public static Mutex isaBusMutex;
|
private static Mutex isaBusMutex;
|
||||||
|
|
||||||
private static string GetDllName() {
|
private static string GetDllName() {
|
||||||
int p = (int)System.Environment.OSVersion.Platform;
|
int p = (int)System.Environment.OSVersion.Platform;
|
||||||
@@ -78,10 +80,7 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
private delegate bool InitializeOlsDelegate();
|
private delegate bool InitializeOlsDelegate();
|
||||||
private delegate void DeinitializeOlsDelegate();
|
private delegate void DeinitializeOlsDelegate();
|
||||||
|
|
||||||
public delegate uint GetDllStatusDelegate();
|
|
||||||
public delegate bool IsCpuidDelegate();
|
public delegate bool IsCpuidDelegate();
|
||||||
public delegate bool CpuidDelegate(uint index, uint ecxValue,
|
|
||||||
out uint eax, out uint ebx, out uint ecx, out uint edx);
|
|
||||||
public delegate bool CpuidTxDelegate(uint index, uint ecxValue,
|
public delegate bool CpuidTxDelegate(uint index, uint ecxValue,
|
||||||
out uint eax, out uint ebx, out uint ecx, out uint edx,
|
out uint eax, out uint ebx, out uint ecx, out uint edx,
|
||||||
UIntPtr threadAffinityMask);
|
UIntPtr threadAffinityMask);
|
||||||
@@ -90,7 +89,6 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
UIntPtr threadAffinityMask);
|
UIntPtr threadAffinityMask);
|
||||||
public delegate byte ReadIoPortByteDelegate(ushort port);
|
public delegate byte ReadIoPortByteDelegate(ushort port);
|
||||||
public delegate void WriteIoPortByteDelegate(ushort port, byte value);
|
public delegate void WriteIoPortByteDelegate(ushort port, byte value);
|
||||||
public delegate void SetPciMaxBusIndexDelegate(byte max);
|
|
||||||
public delegate uint FindPciDeviceByIdDelegate(ushort vendorId,
|
public delegate uint FindPciDeviceByIdDelegate(ushort vendorId,
|
||||||
ushort deviceId, byte index);
|
ushort deviceId, byte index);
|
||||||
public delegate bool ReadPciConfigDwordExDelegate(uint pciAddress,
|
public delegate bool ReadPciConfigDwordExDelegate(uint pciAddress,
|
||||||
@@ -101,85 +99,73 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
UIntPtr threadAffinityMask);
|
UIntPtr threadAffinityMask);
|
||||||
public delegate bool RdtscDelegate(out uint eax, out uint edx);
|
public delegate bool RdtscDelegate(out uint eax, out uint edx);
|
||||||
|
|
||||||
private static InitializeOlsDelegate InitializeOls;
|
private static InitializeOlsDelegate InitializeOls =
|
||||||
private static DeinitializeOlsDelegate DeinitializeOls;
|
CreateDelegate<InitializeOlsDelegate>("InitializeOls");
|
||||||
|
private static DeinitializeOlsDelegate DeinitializeOls =
|
||||||
|
CreateDelegate<DeinitializeOlsDelegate>("DeinitializeOls");
|
||||||
|
|
||||||
public static readonly GetDllStatusDelegate GetDllStatus;
|
public static readonly IsCpuidDelegate IsCpuid =
|
||||||
public static readonly IsCpuidDelegate IsCpuid;
|
CreateDelegate<IsCpuidDelegate>("IsCpuid");
|
||||||
public static readonly CpuidDelegate Cpuid;
|
public static readonly CpuidTxDelegate CpuidTx =
|
||||||
public static readonly CpuidTxDelegate CpuidTx;
|
CreateDelegate<CpuidTxDelegate>("CpuidTx");
|
||||||
public static readonly RdmsrDelegate Rdmsr;
|
public static readonly RdmsrDelegate Rdmsr =
|
||||||
public static readonly RdmsrTxDelegate RdmsrTx;
|
CreateDelegate<RdmsrDelegate>("Rdmsr");
|
||||||
public static readonly ReadIoPortByteDelegate ReadIoPortByte;
|
public static readonly RdmsrTxDelegate RdmsrTx =
|
||||||
public static readonly WriteIoPortByteDelegate WriteIoPortByte;
|
CreateDelegate<RdmsrTxDelegate>("RdmsrTx");
|
||||||
public static readonly SetPciMaxBusIndexDelegate SetPciMaxBusIndex;
|
public static readonly ReadIoPortByteDelegate ReadIoPortByte =
|
||||||
public static readonly FindPciDeviceByIdDelegate FindPciDeviceById;
|
CreateDelegate<ReadIoPortByteDelegate>("ReadIoPortByte");
|
||||||
public static readonly ReadPciConfigDwordExDelegate ReadPciConfigDwordEx;
|
public static readonly WriteIoPortByteDelegate WriteIoPortByte =
|
||||||
public static readonly WritePciConfigDwordExDelegate WritePciConfigDwordEx;
|
CreateDelegate<WriteIoPortByteDelegate>("WriteIoPortByte");
|
||||||
public static readonly RdtscTxDelegate RdtscTx;
|
public static readonly FindPciDeviceByIdDelegate FindPciDeviceById =
|
||||||
public static readonly RdtscDelegate Rdtsc;
|
CreateDelegate<FindPciDeviceByIdDelegate>("FindPciDeviceById");
|
||||||
|
public static readonly ReadPciConfigDwordExDelegate ReadPciConfigDwordEx =
|
||||||
|
CreateDelegate<ReadPciConfigDwordExDelegate>("ReadPciConfigDwordEx");
|
||||||
|
public static readonly WritePciConfigDwordExDelegate WritePciConfigDwordEx =
|
||||||
private static void GetDelegate<T>(string entryPoint, out T newDelegate)
|
CreateDelegate<WritePciConfigDwordExDelegate>("WritePciConfigDwordEx");
|
||||||
where T : class
|
public static readonly RdtscTxDelegate RdtscTx =
|
||||||
{
|
CreateDelegate<RdtscTxDelegate>("RdtscTx");
|
||||||
|
public static readonly RdtscDelegate Rdtsc =
|
||||||
|
CreateDelegate<RdtscDelegate>("Rdtsc");
|
||||||
|
|
||||||
|
private static T CreateDelegate<T>(string entryPoint) where T : class {
|
||||||
DllImportAttribute attribute = new DllImportAttribute(GetDllName());
|
DllImportAttribute attribute = new DllImportAttribute(GetDllName());
|
||||||
attribute.CallingConvention = CallingConvention.Winapi;
|
attribute.CallingConvention = CallingConvention.Winapi;
|
||||||
attribute.PreserveSig = true;
|
attribute.PreserveSig = true;
|
||||||
attribute.EntryPoint = entryPoint;
|
attribute.EntryPoint = entryPoint;
|
||||||
attribute.CharSet = CharSet.Auto;
|
attribute.CharSet = CharSet.Auto;
|
||||||
PInvokeDelegateFactory.CreateDelegate(attribute, out newDelegate);
|
T result;
|
||||||
|
PInvokeDelegateFactory.CreateDelegate(attribute, out result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WinRing0() {
|
public static void Open() {
|
||||||
GetDelegate("InitializeOls", out InitializeOls);
|
|
||||||
GetDelegate("DeinitializeOls", out DeinitializeOls);
|
|
||||||
GetDelegate("GetDllStatus", out GetDllStatus);
|
|
||||||
GetDelegate("IsCpuid", out IsCpuid);
|
|
||||||
GetDelegate("Cpuid", out Cpuid);
|
|
||||||
GetDelegate("CpuidTx", out CpuidTx);
|
|
||||||
GetDelegate("Rdmsr", out Rdmsr);
|
|
||||||
GetDelegate("RdmsrTx", out RdmsrTx);
|
|
||||||
GetDelegate("ReadIoPortByte", out ReadIoPortByte);
|
|
||||||
GetDelegate("WriteIoPortByte", out WriteIoPortByte);
|
|
||||||
GetDelegate("SetPciMaxBusIndex", out SetPciMaxBusIndex);
|
|
||||||
GetDelegate("FindPciDeviceById", out FindPciDeviceById);
|
|
||||||
GetDelegate("ReadPciConfigDwordEx", out ReadPciConfigDwordEx);
|
|
||||||
GetDelegate("WritePciConfigDwordEx", out WritePciConfigDwordEx);
|
|
||||||
GetDelegate("RdtscTx", out RdtscTx);
|
|
||||||
GetDelegate("Rdtsc", out Rdtsc);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (InitializeOls != null && InitializeOls())
|
if (InitializeOls != null && InitializeOls())
|
||||||
available = true;
|
available = true;
|
||||||
} catch (DllNotFoundException) { }
|
} catch (DllNotFoundException) { }
|
||||||
|
|
||||||
isaBusMutex = new Mutex(false, "Access_ISABUS.HTP.Method");
|
isaBusMutex = new Mutex(false, "Access_ISABUS.HTP.Method");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsAvailable {
|
public static bool IsAvailable {
|
||||||
get { return available; }
|
get { return available; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Close() {
|
||||||
|
if (available)
|
||||||
|
DeinitializeOls();
|
||||||
|
isaBusMutex.Close();
|
||||||
|
}
|
||||||
|
|
||||||
public static bool WaitIsaBusMutex(int millisecondsTimeout) {
|
public static bool WaitIsaBusMutex(int millisecondsTimeout) {
|
||||||
try {
|
try {
|
||||||
return isaBusMutex.WaitOne(millisecondsTimeout);
|
return isaBusMutex.WaitOne(millisecondsTimeout, false);
|
||||||
} catch { return false; }
|
} catch (AbandonedMutexException) { return false; }
|
||||||
|
catch (InvalidOperationException) { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ReleaseIsaBusMutex() {
|
public static void ReleaseIsaBusMutex() {
|
||||||
isaBusMutex.ReleaseMutex();
|
isaBusMutex.ReleaseMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Deinitializer deinitializer = new Deinitializer();
|
|
||||||
private class Deinitializer {
|
|
||||||
~Deinitializer() {
|
|
||||||
if (available)
|
|
||||||
DeinitializeOls();
|
|
||||||
|
|
||||||
isaBusMutex.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
|
@@ -50,4 +50,5 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user