diff --git a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs index 8c016c54e..f56051716 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs @@ -217,12 +217,6 @@ namespace System.Management.Automation } - // The Antimalware Scan Interface is not supported on Linux - internal static bool HasAmsi() - { - return IsWindows; - } - // This is mainly with respect to the auto-mounting of // disconnected network drives on Windows internal static bool HasDriveAutoMounting() diff --git a/src/System.Management.Automation/security/SecuritySupport.cs b/src/System.Management.Automation/security/SecuritySupport.cs index 05ae9f77d..f66d8094c 100644 --- a/src/System.Management.Automation/security/SecuritySupport.cs +++ b/src/System.Management.Automation/security/SecuritySupport.cs @@ -1633,14 +1633,11 @@ namespace System.Management.Automation /// AMSI_RESULT_DETECTED if malware was detected in the sample. internal static AmsiNativeMethods.AMSI_RESULT ScanContent(string content, string sourceMetadata) { - if (Platform.HasAmsi()) - { - return WinScanContent(content,sourceMetadata); - } - else - { - return AmsiNativeMethods.AMSI_RESULT.AMSI_RESULT_NOT_DETECTED; - } +#if LINUX + return AmsiNativeMethods.AMSI_RESULT.AMSI_RESULT_NOT_DETECTED; +#else + return WinScanContent(content,sourceMetadata); +#endif } internal static AmsiNativeMethods.AMSI_RESULT WinScanContent(string content, string sourceMetadata) @@ -1730,14 +1727,9 @@ namespace System.Management.Automation internal static void CurrentDomain_ProcessExit(object sender, EventArgs e) { - if (Platform.HasAmsi()) - { - VerifyAmsiUninitializeCalled(); - } - else - { - throw new PlatformNotSupportedException(); - } +#if !LINUX + VerifyAmsiUninitializeCalled(); +#endif } [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] @@ -1753,16 +1745,9 @@ namespace System.Management.Automation /// internal static void CloseSession() { - if (Platform.HasAmsi()) - { - WinCloseSession(); - } - else - { - // Porting note: cannot throw here because this is called whether or not - // AMSI was initialized in the first place - return; - } +#if !LINUX + WinCloseSession(); +#endif } internal static void WinCloseSession() @@ -1789,16 +1774,9 @@ namespace System.Management.Automation /// internal static void Uninitialize() { - if (Platform.HasAmsi()) - { - WinUninitialize(); - } - else - { - // Porting note: cannot throw here because this is called whether or not - // AMSI was initialized in the first place - return; - } +#if !LINUX + WinUninitialize(); +#endif } internal static void WinUninitialize() diff --git a/test/csharp/test_CorePsPlatform.cs b/test/csharp/test_CorePsPlatform.cs index ce979e818..8709dccab 100644 --- a/test/csharp/test_CorePsPlatform.cs +++ b/test/csharp/test_CorePsPlatform.cs @@ -15,12 +15,6 @@ namespace PSTests Assert.True(Platform.IsCore); } - [Fact] - public static void TestHasAmsi() - { - Assert.False(Platform.HasAmsi()); - } - [Fact] public static void TestHasDriveAutoMounting() {