public AmsiMalwareScanner() { AmsiContextSafeHandle handle; int pInvokeResult = AmsiNativeMethods.AmsiInitialize(AppIdentifier, out handle); if (pInvokeResult != 0 || handle.IsInvalid) { throw new MalwareScanningException( "Failed to initialize AMSI context. For more details see inner exception.", new Win32Exception(Marshal.GetLastWin32Error())); } this.contextHandle = handle; }
public static extern int AmsiScanBuffer(AmsiContextSafeHandle amsiContext, [In][MarshalAs(UnmanagedType.LPArray)] byte[] buffer, uint length, [In()][MarshalAs(UnmanagedType.LPWStr)] string contentName, IntPtr session, out AMSI_RESULT result);
public static extern void AmsiCloseSession(AmsiContextSafeHandle amsiContext, IntPtr session);
public static extern int AmsiOpenSession(AmsiContextSafeHandle amsiContext, out IntPtr session);
public static extern int AmsiInitialize([MarshalAs(UnmanagedType.LPWStr)] string appName, out AmsiContextSafeHandle amsiContext);