mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-09-04 00:05:27 +00:00
Added more report output to the kernel driver loading code. Hopefully this helps to find the problems in Issue 253.
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
Copyright (C) 2010 Michael Möller <mmoeller@openhardwaremonitor.org>
|
Copyright (C) 2010-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -25,12 +25,14 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Install(string path) {
|
public bool Install(string path, out string errorMessage) {
|
||||||
IntPtr manager = NativeMethods.OpenSCManager(null, null,
|
IntPtr manager = NativeMethods.OpenSCManager(null, null,
|
||||||
ServiceControlManagerAccessRights.SC_MANAGER_ALL_ACCESS);
|
ServiceControlManagerAccessRights.SC_MANAGER_ALL_ACCESS);
|
||||||
|
|
||||||
if (manager == IntPtr.Zero)
|
if (manager == IntPtr.Zero) {
|
||||||
|
errorMessage = "OpenSCManager returned zero.";
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
IntPtr service = NativeMethods.CreateService(manager, id, id,
|
IntPtr service = NativeMethods.CreateService(manager, id, id,
|
||||||
ServiceAccessRights.SERVICE_ALL_ACCESS,
|
ServiceAccessRights.SERVICE_ALL_ACCESS,
|
||||||
@@ -42,13 +44,22 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
if (Marshal.GetHRForLastWin32Error() == ERROR_SERVICE_EXISTS)
|
if (Marshal.GetHRForLastWin32Error() == ERROR_SERVICE_EXISTS)
|
||||||
service = NativeMethods.OpenService(manager, id,
|
service = NativeMethods.OpenService(manager, id,
|
||||||
ServiceAccessRights.SERVICE_ALL_ACCESS);
|
ServiceAccessRights.SERVICE_ALL_ACCESS);
|
||||||
else
|
else {
|
||||||
|
errorMessage = "CreateService returned the error: " +
|
||||||
|
Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()).Message;
|
||||||
|
NativeMethods.CloseServiceHandle(manager);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NativeMethods.StartService(service, 0, null)) {
|
if (!NativeMethods.StartService(service, 0, null)) {
|
||||||
if (Marshal.GetHRForLastWin32Error() != ERROR_SERVICE_ALREADY_RUNNING)
|
if (Marshal.GetHRForLastWin32Error() != ERROR_SERVICE_ALREADY_RUNNING) {
|
||||||
|
errorMessage = "StartService returned the error: " +
|
||||||
|
Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()).Message;
|
||||||
|
NativeMethods.CloseServiceHandle(service);
|
||||||
|
NativeMethods.CloseServiceHandle(manager);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeMethods.CloseServiceHandle(service);
|
NativeMethods.CloseServiceHandle(service);
|
||||||
@@ -62,7 +73,8 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
"O:BAG:SYD:(A;;FA;;;SY)(A;;FA;;;BA)");
|
"O:BAG:SYD:(A;;FA;;;SY)(A;;FA;;;BA)");
|
||||||
File.SetAccessControl(@"\\.\" + id, fileSecurity);
|
File.SetAccessControl(@"\\.\" + id, fileSecurity);
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
|
errorMessage = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -127,7 +127,8 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
|
|
||||||
fileName = GetTempFileName();
|
fileName = GetTempFileName();
|
||||||
if (fileName != null && ExtractDriver(fileName)) {
|
if (fileName != null && ExtractDriver(fileName)) {
|
||||||
if (driver.Install(fileName)) {
|
string installError;
|
||||||
|
if (driver.Install(fileName, out installError)) {
|
||||||
driver.Open();
|
driver.Open();
|
||||||
|
|
||||||
if (!driver.IsOpen) {
|
if (!driver.IsOpen) {
|
||||||
@@ -135,10 +136,13 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
report.AppendLine("Status: Opening driver failed after install");
|
report.AppendLine("Status: Opening driver failed after install");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
string errorFirstInstall = installError;
|
||||||
|
|
||||||
// install failed, try to delete and reinstall
|
// install failed, try to delete and reinstall
|
||||||
driver.Delete();
|
driver.Delete();
|
||||||
|
|
||||||
if (driver.Install(fileName)) {
|
string errorSecondInstall;
|
||||||
|
if (driver.Install(fileName, out errorSecondInstall)) {
|
||||||
driver.Open();
|
driver.Open();
|
||||||
|
|
||||||
if (!driver.IsOpen) {
|
if (!driver.IsOpen) {
|
||||||
@@ -150,9 +154,8 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
report.AppendLine("Status: Installing driver \"" +
|
report.AppendLine("Status: Installing driver \"" +
|
||||||
fileName + "\" failed" +
|
fileName + "\" failed" +
|
||||||
(File.Exists(fileName) ? " and file exists" : ""));
|
(File.Exists(fileName) ? " and file exists" : ""));
|
||||||
report.AppendLine();
|
report.AppendLine("First Exception: " + errorFirstInstall);
|
||||||
report.Append("Exception: " + Marshal.GetExceptionForHR(
|
report.AppendLine("Second Exception: " + errorSecondInstall);
|
||||||
Marshal.GetHRForLastWin32Error()).Message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -10,5 +10,5 @@
|
|||||||
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion("0.4.0.18")]
|
[assembly: AssemblyVersion("0.4.0.19")]
|
||||||
[assembly: AssemblyInformationalVersion("0.4.0.18 Alpha")]
|
[assembly: AssemblyInformationalVersion("0.4.0.19 Alpha")]
|
Reference in New Issue
Block a user