diff --git a/Hardware/Ring0.cs b/Hardware/Ring0.cs index b37ac80..155be61 100644 --- a/Hardware/Ring0.cs +++ b/Hardware/Ring0.cs @@ -98,13 +98,29 @@ namespace OpenHardwareMonitor.Hardware { try { using (FileStream target = new FileStream(fileName, FileMode.Create)) { target.Write(buffer, 0, buffer.Length); + target.Flush(); } } catch (IOException) { // for example there is not enough space on the disk return false; } - return true; + // make sure the file is actually writen to the file system + for (int i = 0; i < 20; i++) { + try { + if (File.Exists(fileName) && + new FileInfo(fileName).Length == buffer.Length) + { + return true; + } + Thread.Sleep(100); + } catch (IOException) { + Thread.Sleep(10); + } + } + + // file still has not the right size, something is wrong + return false; } public static void Open() { @@ -141,6 +157,9 @@ namespace OpenHardwareMonitor.Hardware { // install failed, try to delete and reinstall driver.Delete(); + // wait a short moment to give the OS a chance to remove the driver + Thread.Sleep(2000); + string errorSecondInstall; if (driver.Install(fileName, out errorSecondInstall)) { driver.Open(); diff --git a/Properties/AssemblyVersion.cs b/Properties/AssemblyVersion.cs index 8e06c7f..28c56fd 100644 --- a/Properties/AssemblyVersion.cs +++ b/Properties/AssemblyVersion.cs @@ -10,5 +10,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.5.1.1")] -[assembly: AssemblyInformationalVersion("0.5.1.1 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.5.1.2")] +[assembly: AssemblyInformationalVersion("0.5.1.2 Alpha")] \ No newline at end of file