mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Remove Platform.HasAmsi query
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -1633,14 +1633,11 @@ namespace System.Management.Automation
|
||||
/// <returns>AMSI_RESULT_DETECTED if malware was detected in the sample.</returns>
|
||||
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
|
||||
/// </summary>
|
||||
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
|
||||
/// </summary>
|
||||
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()
|
||||
|
||||
@@ -15,12 +15,6 @@ namespace PSTests
|
||||
Assert.True(Platform.IsCore);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestHasAmsi()
|
||||
{
|
||||
Assert.False(Platform.HasAmsi());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestHasDriveAutoMounting()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user