How to detect it and protect it?

It is very difficult to detect the virus especially if it was being hidden by the mining software that you have downloaded. Antivirus is your only option to detect them so it will be best if you will install the top ranking antivirus in order to lessen the chance of any virus to bypass it.
Aside from it, it will be best also if you will download the mining software that were being used by many so you can assure that it was tested already and there are no virus inside your download.