Update VirtualMachineDetector.cs

This commit is contained in:
Lau 2024-04-22 11:26:20 +02:00 committed by GitHub
parent e4a82e2f63
commit 8b3f9b0838
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -105,7 +105,6 @@ namespace SafeExamBrowser.SystemComponents
{ {
var isVirtualRegistry = false; var isVirtualRegistry = false;
isVirtualRegistry |= HasHistoricVirtualMachineHardwareConfiguration();
isVirtualRegistry |= HasLocalVirtualMachineDeviceCache(); isVirtualRegistry |= HasLocalVirtualMachineDeviceCache();
return isVirtualRegistry; return isVirtualRegistry;
@ -134,46 +133,6 @@ namespace SafeExamBrowser.SystemComponents
return isVirtualSystem; return isVirtualSystem;
} }
private bool HasHistoricVirtualMachineHardwareConfiguration()
{
var hasHistoricConfiguration = false;
if (registry.TryGetSubKeys(RegistryValue.MachineHive.HardwareConfig_Key, out var hardwareConfigSubkeys))
{
foreach (var configId in hardwareConfigSubkeys)
{
var hardwareConfigKey = $@"{RegistryValue.MachineHive.HardwareConfig_Key}\{configId}";
var computerIdsKey = $@"{hardwareConfigKey}\ComputerIds";
var success = true;
success &= registry.TryRead(hardwareConfigKey, "BIOSVendor", out var biosVendor);
success &= registry.TryRead(hardwareConfigKey, "BIOSVersion", out var biosVersion);
success &= registry.TryRead(hardwareConfigKey, "SystemManufacturer", out var systemManufacturer);
success &= registry.TryRead(hardwareConfigKey, "SystemProductName", out var systemProductName);
if (success)
{
var biosInfo = $"{(string) biosVendor} {(string) biosVersion}";
hasHistoricConfiguration |= IsVirtualSystem(biosInfo, (string) systemManufacturer, (string) systemProductName);
if (registry.TryGetNames(computerIdsKey, out var computerIdNames))
{
foreach (var computerIdName in computerIdNames)
{
if (registry.TryRead(computerIdsKey, computerIdName, out var computerSummary))
{
hasHistoricConfiguration |= IsVirtualSystem((string) computerSummary, (string) systemManufacturer, (string) systemProductName);
}
}
}
}
}
}
return hasHistoricConfiguration;
}
private bool HasLocalVirtualMachineDeviceCache() private bool HasLocalVirtualMachineDeviceCache()
{ {
var deviceName = System.Environment.GetEnvironmentVariable("COMPUTERNAME"); var deviceName = System.Environment.GetEnvironmentVariable("COMPUTERNAME");