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.

This commit is contained in:
Michael Möller 2012-09-23 18:37:43 +00:00
parent 5a8544454e
commit c2f1a51725
4 changed files with 24 additions and 23 deletions

View File

@ -290,6 +290,7 @@ namespace OpenHardwareMonitor.GUI {
// Make sure the settings are saved when the user logs off
Microsoft.Win32.SystemEvents.SessionEnded += delegate {
computer.Close();
SaveConfiguration();
if (runWebServer.Value)
server.Quit();

View File

@ -41,13 +41,13 @@ namespace OpenHardwareMonitor.Hardware {
null);
if (service == IntPtr.Zero) {
if (Marshal.GetHRForLastWin32Error() == ERROR_SERVICE_EXISTS)
service = NativeMethods.OpenService(manager, id,
ServiceAccessRights.SERVICE_ALL_ACCESS);
else {
if (Marshal.GetHRForLastWin32Error() == ERROR_SERVICE_EXISTS) {
errorMessage = "Service already exists";
return false;
} else {
errorMessage = "CreateService returned the error: " +
Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()).Message;
NativeMethods.CloseServiceHandle(manager);
NativeMethods.CloseServiceHandle(manager);
return false;
}
}

View File

@ -46,29 +46,29 @@ namespace OpenHardwareMonitor.Hardware {
IOControlCode.Access.Read);
private static string GetTempFileName() {
// try to get a file in the temporary folder
try {
return Path.GetTempFileName();
} catch (IOException) {
// some I/O exception
}
catch (UnauthorizedAccessException) {
// we do not have the right to create a file in the temp folder
}
catch (NotSupportedException) {
// invalid path format of the TMP system environment variable
}
// if this failed, we try to create one in the application folder
// try to create one in the application folder
string fileName = Path.ChangeExtension(
Assembly.GetExecutingAssembly().Location, ".sys");
Assembly.GetEntryAssembly().Location, ".sys");
try {
using (FileStream stream = File.Create(fileName)) {
return fileName;
}
} catch (IOException) { }
catch (UnauthorizedAccessException) { }
// if this failed, try to get a file in the temporary folder
try {
return Path.GetTempFileName();
} catch (IOException) {
// some I/O exception
}
catch (UnauthorizedAccessException) {
// we do not have the right to create a file in the temp folder
}
catch (NotSupportedException) {
// invalid path format of the TMP system environment variable
}
return null;
}

View File

@ -10,5 +10,5 @@
using System.Reflection;
[assembly: AssemblyVersion("0.5.1.2")]
[assembly: AssemblyInformationalVersion("0.5.1.2 Alpha")]
[assembly: AssemblyVersion("0.5.1.4")]
[assembly: AssemblyInformationalVersion("0.5.1.4 Alpha")]