We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- namespace Microsoft.Win32
- {
- using System;
- using System.Security;
- using System.Security.Principal;
- using System.Text;
- using System.Configuration.Assemblies;
- using System.Runtime.Remoting;
- using System.Runtime.InteropServices;
- using System.Threading;
- using Microsoft.Win32.SafeHandles;
- using System.Runtime.ConstrainedExecution;
- using System.Runtime.Versioning;
-
- using BOOL = System.Int32;
- using DWORD = System.UInt32;
- using ULONG = System.UInt32;
-
-
-
-
-
- [SuppressUnmanagedCodeSecurityAttribute()]
- static internal class Win32Native
- {
-
-
-
- internal const int READ_CONTROL = 131072;
- internal const int SYNCHRONIZE = 1048576;
-
- internal const int STANDARD_RIGHTS_READ = READ_CONTROL;
- internal const int STANDARD_RIGHTS_WRITE = READ_CONTROL;
-
-
-
-
-
-
-
-
-
- internal const int SEMAPHORE_MODIFY_STATE = 2;
- internal const int EVENT_MODIFY_STATE = 2;
- internal const int MUTEX_MODIFY_STATE = 1;
- internal const int MUTEX_ALL_ACCESS = 2031617;
-
-
- internal const int LMEM_FIXED = 0;
- internal const int LMEM_ZEROINIT = 64;
- internal const int LPTR = (LMEM_FIXED | LMEM_ZEROINIT);
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- internal class OSVERSIONINFO
- {
- internal OSVERSIONINFO()
- {
- OSVersionInfoSize = (int)Marshal.SizeOf(this);
- }
-
-
- internal int OSVersionInfoSize = 0;
- internal int MajorVersion = 0;
- internal int MinorVersion = 0;
- internal int BuildNumber = 0;
- internal int PlatformId = 0;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
- internal string CSDVersion = null;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- internal class OSVERSIONINFOEX
- {
-
- public OSVERSIONINFOEX()
- {
- OSVersionInfoSize = (int)Marshal.SizeOf(this);
- }
-
-
- internal int OSVersionInfoSize = 0;
- internal int MajorVersion = 0;
- internal int MinorVersion = 0;
- internal int BuildNumber = 0;
- internal int PlatformId = 0;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
- internal string CSDVersion = null;
- internal ushort ServicePackMajor = 0;
- internal ushort ServicePackMinor = 0;
- internal short SuiteMask = 0;
- internal byte ProductType = 0;
- internal byte Reserved = 0;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct SYSTEM_INFO
- {
- internal int dwOemId;
-
- internal int dwPageSize;
- internal IntPtr lpMinimumApplicationAddress;
- internal IntPtr lpMaximumApplicationAddress;
- internal IntPtr dwActiveProcessorMask;
- internal int dwNumberOfProcessors;
- internal int dwProcessorType;
- internal int dwAllocationGranularity;
- internal short wProcessorLevel;
- internal short wProcessorRevision;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal class SECURITY_ATTRIBUTES
- {
- internal int nLength = 0;
- unsafe internal byte* pSecurityDescriptor = null;
- internal int bInheritHandle = 0;
- }
-
- [StructLayout(LayoutKind.Sequential), Serializable()]
- internal struct WIN32_FILE_ATTRIBUTE_DATA
- {
- internal int fileAttributes;
- internal uint ftCreationTimeLow;
- internal uint ftCreationTimeHigh;
- internal uint ftLastAccessTimeLow;
- internal uint ftLastAccessTimeHigh;
- internal uint ftLastWriteTimeLow;
- internal uint ftLastWriteTimeHigh;
- internal int fileSizeHigh;
- internal int fileSizeLow;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct FILE_TIME
- {
- public FILE_TIME(long fileTime)
- {
- ftTimeLow = (uint)fileTime;
- ftTimeHigh = (uint)(fileTime >> 32);
- }
-
- public long ToTicks()
- {
- return ((long)ftTimeHigh << 32) + ftTimeLow;
- }
-
- internal uint ftTimeLow;
- internal uint ftTimeHigh;
- }
-
-
-
- #if !PLATFORM_UNIX
- internal const string DLLPREFIX = "";
- internal const string DLLSUFFIX = ".dll";
- #else // !PLATFORM_UNIX
- #if __APPLE__
- internal const string DLLPREFIX = "lib";
- internal const string DLLSUFFIX = ".dylib";
- #else
- internal const string DLLPREFIX = "lib";
- internal const string DLLSUFFIX = ".so";
- #endif
- #endif // !PLATFORM_UNIX
-
- internal const string KERNEL32 = DLLPREFIX + "rotor_pal" + DLLSUFFIX;
- internal const string USER32 = DLLPREFIX + "rotor_pal" + DLLSUFFIX;
- internal const string ADVAPI32 = DLLPREFIX + "rotor_pal" + DLLSUFFIX;
- internal const string OLE32 = DLLPREFIX + "rotor_pal" + DLLSUFFIX;
- internal const string OLEAUT32 = DLLPREFIX + "rotor_palrt" + DLLSUFFIX;
- internal const string SHIM = DLLPREFIX + "sscoree" + DLLSUFFIX;
- internal const string MSCORWKS = DLLPREFIX + "mscorwks" + DLLSUFFIX;
-
-
- internal const string LSTRCPY = "lstrcpy";
- internal const string LSTRCPYN = "lstrcpyn";
- internal const string LSTRLEN = "lstrlen";
- internal const string LSTRLENA = "lstrlenA";
- internal const string LSTRLENW = "lstrlenW";
- internal const string MOVEMEMORY = "RtlMoveMemory";
-
-
-
- internal const int SEM_FAILCRITICALERRORS = 1;
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern void SetLastError(int errorCode);
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern bool GetVersionEx( [In(), Out()]
- OSVERSIONINFO ver);
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern bool GetVersionEx( [In(), Out()]
- OSVERSIONINFOEX ver);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern void GetSystemInfo(ref SYSTEM_INFO lpSystemInfo);
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, BestFitMapping = true)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern int FormatMessage(int dwFlags, IntPtr lpSource, int dwMessageId, int dwLanguageId, StringBuilder lpBuffer, int nSize, IntPtr va_list_arguments);
-
-
- static internal string GetMessage(int errorCode)
- {
- StringBuilder sb = new StringBuilder(512);
- int result = Win32Native.FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, Win32Native.NULL, errorCode, 0, sb, sb.Capacity, Win32Native.NULL);
- if (result != 0) {
-
-
-
- string s = sb.ToString();
- return s;
- }
- else {
- return Environment.GetResourceString("UnknownError_Num", errorCode);
- }
- }
-
- [DllImport(KERNEL32, EntryPoint = "LocalAlloc")]
- [ResourceExposure(ResourceScope.None)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- static internal extern IntPtr LocalAlloc_NoSafeHandle(int uFlags, IntPtr sizetdwBytes);
-
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- static internal extern IntPtr LocalFree(IntPtr handle);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- static internal extern void ZeroMemory(IntPtr handle, uint length);
-
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern uint GetTempPath(int bufferLen, StringBuilder buffer);
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, EntryPoint = LSTRCPY, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern IntPtr lstrcpy(IntPtr dst, string src);
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, EntryPoint = LSTRCPY, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern IntPtr lstrcpy(StringBuilder dst, IntPtr src);
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, EntryPoint = LSTRLEN)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern int lstrlen(sbyte[] ptr);
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, EntryPoint = LSTRLEN)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern int lstrlen(IntPtr ptr);
-
- [DllImport(KERNEL32, CharSet = CharSet.Ansi, EntryPoint = LSTRLENA)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern int lstrlenA(IntPtr ptr);
-
- [DllImport(KERNEL32, CharSet = CharSet.Unicode, EntryPoint = LSTRLENW)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern int lstrlenW(IntPtr ptr);
-
- [DllImport(Win32Native.OLEAUT32, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- static internal extern IntPtr SysAllocStringLen(string src, int len);
-
- [DllImport(Win32Native.OLEAUT32)]
- [ResourceExposure(ResourceScope.None)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- static internal extern int SysStringLen(IntPtr bstr);
-
- [DllImport(Win32Native.OLEAUT32)]
- [ResourceExposure(ResourceScope.None)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- static internal extern void SysFreeString(IntPtr bstr);
-
- [DllImport(KERNEL32, CharSet = CharSet.Unicode, EntryPoint = MOVEMEMORY)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern void CopyMemoryUni(IntPtr pdst, string psrc, IntPtr sizetcb);
-
- [DllImport(KERNEL32, CharSet = CharSet.Unicode, EntryPoint = MOVEMEMORY)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern void CopyMemoryUni(StringBuilder pdst, IntPtr psrc, IntPtr sizetcb);
-
- [DllImport(KERNEL32, CharSet = CharSet.Ansi, EntryPoint = MOVEMEMORY, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern void CopyMemoryAnsi(IntPtr pdst, string psrc, IntPtr sizetcb);
-
- [DllImport(KERNEL32, CharSet = CharSet.Ansi, EntryPoint = MOVEMEMORY, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern void CopyMemoryAnsi(StringBuilder pdst, IntPtr psrc, IntPtr sizetcb);
-
-
- [DllImport(KERNEL32)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern int GetACP();
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern bool SetEvent(SafeWaitHandle handle);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern bool ResetEvent(SafeWaitHandle handle);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
-
- static internal extern SafeWaitHandle CreateEvent(SECURITY_ATTRIBUTES lpSecurityAttributes, bool isManualReset, bool initialState, string name);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern SafeWaitHandle OpenEvent(int desiredAccess, bool inheritHandle, string name);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- static internal extern SafeWaitHandle CreateMutex(SECURITY_ATTRIBUTES lpSecurityAttributes, bool initialOwner, string name);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern SafeWaitHandle OpenMutex(int desiredAccess, bool inheritHandle, string name);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- static internal extern bool ReleaseMutex(SafeWaitHandle handle);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern int GetFullPathName( [In()]
- char[] path, int numBufferChars, [Out()]
- char[] buffer, IntPtr mustBeZero);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- unsafe static internal extern int GetFullPathName(char* path, int numBufferChars, char* buffer, IntPtr mustBeZero);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern int GetLongPathName(string path, StringBuilder longPathBuffer, int bufferLength);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern int GetLongPathName( [In()]
- char[] path, [Out()]
- char[] longPathBuffer, int bufferLength);
-
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- unsafe static internal extern int GetLongPathName(char* path, char* longPathBuffer, int bufferLength);
-
-
-
-
-
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- static internal SafeFileHandle SafeCreateFile(string lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile)
- {
- SafeFileHandle handle = CreateFile(lpFileName, dwDesiredAccess, dwShareMode, securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
-
- if (!handle.IsInvalid) {
- int fileType = Win32Native.GetFileType(handle);
- if (fileType != Win32Native.FILE_TYPE_DISK) {
- handle.Dispose();
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_FileStreamOnNonFiles"));
- }
- }
-
- return handle;
- }
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- static internal SafeFileHandle UnsafeCreateFile(string lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile)
- {
- SafeFileHandle handle = CreateFile(lpFileName, dwDesiredAccess, dwShareMode, securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
-
- return handle;
- }
-
-
-
-
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- private static extern SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern SafeFileMappingHandle CreateFileMapping(SafeFileHandle hFile, IntPtr lpAttributes, uint fProtect, uint dwMaximumSizeHigh, uint dwMaximumSizeLow, string lpName);
-
- [DllImport(KERNEL32, SetLastError = true, ExactSpelling = true)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern SafeViewOfFileHandle MapViewOfFile(SafeFileMappingHandle handle, uint dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow, UIntPtr dwNumerOfBytesToMap);
-
- [DllImport(KERNEL32, ExactSpelling = true)]
- [ResourceExposure(ResourceScope.Machine)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- static internal extern bool UnmapViewOfFile(IntPtr lpBaseAddress);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.Machine)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- static internal extern bool CloseHandle(IntPtr handle);
-
- [DllImport(KERNEL32)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern int GetFileType(SafeFileHandle handle);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern bool SetEndOfFile(SafeFileHandle hFile);
-
- [DllImport(KERNEL32, SetLastError = true, EntryPoint = "SetFilePointer")]
- [ResourceExposure(ResourceScope.None)]
- unsafe private static extern int SetFilePointerWin32(SafeFileHandle handle, int lo, int* hi, int origin);
-
- [ResourceExposure(ResourceScope.None)]
- unsafe static internal long SetFilePointer(SafeFileHandle handle, long offset, System.IO.SeekOrigin origin, out int hr)
- {
- hr = 0;
- int lo = (int)offset;
- int hi = (int)(offset >> 32);
- lo = SetFilePointerWin32(handle, lo, &hi, (int)origin);
-
- if (lo == -1 && ((hr = Marshal.GetLastWin32Error()) != 0))
- return -1;
- return (long)(((ulong)((uint)hi)) << 32) | ((uint)lo);
- }
-
-
-
-
-
-
-
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- unsafe static internal extern int ReadFile(SafeFileHandle handle, byte* bytes, int numBytesToRead, IntPtr numBytesRead_mustBeZero, NativeOverlapped* overlapped);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- unsafe static internal extern int ReadFile(SafeFileHandle handle, byte* bytes, int numBytesToRead, out int numBytesRead, IntPtr mustBeZero);
-
-
-
-
-
-
-
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- unsafe static internal extern int WriteFile(SafeFileHandle handle, byte* bytes, int numBytesToWrite, IntPtr numBytesWritten_mustBeZero, NativeOverlapped* lpOverlapped);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- unsafe static internal extern int WriteFile(SafeFileHandle handle, byte* bytes, int numBytesToWrite, out int numBytesWritten, IntPtr mustBeZero);
-
-
-
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern bool GetDiskFreeSpaceEx(string drive, out long freeBytesForUser, out long totalBytes, out long freeBytes);
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern int GetDriveType(string drive);
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern bool GetVolumeInformation(string drive, StringBuilder volumeName, int volumeNameBufLen, out int volSerialNumber, out int maxFileNameLen, out int fileSystemFlags, StringBuilder fileSystemName, int fileSystemNameBufLen);
-
- [DllImport(KERNEL32, CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern bool SetVolumeLabel(string driveLetter, string volumeName);
-
-
- [DllImport(KERNEL32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "PAL_GetPALDirectoryW", BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern int GetSystemDirectory(StringBuilder sb, int length);
-
- [DllImport(OLEAUT32, CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "PAL_FetchConfigurationStringW")]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern bool FetchConfigurationString(bool perMachine, string parameterName, StringBuilder parameterValue, int parameterValueLength);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- unsafe static internal extern bool SetFileTime(SafeFileHandle hFile, FILE_TIME* creationTime, FILE_TIME* lastAccessTime, FILE_TIME* lastWriteTime);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern int GetFileSize(SafeFileHandle hFile, out int highSize);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern bool LockFile(SafeFileHandle handle, int offsetLow, int offsetHigh, int countLow, int countHigh);
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.None)]
- static internal extern bool UnlockFile(SafeFileHandle handle, int offsetLow, int offsetHigh, int countLow, int countHigh);
-
- static internal readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
-
- static internal readonly IntPtr NULL = IntPtr.Zero;
-
-
- internal const int STD_INPUT_HANDLE = -10;
- internal const int STD_OUTPUT_HANDLE = -11;
- internal const int STD_ERROR_HANDLE = -12;
-
- [DllImport(KERNEL32, SetLastError = true)]
- [ResourceExposure(ResourceScope.Process)]
- static internal extern IntPtr GetStdHandle(int nStdHandle);
-
-
- internal const int CTRL_C_EVENT = 0;
- internal const int CTRL_BREAK_EVENT = 1;
- internal const int CTRL_CLOSE_EVENT = 2;
- internal const int CTRL_LOGOFF_EVENT = 5;
- internal const int CTRL_SHUTDOWN_EVENT = 6;
- internal const short KEY_EVENT = 1;
-
-
- internal const int FILE_TYPE_DISK = 1;
- internal const int FILE_TYPE_CHAR = 2;
- internal const int FILE_TYPE_PIPE = 3;
-
- internal const int REPLACEFILE_WRITE_THROUGH = 1;
- internal const int REPLACEFILE_IGNORE_MERGE_ERRORS = 2;
-
- private const int FORMAT_MESSAGE_IGNORE_INSERTS = 512;
- private const int FORMAT_MESSAGE_FROM_SYSTEM = 4096;
- private const int FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192;
-
-
- internal const int FILE_ATTRIBUTE_READONLY = 1;
- internal const int FILE_ATTRIBUTE_DIRECTORY = 16;
- internal const int FILE_ATTRIBUTE_REPARSE_POINT = 1024;
-
- internal const int IO_REPARSE_TAG_MOUNT_POINT = unchecked((int)2684354563u);
-
- internal const int PAGE_READWRITE = 4;
-
- internal const int MEM_COMMIT = 4096;
- internal const int MEM_RESERVE = 8192;
- internal const int MEM_RELEASE = 32768;
- internal const int MEM_FREE = 65536;
-
-
- internal const int ERROR_SUCCESS = 0;
- internal const int ERROR_INVALID_FUNCTION = 1;
- internal const int ERROR_FILE_NOT_FOUND = 2;
- internal const int ERROR_PATH_NOT_FOUND = 3;
- internal const int ERROR_ACCESS_DENIED = 5;
- internal const int ERROR_INVALID_HANDLE = 6;
- internal const int ERROR_NOT_ENOUGH_MEMORY = 8;
- internal const int ERROR_INVALID_DATA = 13;
- internal const int ERROR_INVALID_DRIVE = 15;
- internal const int ERROR_NO_MORE_FILES = 18;
- internal const int ERROR_NOT_READY = 21;
- internal const int ERROR_BAD_LENGTH = 24;
- internal const int ERROR_SHARING_VIOLATION = 32;
- internal const int ERROR_NOT_SUPPORTED = 50;
- internal const int ERROR_FILE_EXISTS = 80;
- internal const int ERROR_INVALID_PARAMETER = 87;
- internal const int ERROR_CALL_NOT_IMPLEMENTED = 120;
- internal const int ERROR_INSUFFICIENT_BUFFER = 122;
- internal const int ERROR_INVALID_NAME = 123;
- internal const int ERROR_BAD_PATHNAME = 161;
- internal const int ERROR_ALREADY_EXISTS = 183;
- internal const int ERROR_ENVVAR_NOT_FOUND = 203;
- internal const int ERROR_FILENAME_EXCED_RANGE = 206;
-
- internal const int ERROR_NO_DATA = 232;
- internal const int ERROR_PIPE_NOT_CONNECTED = 233;
- internal const int ERROR_MORE_DATA = 234;
- internal const int ERROR_OPERATION_ABORTED = 995;
-
- internal const int ERROR_NO_TOKEN = 1008;
- internal const int ERROR_DLL_INIT_FAILED = 1114;
- internal const int ERROR_NON_ACCOUNT_SID = 1257;
- internal const int ERROR_NOT_ALL_ASSIGNED = 1300;
- internal const int ERROR_UNKNOWN_REVISION = 1305;
- internal const int ERROR_INVALID_OWNER = 1307;
- internal const int ERROR_INVALID_PRIMARY_GROUP = 1308;
- internal const int ERROR_NO_SUCH_PRIVILEGE = 1313;
- internal const int ERROR_PRIVILEGE_NOT_HELD = 1314;
- internal const int ERROR_NONE_MAPPED = 1332;
- internal const int ERROR_INVALID_ACL = 1336;
- internal const int ERROR_INVALID_SID = 1337;
- internal const int ERROR_INVALID_SECURITY_DESCR = 1338;
- internal const int ERROR_BAD_IMPERSONATION_LEVEL = 1346;
- internal const int ERROR_CANT_OPEN_ANONYMOUS = 1347;
- internal const int ERROR_NO_SECURITY_ON_OBJECT = 1350;
- internal const int ERROR_TRUSTED_RELATIONSHIP_FAILURE = 1789;
-
-
- internal const uint STATUS_SOME_NOT_MAPPED = 263;
- internal const uint STATUS_NO_MEMORY = 3221225495u;
- internal const uint STATUS_NONE_MAPPED = 3221225587u;
- internal const uint STATUS_INSUFFICIENT_RESOURCES = 3221225626u;
- internal const uint STATUS_ACCESS_DENIED = 3221225506u;
-
- internal const int INVALID_FILE_SIZE = -1;
-
-
- internal const int STATUS_ACCOUNT_RESTRICTION = unchecked((int)3221225582u);
-
-
-
- static internal int MakeHRFromErrorCode(int errorCode)
- {
- BCLDebug.Assert((4294901760u & errorCode) == 0, "This is an HRESULT, not an error code!");
- return unchecked(((int)2147942400u) | errorCode);
- }
-
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto), Serializable()]
- [BestFitMapping(false)]
- internal class WIN32_FIND_DATA
- {
- internal int dwFileAttributes = 0;
-
- internal int ftCreationTime_dwLowDateTime = 0;
- internal int ftCreationTime_dwHighDateTime = 0;
-
- internal int ftLastAccessTime_dwLowDateTime = 0;
- internal int ftLastAccessTime_dwHighDateTime = 0;
-
- internal int ftLastWriteTime_dwLowDateTime = 0;
- internal int ftLastWriteTime_dwHighDateTime = 0;
- internal int nFileSizeHigh = 0;
- internal int nFileSizeLow = 0;
-
-
-
-
- internal int dwReserved0 = 0;
- internal int dwReserved1 = 0;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
- internal string cFileName = null;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
- internal string cAlternateFileName = null;
- }
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern bool CopyFile(string src, string dst, bool failIfExists);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern bool CreateDirectory(string path, SECURITY_ATTRIBUTES lpSecurityAttributes);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern bool DeleteFile(string path);
-
- [DllImport(KERNEL32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
- [ResourceExposure(ResourceScope.Machine)]
- static internal extern bool ReplaceFile(string replacedFileName, string replacementFileName, string backupFileName, int dwReplaceFlags, IntPtr lpExclude, IntPtr lpReserved);
- &