Fixed name Vendor #6 and new Property added
This commit is contained in:
parent
bcdfa36e0d
commit
1de5848edb
3 changed files with 38 additions and 10 deletions
|
@ -47,5 +47,10 @@ namespace SafeExamBrowser.SystemComponents.Contracts
|
|||
/// The MAC Addres of the network addapter
|
||||
/// </summary>
|
||||
string MacAddress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides the DeviceID information of the user's Plug and Play devices
|
||||
/// </summary>
|
||||
string[] DeviceId { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<string> deviceList = new List<string>();
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<PropertyData>().First().Value).ToLower().Contains);
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
logger.Debug($"Computer '{systemInfo.Name}' appears to {(isVirtualMachine ? "" : "not ")}be a virtual machine.");
|
||||
|
||||
return isVirtualMachine;
|
||||
|
|
Loading…
Reference in a new issue