Also try using executing assembly name as service name for Ring0
This commit is contained in:
@@ -36,7 +36,6 @@ namespace LibreHardwareMonitor.Hardware
|
||||
if (_driver != null)
|
||||
return;
|
||||
|
||||
|
||||
// clear the current report
|
||||
_report.Length = 0;
|
||||
|
||||
@@ -58,15 +57,13 @@ namespace LibreHardwareMonitor.Hardware
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorFirstInstall = installError;
|
||||
|
||||
// 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);
|
||||
|
||||
if (_driver.Install(_filePath, out string errorSecondInstall))
|
||||
if (_driver.Install(_filePath, out string secondError))
|
||||
{
|
||||
_driver.Open();
|
||||
|
||||
@@ -75,9 +72,9 @@ namespace LibreHardwareMonitor.Hardware
|
||||
}
|
||||
else
|
||||
{
|
||||
_report.AppendLine("Status: Installing driver \"" + _filePath + "\" failed" + (File.Exists(_filePath) ? " and file exists" : string.Empty));
|
||||
_report.AppendLine("First Exception: " + errorFirstInstall);
|
||||
_report.AppendLine("Second Exception: " + errorSecondInstall);
|
||||
_report.Append("Status: Installing driver \"").Append(_filePath).Append("\" failed").AppendLine((File.Exists(_filePath) ? " and file exists" : string.Empty));
|
||||
_report.Append("First Exception: ").AppendLine(installError);
|
||||
_report.Append("Second Exception: ").AppendLine(secondError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +85,9 @@ namespace LibreHardwareMonitor.Hardware
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_report.AppendLine("Status: Extracting driver failed");
|
||||
}
|
||||
}
|
||||
|
||||
if (!_driver.IsOpen)
|
||||
@@ -168,8 +167,7 @@ namespace LibreHardwareMonitor.Hardware
|
||||
|
||||
if (buffer == null)
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
using FileStream target = new(filePath, FileMode.Create);
|
||||
@@ -229,7 +227,7 @@ namespace LibreHardwareMonitor.Hardware
|
||||
{
|
||||
name = Path.GetFileNameWithoutExtension(processModule.FileName);
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
return GetWinRing0Name(name);
|
||||
return GetName(name);
|
||||
}
|
||||
}
|
||||
catch
|
||||
@@ -237,18 +235,23 @@ namespace LibreHardwareMonitor.Hardware
|
||||
// Continue with the other options.
|
||||
}
|
||||
|
||||
AssemblyName assemblyName = typeof(Ring0).Assembly.GetName();
|
||||
|
||||
name = assemblyName.Name;
|
||||
name = GetNameFromAssembly(Assembly.GetExecutingAssembly());
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
return GetWinRing0Name(name);
|
||||
return GetName(name);
|
||||
|
||||
name = GetNameFromAssembly(typeof(Ring0).Assembly);
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
return GetName(name);
|
||||
|
||||
name = nameof(LibreHardwareMonitor);
|
||||
return GetWinRing0Name(name);
|
||||
return GetName(name);
|
||||
|
||||
static string GetNameFromAssembly(Assembly assembly)
|
||||
{
|
||||
return assembly?.GetName().Name;
|
||||
}
|
||||
|
||||
static string GetWinRing0Name(string name)
|
||||
static string GetName(string name)
|
||||
{
|
||||
return $"R0{name}".Replace(" ", string.Empty).Replace(".", "_");
|
||||
}
|
||||
@@ -277,12 +280,10 @@ namespace LibreHardwareMonitor.Hardware
|
||||
if (!string.IsNullOrEmpty(filePath) && TryCreate(filePath))
|
||||
return filePath;
|
||||
|
||||
|
||||
filePath = GetPathFromAssembly(typeof(Ring0).Assembly);
|
||||
if (!string.IsNullOrEmpty(filePath) && TryCreate(filePath))
|
||||
return filePath;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
filePath = Path.GetTempFileName();
|
||||
@@ -300,7 +301,6 @@ namespace LibreHardwareMonitor.Hardware
|
||||
|
||||
return null;
|
||||
|
||||
|
||||
static string GetPathFromAssembly(Assembly assembly)
|
||||
{
|
||||
try
|
||||
@@ -314,7 +314,6 @@ namespace LibreHardwareMonitor.Hardware
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool TryCreate(string path)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user