Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3649,6 +3649,7 @@ internal static object[] GetSlice(IList list, int startIndex)

internal static class MemberInvocationLoggingOps
{
#if DEBUG
private static readonly Lazy<bool> DumpLogAMSIContent = new Lazy<bool>(
() => {
object result = Environment.GetEnvironmentVariable("__PSDumpAMSILogContent");
Expand All @@ -3659,6 +3660,7 @@ internal static class MemberInvocationLoggingOps
return false;
}
);
#endif

private static string ArgumentToString(object arg)
{
Expand Down Expand Up @@ -3713,33 +3715,41 @@ internal static void LogMemberInvocation(string targetName, string name, object[

string content = $"<{targetName}>.{name}({argsBuilder})";

#if DEBUG
if (DumpLogAMSIContent.Value)
{
Console.WriteLine("\n=== Amsi notification report content ===");
Console.WriteLine(content);
}
#endif

var success = AmsiUtils.ReportContent(
name: contentName,
content: content);

#if DEBUG
if (DumpLogAMSIContent.Value)
{
Console.WriteLine($"=== Amsi notification report success: {success} ===");
}
#endif
}
catch (PSSecurityException)
{
// ReportContent() will throw PSSecurityException if AMSI detects malware, which
// must be propagated.
throw;
}
#pragma warning disable CS0168 // variable declared but never used
catch (Exception ex)
#pragma warning restore CS0168
{
#if DEBUG
if (DumpLogAMSIContent.Value)
{
Console.WriteLine($"!!! Amsi notification report exception: {ex} !!!");
}
#endif
}
}
}
Expand Down
Loading