You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.3 KiB

#nullable enable
using IPA.Config;
using IPA.Logging;
using System;
namespace IPA.AntiMalware
{
/// <summary>
/// Provides a way to access BSIPA's Anti-Malware engine.
/// </summary>
/// <see cref="Engine"/>
/// <see cref="IAntiMalware"/>
public static class AntiMalwareEngine
{
private static IAntiMalware? engine;
/// <summary>
/// Gets the current Anti-Malware engine.
/// </summary>
public static IAntiMalware Engine => engine ?? throw new InvalidOperationException();
internal static bool IsInitialized => engine != null;
internal static void Initialize()
{
engine = CreateEngine();
}
private static IAntiMalware CreateEngine()
{
IAntiMalware? engine = null;
if (SelfConfig.AntiMalware_.UseIfAvailable_)
{
#if !NET35
engine = WindowsCOMAntiMalware.TryInitialize();
#endif
engine ??= WindowsWin32AntiMalware.TryInitialize();
}
engine ??= new NoopAntiMalware();
Logger.AntiMalware.Debug($"Antimalware engine initialized with {engine.GetType()}");
return engine;
}
}
}