1.1 --- a/Hardware/Computer.cs Thu Aug 12 20:53:27 2010 +0000
1.2 +++ b/Hardware/Computer.cs Sun Aug 15 14:46:58 2010 +0000
1.3 @@ -41,6 +41,9 @@
1.4 using System.Globalization;
1.5 using System.Text;
1.6 using System.Threading;
1.7 +using System.Security;
1.8 +using System.Security.Permissions;
1.9 +
1.10
1.11 namespace OpenHardwareMonitor.Hardware {
1.12
1.13 @@ -86,10 +89,13 @@
1.14 HardwareRemoved(hardware);
1.15 }
1.16
1.17 + [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
1.18 public void Open() {
1.19 if (open)
1.20 return;
1.21
1.22 + WinRing0.Open();
1.23 +
1.24 Add(new Mainboard.MainboardGroup(settings));
1.25 Add(new CPU.CPUGroup(settings));
1.26 Add(new ATI.ATIGroup(settings));
1.27 @@ -101,9 +107,11 @@
1.28
1.29 open = true;
1.30 }
1.31 -
1.32 +
1.33 public bool HDDEnabled {
1.34 get { return hddEnabled; }
1.35 +
1.36 + [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
1.37 set {
1.38 if (open && value && !hddEnabled) {
1.39 Add(new HDD.HDDGroup(settings));
1.40 @@ -129,7 +137,7 @@
1.41 }
1.42 }
1.43
1.44 - private void NewSection(TextWriter writer) {
1.45 + private static void NewSection(TextWriter writer) {
1.46 for (int i = 0; i < 8; i++)
1.47 writer.Write("----------");
1.48 writer.WriteLine();
1.49 @@ -186,7 +194,7 @@
1.50
1.51 private void ReportHardware(IHardware hardware, TextWriter w) {
1.52 string hardwareReport = hardware.GetReport();
1.53 - if (hardwareReport != null && hardwareReport != "") {
1.54 + if (!string.IsNullOrEmpty(hardwareReport)) {
1.55 NewSection(w);
1.56 w.Write(hardwareReport);
1.57 }
1.58 @@ -237,7 +245,7 @@
1.59
1.60 foreach (IGroup group in groups) {
1.61 string report = group.GetReport();
1.62 - if (report != null && report != "") {
1.63 + if (!string.IsNullOrEmpty(report)) {
1.64 NewSection(w);
1.65 w.Write(report);
1.66 }
1.67 @@ -259,6 +267,8 @@
1.68 group.Close();
1.69 groups.Clear();
1.70
1.71 + WinRing0.Close();
1.72 +
1.73 open = false;
1.74 }
1.75
1.76 @@ -266,8 +276,9 @@
1.77 public event HardwareEventHandler HardwareRemoved;
1.78
1.79 public void Accept(IVisitor visitor) {
1.80 - if (visitor != null)
1.81 - visitor.VisitComputer(this);
1.82 + if (visitor == null)
1.83 + throw new ArgumentNullException("visitor");
1.84 + visitor.VisitComputer(this);
1.85 }
1.86
1.87 public void Traverse(IVisitor visitor) {