SEB-Patcher/SEBPatcher.Monitoring/patch_VirtualMachineDetector.cs

47 lines
1.9 KiB
C#
Raw Normal View History

using MonoMod;
using SEBPatcherUtils;
2024-10-14 21:35:33 +02:00
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.Registry;
namespace SafeExamBrowser.Monitoring
{
#pragma warning disable IDE1006 // Naming Styles
public class patch_VirtualMachineDetector : VirtualMachineDetector
#pragma warning restore IDE1006 // Naming Styles
{
2024-10-16 08:11:06 +02:00
public PatchLogger patchlogger;
2024-10-14 21:35:33 +02:00
[MonoModIgnore] public patch_VirtualMachineDetector(ILogger logger, IRegistry registry, ISystemInfo systemInfo) : base(logger, registry, systemInfo) { }
2024-10-16 08:11:06 +02:00
#pragma warning disable IDE1006 // Naming Styles
[MonoModOriginal] public extern void orig_VirtualMachineDetector(ILogger logger, IRegistry registry, ISystemInfo systemInfo);
#pragma warning restore IDE1006 // Naming Styles
[MonoModConstructor] public void VirtualMachineDetector(ILogger logger, IRegistry registry, ISystemInfo systemInfo)
{
2024-10-16 08:11:06 +02:00
orig_VirtualMachineDetector(logger, registry, systemInfo);
patchlogger = new PatchLogger("MonitoringVirtualMachineDetector");
}
2024-10-14 21:35:33 +02:00
#pragma warning disable IDE1006 // Naming Styles
[MonoModOriginal] public extern bool orig_IsVirtualMachine();
#pragma warning restore IDE1006 // Naming Styles
#pragma warning disable CS0108 // Member hides inherited member; missing new keyword
public bool IsVirtualMachine()
#pragma warning restore CS0108 // Member hides inherited member; missing new keyword
{
bool isVirtualMachine = orig_IsVirtualMachine();
2024-10-16 08:11:06 +02:00
if (isVirtualMachine)
{
patchlogger.Info("SEB detected host as virtual machine! (will be ignored, ofcourse ;D)");
}
else
{
patchlogger.Info("SEB did not detect host as virtual machine.");
}
2024-10-14 21:35:33 +02:00
return false;
}
}
}