Restore SEBPatch
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using SafeExamBrowser.WindowsApi.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Monitoring.Contracts.Applications
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides information about the currently active application.
|
||||
/// </summary>
|
||||
public class ActiveApplication
|
||||
{
|
||||
/// <summary>
|
||||
/// The process which owns the currently active window.
|
||||
/// </summary>
|
||||
public IProcess Process { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The currently active window (i.e. the window which currently has input focus).
|
||||
/// </summary>
|
||||
public IWindow Window { get; }
|
||||
|
||||
public ActiveApplication(IProcess process, IWindow window)
|
||||
{
|
||||
Process = process;
|
||||
Window = window;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Monitoring.Contracts.Applications.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the Windows Explorer has been started.
|
||||
/// </summary>
|
||||
public delegate void ExplorerStartedEventHandler();
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using SafeExamBrowser.WindowsApi.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Monitoring.Contracts.Applications.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that a new instance of a whitelisted application has been started.
|
||||
/// </summary>
|
||||
public delegate void InstanceStartedEventHandler(Guid applicationId, IProcess process);
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SafeExamBrowser.Monitoring.Contracts.Applications.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the given blacklisted applications could not be terminated.
|
||||
/// </summary>
|
||||
public delegate void TerminationFailedEventHandler(IEnumerable<RunningApplication> applications);
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using SafeExamBrowser.Monitoring.Contracts.Applications.Events;
|
||||
using SafeExamBrowser.Settings.Applications;
|
||||
|
||||
namespace SafeExamBrowser.Monitoring.Contracts.Applications
|
||||
{
|
||||
/// <summary>
|
||||
/// Monitors applications running on the computer.
|
||||
/// </summary>
|
||||
public interface IApplicationMonitor
|
||||
{
|
||||
/// <summary>
|
||||
/// Event fired when a new instance of the Windows Explorer has been started.
|
||||
/// </summary>
|
||||
event ExplorerStartedEventHandler ExplorerStarted;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when a new instance of a whitelisted application has been started.
|
||||
/// </summary>
|
||||
event InstanceStartedEventHandler InstanceStarted;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the automatic termination of a blacklisted application failed.
|
||||
/// </summary>
|
||||
event TerminationFailedEventHandler TerminationFailed;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the application monitor.
|
||||
/// </summary>
|
||||
InitializationResult Initialize(ApplicationSettings settings);
|
||||
|
||||
/// <summary>
|
||||
/// Starts monitoring all initialized applications. Windows Explorer will always be monitored.
|
||||
/// </summary>
|
||||
void Start();
|
||||
|
||||
/// <summary>
|
||||
/// Stops the application monitoring.
|
||||
/// </summary>
|
||||
void Stop();
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to retrieve the currently active application (i.e. the application which currently has input focus). Returns <c>true</c> if
|
||||
/// successful, otherwise <c>false</c>.
|
||||
/// </summary>
|
||||
bool TryGetActiveApplication(out ActiveApplication application);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to terminate all processes of the specified application. Returns <c>true</c> if successful, otherwise <c>false</c>.
|
||||
/// </summary>
|
||||
bool TryTerminate(RunningApplication application);
|
||||
}
|
||||
}
|
28
SafeExamBrowser.Monitoring.Contracts/Applications/IWindow.cs
Normal file
28
SafeExamBrowser.Monitoring.Contracts/Applications/IWindow.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace SafeExamBrowser.Monitoring.Contracts.Applications
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a native window handled by the operating system.
|
||||
/// </summary>
|
||||
public interface IWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// The handle of the window.
|
||||
/// </summary>
|
||||
IntPtr Handle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The title of the window.
|
||||
/// </summary>
|
||||
string Title { get; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SafeExamBrowser.Monitoring.Contracts.Applications
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides information about the initialization of the <see cref="IApplicationMonitor"/>.
|
||||
/// </summary>
|
||||
public class InitializationResult
|
||||
{
|
||||
/// <summary>
|
||||
/// A list of currently running applications which could not be automatically terminated.
|
||||
/// </summary>
|
||||
public IList<RunningApplication> FailedAutoTerminations { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of currently running applications which need to be terminated.
|
||||
/// </summary>
|
||||
public IList<RunningApplication> RunningApplications { get; }
|
||||
|
||||
public InitializationResult()
|
||||
{
|
||||
FailedAutoTerminations = new List<RunningApplication>();
|
||||
RunningApplications = new List<RunningApplication>();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using SafeExamBrowser.WindowsApi.Contracts;
|
||||
|
||||
namespace SafeExamBrowser.Monitoring.Contracts.Applications
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides information about a running application.
|
||||
/// </summary>
|
||||
public class RunningApplication
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the application.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of processes which belong to the application.
|
||||
/// </summary>
|
||||
public IList<IProcess> Processes { get; }
|
||||
|
||||
public RunningApplication(string name)
|
||||
{
|
||||
Name = name;
|
||||
Processes = new List<IProcess>();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user