Fixed Issue 216.
1.1 --- a/Hardware/Ring0.cs Sat May 14 13:26:09 2011 +0000
1.2 +++ b/Hardware/Ring0.cs Sun May 15 15:37:50 2011 +0000
1.3 @@ -46,6 +46,7 @@
1.4 internal static class Ring0 {
1.5
1.6 private static KernelDriver driver;
1.7 + private static string fileName;
1.8 private static Mutex isaBusMutex;
1.9 private static readonly StringBuilder report = new StringBuilder();
1.10
1.11 @@ -117,10 +118,9 @@
1.12 // driver is not loaded, try to reinstall and open
1.13
1.14 driver.Delete();
1.15 - string fileName = Path.GetTempFileName();
1.16 + fileName = Path.GetTempFileName();
1.17 if (ExtractDriver(fileName)) {
1.18 if (driver.Install(fileName)) {
1.19 - File.Delete(fileName);
1.20 driver.Open();
1.21
1.22 if (!driver.IsOpen) {
1.23 @@ -135,10 +135,19 @@
1.24 report.Append("Exception: " + Marshal.GetExceptionForHR(
1.25 Marshal.GetHRForLastWin32Error()).Message);
1.26 }
1.27 +
1.28 } else {
1.29 report.AppendLine(
1.30 "Status: Extracting driver to \"" + fileName + "\" failed");
1.31 }
1.32 +
1.33 + try {
1.34 + // try to delte the driver file
1.35 + if (File.Exists(fileName))
1.36 + File.Delete(fileName);
1.37 + fileName = null;
1.38 + } catch (IOException) { }
1.39 + catch (UnauthorizedAccessException) { }
1.40 }
1.41
1.42 if (!driver.IsOpen)
1.43 @@ -165,7 +174,16 @@
1.44
1.45 driver = null;
1.46
1.47 - isaBusMutex.Close();
1.48 + isaBusMutex.Close();
1.49 +
1.50 + // try to delete temporary driver file again if failed during open
1.51 + if (fileName != null && File.Exists(fileName)) {
1.52 + try {
1.53 + File.Delete(fileName);
1.54 + fileName = null;
1.55 + } catch (IOException) { }
1.56 + catch (UnauthorizedAccessException) { }
1.57 + }
1.58 }
1.59
1.60 public static string GetReport() {