using System; using System.Runtime.InteropServices; namespace Developpez.Dotnet.System.Providers.Windows { /// /// Infrastructure (Interop) /// internal static class Win32Api { [DllImport("user32.dll")] public static extern bool ExitWindowsEx(ShutdownMethod uMethod, ShutdownReason dwReason); [DllImport("advapi32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool AdjustTokenPrivileges(IntPtr TokenHandle, [MarshalAs(UnmanagedType.Bool)]bool DisableAllPrivileges, ref TOKEN_PRIVILEGES NewState, UInt32 BufferLength, IntPtr PreviousState, IntPtr ReturnLength); [DllImport("advapi32.dll", SetLastError = true)] public static extern bool OpenProcessToken(IntPtr ProcessHandle, UInt32 DesiredAccess, out IntPtr TokenHandle); [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)] public static extern bool LookupPrivilegeValue(string lpSystemName, string lpName, out LUID lpLuid); /* consts */ public const int TOKEN_QUERY = 0x08; public const int TOKEN_ADJUST_PRIVILEGES = 0x20; public const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege"; public const int SE_PRIVILEGE_ENABLED = 0x02; } }