From 4a588b5d5ceb4f0fb08f67e7359011477d112908 Mon Sep 17 00:00:00 2001 From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Sun, 1 Dec 2019 18:03:46 +0300 Subject: [PATCH] Implemented BasicDisplay autostart enable/disable tasks --- RadeonResetBugFixService/Constants.cs | 2 ++ RadeonResetBugFixService/MainHandler.cs | 2 ++ .../RadeonResetBugFixService.csproj | 2 ++ .../Tasks/DisableBasicDisplayStartupTask.cs | 17 +++++++++++++++++ .../Tasks/EnableBasicDisplayStartupTask.cs | 17 +++++++++++++++++ 5 files changed, 40 insertions(+) create mode 100644 RadeonResetBugFixService/Tasks/DisableBasicDisplayStartupTask.cs create mode 100644 RadeonResetBugFixService/Tasks/EnableBasicDisplayStartupTask.cs diff --git a/RadeonResetBugFixService/Constants.cs b/RadeonResetBugFixService/Constants.cs index 6a7d25b..3402328 100644 --- a/RadeonResetBugFixService/Constants.cs +++ b/RadeonResetBugFixService/Constants.cs @@ -5,5 +5,7 @@ static class Constants { public static TimeSpan ServiceTimeout { get; } = TimeSpan.FromMinutes(5); + + public static string BasicDisplayRegistryKey { get; } = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BasicDisplay"; } } diff --git a/RadeonResetBugFixService/MainHandler.cs b/RadeonResetBugFixService/MainHandler.cs index c4ec2f1..d8eb37a 100644 --- a/RadeonResetBugFixService/MainHandler.cs +++ b/RadeonResetBugFixService/MainHandler.cs @@ -49,6 +49,7 @@ logger, new ITask[] { + new EnableBasicDisplayStartupTask(), new SleepTask(TimeSpan.FromSeconds(20)), new DisableVirtualVideoTask(this.StartupDevicesStatus), new EnableAmdVideoTask(this.StartupDevicesStatus), @@ -88,6 +89,7 @@ new EnableVirtualVideoTask(this.ShutdownDevicesStatus), new LastResortDevicesRestoreTask(this.StartupDevicesStatus), new LastResortDevicesRestoreTask(this.StartupDevicesStatus), // just in case + new DisableBasicDisplayStartupTask(), }); } } diff --git a/RadeonResetBugFixService/RadeonResetBugFixService.csproj b/RadeonResetBugFixService/RadeonResetBugFixService.csproj index 0a1e988..a8a232b 100644 --- a/RadeonResetBugFixService/RadeonResetBugFixService.csproj +++ b/RadeonResetBugFixService/RadeonResetBugFixService.csproj @@ -73,6 +73,8 @@ + + diff --git a/RadeonResetBugFixService/Tasks/DisableBasicDisplayStartupTask.cs b/RadeonResetBugFixService/Tasks/DisableBasicDisplayStartupTask.cs new file mode 100644 index 0000000..6953bd1 --- /dev/null +++ b/RadeonResetBugFixService/Tasks/DisableBasicDisplayStartupTask.cs @@ -0,0 +1,17 @@ +namespace RadeonResetBugFixService.Tasks +{ + using Microsoft.Win32; + using Contracts; + + class DisableBasicDisplayStartupTask : ITask + { + string ITask.TaskName => "Disabling basic display automatic start"; + + void ITask.Run(ILogger logger) + { + var originalValue = Registry.GetValue(Constants.BasicDisplayRegistryKey, "Start", -1); + logger.Log($"Original start value {originalValue}"); + Registry.SetValue(Constants.BasicDisplayRegistryKey, "Start", 4); + } + } +} diff --git a/RadeonResetBugFixService/Tasks/EnableBasicDisplayStartupTask.cs b/RadeonResetBugFixService/Tasks/EnableBasicDisplayStartupTask.cs new file mode 100644 index 0000000..b3b3809 --- /dev/null +++ b/RadeonResetBugFixService/Tasks/EnableBasicDisplayStartupTask.cs @@ -0,0 +1,17 @@ +namespace RadeonResetBugFixService.Tasks +{ + using Microsoft.Win32; + using Contracts; + + class EnableBasicDisplayStartupTask : ITask + { + string ITask.TaskName => "Enabling basic display automatic start"; + + void ITask.Run(ILogger logger) + { + var originalValue = Registry.GetValue(Constants.BasicDisplayRegistryKey, "Start", -1); + logger.Log($"Original start value {originalValue}"); + Registry.SetValue(Constants.BasicDisplayRegistryKey, "Start", 3); + } + } +}