/*
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
*
* 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 System.Collections.Generic;
using SafeExamBrowser.Monitoring.Contracts.Keyboard;
using SafeExamBrowser.Monitoring.Contracts.Mouse;
using SafeExamBrowser.WindowsApi.Contracts.Events;
namespace SafeExamBrowser.WindowsApi.Contracts
{
///
/// Defines and wraps the functionality available via the native Windows API.
///
public interface INativeMethods
{
///
/// Deregisters the system hook for the given keyboard interceptor.
///
///
/// If the hook for the given interceptor could not be successfully removed.
///
void DeregisterKeyboardHook(IKeyboardInterceptor interceptor);
///
/// Deregisters the system hook for the given mouse interceptor.
///
///
/// If the hook for the given interceptor could not be successfully removed.
///
void DeregisterMouseHook(IMouseInterceptor interceptor);
///
/// Deregisters a previously registered system event hook.
///
///
/// If the event hook could not be successfully removed.
///
void DeregisterSystemEventHook(Guid hookId);
///
/// Empties the clipboard.
///
///
/// If the emptying of the clipboard failed.
///
void EmptyClipboard();
///
/// Retrieves a collection of handles to all currently open (i.e. visible) windows.
///
///
/// If the open windows could not be retrieved.
///
IEnumerable GetOpenWindows();
///
/// Retrieves the process identifier for the specified window handle.
///
uint GetProcessIdFor(IntPtr window);
///
/// Retrieves a window handle to the Windows taskbar. Returns IntPtr.Zero
/// if the taskbar could not be found (i.e. if it isn't running).
///
IntPtr GetShellWindowHandle();
///
/// Retrieves the process ID of the main Windows explorer instance controlling
/// desktop and taskbar or 0, if the process isn't running.
///
uint GetShellProcessId();
///
/// Retrieves the path of the currently configured wallpaper image, or an empty string, if there is no wallpaper set.
///
///
/// If the wallpaper path could not be retrieved.
///
string GetWallpaperPath();
///
/// Retrieves the title of the specified window, or an empty string, if the given window does not have a title.
///
string GetWindowTitle(IntPtr window);
///
/// Retrieves the currently configured working area of the primary screen.
///
///
/// If the working area could not be retrieved.
///
IBounds GetWorkingArea();
///
/// Hides the given window. Returns true if successful, otherwise false.
///
bool HideWindow(IntPtr window);
///
/// Minimizes all open windows.
///
void MinimizeAllOpenWindows();
///
/// Instructs the main Windows explorer process to shut down.
///
///
/// If the message could not be successfully posted. Does not apply if the process isn't running!
///
void PostCloseMessageToShell();
///
/// Prevents Windows from entering sleep mode and keeps all displays powered on.
///
void PreventSleepMode();
///
/// Registers a system hook for the given keyboard interceptor.
///
void RegisterKeyboardHook(IKeyboardInterceptor interceptor);
///
/// Registers a system hook for the given mouse interceptor.
///
void RegisterMouseHook(IMouseInterceptor interceptor);
///
/// Registers a system event which will invoke the specified callback when a window has received mouse capture.
/// Returns the ID of the newly registered Windows event hook.
///
Guid RegisterSystemCaptureStartEvent(SystemEventCallback callback);
///
/// Registers a system event which will invoke the specified callback when the foreground window has changed.
/// Returns a handle to the newly registered Windows event hook.
///
Guid RegisterSystemForegroundEvent(SystemEventCallback callback);
///
/// Removes the currently configured desktop wallpaper.
///
///
/// If the wallpaper could not be removed.
///
void RemoveWallpaper();
///
/// Restores the specified window to its original size and position.
///
void RestoreWindow(IntPtr window);
///
/// Attempts to resume the thread referenced by the given thread ID. Returns true if the thread was successfully resumed,
/// otherwise false.
///
bool ResumeThread(int threadId);
///
/// Sends a close message to the given window.
///
void SendCloseMessageTo(IntPtr window);
///
/// Sets the wallpaper to the image located at the specified file path.
///
///
/// If the wallpaper could not be set.
///
void SetWallpaper(string filePath);
///
/// Sets the working area of the primary screen according to the given dimensions.
///
///
/// If the working area could not be set.
///
void SetWorkingArea(IBounds bounds);
///
/// Attempts to suspend the thread referenced by the given thread ID. Returns true if the thread was successfully suspended,
/// otherwise false.
///
bool SuspendThread(int threadId);
}
}