# HG changeset patch # User moel.mich # Date 1297202549 0 # Node ID d8079800a88889f2b01072a8faec472d9737a885 # Parent 0044b05a3094243ed077138e522f8a0663ed9b71 Added some error reporting to the Ring0 driver loading code. diff -r 0044b05a3094 -r d8079800a888 Hardware/Computer.cs --- a/Hardware/Computer.cs Mon Feb 07 22:06:58 2011 +0000 +++ b/Hardware/Computer.cs Tue Feb 08 22:02:29 2011 +0000 @@ -222,6 +222,13 @@ w.WriteLine(IntPtr.Size == 4 ? "32-Bit" : "64-Bit"); w.WriteLine(); + string r = Ring0.GetReport(); + if (r != null) { + NewSection(w); + w.Write(r); + w.WriteLine(); + } + NewSection(w); w.WriteLine("Sensors"); w.WriteLine(); diff -r 0044b05a3094 -r d8079800a888 Hardware/Ring0.cs --- a/Hardware/Ring0.cs Mon Feb 07 22:06:58 2011 +0000 +++ b/Hardware/Ring0.cs Tue Feb 08 22:02:29 2011 +0000 @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2010 + Portions created by the Initial Developer are Copyright (C) 2010-2011 the Initial Developer. All Rights Reserved. Contributor(s): @@ -40,12 +40,14 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Threading; +using System.Text; namespace OpenHardwareMonitor.Hardware { internal static class Ring0 { private static KernelDriver driver; private static Mutex isaBusMutex; + private static readonly StringBuilder report = new StringBuilder(); private const uint OLS_TYPE = 40000; private static IOControlCode @@ -95,28 +97,41 @@ } public static void Open() { - // No implementation for Unix systems + // no implementation for unix systems int p = (int)Environment.OSVersion.Platform; if ((p == 4) || (p == 128)) return; if (driver != null) return; + + // clear the current report + report.Length = 0; driver = new KernelDriver("WinRing0_1_2_0"); driver.Open(); if (!driver.IsOpen) { + // driver is not loaded, try to install and open string fileName = Path.GetTempFileName(); if (ExtractDriver(fileName)) { + if (driver.Install(fileName)) { + File.Delete(fileName); + driver.Open(); - driver.Install(fileName); - File.Delete(fileName); - - driver.Open(); - - if (!driver.IsOpen) - driver.Delete(); + if (!driver.IsOpen) { + driver.Delete(); + report.AppendLine("Status: Opening driver failed"); + } + } else { + report.AppendLine("Status: Installing driver failed"); + report.AppendLine(); + report.Append("Exception: " + Marshal.GetExceptionForHR( + Marshal.GetHRForLastWin32Error()).Message); + } + } else { + report.AppendLine( + "Status: Extracting driver to \"" + fileName + "\" failed"); } } @@ -147,6 +162,16 @@ isaBusMutex.Close(); } + public static string GetReport() { + if (report.Length > 0) { + report.Insert(0, "Ring0" + Environment.NewLine + + Environment.NewLine); + report.AppendLine(); + return report.ToString(); + } else + return null; + } + public static bool WaitIsaBusMutex(int millisecondsTimeout) { try { return isaBusMutex.WaitOne(millisecondsTimeout, false); diff -r 0044b05a3094 -r d8079800a888 Properties/AssemblyVersion.cs --- a/Properties/AssemblyVersion.cs Mon Feb 07 22:06:58 2011 +0000 +++ b/Properties/AssemblyVersion.cs Tue Feb 08 22:02:29 2011 +0000 @@ -37,5 +37,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.2.1.11")] -[assembly: AssemblyInformationalVersion("0.2.1.11 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.2.1.12")] +[assembly: AssemblyInformationalVersion("0.2.1.12 Alpha")] \ No newline at end of file