diff --git a/README.md b/README.md index eda3f57..ba51c40 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ SafeExamBrowser: [https://safeexambrowser.org/download_en.html](https://safeexam MonoMod: [https://github.com/MonoMod/MonoMod](https://github.com/MonoMod/MonoMod) +stripping/publicizing for development: [https://github.com/bbepis/NStrip](https://github.com/bbepis/NStrip) + **Learning Resources** SafeExamBrowser sourcecode: [https://github.com/SafeExamBrowser/seb-win-refactoring](https://github.com/SafeExamBrowser/seb-win-refactoring) @@ -44,6 +46,8 @@ 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) +Example patch by MonoMod: [https://monomod.dev/docs/README.Patcher.html](https://monomod.dev/docs/README.Patcher.html) + 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.Client/Properties/AssemblyInfo.cs b/SEBPatcher.Client/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d6d276a --- /dev/null +++ b/SEBPatcher.Client/Properties/AssemblyInfo.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("SEBPatcher.Client")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("${AuthorCopyright}")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/SEBPatcher.Client/SEBPatcher.Client.csproj b/SEBPatcher.Client/SEBPatcher.Client.csproj new file mode 100644 index 0000000..738af0e --- /dev/null +++ b/SEBPatcher.Client/SEBPatcher.Client.csproj @@ -0,0 +1,142 @@ + + + + Debug + AnyCPU + {48A5F9AC-B556-4F24-990C-017E485790D2} + Library + SEBPatcher.Client + SafeExamBrowser.Client.SEBPatcher.mm + v4.7 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + true + bin\Release + prompt + 4 + false + + + + + $(ReferenceBasePath)\MonoMod.exe + + + $(ReferenceBasePath)\0Harmony.dll + + + $(ReferenceBasePath)\Mono.Cecil.dll + + + $(ReferenceBasePath)\Mono.Cecil.Mdb.dll + + + $(ReferenceBasePath)\Mono.Cecil.Pdb.dll + + + $(ReferenceBasePath)\Mono.Cecil.Rocks.dll + + + $(ReferenceBasePath)\MonoMod.Common.dll + + + $(ReferenceBasePath)\MonoMod.RuntimeDetour.dll + + + $(ReferenceBasePath)\MonoMod.UnitTest.dll + + + $(ReferenceBasePath)\MonoMod.Utils.dll + + + $(ReferenceBasePath)\SafeExamBrowser.Client-nstrip.exe + False + + + $(ReferenceBasePath)\SafeExamBrowser.UserInterface.Contracts.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.Monitoring.Contracts.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.WindowsApi.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.WindowsApi.Contracts.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.Configuration.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.Configuration.Contracts.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.Logging.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.Logging.Contracts.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.SystemComponents.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.SystemComponents.Contracts.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.Core.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.Core.Contracts.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.Communication.Contracts.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.Communication.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.I18n.dll + False + + + $(ReferenceBasePath)\SafeExamBrowser.I18n.Contracts.dll + False + + + + + + + + + {82F861DC-D8C7-46F9-AA60-B67CF43712D5} + SEBPatcherUtils + False + + + + \ No newline at end of file diff --git a/SEBPatcher.Client/patch_ClientController.cs b/SEBPatcher.Client/patch_ClientController.cs new file mode 100644 index 0000000..d79322e --- /dev/null +++ b/SEBPatcher.Client/patch_ClientController.cs @@ -0,0 +1,34 @@ +using System; +using MonoMod; +using SEBPatcherUtils; +using System.Security.Permissions; +using SafeExamBrowser.Client.Contracts; + +#pragma warning disable CS0618 // Type or member is obsolete +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] +#pragma warning restore CS0618 // Type or member is obsolete + +namespace SafeExamBrowser.Client +{ +#pragma warning disable IDE1006 // Naming Styles + internal class patch_ClientController : ClientController +#pragma warning restore IDE1006 // Naming Styles + { + public PatchLogger patchlogger; + + [MonoModIgnore] internal patch_ClientController(SafeExamBrowser.UserInterface.Contracts.Shell.IActionCenter actionCenter, SafeExamBrowser.Monitoring.Contracts.Applications.IApplicationMonitor applicationMonitor, ClientContext context, ICoordinator coordinator, SafeExamBrowser.Monitoring.Contracts.Display.IDisplayMonitor displayMonitor, SafeExamBrowser.WindowsApi.Contracts.IExplorerShell explorerShell, SafeExamBrowser.UserInterface.Contracts.FileSystemDialog.IFileSystemDialog fileSystemDialog, SafeExamBrowser.Configuration.Contracts.Cryptography.IHashAlgorithm hashAlgorithm, SafeExamBrowser.Logging.Contracts.ILogger logger, SafeExamBrowser.UserInterface.Contracts.MessageBox.IMessageBox messageBox, SafeExamBrowser.SystemComponents.Contracts.Network.INetworkAdapter networkAdapter, SafeExamBrowser.Core.Contracts.OperationModel.IOperationSequence operations, SafeExamBrowser.Communication.Contracts.Proxies.IRuntimeProxy runtime, Action shutdown, SafeExamBrowser.UserInterface.Contracts.Windows.ISplashScreen splashScreen, SafeExamBrowser.Monitoring.Contracts.System.ISystemSentinel sentinel, SafeExamBrowser.UserInterface.Contracts.Shell.ITaskbar taskbar, SafeExamBrowser.I18n.Contracts.IText text, SafeExamBrowser.UserInterface.Contracts.IUserInterfaceFactory uiFactory) : base(actionCenter, applicationMonitor, context, coordinator, displayMonitor, explorerShell, fileSystemDialog, hashAlgorithm, logger, messageBox, networkAdapter, operations, runtime, shutdown, splashScreen, sentinel, taskbar, text, uiFactory) { } +#pragma warning disable IDE1006 // Naming Styles +#pragma warning disable RECS0082 // Parameter has the same name as a member and hides it + [MonoModOriginal] internal extern void orig_ClientController(SafeExamBrowser.UserInterface.Contracts.Shell.IActionCenter actionCenter, SafeExamBrowser.Monitoring.Contracts.Applications.IApplicationMonitor applicationMonitor, ClientContext context, ICoordinator coordinator, SafeExamBrowser.Monitoring.Contracts.Display.IDisplayMonitor displayMonitor, SafeExamBrowser.WindowsApi.Contracts.IExplorerShell explorerShell, SafeExamBrowser.UserInterface.Contracts.FileSystemDialog.IFileSystemDialog fileSystemDialog, SafeExamBrowser.Configuration.Contracts.Cryptography.IHashAlgorithm hashAlgorithm, SafeExamBrowser.Logging.Contracts.ILogger logger, SafeExamBrowser.UserInterface.Contracts.MessageBox.IMessageBox messageBox, SafeExamBrowser.SystemComponents.Contracts.Network.INetworkAdapter networkAdapter, SafeExamBrowser.Core.Contracts.OperationModel.IOperationSequence operations, SafeExamBrowser.Communication.Contracts.Proxies.IRuntimeProxy runtime, Action shutdown, SafeExamBrowser.UserInterface.Contracts.Windows.ISplashScreen splashScreen, SafeExamBrowser.Monitoring.Contracts.System.ISystemSentinel sentinel, SafeExamBrowser.UserInterface.Contracts.Shell.ITaskbar taskbar, SafeExamBrowser.I18n.Contracts.IText text, SafeExamBrowser.UserInterface.Contracts.IUserInterfaceFactory uiFactory); +#pragma warning restore RECS0082 // Parameter has the same name as a member and hides it +#pragma warning restore IDE1006 // Naming Styles +#pragma warning disable RECS0082 // Parameter has the same name as a member and hides it + [MonoModConstructor] internal void ClientController(SafeExamBrowser.UserInterface.Contracts.Shell.IActionCenter actionCenter, SafeExamBrowser.Monitoring.Contracts.Applications.IApplicationMonitor applicationMonitor, ClientContext context, ICoordinator coordinator, SafeExamBrowser.Monitoring.Contracts.Display.IDisplayMonitor displayMonitor, SafeExamBrowser.WindowsApi.Contracts.IExplorerShell explorerShell, SafeExamBrowser.UserInterface.Contracts.FileSystemDialog.IFileSystemDialog fileSystemDialog, SafeExamBrowser.Configuration.Contracts.Cryptography.IHashAlgorithm hashAlgorithm, SafeExamBrowser.Logging.Contracts.ILogger logger, SafeExamBrowser.UserInterface.Contracts.MessageBox.IMessageBox messageBox, SafeExamBrowser.SystemComponents.Contracts.Network.INetworkAdapter networkAdapter, SafeExamBrowser.Core.Contracts.OperationModel.IOperationSequence operations, SafeExamBrowser.Communication.Contracts.Proxies.IRuntimeProxy runtime, Action shutdown, SafeExamBrowser.UserInterface.Contracts.Windows.ISplashScreen splashScreen, SafeExamBrowser.Monitoring.Contracts.System.ISystemSentinel sentinel, SafeExamBrowser.UserInterface.Contracts.Shell.ITaskbar taskbar, SafeExamBrowser.I18n.Contracts.IText text, SafeExamBrowser.UserInterface.Contracts.IUserInterfaceFactory uiFactory) +#pragma warning restore RECS0082 // Parameter has the same name as a member and hides it + { + orig_ClientController(actionCenter, applicationMonitor, context, coordinator, displayMonitor, explorerShell, fileSystemDialog, hashAlgorithm, logger, messageBox, networkAdapter, operations, runtime, shutdown, splashScreen, sentinel, taskbar, text, uiFactory); + patchlogger = new PatchLogger("Client.ClientController"); + patchlogger.Info("Client loaded!"); + } + } +} diff --git a/SEBPatcher.Configuration/patch_IntegrityModule.cs b/SEBPatcher.Configuration/Integrity/patch_IntegrityModule.cs similarity index 86% rename from SEBPatcher.Configuration/patch_IntegrityModule.cs rename to SEBPatcher.Configuration/Integrity/patch_IntegrityModule.cs index 2c1e0c4..e6e91a6 100644 --- a/SEBPatcher.Configuration/patch_IntegrityModule.cs +++ b/SEBPatcher.Configuration/Integrity/patch_IntegrityModule.cs @@ -1,15 +1,18 @@ -using System; -using MonoMod; +using MonoMod; using SEBPatcherUtils; namespace SafeExamBrowser.Configuration.Integrity { +#pragma warning disable IDE1006 // Naming Styles public class patch_IntegrityModule : IntegrityModule +#pragma warning restore IDE1006 // Naming Styles { public PatchLogger patchlogger; [MonoModIgnore] public patch_IntegrityModule(Configuration.Contracts.AppConfig appConfig, SafeExamBrowser.Logging.Contracts.ILogger logger) : base(appConfig, logger) { } +#pragma warning disable IDE1006 // Naming Styles [MonoModOriginal] public extern void orig_IntegityModule(Configuration.Contracts.AppConfig appConfig, SafeExamBrowser.Logging.Contracts.ILogger logger); +#pragma warning restore IDE1006 // Naming Styles [MonoModConstructor] public void IntegrityModule(Configuration.Contracts.AppConfig appConfig, SafeExamBrowser.Logging.Contracts.ILogger logger) { orig_IntegityModule(appConfig, logger); diff --git a/SEBPatcher.Configuration/SEBPatcher.Configuration.csproj b/SEBPatcher.Configuration/SEBPatcher.Configuration.csproj index 91698de..0dbc182 100644 --- a/SEBPatcher.Configuration/SEBPatcher.Configuration.csproj +++ b/SEBPatcher.Configuration/SEBPatcher.Configuration.csproj @@ -60,17 +60,20 @@ $(ReferenceBasePath)\SafeExamBrowser.Configuration.dll + False $(ReferenceBasePath)\SafeExamBrowser.Logging.Contracts.dll + False $(ReferenceBasePath)\SafeExamBrowser.Configuration.Contracts.dll + False - + @@ -78,5 +81,8 @@ SEBPatcherUtils + + + \ No newline at end of file diff --git a/SEBPatcher.Monitoring/Display/patch_DisplayMonitor.cs b/SEBPatcher.Monitoring/Display/patch_DisplayMonitor.cs index 6c40b45..0428609 100644 --- a/SEBPatcher.Monitoring/Display/patch_DisplayMonitor.cs +++ b/SEBPatcher.Monitoring/Display/patch_DisplayMonitor.cs @@ -15,7 +15,9 @@ namespace SafeExamBrowser.Monitoring.Display public PatchLogger patchlogger; [MonoModIgnore] public patch_DisplayMonitor(ILogger logger, INativeMethods nativeMethods, ISystemInfo systemInfo) : base(logger, nativeMethods, systemInfo) { } +#pragma warning disable IDE1006 // Naming Styles [MonoModOriginal] public extern void orig_DisplayMonitor(ILogger logger, INativeMethods nativeMethods, ISystemInfo systemInfo); +#pragma warning restore IDE1006 // Naming Styles [MonoModConstructor] public void DisplayMonitor(ILogger logger, INativeMethods nativeMethods, ISystemInfo systemInfo) { orig_DisplayMonitor(logger, nativeMethods, systemInfo); @@ -30,7 +32,7 @@ namespace SafeExamBrowser.Monitoring.Display #pragma warning restore CS0108 // Member hides inherited member; missing new keyword { ValidationResult result = orig_ValidateConfiguration(settings); - + patchlogger.Info($"SEB display validation result: {result}"); return new ValidationResult diff --git a/SEBPatcher.Monitoring/Keyboard/patch_KeyboardInterceptor.cs b/SEBPatcher.Monitoring/Keyboard/patch_KeyboardInterceptor.cs new file mode 100644 index 0000000..49fdfa0 --- /dev/null +++ b/SEBPatcher.Monitoring/Keyboard/patch_KeyboardInterceptor.cs @@ -0,0 +1,26 @@ +using System; +using MonoMod; +using SEBPatcherUtils; +using SafeExamBrowser.Logging.Contracts; +using SafeExamBrowser.Settings.Monitoring; +using SafeExamBrowser.WindowsApi.Contracts; + +namespace SafeExamBrowser.Monitoring.Keyboard +{ +#pragma warning disable IDE1006 // Naming Styles + public class patch_KeyboardInterceptor : KeyboardInterceptor +#pragma warning restore IDE1006 // Naming Styles + { + public PatchLogger patchlogger; + + [MonoModIgnore] public patch_KeyboardInterceptor(ILogger logger, INativeMethods nativeMethods, KeyboardSettings settings) : base(logger, nativeMethods, settings) { } +#pragma warning disable IDE1006 // Naming Styles + [MonoModOriginal] public extern void orig_KeyboardInterceptor(ILogger logger, INativeMethods nativeMethods, KeyboardSettings settings); +#pragma warning restore IDE1006 // Naming Styles + [MonoModConstructor] public void KeyboardInterceptor(ILogger logger, INativeMethods nativeMethods, KeyboardSettings settings) + { + orig_KeyboardInterceptor(logger, nativeMethods, settings); + patchlogger = new PatchLogger("Monitoring.Keyboard.KeyboardInterceptor"); + } + } +} \ No newline at end of file diff --git a/SEBPatcher.Monitoring/SEBPatcher.Monitoring.csproj b/SEBPatcher.Monitoring/SEBPatcher.Monitoring.csproj index cc50be5..08fe4e4 100644 --- a/SEBPatcher.Monitoring/SEBPatcher.Monitoring.csproj +++ b/SEBPatcher.Monitoring/SEBPatcher.Monitoring.csproj @@ -51,12 +51,15 @@ $(ReferenceBasePath)\SafeExamBrowser.Logging.Contracts.dll + False $(ReferenceBasePath)\SafeExamBrowser.Monitoring.dll + False $(ReferenceBasePath)\SafeExamBrowser.SystemComponents.Contracts.dll + False $(ReferenceBasePath)\0Harmony.dll @@ -69,12 +72,15 @@ $(ReferenceBasePath)\SafeExamBrowser.WindowsApi.Contracts.dll + False $(ReferenceBasePath)\SafeExamBrowser.Settings.dll + False $(ReferenceBasePath)\SafeExamBrowser.Monitoring.Contracts.dll + False @@ -83,9 +89,11 @@ + + diff --git a/SEBPatcher.Monitoring/patch_Clipboard.cs b/SEBPatcher.Monitoring/patch_Clipboard.cs index 748c4a5..83d0bd2 100644 --- a/SEBPatcher.Monitoring/patch_Clipboard.cs +++ b/SEBPatcher.Monitoring/patch_Clipboard.cs @@ -11,7 +11,9 @@ namespace SafeExamBrowser.Monitoring public PatchLogger patchlogger; [MonoModIgnore] public patch_Clipboard(ILogger logger, SafeExamBrowser.WindowsApi.Contracts.INativeMethods nativeMethods, int timeout_ms = 50) : base(logger, nativeMethods, timeout_ms) { } +#pragma warning disable IDE1006 // Naming Styles [MonoModOriginal] public extern void orig_Clipboard(ILogger logger, SafeExamBrowser.WindowsApi.Contracts.INativeMethods nativeMethods, int timeout_ms = 50); +#pragma warning restore IDE1006 // Naming Styles [MonoModConstructor] public void Clipboard(ILogger logger, SafeExamBrowser.WindowsApi.Contracts.INativeMethods nativeMethods, int timeout_ms = 50) { orig_Clipboard(logger, nativeMethods, timeout_ms); diff --git a/SEBPatcher.Monitoring/patch_VirtualMachineDetector.cs b/SEBPatcher.Monitoring/patch_VirtualMachineDetector.cs index e97d14c..a36e8c4 100644 --- a/SEBPatcher.Monitoring/patch_VirtualMachineDetector.cs +++ b/SEBPatcher.Monitoring/patch_VirtualMachineDetector.cs @@ -19,7 +19,7 @@ namespace SafeExamBrowser.Monitoring [MonoModConstructor] public void VirtualMachineDetector(ILogger logger, IRegistry registry, ISystemInfo systemInfo) { orig_VirtualMachineDetector(logger, registry, systemInfo); - patchlogger = new PatchLogger("MonitoringVirtualMachineDetector"); + patchlogger = new PatchLogger("Monitoring.VirtualMachineDetector"); } #pragma warning disable IDE1006 // Naming Styles diff --git a/SEBPatcher.sln b/SEBPatcher.sln index 6956a1b..c65d3f7 100644 --- a/SEBPatcher.sln +++ b/SEBPatcher.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SEBPatcher.Configuration", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SEBPatcherUtils", "SEBPatcherUtils\SEBPatcherUtils.csproj", "{82F861DC-D8C7-46F9-AA60-B67CF43712D5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SEBPatcher.Client", "SEBPatcher.Client\SEBPatcher.Client.csproj", "{48A5F9AC-B556-4F24-990C-017E485790D2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -25,5 +27,9 @@ Global {82F861DC-D8C7-46F9-AA60-B67CF43712D5}.Debug|Any CPU.Build.0 = Debug|Any CPU {82F861DC-D8C7-46F9-AA60-B67CF43712D5}.Release|Any CPU.ActiveCfg = Release|Any CPU {82F861DC-D8C7-46F9-AA60-B67CF43712D5}.Release|Any CPU.Build.0 = Release|Any CPU + {48A5F9AC-B556-4F24-990C-017E485790D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {48A5F9AC-B556-4F24-990C-017E485790D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {48A5F9AC-B556-4F24-990C-017E485790D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {48A5F9AC-B556-4F24-990C-017E485790D2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal