diff --git a/README.md b/README.md
index 3583540..eda3f57 100644
--- a/README.md
+++ b/README.md
@@ -45,3 +45,5 @@ MonoMod API documentation: [https://monomod.github.io/api/index.html](https://mo
MonoMod step-by-step example implementation: [https://github.com/TROYTRON/ti-mods/blob/main/tutorials/MonoMod%20Guide.md](https://github.com/TROYTRON/ti-mods/blob/main/tutorials/MonoMod%20Guide.md)
dnSpy decomp/analysis tool: [https://github.com/dnSpyEx/dnSpy](https://github.com/dnSpyEx/dnSpy)
+
+sandbox for testing modifications (if you cant host a seb server): [https://sandbox.moodledemo.net](https://sandbox.moodledemo.net)
diff --git a/SEBPatcher.Configuration/SEBPatcher.Configuration.csproj b/SEBPatcher.Configuration/SEBPatcher.Configuration.csproj
index 4cf1611..91698de 100644
--- a/SEBPatcher.Configuration/SEBPatcher.Configuration.csproj
+++ b/SEBPatcher.Configuration/SEBPatcher.Configuration.csproj
@@ -72,5 +72,11 @@
+
+
+ {82F861DC-D8C7-46F9-AA60-B67CF43712D5}
+ SEBPatcherUtils
+
+
\ No newline at end of file
diff --git a/SEBPatcher.Configuration/patch_IntegrityModule.cs b/SEBPatcher.Configuration/patch_IntegrityModule.cs
index 1031b56..2c1e0c4 100644
--- a/SEBPatcher.Configuration/patch_IntegrityModule.cs
+++ b/SEBPatcher.Configuration/patch_IntegrityModule.cs
@@ -1,11 +1,20 @@
using System;
using MonoMod;
+using SEBPatcherUtils;
namespace SafeExamBrowser.Configuration.Integrity
{
public class patch_IntegrityModule : IntegrityModule
{
+ public PatchLogger patchlogger;
+
[MonoModIgnore] public patch_IntegrityModule(Configuration.Contracts.AppConfig appConfig, SafeExamBrowser.Logging.Contracts.ILogger logger) : base(appConfig, logger) { }
+ [MonoModOriginal] public extern void orig_IntegityModule(Configuration.Contracts.AppConfig appConfig, SafeExamBrowser.Logging.Contracts.ILogger logger);
+ [MonoModConstructor] public void IntegrityModule(Configuration.Contracts.AppConfig appConfig, SafeExamBrowser.Logging.Contracts.ILogger logger)
+ {
+ orig_IntegityModule(appConfig, logger);
+ patchlogger = new PatchLogger("Configuration.Integrity");
+ }
[MonoModOriginal] public extern bool orig_TryVerifyCodeSignature(out bool isValid);
#pragma warning disable CS0108 // Member hides inherited member; missing new keyword
@@ -13,6 +22,9 @@ namespace SafeExamBrowser.Configuration.Integrity
#pragma warning restore CS0108 // Member hides inherited member; missing new keyword
{
bool result = orig_TryVerifyCodeSignature(out isValid);
+
+ patchlogger.Info($"SEB integrity check result: {result}");
+
isValid = true;
return true;
}
diff --git a/SEBPatcher.Monitoring/Display/patch_DisplayMonitor.cs b/SEBPatcher.Monitoring/Display/patch_DisplayMonitor.cs
index 34df7a3..6c40b45 100644
--- a/SEBPatcher.Monitoring/Display/patch_DisplayMonitor.cs
+++ b/SEBPatcher.Monitoring/Display/patch_DisplayMonitor.cs
@@ -1,5 +1,5 @@
-using System;
-using MonoMod;
+using MonoMod;
+using SEBPatcherUtils;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.Monitoring.Contracts.Display;
@@ -12,7 +12,15 @@ namespace SafeExamBrowser.Monitoring.Display
public class patch_DisplayMonitor : DisplayMonitor
#pragma warning restore IDE1006 // Naming Styles
{
+ public PatchLogger patchlogger;
+
[MonoModIgnore] public patch_DisplayMonitor(ILogger logger, INativeMethods nativeMethods, ISystemInfo systemInfo) : base(logger, nativeMethods, systemInfo) { }
+ [MonoModOriginal] public extern void orig_DisplayMonitor(ILogger logger, INativeMethods nativeMethods, ISystemInfo systemInfo);
+ [MonoModConstructor] public void DisplayMonitor(ILogger logger, INativeMethods nativeMethods, ISystemInfo systemInfo)
+ {
+ orig_DisplayMonitor(logger, nativeMethods, systemInfo);
+ patchlogger = new PatchLogger("Monitoring.Display.DisplayMonitor");
+ }
#pragma warning disable IDE1006 // Naming Styles
[MonoModOriginal] public extern ValidationResult orig_ValidateConfiguration(DisplaySettings settings);
@@ -23,6 +31,8 @@ namespace SafeExamBrowser.Monitoring.Display
{
ValidationResult result = orig_ValidateConfiguration(settings);
+ patchlogger.Info($"SEB display validation result: {result}");
+
return new ValidationResult
{
ExternalDisplays = 0,
diff --git a/SEBPatcher.Monitoring/patch_Clipboard.cs b/SEBPatcher.Monitoring/patch_Clipboard.cs
index 020a3c0..748c4a5 100644
--- a/SEBPatcher.Monitoring/patch_Clipboard.cs
+++ b/SEBPatcher.Monitoring/patch_Clipboard.cs
@@ -1,4 +1,5 @@
using MonoMod;
+using SEBPatcherUtils;
using SafeExamBrowser.Logging.Contracts;
namespace SafeExamBrowser.Monitoring
@@ -7,7 +8,15 @@ namespace SafeExamBrowser.Monitoring
public class patch_Clipboard : Clipboard
#pragma warning restore IDE1006 // Naming Styles
{
+ public PatchLogger patchlogger;
+
[MonoModIgnore] public patch_Clipboard(ILogger logger, SafeExamBrowser.WindowsApi.Contracts.INativeMethods nativeMethods, int timeout_ms = 50) : base(logger, nativeMethods, timeout_ms) { }
+ [MonoModOriginal] public extern void orig_Clipboard(ILogger logger, SafeExamBrowser.WindowsApi.Contracts.INativeMethods nativeMethods, int timeout_ms = 50);
+ [MonoModConstructor] public void Clipboard(ILogger logger, SafeExamBrowser.WindowsApi.Contracts.INativeMethods nativeMethods, int timeout_ms = 50)
+ {
+ orig_Clipboard(logger, nativeMethods, timeout_ms);
+ patchlogger = new PatchLogger("Monitoring.Clipboard");
+ }
#pragma warning disable IDE0044 // Add readonly modifier
[MonoModIgnore] private ILogger logger;
@@ -18,6 +27,7 @@ namespace SafeExamBrowser.Monitoring
#pragma warning restore CS0108 // Member hides inherited member; missing new keyword
{
this.logger.Info(string.Format("Initialized clipboard for policy '{0}'.", policy));
+ patchlogger.Info($"SEB wants clipboard policy {policy} (won't get it though!)");
}
#pragma warning disable CS0108 // Member hides inherited member; missing new keyword
@@ -25,6 +35,7 @@ namespace SafeExamBrowser.Monitoring
#pragma warning restore CS0108 // Member hides inherited member; missing new keyword
{
this.logger.Info("Finalized clipboard");
+ patchlogger.Info("Clipboard monitoring 'terminated' (didn't even exist in the first place ;D)");
}
}
}
diff --git a/SEBPatcher.Monitoring/patch_RemoteSessionDetector.cs b/SEBPatcher.Monitoring/patch_RemoteSessionDetector.cs
index f675d8d..db6f938 100644
--- a/SEBPatcher.Monitoring/patch_RemoteSessionDetector.cs
+++ b/SEBPatcher.Monitoring/patch_RemoteSessionDetector.cs
@@ -1,5 +1,5 @@
-using System;
-using MonoMod;
+using MonoMod;
+using SEBPatcherUtils;
using SafeExamBrowser.Logging.Contracts;
namespace SafeExamBrowser.Monitoring
@@ -8,7 +8,17 @@ namespace SafeExamBrowser.Monitoring
public class patch_RemoteSessionDetector : RemoteSessionDetector
#pragma warning restore IDE1006 // Naming Styles
{
+ public PatchLogger patchlogger;
+
[MonoModIgnore] public patch_RemoteSessionDetector(ILogger logger) : base(logger) { }
+#pragma warning disable IDE1006 // Naming Styles
+ [MonoModOriginal] public extern void orig_RemoteSessionDetector(ILogger logger);
+#pragma warning restore IDE1006 // Naming Styles
+ [MonoModConstructor] public void RemoteSessionDetector(ILogger logger)
+ {
+ orig_RemoteSessionDetector(logger);
+ patchlogger = new PatchLogger("Monitoring.RemoteSessionDetector");
+ }
#pragma warning disable IDE1006 // Naming Styles
[MonoModOriginal] public extern bool orig_IsRemoteSession();
@@ -19,6 +29,15 @@ namespace SafeExamBrowser.Monitoring
{
bool isRemoteSession = orig_IsRemoteSession();
+ if (isRemoteSession)
+ {
+ patchlogger.Info("SEB detected remote session on host! (will be ignored, ofcourse ;D)");
+ }
+ else
+ {
+ patchlogger.Info("SEB did not detect remote session on host");
+ }
+
return false;
}
}
diff --git a/SEBPatcher.Monitoring/patch_VirtualMachineDetector.cs b/SEBPatcher.Monitoring/patch_VirtualMachineDetector.cs
index 93ab2f7..e97d14c 100644
--- a/SEBPatcher.Monitoring/patch_VirtualMachineDetector.cs
+++ b/SEBPatcher.Monitoring/patch_VirtualMachineDetector.cs
@@ -10,11 +10,16 @@ namespace SafeExamBrowser.Monitoring
public class patch_VirtualMachineDetector : VirtualMachineDetector
#pragma warning restore IDE1006 // Naming Styles
{
+ public PatchLogger patchlogger;
+
[MonoModIgnore] public patch_VirtualMachineDetector(ILogger logger, IRegistry registry, ISystemInfo systemInfo) : base(logger, registry, systemInfo) { }
- [MonoModOriginal] public extern void orig_VirtualMachineDetector();
- [MonoModConstructor] public void VirtualMachineDetector()
+#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)
{
- orig_VirtualMachineDetector();
+ orig_VirtualMachineDetector(logger, registry, systemInfo);
+ patchlogger = new PatchLogger("MonitoringVirtualMachineDetector");
}
#pragma warning disable IDE1006 // Naming Styles
@@ -26,6 +31,15 @@ namespace SafeExamBrowser.Monitoring
{
bool isVirtualMachine = orig_IsVirtualMachine();
+ 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.");
+ }
+
return false;
}
}
diff --git a/SEBPatcherUtils/PatchLogger.cs b/SEBPatcherUtils/PatchLogger.cs
index b0c1d5d..d49f9dd 100644
--- a/SEBPatcherUtils/PatchLogger.cs
+++ b/SEBPatcherUtils/PatchLogger.cs
@@ -8,9 +8,9 @@ namespace SEBPatcherUtils
private readonly string _logFilePath;
private readonly string _logModule;
- public PatchLogger(string logModule, string logFilePath)
+ public PatchLogger(string logModule)
{
- _logFilePath = logFilePath;
+ _logFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SafeExamBrowser", "SEBPatcher.log");
_logModule = logModule;
}
@@ -40,7 +40,7 @@ namespace SEBPatcherUtils
Log(message, "DEBUG");
}
- public void AppendToFile(string logEntry)
+ private void AppendToFile(string logEntry)
{
try
{