# HG changeset patch # User moel.mich # Date 1305473870 0 # Node ID 1c301069cfce82274bb36f5419c4cd49121df894 # Parent 2bc456906ad6e76290e35722be4212ce5fa86339 Fixed Issue 216. diff -r 2bc456906ad6 -r 1c301069cfce Hardware/Ring0.cs --- a/Hardware/Ring0.cs Sat May 14 13:26:09 2011 +0000 +++ b/Hardware/Ring0.cs Sun May 15 15:37:50 2011 +0000 @@ -46,6 +46,7 @@ internal static class Ring0 { private static KernelDriver driver; + private static string fileName; private static Mutex isaBusMutex; private static readonly StringBuilder report = new StringBuilder(); @@ -117,10 +118,9 @@ // driver is not loaded, try to reinstall and open driver.Delete(); - string fileName = Path.GetTempFileName(); + fileName = Path.GetTempFileName(); if (ExtractDriver(fileName)) { if (driver.Install(fileName)) { - File.Delete(fileName); driver.Open(); if (!driver.IsOpen) { @@ -135,10 +135,19 @@ report.Append("Exception: " + Marshal.GetExceptionForHR( Marshal.GetHRForLastWin32Error()).Message); } + } else { report.AppendLine( "Status: Extracting driver to \"" + fileName + "\" failed"); } + + try { + // try to delte the driver file + if (File.Exists(fileName)) + File.Delete(fileName); + fileName = null; + } catch (IOException) { } + catch (UnauthorizedAccessException) { } } if (!driver.IsOpen) @@ -165,7 +174,16 @@ driver = null; - isaBusMutex.Close(); + isaBusMutex.Close(); + + // try to delete temporary driver file again if failed during open + if (fileName != null && File.Exists(fileName)) { + try { + File.Delete(fileName); + fileName = null; + } catch (IOException) { } + catch (UnauthorizedAccessException) { } + } } public static string GetReport() {