diff --git a/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs b/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs index c1bad51f..9142fbbe 100644 --- a/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs +++ b/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs @@ -14,12 +14,16 @@ namespace SafeExamBrowser.SystemComponents { public class VirtualMachineDetector : IVirtualMachineDetector { - /// - /// Virtualbox: VBOX, 80EE / RedHat: QUEMU, 1AF4, 1B36 - /// - private static readonly string[] PCI_VENDOR_BLACKLIST = + private static readonly string[] DEVICE_BLACKLIST = { - "vbox", "vid_80ee", "qemu", "ven_1af4", "ven_1b36", "subsys_11001af4", "PROD_VMWARE", "VEN_VMWARE", "VMWARE_IDE" + // Hyper-V + "PROD_VIRTUAL", "HYPER_V", + // QEMU + "qemu", "ven_1af4", "ven_1b36", "subsys_11001af4", + // VirtualBox + "vbox", "vid_80ee", + // VMware + "PROD_VMWARE", "VEN_VMWARE", "VMWARE_IDE" }; private static readonly string QEMU_MAC_PREFIX = "525400"; private static readonly string VIRTUALBOX_MAC_PREFIX = "080027"; @@ -40,24 +44,25 @@ namespace SafeExamBrowser.SystemComponents var macAddress = systemInfo.MacAddress; var manufacturer = systemInfo.Manufacturer.ToLower(); var model = systemInfo.Model.ToLower(); - var plugAndPlayDeviceIds = systemInfo.PlugAndPlayDeviceIds; + var devices = systemInfo.PlugAndPlayDeviceIds; - isVirtualMachine |= biosInfo.Contains("vmware"); + isVirtualMachine |= biosInfo.Contains("hyper-v"); isVirtualMachine |= biosInfo.Contains("virtualbox"); + isVirtualMachine |= biosInfo.Contains("vmware"); isVirtualMachine |= manufacturer.Contains("microsoft corporation") && !model.Contains("surface"); - isVirtualMachine |= manufacturer.Contains("vmware"); isVirtualMachine |= manufacturer.Contains("parallels software"); - isVirtualMachine |= model.Contains("virtualbox"); isVirtualMachine |= manufacturer.Contains("qemu"); + isVirtualMachine |= manufacturer.Contains("vmware"); + isVirtualMachine |= model.Contains("virtualbox"); if (macAddress != null && macAddress.Count() > 2) { isVirtualMachine |= macAddress.StartsWith(QEMU_MAC_PREFIX) || macAddress.StartsWith(VIRTUALBOX_MAC_PREFIX); } - foreach (var device in plugAndPlayDeviceIds) + foreach (var device in devices) { - isVirtualMachine |= PCI_VENDOR_BLACKLIST.Any(v => device.ToLower().Contains(v.ToLower())); + isVirtualMachine |= DEVICE_BLACKLIST.Any(d => device.ToLower().Contains(d.ToLower())); } logger.Debug($"Computer '{systemInfo.Name}' appears {(isVirtualMachine ? "" : "not ")}to be a virtual machine.");