diff --git a/.gitignore b/.gitignore index b5d7fe6..f9662e4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +# Personally customizable settings +Directory.Build.props + # User-specific files *.suo *.user diff --git a/README.md b/README.md index ba51c40..fc81f7d 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,15 @@ In order to use the patches, do the following: 1. Get the patch DLLs: build them or get them from releases. -2. Put patch DLLs into SafeExamBrowser\Application. +2. Put patch DLLs into %appdata%\SafeExamBrowser\Application. -3. Get MonoMod and put all its files into SafeExamBrowser\Application. +3. Get MonoMod and put all its files into %appdata%\SafeExamBrowser\Application. -4. Run MonoMod on all relevant DLLs, eg. `.\MonoMod.exe SafeExamBrowser.Monitoring.dll` +4. Run MonoMod on all target DLLs, eg. `.\MonoMod.exe SafeExamBrowser.Monitoring.dll`. +Note that you might get an error about not being able to find dependencies, in this case you should set the environment variable 'MONOMOD_DEPENDENCY_MISSING_THROW' to '1'. +If you have to do this, make sure to doublecheck the patched DLLs with something like dnSpy so that they are correct. + +5. Rename the patched DLLs once they have been patched correctly (MONOMODDED_xxxxx) and remove the MONOMODDED prefix, replacing the original files. ## Development @@ -26,6 +30,8 @@ Set `ReferenceBasePath` to your SEB installation (SafeExamBrowser\Application). If you want to separate your development/testing files from your actual SEB installation, I recommend copying the files in SafeExamBrowser\Application and the MonoMod files to their own directory. +Some targets (namely SafeExamBrowser.Client.exe) has private/internal members that we need to deal with, to do this we first publicize it using n-strip, and then reference to the stripped binary instead. + ## Resources This depends on MonoMod and SafeExamBrowser. diff --git a/SEBPatcher.Client/SEBPatcher.Client.csproj b/SEBPatcher.Client/SEBPatcher.Client.csproj index 738af0e..9414039 100644 --- a/SEBPatcher.Client/SEBPatcher.Client.csproj +++ b/SEBPatcher.Client/SEBPatcher.Client.csproj @@ -94,10 +94,6 @@ $(ReferenceBasePath)\SafeExamBrowser.Logging.Contracts.dll False - - $(ReferenceBasePath)\SafeExamBrowser.SystemComponents.dll - False - $(ReferenceBasePath)\SafeExamBrowser.SystemComponents.Contracts.dll False diff --git a/SEBPatcher.Client/patch_ClientController.cs b/SEBPatcher.Client/patch_ClientController.cs index d79322e..c4593d9 100644 --- a/SEBPatcher.Client/patch_ClientController.cs +++ b/SEBPatcher.Client/patch_ClientController.cs @@ -11,19 +11,19 @@ using SafeExamBrowser.Client.Contracts; namespace SafeExamBrowser.Client { #pragma warning disable IDE1006 // Naming Styles - internal class patch_ClientController : ClientController + public 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) { } + [MonoModIgnore] public 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); + [MonoModOriginal] public 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) + [MonoModConstructor] public 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);