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
|
/// The MAC Addres of the network addapter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string MacAddress { get; }
|
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;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
@ -24,6 +25,7 @@ namespace SafeExamBrowser.SystemComponents
|
||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
public OperatingSystem OperatingSystem { get; private set; }
|
public OperatingSystem OperatingSystem { get; private set; }
|
||||||
public string MacAddress { get; private set; }
|
public string MacAddress { get; private set; }
|
||||||
|
public string[] DeviceId { get; private set; }
|
||||||
|
|
||||||
public string OperatingSystemInfo
|
public string OperatingSystemInfo
|
||||||
{
|
{
|
||||||
|
@ -36,6 +38,7 @@ namespace SafeExamBrowser.SystemComponents
|
||||||
InitializeMachineInfo();
|
InitializeMachineInfo();
|
||||||
InitializeOperatingSystem();
|
InitializeOperatingSystem();
|
||||||
InitializeMacAddress();
|
InitializeMacAddress();
|
||||||
|
InitializePnPDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeBattery()
|
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.Logging.Contracts;
|
||||||
using SafeExamBrowser.SystemComponents.Contracts;
|
using SafeExamBrowser.SystemComponents.Contracts;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace SafeExamBrowser.SystemComponents
|
namespace SafeExamBrowser.SystemComponents
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,7 @@ namespace SafeExamBrowser.SystemComponents
|
||||||
var manufacturer = systemInfo.Manufacturer.ToLower();
|
var manufacturer = systemInfo.Manufacturer.ToLower();
|
||||||
var model = systemInfo.Model.ToLower();
|
var model = systemInfo.Model.ToLower();
|
||||||
var macAddress = systemInfo.MacAddress;
|
var macAddress = systemInfo.MacAddress;
|
||||||
|
var deviceId = systemInfo.DeviceId;
|
||||||
|
|
||||||
isVirtualMachine |= manufacturer.Contains("microsoft corporation") && !model.Contains("surface");
|
isVirtualMachine |= manufacturer.Contains("microsoft corporation") && !model.Contains("surface");
|
||||||
isVirtualMachine |= manufacturer.Contains("vmware");
|
isVirtualMachine |= manufacturer.Contains("vmware");
|
||||||
|
@ -40,15 +41,12 @@ namespace SafeExamBrowser.SystemComponents
|
||||||
isVirtualMachine |= manufacturer.Contains("qemu");
|
isVirtualMachine |= manufacturer.Contains("qemu");
|
||||||
|
|
||||||
isVirtualMachine |= ((byte.Parse(macAddress[1].ToString(), NumberStyles.HexNumber) & 2) == 2 || macAddress.StartsWith("080027"));
|
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 (ManagementObject queryObj in searcher.Get())
|
foreach (var device in deviceId)
|
||||||
{
|
{
|
||||||
isVirtualMachine |= pciVendorBlacklist.Any(System.Convert.ToString(queryObj.Properties.Cast<PropertyData>().First().Value).ToLower().Contains);
|
isVirtualMachine |= PCI_VENDOR_BLACKLIST.Any(device.ToLower().Contains);
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
logger.Debug($"Computer '{systemInfo.Name}' appears to {(isVirtualMachine ? "" : "not ")}be a virtual machine.");
|
logger.Debug($"Computer '{systemInfo.Name}' appears to {(isVirtualMachine ? "" : "not ")}be a virtual machine.");
|
||||||
|
|
||||||
return isVirtualMachine;
|
return isVirtualMachine;
|
||||||
|
|
Loading…
Reference in a new issue