From 76c93c81e571c1697e3036d4b0c036b3ccbd7afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Mon, 28 Nov 2022 11:11:30 +0100 Subject: [PATCH] Fix `AccessDenied` in Steam Detection --- RELEASE.md | 1 + SteamController/Helpers/SteamConfiguration.cs | 25 +++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 3736f26..da253e3 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -29,3 +29,4 @@ It does help this project on being supported. - Append `controller_blacklist` to `config.vdf` if missing - Add configurable BackPanel keys (allowed mappings are subject to change) - Fix delay in X360Rumble: Do not send repeated haptic if disabled +- Fix `AccessDenied` in Steam Detection diff --git a/SteamController/Helpers/SteamConfiguration.cs b/SteamController/Helpers/SteamConfiguration.cs index 00adf02..04b680e 100644 --- a/SteamController/Helpers/SteamConfiguration.cs +++ b/SteamController/Helpers/SteamConfiguration.cs @@ -27,17 +27,8 @@ namespace SteamController.Helpers var value = GetValue(ActiveProcessKey, PIDValue); if (value is null) return null; - try - { - using (var process = Process.GetProcessById(value.Value)) - { - return !process.HasExited; - } - } - catch (ArgumentException) - { - return false; - } + using (var process = SteamProcess) + return process is not null; } } @@ -102,12 +93,14 @@ namespace SteamController.Helpers return null; try { - return Process.GetProcessById(value.Value); - } - catch (ArgumentException) - { - return null; + var process = Process.GetProcessById(value.Value); + if (!process.ProcessName.Equals("Steam", StringComparison.CurrentCultureIgnoreCase)) + return null; + if (process.HasExited) + return null; + return process; } + catch { return null; } } }