From 1f1811b9acb7e3e98d9c8c1afebb3b3be9a45096 Mon Sep 17 00:00:00 2001 From: Emma Alyx Wunder Date: Thu, 13 Jun 2024 03:18:48 +0200 Subject: [PATCH] Added log message for third-party AVs --- src/Ryujinx.Common/Utilities/AVUtils.cs | 38 +++++++++++++++++++++++++ src/Ryujinx.Gtk3/Program.cs | 7 +++++ src/Ryujinx/Program.cs | 7 +++++ 3 files changed, 52 insertions(+) create mode 100644 src/Ryujinx.Common/Utilities/AVUtils.cs diff --git a/src/Ryujinx.Common/Utilities/AVUtils.cs b/src/Ryujinx.Common/Utilities/AVUtils.cs new file mode 100644 index 000000000..246d0740b --- /dev/null +++ b/src/Ryujinx.Common/Utilities/AVUtils.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq; +using System.Management; + +namespace Ryujinx.Common.Utilities +{ + public static class AVUtils + { + public static string GetAVName() + { + if (!OperatingSystem.IsWindows()) + { + return null; + } + + ManagementObjectSearcher wmiData = new ManagementObjectSearcher(@"root\SecurityCenter2", "SELECT * FROM AntiVirusProduct"); + ManagementObjectCollection data = wmiData.Get(); + + foreach (ManagementObject dataObj in data.Cast()) + { + try + { + string displayName = (string)dataObj["displayName"]; + if (displayName != "Windows Defender") + { + return displayName; + } + } + catch (ManagementException) + { + continue; + } + } + + return null; + } + } +} diff --git a/src/Ryujinx.Gtk3/Program.cs b/src/Ryujinx.Gtk3/Program.cs index 749cb6978..73f2b9f48 100644 --- a/src/Ryujinx.Gtk3/Program.cs +++ b/src/Ryujinx.Gtk3/Program.cs @@ -4,6 +4,7 @@ using Ryujinx.Common.Configuration; using Ryujinx.Common.GraphicsDriver; using Ryujinx.Common.Logging; using Ryujinx.Common.SystemInterop; +using Ryujinx.Common.Utilities; using Ryujinx.Modules; using Ryujinx.SDL2.Common; using Ryujinx.UI; @@ -341,6 +342,12 @@ namespace Ryujinx Logger.Notice.Print(LogClass.Application, $"Ryujinx Version: {Version}"); SystemInfo.Gather().Print(); + string avName = AVUtils.GetAVName(); + if (avName != null) + { + Logger.Notice.Print(LogClass.Application, $"Detected AV: {avName}"); + } + var enabledLogs = Logger.GetEnabledLevels(); Logger.Notice.Print(LogClass.Application, $"Logs Enabled: {(enabledLogs.Count == 0 ? "" : string.Join(", ", enabledLogs))}"); diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index 4f68ca24f..2b86987dd 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -7,6 +7,7 @@ using Ryujinx.Common.Configuration; using Ryujinx.Common.GraphicsDriver; using Ryujinx.Common.Logging; using Ryujinx.Common.SystemInterop; +using Ryujinx.Common.Utilities; using Ryujinx.Modules; using Ryujinx.SDL2.Common; using Ryujinx.UI.Common; @@ -214,6 +215,12 @@ namespace Ryujinx.Ava Logger.Notice.Print(LogClass.Application, $"Ryujinx Version: {Version}"); SystemInfo.Gather().Print(); + string avName = AVUtils.GetAVName(); + if (avName != null) + { + Logger.Notice.Print(LogClass.Application, $"Detected AV: {avName}"); + } + Logger.Notice.Print(LogClass.Application, $"Logs Enabled: {(Logger.GetEnabledLevels().Count == 0 ? "" : string.Join(", ", Logger.GetEnabledLevels()))}"); if (AppDataManager.Mode == AppDataManager.LaunchMode.Custom)