Posts

Showing posts from December, 2016

Consume Antimalware Scan Interface (AMSI) from C#

Image
Windows 10 have a new mechanism that will allow software developers to integrate their applications with the antimalware programs exist on users’ computers. The goal of the new Antimalware Scan Interface (AMSI) is to let applications send content to the locally installed antivirus product to be checked for malware. C# sample code is not available in msdn. Here is the sample C# code to communicate with antimalware product installed in your machine. I have Windows Defender installed in my machine and this code communicates to windows defender internally to get the job done. public enum AMSI_RESULT 3: { 4: AMSI_RESULT_CLEAN = 0, 5: AMSI_RESULT_NOT_DETECTED = 1, 6: AMSI_RESULT_DETECTED = 32768 7: } 8: 9: [DllImport("Amsi.dll", EntryPoint = "AmsiInitialize", CallingConvention = CallingConvention.StdCall)] 10: public static extern int AmsiInitialize([MarshalAs(UnmanagedType.LPWStr)]string appName, out IntPtr amsi