# HG changeset patch # User moel.mich # Date 1348425463 0 # Node ID 573f1fff48b20da55d70fb59a6b78c030e64140e # Parent 7af3aaeb42e9d3d061f6527054129d8eb014c59b Fixed Issue 387. The new implementation does not try to start a ring 0 driver that already exists, but could not be opened. It tries to delete the driver and install it new. The driver is now stored temporarily in the application folder. The driver is not correctly removed on system shutdown. diff -r 7af3aaeb42e9 -r 573f1fff48b2 GUI/MainForm.cs --- a/GUI/MainForm.cs Sat Aug 11 21:48:54 2012 +0000 +++ b/GUI/MainForm.cs Sun Sep 23 18:37:43 2012 +0000 @@ -290,6 +290,7 @@ // Make sure the settings are saved when the user logs off Microsoft.Win32.SystemEvents.SessionEnded += delegate { + computer.Close(); SaveConfiguration(); if (runWebServer.Value) server.Quit(); diff -r 7af3aaeb42e9 -r 573f1fff48b2 Hardware/KernelDriver.cs --- a/Hardware/KernelDriver.cs Sat Aug 11 21:48:54 2012 +0000 +++ b/Hardware/KernelDriver.cs Sun Sep 23 18:37:43 2012 +0000 @@ -41,13 +41,13 @@ null); if (service == IntPtr.Zero) { - if (Marshal.GetHRForLastWin32Error() == ERROR_SERVICE_EXISTS) - service = NativeMethods.OpenService(manager, id, - ServiceAccessRights.SERVICE_ALL_ACCESS); - else { + if (Marshal.GetHRForLastWin32Error() == ERROR_SERVICE_EXISTS) { + errorMessage = "Service already exists"; + return false; + } else { errorMessage = "CreateService returned the error: " + Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()).Message; - NativeMethods.CloseServiceHandle(manager); + NativeMethods.CloseServiceHandle(manager); return false; } } diff -r 7af3aaeb42e9 -r 573f1fff48b2 Hardware/Ring0.cs --- a/Hardware/Ring0.cs Sat Aug 11 21:48:54 2012 +0000 +++ b/Hardware/Ring0.cs Sun Sep 23 18:37:43 2012 +0000 @@ -46,29 +46,29 @@ IOControlCode.Access.Read); private static string GetTempFileName() { - - // try to get a file in the temporary folder - try { - return Path.GetTempFileName(); - } catch (IOException) { - // some I/O exception - } - catch (UnauthorizedAccessException) { - // we do not have the right to create a file in the temp folder - } - catch (NotSupportedException) { - // invalid path format of the TMP system environment variable - } - - // if this failed, we try to create one in the application folder + + // try to create one in the application folder string fileName = Path.ChangeExtension( - Assembly.GetExecutingAssembly().Location, ".sys"); + Assembly.GetEntryAssembly().Location, ".sys"); try { using (FileStream stream = File.Create(fileName)) { return fileName; } } catch (IOException) { } catch (UnauthorizedAccessException) { } + + // if this failed, try to get a file in the temporary folder + try { + return Path.GetTempFileName(); + } catch (IOException) { + // some I/O exception + } + catch (UnauthorizedAccessException) { + // we do not have the right to create a file in the temp folder + } + catch (NotSupportedException) { + // invalid path format of the TMP system environment variable + } return null; } diff -r 7af3aaeb42e9 -r 573f1fff48b2 Properties/AssemblyVersion.cs --- a/Properties/AssemblyVersion.cs Sat Aug 11 21:48:54 2012 +0000 +++ b/Properties/AssemblyVersion.cs Sun Sep 23 18:37:43 2012 +0000 @@ -10,5 +10,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.5.1.2")] -[assembly: AssemblyInformationalVersion("0.5.1.2 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.5.1.4")] +[assembly: AssemblyInformationalVersion("0.5.1.4 Alpha")] \ No newline at end of file