diff --git a/SafeExamBrowser.SystemComponents.Contracts/ISystemInfo.cs b/SafeExamBrowser.SystemComponents.Contracts/ISystemInfo.cs
index 9b6d9742..6ee34b08 100644
--- a/SafeExamBrowser.SystemComponents.Contracts/ISystemInfo.cs
+++ b/SafeExamBrowser.SystemComponents.Contracts/ISystemInfo.cs
@@ -47,5 +47,10 @@ namespace SafeExamBrowser.SystemComponents.Contracts
/// The MAC Addres of the network addapter
///
string MacAddress { get; }
+
+ ///
+ /// Provides the DeviceID information of the user's Plug and Play devices
+ ///
+ string[] DeviceId { get; }
}
}
diff --git a/SafeExamBrowser.SystemComponents/SystemInfo.cs b/SafeExamBrowser.SystemComponents/SystemInfo.cs
index 570dd6ef..102d66bf 100644
--- a/SafeExamBrowser.SystemComponents/SystemInfo.cs
+++ b/SafeExamBrowser.SystemComponents/SystemInfo.cs
@@ -7,6 +7,7 @@
*/
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Windows.Forms;
@@ -24,6 +25,7 @@ namespace SafeExamBrowser.SystemComponents
public string Name { get; private set; }
public OperatingSystem OperatingSystem { get; private set; }
public string MacAddress { get; private set; }
+ public string[] DeviceId { get; private set; }
public string OperatingSystemInfo
{
@@ -36,6 +38,7 @@ namespace SafeExamBrowser.SystemComponents
InitializeMachineInfo();
InitializeOperatingSystem();
InitializeMacAddress();
+ InitializePnPDevices();
}
private void InitializeBattery()
@@ -155,5 +158,27 @@ namespace SafeExamBrowser.SystemComponents
}
}
}
+ private void InitializePnPDevices()
+ {
+ List deviceList = new List();
+ using (var searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT DeviceID FROM Win32_PnPEntity"))
+ using (var results = searcher.Get())
+ {
+ foreach (ManagementObject queryObj in results)
+ {
+ using (queryObj)
+ foreach (var property in queryObj.Properties)
+ {
+ if (property.Name.Equals("DeviceID"))
+ {
+ Console.WriteLine(Convert.ToString(property.Value));
+ deviceList.Add(Convert.ToString(property.Value).ToLower());
+ }
+ }
+ }
+ DeviceId = deviceList.ToArray();
+
+ }
+ }
}
}
diff --git a/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs b/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs
index df4b24a6..78201332 100644
--- a/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs
+++ b/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs
@@ -9,7 +9,7 @@
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.SystemComponents.Contracts;
using System.Globalization;
-
+using System.Linq;
namespace SafeExamBrowser.SystemComponents
{
@@ -32,7 +32,8 @@ namespace SafeExamBrowser.SystemComponents
var manufacturer = systemInfo.Manufacturer.ToLower();
var model = systemInfo.Model.ToLower();
var macAddress = systemInfo.MacAddress;
-
+ var deviceId = systemInfo.DeviceId;
+
isVirtualMachine |= manufacturer.Contains("microsoft corporation") && !model.Contains("surface");
isVirtualMachine |= manufacturer.Contains("vmware");
isVirtualMachine |= manufacturer.Contains("parallels software");
@@ -40,15 +41,12 @@ namespace SafeExamBrowser.SystemComponents
isVirtualMachine |= manufacturer.Contains("qemu");
isVirtualMachine |= ((byte.Parse(macAddress[1].ToString(), NumberStyles.HexNumber) & 2) == 2 || macAddress.StartsWith("080027"));
- /*
- using (var searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT DeviceID FROM Win32_PnPEntity"))
+
+ foreach (var device in deviceId)
+ {
+ isVirtualMachine |= PCI_VENDOR_BLACKLIST.Any(device.ToLower().Contains);
- foreach (ManagementObject queryObj in searcher.Get())
- {
- isVirtualMachine |= pciVendorBlacklist.Any(System.Convert.ToString(queryObj.Properties.Cast().First().Value).ToLower().Contains);
-
- }
- */
+ }
logger.Debug($"Computer '{systemInfo.Name}' appears to {(isVirtualMachine ? "" : "not ")}be a virtual machine.");
return isVirtualMachine;