diff --git a/SafeExamBrowser.SystemComponents.Contracts/ISystemInfo.cs b/SafeExamBrowser.SystemComponents.Contracts/ISystemInfo.cs
index 194bb969..6d5c2a04 100644
--- a/SafeExamBrowser.SystemComponents.Contracts/ISystemInfo.cs
+++ b/SafeExamBrowser.SystemComponents.Contracts/ISystemInfo.cs
@@ -13,11 +13,17 @@ namespace SafeExamBrowser.SystemComponents.Contracts
///
public interface ISystemInfo
{
+
///
/// The manufacturer and name of the BIOS.
///
string BiosInfo { get; }
+ ///
+ /// The name of the CPU.
+ ///
+ string Cpu { get; }
+
///
/// Reveals whether the computer system contains a battery.
///
diff --git a/SafeExamBrowser.SystemComponents/Registry/Registry.cs b/SafeExamBrowser.SystemComponents/Registry/Registry.cs
index 43b67ddd..f70185a6 100644
--- a/SafeExamBrowser.SystemComponents/Registry/Registry.cs
+++ b/SafeExamBrowser.SystemComponents/Registry/Registry.cs
@@ -229,7 +229,6 @@ namespace SafeExamBrowser.SystemComponents.Registry
try
{
- logger.Info($"default(RegistryKey) == null: {key == null}");
if (TryGetBaseKeyFromKeyName(keyName, out var baseKey, out var subKey))
{
key = baseKey.OpenSubKey(subKey);
diff --git a/SafeExamBrowser.SystemComponents/SystemInfo.cs b/SafeExamBrowser.SystemComponents/SystemInfo.cs
index 207a2fab..770556a6 100644
--- a/SafeExamBrowser.SystemComponents/SystemInfo.cs
+++ b/SafeExamBrowser.SystemComponents/SystemInfo.cs
@@ -20,6 +20,7 @@ namespace SafeExamBrowser.SystemComponents
public class SystemInfo : ISystemInfo
{
public string BiosInfo { get; private set; }
+ public string Cpu { get; private set; }
public bool HasBattery { get; private set; }
public string MacAddress { get; private set; }
public string Manufacturer { get; private set; }
@@ -33,6 +34,7 @@ namespace SafeExamBrowser.SystemComponents
{
InitializeBattery();
InitializeBiosInfo();
+ InitializeCpu();
InitializeMacAddress();
InitializeMachineInfo();
InitializeOperatingSystem();
@@ -79,6 +81,22 @@ namespace SafeExamBrowser.SystemComponents
}
}
+ private void InitializeCpu()
+ {
+ try
+ {
+ var cpuObjSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
+ foreach (var cpuObj in cpuObjSearcher.Get())
+ {
+ Cpu = ((string) cpuObj["Name"]);
+ }
+ }
+ catch (Exception)
+ {
+ Cpu = "";
+ }
+ }
+
private void InitializeMachineInfo()
{
var model = default(string);
diff --git a/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs b/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs
index f6b7a271..8d9ee3fd 100644
--- a/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs
+++ b/SafeExamBrowser.SystemComponents/VirtualMachineDetector.cs
@@ -66,7 +66,7 @@ namespace SafeExamBrowser.SystemComponents
// redundancy: registry check does this aswell (systemInfo may be using different methods)
isVirtualMachine |= IsVirtualSystemInfo(biosInfo, manufacturer, model);
- isVirtualMachine |= IsVirtualWmi();
+ isVirtualMachine |= IsVirtualCpu();
isVirtualMachine |= IsVirtualRegistry();
if (macAddress != null && macAddress.Count() > 2)
@@ -222,15 +222,11 @@ namespace SafeExamBrowser.SystemComponents
return isVirtualMachine;
}
- private bool IsVirtualWmi()
+ private bool IsVirtualCpu()
{
var isVirtualMachine = false;
- var cpuObjSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
- foreach (var cpuObj in cpuObjSearcher.Get())
- {
- isVirtualMachine |= ((string) cpuObj["Name"]).ToLower().Contains(" kvm "); // qemu (KVM specifically)
- }
+ isVirtualMachine |= systemInfo.Cpu.ToLower().Contains(" kvm "); // qemu (KVM specifically)
return isVirtualMachine;
}