Browse Source

Adjusted log messages to be marginally more helpful

pull/72/head
Anairkoen Schno 3 years ago
parent
commit
0c3649861b
Signed by: DaNike GPG Key ID: BEFB74D5F3FC4387
5 changed files with 15 additions and 7 deletions
  1. +3
    -0
      IPA.Loader/AntiMalware/AntiMalwareEngine.cs
  2. +8
    -3
      IPA.Loader/AntiMalware/WindowsWin32AntiMalware.cs
  3. +1
    -1
      IPA.Loader/AntiMalware/_HideInNet3/ComAPI/IAntimalware.cs
  4. +3
    -3
      IPA.Loader/AntiMalware/_HideInNet3/WindowsCOMAntiMalware.cs
  5. BIN
      Refs/UnityEngine.CoreModule.Net4.dll

+ 3
- 0
IPA.Loader/AntiMalware/AntiMalwareEngine.cs View File

@ -1,4 +1,5 @@
#nullable enable
using IPA.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
@ -28,6 +29,8 @@ namespace IPA.AntiMalware
engine ??= WindowsWin32AntiMalware.TryInitialize();
engine ??= new NoopAntiMalware();
Logger.AntiMalware.Debug($"Antimalware engine initialized with {engine.GetType()}");
return engine;
}
}


+ 8
- 3
IPA.Loader/AntiMalware/WindowsWin32AntiMalware.cs View File

@ -1,5 +1,4 @@
#nullable enable
using IPA.AntiMalware.ComAPI;
using IPA.Logging;
using System;
using System.Collections.Generic;
@ -21,7 +20,7 @@ namespace IPA.AntiMalware
}
catch (Exception e)
{
Logger.AntiMalware.Warn("Could not initialize antimalware engine:");
Logger.AntiMalware.Warn("Could not initialize Win32-based antimalware engine:");
Logger.AntiMalware.Warn(e);
return null;
}
@ -56,7 +55,7 @@ namespace IPA.AntiMalware
AmsiScanBuffer(handle, data, (uint)data.Length, contentName, IntPtr.Zero, out var result);
Logger.AntiMalware.Debug($"Scanned data named '{contentName}' and got '{result}'");
Logger.AntiMalware.Trace($"Scanned data named '{contentName}' and got '{result}'");
return ScanResultFromAmsiResult(result);
}
@ -88,15 +87,21 @@ namespace IPA.AntiMalware
}
[DllImport("amsi", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true)]
#if !NET35
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
#endif
private static extern void AmsiInitialize([MarshalAs(UnmanagedType.LPWStr)] string appName, [Out] out IntPtr handle);
[DllImport("amsi", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true)]
#if !NET35
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
#endif
private static extern void AmsiUninitialize(IntPtr handle);
[DllImport("amsi", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true)]
#if !NET35
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
#endif
private static extern void AmsiScanBuffer(IntPtr context,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] buffer, uint length,
[MarshalAs(UnmanagedType.LPWStr)] string contentName,


+ 1
- 1
IPA.Loader/AntiMalware/_HideInNet3/ComAPI/IAntimalware.cs View File

@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace IPA.AntiMalware.WinAPI
namespace IPA.AntiMalware.ComAPI
{
[Guid("82d29c2e-f062-44e6-b5c9-3d9a2f24a2df")]
[ComVisible(true)]


+ 3
- 3
IPA.Loader/AntiMalware/_HideInNet3/WindowsCOMAntiMalware.cs View File

@ -20,7 +20,7 @@ namespace IPA.AntiMalware
}
catch (Exception e)
{
Logger.AntiMalware.Warn("Could not initialize antimalware engine:");
Logger.AntiMalware.Warn("Could not initialize COM-based antimalware engine:");
Logger.AntiMalware.Warn(e);
return null;
}
@ -47,7 +47,7 @@ namespace IPA.AntiMalware
{
using var stream = new AmsiFileStream(file, IntPtr.Zero);
amInterface.Scan(stream, out var result, out var provider);
Logger.AntiMalware.Debug($"Scanned file '{file}' with {provider.DisplayName()}, and got '{result}'");
Logger.AntiMalware.Trace($"Scanned file '{file}' with {provider.DisplayName()}, and got '{result}'");
return ScanResultFromAmsiResult(result);
}
@ -56,7 +56,7 @@ namespace IPA.AntiMalware
contentName ??= $"unknown_data_{Guid.NewGuid()}";
using var stream = new AmsiMemoryStream(contentName, data, IntPtr.Zero);
amInterface.Scan(stream, out var result, out var provider);
Logger.AntiMalware.Debug($"Scanned data named '{contentName}' with {provider.DisplayName()}, and got '{result}'");
Logger.AntiMalware.Trace($"Scanned data named '{contentName}' with {provider.DisplayName()}, and got '{result}'");
return ScanResultFromAmsiResult(result);
}
}


BIN
Refs/UnityEngine.CoreModule.Net4.dll View File


Loading…
Cancel
Save