24

I love how Microsoft made third party anti virus protection obsolete with Defender - it just works.

Unfortunately for me as a developer this sometimes means it works a bit too well, and slows down processes I know are secure - for example Gradle builds in Android Studio. I know I can exclude some files and processes from the scanning - but I don't actually know which ones to exclude. The UI of Android Studio? OpenJDK? My Android Emulator?

Some other anti virus product like Avira offered a view of files and programs that it scanned, even offering direct "exclude from scan" buttons.

Is there a way to monitor what real time protection is scanning, which files or processes are causing it to spin up and max my CPU?

5
  • You should find out what process is responsible for the real time protection. Then you can monitor it with the performance monitor included in windows 10. Oct 18, 2017 at 17:09
  • Per the first answer this would be MsMpEng.exe - how could I monitor that with the included performance monitor?
    – janpio
    Oct 18, 2017 at 20:56
  • performance monitoring: digital.ni.com/public.nsf/allkb/… Oct 19, 2017 at 6:32
  • Why don't you just exclude all the suspected folders? This will take much less time than analyzing file accesses.
    – harrymc
    Oct 19, 2017 at 10:25
  • This might very well be the conclusion to draw at the end of this ;) (You might want to post it as an answer...)
    – janpio
    Oct 19, 2017 at 10:49

4 Answers 4

25
+50

You can do this using ProcMon from SysInternals: https://docs.microsoft.com/en-us/sysinternals/downloads/procmon

  1. Run ProcMon as administrator.
  2. Open the Filter (Filter > Filter...).
  3. Create a Filter where Process Name - is - MsMpEng.exe then Include.
  4. Click Add and OK.

Your list should now filter and you can view and log files the engine touches as it touches them.

Another tool that can add information to this process is Process Explorer, also from SysInternals: https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer

Run ProcExp when you are running ProcMon and as you find entries in the ProcMon log that you suspect may be causing the slowness, find them in ProcExp's list of processes.

ProcExp shows applications in a hierarchical view ("tree view") that lists processes as parents and children. It also allows you to search for individual threads and in-use files and identify the process(es) that are using them.

However I think you're complicating the problem.

What you want to do first is identify and whitelist not each individual file being run in the SDKs and emulators, but the executables in the SDK and the emulators themselves that are running the files.

Do this first, and only proceed to whitelisting the individual files if the first step doesn't solve the problem.

8
  • Awesome - and frightening. So much stuff... any other useful filter options? This only lists the files though, not the processes, correct? Any way to correlate this to CPU load of the process?
    – janpio
    Oct 18, 2017 at 20:51
  • A process is a file in use, more or less. If you're looking for info on which processes you should whitelist, this will collect the necessary information for you. I don't see a simple way to view the CPU time involved in each process, though using Process Explorer (also from SysInternals) should help in that regard. Oct 18, 2017 at 20:55
  • I am not sure if I understand: I now have a list of files being accessed by this process. How do I go from the files to the process name to exclude? (unless it is obvious by the path of course)
    – janpio
    Oct 18, 2017 at 20:59
  • Winword.exe is a file. It sits inside your Program Files. When you open a .doc file or click one of the various shortcuts to open Word, Winword.exe is opened and becomes a process. At that time, MsMpEng.exe grabs Winword.exe and checks it out and if the program passes the tests, it is allowed to run. If winword.exe was triggered by opening a .doc file, the AV also checks the .doc file. Oct 18, 2017 at 21:04
  • 1
    If you want to know the process (file in use) that is calling/running specific files, use Process Explorer and look for the file you see in the ProcMon logs in the ProcExp tree. This will show you which process called that file. You may want to check and see if it is more effective to exclude the processes that are running, or the files that are being called. Oct 18, 2017 at 21:18
6

Microsoft offers now for this purpose Microsoft Defender Antivirus Performance Analyzer:

A PowerShell command-line tool that helps you determine files, file extensions, and processes that might be causing performance issues on individual endpoints during antivirus scans.

Some options to analyze include:

  • Top paths that impact scan time
  • Top files that impact scan time
  • Top processes that impact scan time
  • Top file extensions that impact scan time
  • Combinations – for example:
    • top files per extension
    • top paths per extension
    • top processes per path
    • top scans per file
    • top scans per file per process

https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/tune-performance-defender-antivirus?view=o365-worldwide#what-is-microsoft-defender-antivirus-performance-analyzer

4

Process Hacker can be used to view the files that are being scanned as well. Once installed, run the program as an Administrator, or click Show details for all processes in the Hacker dropdown menu.

From there, go to the Disk tab. All files that are being read or written to will be displayed; any file in that list that says it is being read by MsMpEng.exe (Defender's main executable) is being scanned. It's easier to see what is being scanned if you paste MsMpEng.exe into the search bar at the top right of the window and then click the File column to sort alphabetically, as this filters the list so that only the files being scanned by Defender appear.

1

Just a note to say that Microsoft actually has an article on creating exclusions for Android developers https://docs.microsoft.com/en-us/windows/android/defender-settings

2
  • 2
    Welcome to SuperUser! Please do not post link only answers as they may become obsolete if the linked content changes. Instead quote the most important parts from the linked site and include the link for reference only. Jan 28, 2022 at 19:33
  • 1
    Welcome Dan, this is almost an answer. On SE sites the practice is to link where the advice comes from, as you have done, but to duplicate the important steps here so that this is a standalone resource. If you copy the steps from "How to add exclusions [...]" and then maybe mention the gradle cache location as a particular exclusion then that would make this a good answer, IMO. Just providing a link risks your answer being deleted (it's one of the preset mod responses). Cheers.
    – pbhj
    Jan 28, 2022 at 19:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .