# HG changeset patch # User moel.mich # Date 1342642826 0 # Node ID 45215572a77485f9d2b1e58f35edd2bf02043312 # Parent 667c75cad9372887ff8cb6a9eaae34c09550ee00 Added more report output to the kernel driver loading code. Hopefully this helps to find the problems in Issue 253. diff -r 667c75cad937 -r 45215572a774 Hardware/KernelDriver.cs --- a/Hardware/KernelDriver.cs Wed Jul 18 19:45:59 2012 +0000 +++ b/Hardware/KernelDriver.cs Wed Jul 18 20:20:26 2012 +0000 @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2010 Michael Möller + Copyright (C) 2010-2012 Michael Möller */ @@ -25,12 +25,14 @@ this.id = id; } - public bool Install(string path) { + public bool Install(string path, out string errorMessage) { IntPtr manager = NativeMethods.OpenSCManager(null, null, ServiceControlManagerAccessRights.SC_MANAGER_ALL_ACCESS); - if (manager == IntPtr.Zero) + if (manager == IntPtr.Zero) { + errorMessage = "OpenSCManager returned zero."; return false; + } IntPtr service = NativeMethods.CreateService(manager, id, id, ServiceAccessRights.SERVICE_ALL_ACCESS, @@ -42,13 +44,22 @@ if (Marshal.GetHRForLastWin32Error() == ERROR_SERVICE_EXISTS) service = NativeMethods.OpenService(manager, id, ServiceAccessRights.SERVICE_ALL_ACCESS); - else + else { + errorMessage = "CreateService returned the error: " + + Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()).Message; + NativeMethods.CloseServiceHandle(manager); return false; + } } if (!NativeMethods.StartService(service, 0, null)) { - if (Marshal.GetHRForLastWin32Error() != ERROR_SERVICE_ALREADY_RUNNING) + if (Marshal.GetHRForLastWin32Error() != ERROR_SERVICE_ALREADY_RUNNING) { + errorMessage = "StartService returned the error: " + + Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()).Message; + NativeMethods.CloseServiceHandle(service); + NativeMethods.CloseServiceHandle(manager); return false; + } } NativeMethods.CloseServiceHandle(service); @@ -62,7 +73,8 @@ "O:BAG:SYD:(A;;FA;;;SY)(A;;FA;;;BA)"); File.SetAccessControl(@"\\.\" + id, fileSecurity); } catch { } - + + errorMessage = null; return true; } diff -r 667c75cad937 -r 45215572a774 Hardware/Ring0.cs --- a/Hardware/Ring0.cs Wed Jul 18 19:45:59 2012 +0000 +++ b/Hardware/Ring0.cs Wed Jul 18 20:20:26 2012 +0000 @@ -127,7 +127,8 @@ fileName = GetTempFileName(); if (fileName != null && ExtractDriver(fileName)) { - if (driver.Install(fileName)) { + string installError; + if (driver.Install(fileName, out installError)) { driver.Open(); if (!driver.IsOpen) { @@ -135,10 +136,13 @@ report.AppendLine("Status: Opening driver failed after install"); } } else { + string errorFirstInstall = installError; + // install failed, try to delete and reinstall driver.Delete(); - if (driver.Install(fileName)) { + string errorSecondInstall; + if (driver.Install(fileName, out errorSecondInstall)) { driver.Open(); if (!driver.IsOpen) { @@ -150,9 +154,8 @@ report.AppendLine("Status: Installing driver \"" + fileName + "\" failed" + (File.Exists(fileName) ? " and file exists" : "")); - report.AppendLine(); - report.Append("Exception: " + Marshal.GetExceptionForHR( - Marshal.GetHRForLastWin32Error()).Message); + report.AppendLine("First Exception: " + errorFirstInstall); + report.AppendLine("Second Exception: " + errorSecondInstall); } } } else { diff -r 667c75cad937 -r 45215572a774 Properties/AssemblyVersion.cs --- a/Properties/AssemblyVersion.cs Wed Jul 18 19:45:59 2012 +0000 +++ b/Properties/AssemblyVersion.cs Wed Jul 18 20:20:26 2012 +0000 @@ -10,5 +10,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.4.0.18")] -[assembly: AssemblyInformationalVersion("0.4.0.18 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.4.0.19")] +[assembly: AssemblyInformationalVersion("0.4.0.19 Alpha")] \ No newline at end of file