diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 7d98454f9..3c88f1a4a 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -663,6 +663,7 @@ True Resources.resx + diff --git a/Artemis/Artemis/ArtemisBootstrapper.cs b/Artemis/Artemis/ArtemisBootstrapper.cs index c50498429..978297814 100644 --- a/Artemis/Artemis/ArtemisBootstrapper.cs +++ b/Artemis/Artemis/ArtemisBootstrapper.cs @@ -8,6 +8,7 @@ using System.Windows.Controls; using System.Windows.Input; using Artemis.DAL; using Artemis.InjectionModules; +using Artemis.Services; using Artemis.Settings; using Artemis.Utilities; using Artemis.Utilities.ActiveWindowDetection; @@ -32,6 +33,8 @@ namespace Artemis Logging.SetupLogging(SettingsProvider.Load().LogLevel); // Restore DDLs before interacting with any SDKs DllManager.RestoreLogitechDll(); + // Check compatibility before trying to boot further + CompatibilityService.CheckRivaTuner(); Initialize(); BindSpecialValues(); diff --git a/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs b/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs index d7eaa7bfc..ec8ecd391 100644 --- a/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs +++ b/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs @@ -14,8 +14,7 @@ namespace Artemis.DeviceProviders.Logitech DllManager.RestoreLogitechDll(); // Check to see if VC++ 2012 x64 is installed. - if (Registry.LocalMachine.OpenSubKey( - @"SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}") == null) + if (Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}") == null) { CantEnableText = "Couldn't connect to your Logitech keyboard.\n" + "The Visual C++ 2012 Redistributable v11.0.61030.0 could not be found, which is required.\n" + diff --git a/Artemis/Artemis/Services/CompatibilityService.cs b/Artemis/Artemis/Services/CompatibilityService.cs new file mode 100644 index 000000000..0bd2d07e2 --- /dev/null +++ b/Artemis/Artemis/Services/CompatibilityService.cs @@ -0,0 +1,41 @@ +using System.IO; +using System.Linq; +using System.Threading; +using Microsoft.Win32; +using NLog; + +namespace Artemis.Services +{ + public static class CompatibilityService + { + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + // Checks to see if RivaTuner Statistics Server is installed and if so places a profile disabling it for Artemis + public static void CheckRivaTuner() + { + // Find the installation path in the registry + var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Unwinder\RTSS"); + var value = key?.GetValue("InstallPath"); + var installDir = Path.GetDirectoryName(value?.ToString()); + + if (installDir == null) + return; + var profilePath = Path.Combine(installDir, "ProfileTemplates\\Artemis.exe.cfg"); + if (File.Exists(profilePath)) + return; + + File.WriteAllText(profilePath, "[Hooking]\r\nEnableHooking\t\t= 0"); + + // It's kill or be killed... + var rtssProcess = System.Diagnostics.Process.GetProcessesByName("RTSS").FirstOrDefault(); + var rtssHookProcess = System.Diagnostics.Process.GetProcessesByName("RTSSHooksLoader64").FirstOrDefault(); + rtssProcess?.Kill(); + rtssHookProcess?.Kill(); + + // Funnily enough sleeping prevents the RTSS injection so that the process gets killed in time + Thread.Sleep(1000); + + Logger.Info("Detected that RivaTuner Statistics Server is installed, inserted a profile to prevent crashes."); + } + } +}