Exemplo n.º 1
0
        public bool IsMalware(string payload, string contentName)
        {
            var returnValue = Amsi.AmsiScanString(_handle, payload, contentName, s_defaultSession, out var result);

            if (returnValue != 0)
            {
                throw new Win32Exception(returnValue);
            }

            return(Amsi.AmsiResultIsMalware(result));
        }
Exemplo n.º 2
0
        public bool IsMalware(byte[] payload, string contentName)
        {
            var returnValue = Amsi.AmsiScanBuffer(_handle, payload, (uint)payload.Length, contentName, s_defaultSession, out var result);

            if (returnValue != 0)
            {
                throw new Win32Exception(returnValue);
            }

            return(Amsi.AmsiResultIsMalware(result));
        }
Exemplo n.º 3
0
        public static AmsiContext Create(string applicationName)
        {
            int result = Amsi.AmsiInitialize(applicationName, out var context);

            if (result != 0)
            {
                throw new Win32Exception(result);
            }

            return(new AmsiContext(context));
        }
Exemplo n.º 4
0
        public AmsiSession CreateSession()
        {
            var result = Amsi.AmsiOpenSession(_handle, out var session);

            session.Context = _handle;
            if (result != 0)
            {
                throw new Win32Exception(result);
            }

            return(new AmsiSession(this, session));
        }
 protected override bool ReleaseHandle()
 {
     Amsi.AmsiCloseSession(Context, handle);
     return(true);
 }
Exemplo n.º 6
0
 protected override bool ReleaseHandle()
 {
     Amsi.AmsiUninitialize(handle);
     return(true);
 }
 protected override bool ReleaseHandle()
 {
     Debug.Assert(Context != null);
     Amsi.AmsiCloseSession(Context, handle);
     return(true);
 }