# HG changeset patch # User moel.mich # Date 1344721734 0 # Node ID 7af3aaeb42e9d3d061f6527054129d8eb014c59b # Parent 64d3ddf8d73b8f1a4ccc33bdc0b90d4c3d075294 Added a few checks and delays to the driver loading code to increase the chance of loading the driver. diff -r 64d3ddf8d73b -r 7af3aaeb42e9 Hardware/Ring0.cs --- a/Hardware/Ring0.cs Sat Aug 11 21:32:59 2012 +0000 +++ b/Hardware/Ring0.cs Sat Aug 11 21:48:54 2012 +0000 @@ -98,13 +98,29 @@ 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 @@ // 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 -r 64d3ddf8d73b -r 7af3aaeb42e9 Properties/AssemblyVersion.cs --- a/Properties/AssemblyVersion.cs Sat Aug 11 21:32:59 2012 +0000 +++ b/Properties/AssemblyVersion.cs Sat Aug 11 21:48:54 2012 +0000 @@ -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