Restore SEBPatch
This commit is contained in:
52
SafeExamBrowser.ResetUtility/NativeMethods.cs
Normal file
52
SafeExamBrowser.ResetUtility/NativeMethods.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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 System.Runtime.InteropServices;
|
||||
|
||||
namespace SafeExamBrowser.ResetUtility
|
||||
{
|
||||
internal class NativeMethods
|
||||
{
|
||||
private const int GWL_STYLE = -16;
|
||||
private const int MF_BYCOMMAND = 0x0;
|
||||
private const int SC_MAXIMIZE = 0xF030;
|
||||
private const int SC_MINIMIZE = 0xF020;
|
||||
private const int SC_SIZE = 0xF000;
|
||||
private const int WS_MAXIMIZEBOX = 0x10000;
|
||||
private const int WS_MINIMIZEBOX = 0x20000;
|
||||
|
||||
internal void TryDisableSystemMenu()
|
||||
{
|
||||
try
|
||||
{
|
||||
// DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_MINIMIZE, MF_BYCOMMAND);
|
||||
DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_MAXIMIZE, MF_BYCOMMAND);
|
||||
DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_SIZE, MF_BYCOMMAND);
|
||||
// SetWindowLong(GetConsoleWindow(), GWL_STYLE, GetWindowLong(GetConsoleWindow(), GWL_STYLE) & ~WS_MINIMIZEBOX);
|
||||
SetWindowLong(GetConsoleWindow(), GWL_STYLE, GetWindowLong(GetConsoleWindow(), GWL_STYLE) & ~WS_MAXIMIZEBOX);
|
||||
}
|
||||
catch(Exception) { }
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int DeleteMenu(IntPtr hMenu, int nPosition, int wFlags);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern IntPtr GetConsoleWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user