diff -r fa9dfbfc4145 -r b7cc9d09aefe Hardware/Computer.cs --- a/Hardware/Computer.cs Thu Aug 12 20:53:27 2010 +0000 +++ b/Hardware/Computer.cs Sun Aug 15 14:46:58 2010 +0000 @@ -41,6 +41,9 @@ using System.Globalization; using System.Text; using System.Threading; +using System.Security; +using System.Security.Permissions; + namespace OpenHardwareMonitor.Hardware { @@ -86,10 +89,13 @@ HardwareRemoved(hardware); } + [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] public void Open() { if (open) return; + WinRing0.Open(); + Add(new Mainboard.MainboardGroup(settings)); Add(new CPU.CPUGroup(settings)); Add(new ATI.ATIGroup(settings)); @@ -101,9 +107,11 @@ open = true; } - + public bool HDDEnabled { get { return hddEnabled; } + + [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] set { if (open && value && !hddEnabled) { Add(new HDD.HDDGroup(settings)); @@ -129,7 +137,7 @@ } } - private void NewSection(TextWriter writer) { + private static void NewSection(TextWriter writer) { for (int i = 0; i < 8; i++) writer.Write("----------"); writer.WriteLine(); @@ -186,7 +194,7 @@ private void ReportHardware(IHardware hardware, TextWriter w) { string hardwareReport = hardware.GetReport(); - if (hardwareReport != null && hardwareReport != "") { + if (!string.IsNullOrEmpty(hardwareReport)) { NewSection(w); w.Write(hardwareReport); } @@ -237,7 +245,7 @@ foreach (IGroup group in groups) { string report = group.GetReport(); - if (report != null && report != "") { + if (!string.IsNullOrEmpty(report)) { NewSection(w); w.Write(report); } @@ -259,6 +267,8 @@ group.Close(); groups.Clear(); + WinRing0.Close(); + open = false; } @@ -266,8 +276,9 @@ public event HardwareEventHandler HardwareRemoved; public void Accept(IVisitor visitor) { - if (visitor != null) - visitor.VisitComputer(this); + if (visitor == null) + throw new ArgumentNullException("visitor"); + visitor.VisitComputer(this); } public void Traverse(IVisitor visitor) {