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.
authormoel.mich
Sun, 23 Sep 2012 18:37:43 +0000
changeset 380573f1fff48b2
parent 379 7af3aaeb42e9
child 381 ed5d5fc482ed
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.
GUI/MainForm.cs
Hardware/KernelDriver.cs
Hardware/Ring0.cs
Properties/AssemblyVersion.cs
     1.1 --- a/GUI/MainForm.cs	Sat Aug 11 21:48:54 2012 +0000
     1.2 +++ b/GUI/MainForm.cs	Sun Sep 23 18:37:43 2012 +0000
     1.3 @@ -290,6 +290,7 @@
     1.4  
     1.5        // Make sure the settings are saved when the user logs off
     1.6        Microsoft.Win32.SystemEvents.SessionEnded += delegate {
     1.7 +        computer.Close();
     1.8          SaveConfiguration();
     1.9          if (runWebServer.Value) 
    1.10              server.Quit();
     2.1 --- a/Hardware/KernelDriver.cs	Sat Aug 11 21:48:54 2012 +0000
     2.2 +++ b/Hardware/KernelDriver.cs	Sun Sep 23 18:37:43 2012 +0000
     2.3 @@ -41,13 +41,13 @@
     2.4          null);
     2.5  
     2.6        if (service == IntPtr.Zero) {
     2.7 -        if (Marshal.GetHRForLastWin32Error() == ERROR_SERVICE_EXISTS)
     2.8 -          service = NativeMethods.OpenService(manager, id,
     2.9 -            ServiceAccessRights.SERVICE_ALL_ACCESS);
    2.10 -        else {
    2.11 +        if (Marshal.GetHRForLastWin32Error() == ERROR_SERVICE_EXISTS) {
    2.12 +          errorMessage = "Service already exists";
    2.13 +          return false;
    2.14 +        } else {
    2.15            errorMessage = "CreateService returned the error: " +
    2.16              Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()).Message;
    2.17 -          NativeMethods.CloseServiceHandle(manager);    
    2.18 +          NativeMethods.CloseServiceHandle(manager);
    2.19            return false;
    2.20          }
    2.21        }
     3.1 --- a/Hardware/Ring0.cs	Sat Aug 11 21:48:54 2012 +0000
     3.2 +++ b/Hardware/Ring0.cs	Sun Sep 23 18:37:43 2012 +0000
     3.3 @@ -46,29 +46,29 @@
     3.4          IOControlCode.Access.Read);
     3.5  
     3.6      private static string GetTempFileName() {
     3.7 -
     3.8 -      // try to get a file in the temporary folder
     3.9 -      try {
    3.10 -        return Path.GetTempFileName();        
    3.11 -      } catch (IOException) { 
    3.12 -          // some I/O exception
    3.13 -        } 
    3.14 -        catch (UnauthorizedAccessException) { 
    3.15 -          // we do not have the right to create a file in the temp folder
    3.16 -        }
    3.17 -        catch (NotSupportedException) {
    3.18 -          // invalid path format of the TMP system environment variable
    3.19 -        }
    3.20 -
    3.21 -      // if this failed, we try to create one in the application folder
    3.22 +      
    3.23 +      // try to create one in the application folder
    3.24        string fileName = Path.ChangeExtension(
    3.25 -        Assembly.GetExecutingAssembly().Location, ".sys");
    3.26 +        Assembly.GetEntryAssembly().Location, ".sys");
    3.27        try {
    3.28          using (FileStream stream = File.Create(fileName)) {
    3.29            return fileName;
    3.30          }        
    3.31        } catch (IOException) { } 
    3.32          catch (UnauthorizedAccessException) { }
    3.33 +
    3.34 +      // if this failed, try to get a file in the temporary folder
    3.35 +      try {
    3.36 +        return Path.GetTempFileName();        
    3.37 +      } catch (IOException) { 
    3.38 +          // some I/O exception
    3.39 +      } 
    3.40 +      catch (UnauthorizedAccessException) { 
    3.41 +        // we do not have the right to create a file in the temp folder
    3.42 +      }
    3.43 +      catch (NotSupportedException) {
    3.44 +        // invalid path format of the TMP system environment variable
    3.45 +      }
    3.46       
    3.47        return null;
    3.48      }
     4.1 --- a/Properties/AssemblyVersion.cs	Sat Aug 11 21:48:54 2012 +0000
     4.2 +++ b/Properties/AssemblyVersion.cs	Sun Sep 23 18:37:43 2012 +0000
     4.3 @@ -10,5 +10,5 @@
     4.4  
     4.5  using System.Reflection;
     4.6  
     4.7 -[assembly: AssemblyVersion("0.5.1.2")]
     4.8 -[assembly: AssemblyInformationalVersion("0.5.1.2 Alpha")]
     4.9 \ No newline at end of file
    4.10 +[assembly: AssemblyVersion("0.5.1.4")]
    4.11 +[assembly: AssemblyInformationalVersion("0.5.1.4 Alpha")]
    4.12 \ No newline at end of file