// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. // // Copyright (c) Microsoft Corporation. All rights reserved using System; using System.Runtime.InteropServices; namespace Microsoft.Samples.DynamicAccessControl.Utility { using BOOL = System.Int32; static internal class Win32 { public const BOOL FALSE = 0; public const BOOL TRUE = 1; public const int MAX_PATH = 260; public const int MAX_LONG_PATH = 33000; public static bool NT_SUCCESS(int status) { return status >= 0; } public const string ADVAPI32_DLL = "advapi32.dll"; public const string AUTHZ_DLL = "authz.dll"; public const string KERNEL32_DLL = "kernel32.dll"; public const string MPR_DLL = "Mpr.dll"; public const string NETAPI32_DLL = "Netapi32.dll"; public const string SHLWAPI_DLL = "shlwapi.dll"; [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct LUID { public uint LowPart; public uint HighPart; public static LUID NullLuid { get { LUID Empty; Empty.LowPart = 0; Empty.HighPart = 0; return Empty; } } } } static internal class Win32Error { // Note - the error codes here should all match the definitions in winerror.h. /// /// Equal to ERROR_SUCCESS (The operation completed successfully). /// public const int NO_ERROR = 0; /// /// Error code indicating: The operation completed successfully. /// public const int ERROR_SUCCESS = 0; /// /// The system cannot find the file specified. /// public const int ERROR_FILE_NOT_FOUND = 2; /// /// Error code indicating: Access is denied. /// public const int ERROR_ACCESS_DENIED = 5; /// /// Error code indicating: Not enough storage is available to process this command /// public const int ERROR_NOT_ENOUGH_MEMORY = 8; /// /// The data area passed to a system call is too small. /// public const int ERROR_INSUFFICIENT_BUFFER = 122; /// /// The filename or extension is too long. /// public const int ERROR_FILENAME_EXCED_RANGE = 206; /// /// More data is available. /// public const int ERROR_MORE_DATA = 234; /// /// An attempt was made to reference a token that does not exist. /// public const int ERROR_NO_TOKEN = 1008; /// /// The specified device name is invalid. /// public const int ERROR_BAD_DEVICE = 1200; /// /// Not all privileges or groups referenced are assigned to the caller. /// public const int ERROR_NOT_ALL_ASSIGNED = 1300; /// /// A specified privilege does not exist. /// public const int ERROR_NO_SUCH_PRIVILEGE = 1313; /// /// Cannot open an anonymous level security token. /// public const int ERROR_CANT_OPEN_ANONYMOUS = 1347; /// /// The RPC server is unavailable. /// public const int RPC_S_SERVER_UNAVAILABLE = 1722; /// /// There are no more endpoints available from the endpoint mapper. /// public const int EPT_S_NOT_REGISTERED = 1753; /// /// This network connection does not exist. /// public const int ERROR_NOT_CONNECTED = 2250; } }