1334 references to Win32Native
mscorlib (1334)
microsoft\win32\fusionwrap.cs (2)
128hr = Win32Native.CreateAssemblyNameObject(out aNameEnum, name, CANOF.PARSE_DISPLAY_NAME, IntPtr.Zero); 133hr = Win32Native.CreateAssemblyEnum(out aEnum, AppCtx, aNameEnum, nFlag, IntPtr.Zero);
microsoft\win32\registrykey.cs (73)
264Win32Native.RegFlushKey(hkey); 364Win32Native.SECURITY_ATTRIBUTES secAttrs = null; 369secAttrs = new Win32Native.SECURITY_ATTRIBUTES(); 384int ret = Win32Native.RegCreateKeyEx(hkey, 452ret = Win32Native.RegDeleteKeyEx(hkey, subkey, (int)regView, 0); 456ret = Win32Native.RegDeleteKey(hkey, subkey); 460if (ret == Win32Native.ERROR_FILE_NOT_FOUND) { 520ret = Win32Native.RegDeleteKeyEx(hkey, subkey, (int)regView, 0); 524ret = Win32Native.RegDeleteKey(hkey, subkey); 557ret = Win32Native.RegDeleteKeyEx(hkey, subkey, (int)regView, 0); 561ret = Win32Native.RegDeleteKey(hkey, subkey); 587int errorCode = Win32Native.RegDeleteValue(hkey, name); 593if (errorCode == Win32Native.ERROR_FILE_NOT_FOUND || errorCode == Win32Native.ERROR_FILENAME_EXCED_RANGE) { 694int ret = Win32Native.RegConnectRegistry(machineName, new SafeRegistryHandle(new IntPtr((int)hKey), false), out foreignHKey); 696if (ret == Win32Native.ERROR_DLL_INIT_FAILED) 736int ret = Win32Native.RegOpenKeyEx(hkey, 750if (ret == Win32Native.ERROR_ACCESS_DENIED || ret == Win32Native.ERROR_BAD_IMPERSONATION_LEVEL) { 800int ret = Win32Native.RegOpenKeyEx(hkey, name, 0, (rights | (int)regView), out result); 809if (ret == Win32Native.ERROR_ACCESS_DENIED || ret == Win32Native.ERROR_BAD_IMPERSONATION_LEVEL) { 829int ret = Win32Native.RegOpenKeyEx(hkey, 890int ret = Win32Native.ERROR_INVALID_HANDLE; 921ret = Win32Native.RegOpenKeyEx(baseKey, 937throw new IOException(Win32Native.GetMessage(ret), ret); 969int ret = Win32Native.RegQueryInfoKey(hkey, 1017int ret = Win32Native.RegEnumKeyEx(hkey, 1053int ret = Win32Native.RegQueryInfoKey(hkey, 1092int ret = Win32Native.RegEnumValue(hkey, 1103if (!(IsPerfDataKey() && ret == Win32Native.ERROR_MORE_DATA)) 1183int ret = Win32Native.RegQueryValueEx(hkey, name, null, ref type, (byte[])null, ref datasize); 1192while (Win32Native.ERROR_MORE_DATA == (r = Win32Native.RegQueryValueEx(hkey, name, null, ref type, blob, ref sizeInput))) { 1215if (ret != Win32Native.ERROR_MORE_DATA) 1228case Win32Native.REG_NONE: 1229case Win32Native.REG_DWORD_BIG_ENDIAN: 1230case Win32Native.REG_BINARY: { 1232ret = Win32Native.RegQueryValueEx(hkey, name, null, ref type, blob, ref datasize); 1236case Win32Native.REG_QWORD: 1240goto case Win32Native.REG_BINARY; 1245ret = Win32Native.RegQueryValueEx(hkey, name, null, ref type, ref blob, ref datasize); 1250case Win32Native.REG_DWORD: 1254goto case Win32Native.REG_QWORD; 1259ret = Win32Native.RegQueryValueEx(hkey, name, null, ref type, ref blob, ref datasize); 1265case Win32Native.REG_SZ: 1278ret = Win32Native.RegQueryValueEx(hkey, name, null, ref type, blob, ref datasize); 1290case Win32Native.REG_EXPAND_SZ: 1303ret = Win32Native.RegQueryValueEx(hkey, name, null, ref type, blob, ref datasize); 1318case Win32Native.REG_MULTI_SZ: 1331ret = Win32Native.RegQueryValueEx(hkey, name, null, ref type, blob, ref datasize); 1382case Win32Native.REG_LINK: 1399int ret = Win32Native.RegQueryValueEx(hkey, name, null, ref type, (byte[])null, ref datasize); 1402if (type == Win32Native.REG_NONE) 1491ret = Win32Native.RegSetValueEx(hkey, 1534ret = Win32Native.RegSetValueEx(hkey, 1547ret = Win32Native.RegSetValueEx(hkey, 1550(valueKind == RegistryValueKind.None ? Win32Native.REG_NONE: RegistryValueKind.Binary), 1561ret = Win32Native.RegSetValueEx(hkey, 1574ret = Win32Native.RegSetValueEx(hkey, 1665case Win32Native.ERROR_ACCESS_DENIED: 1671case Win32Native.ERROR_INVALID_HANDLE: 1693case Win32Native.ERROR_FILE_NOT_FOUND: 1697throw new IOException(Win32Native.GetMessage(errorCode), errorCode); 1704case Win32Native.ERROR_ACCESS_DENIED: 1711throw new IOException(Win32Native.GetMessage(errorCode), errorCode); 2087int retval = Win32Native.RegQueryValueEx(hkey, name, null, ref type, (byte[])null, ref datasize); 2109winAccess = Win32Native.KEY_READ; 2112winAccess = Win32Native.KEY_READ | Win32Native.KEY_WRITE; 2123winAccess = Win32Native.KEY_READ; 2127winAccess = Win32Native.KEY_READ| Win32Native.KEY_WRITE;
microsoft\win32\RegistryOptions.cs (2)
20None = Win32Native.REG_OPTION_NON_VOLATILE, // 0x0000 21Volatile = Win32Native.REG_OPTION_VOLATILE, // 0x0001
microsoft\win32\RegistryValueKind.cs (6)
10String = Win32Native.REG_SZ, 11ExpandString = Win32Native.REG_EXPAND_SZ, 12Binary = Win32Native.REG_BINARY, 13DWord = Win32Native.REG_DWORD, 14MultiString = Win32Native.REG_MULTI_SZ, 15QWord = Win32Native.REG_QWORD,
microsoft\win32\RegistryView.cs (2)
20Registry64 = Win32Native.KEY_WOW64_64KEY, // 0x0100 operate on the 64-bit registry view 21Registry32 = Win32Native.KEY_WOW64_32KEY, // 0x0200 operate on the 32-bit registry view
microsoft\win32\safehandles\safefilehandle.cs (1)
43return Win32Native.CloseHandle(handle);
microsoft\win32\safehandles\safefilemappinghandle.cs (1)
43return Win32Native.CloseHandle(handle);
microsoft\win32\safehandles\safefindhandle.cs (1)
34return Win32Native.FindClose(handle);
microsoft\win32\safehandles\safelocalallochandle.cs (1)
25return Win32Native.LocalFree(handle) == IntPtr.Zero;
microsoft\win32\safehandles\saferegistryhandle.cs (2)
36return (RegCloseKey(handle) == Win32Native.ERROR_SUCCESS); 39[DllImport(Win32Native.ADVAPI32),
microsoft\win32\safehandles\safeviewoffilehandle.cs (1)
44if (Win32Native.UnmapViewOfFile(handle))
microsoft\win32\safehandles\safewaithandle.cs (1)
48return Win32Native.CloseHandle(handle);
microsoft\win32\unsafenativemethods.cs (16)
29[DllImport(Win32Native.KERNEL32, EntryPoint="GetTimeZoneInformation", SetLastError = true, ExactSpelling = true)] 31internal static extern int GetTimeZoneInformation(out Win32Native.TimeZoneInformation lpTimeZoneInformation); 33[DllImport(Win32Native.KERNEL32, EntryPoint="GetDynamicTimeZoneInformation", SetLastError = true, ExactSpelling = true)] 35internal static extern int GetDynamicTimeZoneInformation(out Win32Native.DynamicTimeZoneInformation lpDynamicTimeZoneInformation); 48[DllImport(Win32Native.KERNEL32, EntryPoint="GetFileMUIPath", SetLastError = true, ExactSpelling = true)] 64[DllImport(Win32Native.USER32, EntryPoint="LoadStringW", SetLastError=true, CharSet=CharSet.Unicode, ExactSpelling=true, CallingConvention=CallingConvention.StdCall)] 68[DllImport(Win32Native.KERNEL32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)] 72[DllImport(Win32Native.KERNEL32, CharSet=System.Runtime.InteropServices.CharSet.Unicode)] 126[DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventRegister", CharSet = System.Runtime.InteropServices.CharSet.Unicode)] 137[DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventUnregister", CharSet = System.Runtime.InteropServices.CharSet.Unicode)] 146[DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventWrite", CharSet = System.Runtime.InteropServices.CharSet.Unicode)] 156[DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventWriteString", CharSet = System.Runtime.InteropServices.CharSet.Unicode)] 195[DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventWriteTransfer", CharSet = System.Runtime.InteropServices.CharSet.Unicode)] 216[DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventActivityIdControl", CharSet = System.Runtime.InteropServices.CharSet.Unicode)] 228[DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EventSetInformation", CharSet = System.Runtime.InteropServices.CharSet.Unicode)] 273[DllImport(Win32Native.ADVAPI32, ExactSpelling = true, EntryPoint = "EnumerateTraceGuidsEx", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
microsoft\win32\win32native.cs (18)
265public TimeZoneInformation(Win32Native.DynamicTimeZoneInformation dtzi) { 309public RegistryTimeZoneInformation(Win32Native.TimeZoneInformation tzi) { 744int result = Win32Native.FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | 833IntPtr hModule = Win32Native.GetModuleHandle(moduleName); 838IntPtr functionPointer = Win32Native.GetProcAddress(hModule, methodName); 866[DllImport(Win32Native.OLEAUT32, CharSet=CharSet.Unicode)] 871[DllImport(Win32Native.OLEAUT32)] 876[DllImport(Win32Native.OLEAUT32)] 881[DllImport(Win32Native.OLEAUT32)] 887[DllImport(Win32Native.OLEAUT32)] 893[DllImport(Win32Native.OLEAUT32)] 980int fileType = Win32Native.GetFileType(handle); 981if (fileType != Win32Native.FILE_TYPE_DISK) { 1557[DllImport(Win32Native.OLE32)] 1561[DllImport(Win32Native.OLE32)] 1565[DllImport(Win32Native.OLE32)] 2031[DllImport(Win32Native.ADVAPI32, CharSet=CharSet.Unicode, SetLastError=true)] 2040[DllImport(Win32Native.ADVAPI32, CharSet=CharSet.Unicode, SetLastError=true)]
system\AppContext\AppContextDefaultValues.DesktopOverrides.cs (3)
137if (Win32Native.RegOpenKeyEx(hklm, REG_KEY_APPCONTEXT, 0, Win32Native.KEY_READ, out hkey) == 0) 142if (Win32Native.RegQueryValueEx(hkey, switchName, null, ref type, keyBuffer, ref size) == 0)
system\appdomain.cs (1)
2572[DllImport(Microsoft.Win32.Win32Native.KERNEL32)]
system\console.cs (165)
87private static Win32Native.InputRecord _cachedInputRecord; 159_consoleInputHandle = Win32Native.GetStdHandle(Win32Native.STD_INPUT_HANDLE); 171_consoleOutputHandle = Win32Native.GetStdHandle(Win32Native.STD_OUTPUT_HANDLE); 188int fileType = Win32Native.GetFileType(safeIOHandle); 189if ((fileType & Win32Native.FILE_TYPE_CHAR) != Win32Native.FILE_TYPE_CHAR) 195bool success = Win32Native.GetConsoleMode(ioHandle, out mode); 256IntPtr errHndle = Win32Native.GetStdHandle(Win32Native.STD_ERROR_HANDLE); 453case Win32Native.STD_INPUT_HANDLE: 456case Win32Native.STD_OUTPUT_HANDLE: 459case Win32Native.STD_ERROR_HANDLE: 483IntPtr handle = Win32Native.GetStdHandle(stdHandleName); 496if (stdHandleName != Win32Native.STD_INPUT_HANDLE && !ConsoleHandleIsWritable(sh)) { 535int r = Win32Native.WriteFile(outErrHandle, &junkByte, 0, out bytesWritten, IntPtr.Zero); 555uint cp = Win32Native.GetConsoleCP(); 578bool r = Win32Native.SetConsoleCP(cp); 608uint cp = Win32Native.GetConsoleOutputCP(); 641bool r = Win32Native.SetConsoleOutputCP(cp); 671Win32Native.Beep(frequency, duration); 679Win32Native.COORD coordScreen = new Win32Native.COORD(); 680Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi; 685if (hConsole == Win32Native.INVALID_HANDLE_VALUE) 697success = Win32Native.FillConsoleOutputCharacter(hConsole, ' ', 705success = Win32Native.FillConsoleOutputAttribute(hConsole, csbi.wAttributes, 712success = Win32Native.SetConsoleCursorPosition(hConsole, coordScreen); 718private static Win32Native.Color ConsoleColorToColorAttribute(ConsoleColor color, bool isBackground) 724Win32Native.Color c = (Win32Native.Color) color; 728c = (Win32Native.Color) ((int)c << 4); 733private static ConsoleColor ColorAttributeToConsoleColor(Win32Native.Color c) 736if ((c & Win32Native.Color.BackgroundMask) != 0) 737c = (Win32Native.Color) (((int)c) >> 4); 748Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(false, out succeeded); 754Win32Native.Color c = (Win32Native.Color) csbi.wAttributes & Win32Native.Color.BackgroundMask; 763Win32Native.Color c = ConsoleColorToColorAttribute(value, true); 766Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(false, out succeeded); 774attrs &= ~((short)Win32Native.Color.BackgroundMask); 779Win32Native.SetConsoleTextAttribute(ConsoleOutputHandle, attrs); 789Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(false, out succeeded); 795Win32Native.Color c = (Win32Native.Color) csbi.wAttributes & Win32Native.Color.ForegroundMask; 804Win32Native.Color c = ConsoleColorToColorAttribute(value, false); 807Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(false, out succeeded); 815attrs &= ~((short)Win32Native.Color.ForegroundMask); 820Win32Native.SetConsoleTextAttribute(ConsoleOutputHandle, attrs); 832Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(false, out succeeded); 842Win32Native.SetConsoleTextAttribute(ConsoleOutputHandle, defaultAttrs); 867Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 868Win32Native.COORD bufferSize = csbi.dwSize; 900Win32Native.CHAR_INFO[] data = new Win32Native.CHAR_INFO[sourceWidth * sourceHeight]; 903Win32Native.COORD bufferCoord = new Win32Native.COORD(); 904Win32Native.SMALL_RECT readRegion = new Win32Native.SMALL_RECT(); 911fixed(Win32Native.CHAR_INFO* pCharInfo = data) 912r = Win32Native.ReadConsoleOutput(ConsoleOutputHandle, pCharInfo, bufferSize, bufferCoord, ref readRegion); 918Win32Native.COORD writeCoord = new Win32Native.COORD(); 920Win32Native.Color c = ConsoleColorToColorAttribute(sourceBackColor, true); 926r = Win32Native.FillConsoleOutputCharacter(ConsoleOutputHandle, sourceChar, sourceWidth, writeCoord, out numWritten); 931r = Win32Native.FillConsoleOutputAttribute(ConsoleOutputHandle, attr, sourceWidth, writeCoord, out numWritten); 937Win32Native.SMALL_RECT writeRegion = new Win32Native.SMALL_RECT(); 943fixed(Win32Native.CHAR_INFO* pCharInfo = data) 944r = Win32Native.WriteConsoleOutput(ConsoleOutputHandle, pCharInfo, bufferSize, bufferCoord, ref writeRegion); 950private static Win32Native.CONSOLE_SCREEN_BUFFER_INFO GetBufferInfo() 962private static Win32Native.CONSOLE_SCREEN_BUFFER_INFO GetBufferInfo(bool throwOnNoConsole, out bool succeeded) 965Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi; 969if (hConsole == Win32Native.INVALID_HANDLE_VALUE) { 971return new Win32Native.CONSOLE_SCREEN_BUFFER_INFO(); 978success = Win32Native.GetConsoleScreenBufferInfo(hConsole, out csbi); 980success = Win32Native.GetConsoleScreenBufferInfo(Win32Native.GetStdHandle(Win32Native.STD_ERROR_HANDLE), out csbi); 982success = Win32Native.GetConsoleScreenBufferInfo(Win32Native.GetStdHandle(Win32Native.STD_INPUT_HANDLE), out csbi); 986if (errorCode == Win32Native.ERROR_INVALID_HANDLE && !throwOnNoConsole) 987return new Win32Native.CONSOLE_SCREEN_BUFFER_INFO(); 995Contract.Assert((int)Win32Native.Color.ColorMask == 0xff, "Make sure one byte is large enough to store a Console color value!"); 996_defaultColors = (byte) (csbi.wAttributes & (short) Win32Native.Color.ColorMask); 1009Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1024Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1042Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1043Win32Native.SMALL_RECT srWindow = csbi.srWindow; 1049Win32Native.COORD size = new Win32Native.COORD(); 1052bool r = Win32Native.SetConsoleScreenBufferSize(ConsoleOutputHandle, size); 1063Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1078Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1102Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1108Win32Native.COORD size = new Win32Native.COORD(); 1124r = Win32Native.SetConsoleScreenBufferSize(ConsoleOutputHandle, size); 1129Win32Native.SMALL_RECT srWindow = csbi.srWindow; 1134r = Win32Native.SetConsoleWindowInfo(ConsoleOutputHandle, true, &srWindow); 1140Win32Native.SetConsoleScreenBufferSize(ConsoleOutputHandle, csbi.dwSize); 1144Win32Native.COORD bounds = Win32Native.GetLargestConsoleWindowSize(ConsoleOutputHandle); 1161Win32Native.COORD bounds = Win32Native.GetLargestConsoleWindowSize(ConsoleOutputHandle); 1173Win32Native.COORD bounds = Win32Native.GetLargestConsoleWindowSize(ConsoleOutputHandle); 1183Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1198Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1216Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1218Win32Native.SMALL_RECT srWindow = csbi.srWindow; 1234bool r = Win32Native.SetConsoleWindowInfo(ConsoleOutputHandle, true, &srWindow); 1244Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1259Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1286Win32Native.COORD coords = new Win32Native.COORD(); 1289bool r = Win32Native.SetConsoleCursorPosition(hConsole, coords); 1293Win32Native.CONSOLE_SCREEN_BUFFER_INFO csbi = GetBufferInfo(); 1308Win32Native.CONSOLE_CURSOR_INFO cci; 1310bool r = Win32Native.GetConsoleCursorInfo(hConsole, out cci); 1327Win32Native.CONSOLE_CURSOR_INFO cci; 1329bool r = Win32Native.GetConsoleCursorInfo(hConsole, out cci); 1334r = Win32Native.SetConsoleCursorInfo(hConsole, ref cci); 1345Win32Native.CONSOLE_CURSOR_INFO cci; 1347bool r = Win32Native.GetConsoleCursorInfo(hConsole, out cci); 1359Win32Native.CONSOLE_CURSOR_INFO cci; 1361bool r = Win32Native.GetConsoleCursorInfo(hConsole, out cci); 1366r = Win32Native.SetConsoleCursorInfo(hConsole, ref cci); 1413if (!Win32Native.SetConsoleTitle(value)) 1447private static bool IsAltKeyDown(Win32Native.InputRecord ir) { 1458private static bool IsKeyDownEvent(Win32Native.InputRecord ir) { 1459return (ir.eventType == Win32Native.KEY_EVENT && ir.keyEvent.keyDown); 1463private static bool IsModKey(Win32Native.InputRecord ir) { 1478Win32Native.InputRecord ir; 1483if (_cachedInputRecord.eventType == Win32Native.KEY_EVENT) { 1497r = Win32Native.ReadConsoleInput(ConsoleInputHandle, out ir, 1, out numEventsRead); 1567if (_cachedInputRecord.eventType == Win32Native.KEY_EVENT) 1570Win32Native.InputRecord ir = new Win32Native.InputRecord(); 1573bool r = Win32Native.PeekConsoleInput(ConsoleInputHandle, out ir, 1, out numEventsRead); 1576if (errorCode == Win32Native.ERROR_INVALID_HANDLE) 1593r = Win32Native.ReadConsoleInput(ConsoleInputHandle, out ir, 1, out numEventsRead); 1610short s = Win32Native.GetKeyState(NumberLockVKCode); 1620short s = Win32Native.GetKeyState(CapsLockVKCode); 1631if (handle == Win32Native.INVALID_HANDLE_VALUE) 1634bool r = Win32Native.GetConsoleMode(handle, out mode); 1637return (mode & Win32Native.ENABLE_PROCESSED_INPUT) == 0; 1646if (handle == Win32Native.INVALID_HANDLE_VALUE) 1650bool r = Win32Native.GetConsoleMode(handle, out mode); 1652mode &= ~Win32Native.ENABLE_PROCESSED_INPUT; 1654mode |= Win32Native.ENABLE_PROCESSED_INPUT; 1655r = Win32Native.SetConsoleMode(handle, mode); 1675private Win32Native.ConsoleCtrlHandlerRoutine _handler; 1680_handler = new Win32Native.ConsoleCtrlHandlerRoutine(BreakEvent); 1696bool r = Win32Native.SetConsoleCtrlHandler(_handler, true); 1710bool r = Win32Native.SetConsoleCtrlHandler(_handler, false); 1743if (controlType == Win32Native.CTRL_C_EVENT || 1744controlType == Win32Native.CTRL_BREAK_EVENT) { 1853return GetStandardFile(Win32Native.STD_ERROR_HANDLE, 1874return GetStandardFile(Win32Native.STD_INPUT_HANDLE, 1895return GetStandardFile(Win32Native.STD_OUTPUT_HANDLE,
system\diagnostics\eventing\eventprovider.cs (2)
158throw new ArgumentException(Win32Native.GetMessage(unchecked((int)status))); 482int processId = unchecked((int)Win32Native.GetCurrentProcessId());
system\diagnostics\eventing\eventsource.cs (1)
3051s_currentPid = Win32Native.GetCurrentProcessId();
system\environment.cs (95)
412int r = Win32Native.GetSystemDirectory(sb, Path.MAX_PATH); 435int r = Win32Native.GetWindowsDirectory(sb, Path.MAX_PATH); 493size = Win32Native.ExpandEnvironmentStrings(envVar, blob, currentSize); 502size = Win32Native.ExpandEnvironmentStrings(envVar, blob, currentSize); 523size = Win32Native.ExpandEnvironmentStrings(name, blob, currentSize); 532size = Win32Native.ExpandEnvironmentStrings(name, blob, currentSize); 549if (Win32Native.GetComputerName(buf, ref len) == 0) 571Win32Native.SYSTEM_INFO info = new Win32Native.SYSTEM_INFO(); 572Win32Native.GetSystemInfo(ref info); 632int requiredSize = Win32Native.GetEnvironmentVariable(variable, blob, blob.Capacity); 635if (Marshal.GetLastWin32Error() == Win32Native.ERROR_ENVVAR_NOT_FOUND) { 644requiredSize = Win32Native.GetEnvironmentVariable(variable, blob, blob.Capacity); 724pStrings = Win32Native.GetEnvironmentStrings(); 748Win32Native.FreeEnvironmentStrings(pStrings); 913if(!Win32Native.SetEnvironmentVariable(variable, value)) { 917if( errorCode == Win32Native.ERROR_ENVVAR_NOT_FOUND) { 923if( errorCode == Win32Native.ERROR_FILENAME_EXCED_RANGE) { 927throw new ArgumentException(Win32Native.GetMessage(errorCode)); 1016IntPtr r = Win32Native.SendMessageTimeout(new IntPtr(Win32Native.HWND_BROADCAST), Win32Native.WM_SETTINGCHANGE, IntPtr.Zero, "Environment", 0, 1000, IntPtr.Zero); 1037int drives = Win32Native.GetLogicalDrives(); 1126Microsoft.Win32.Win32Native.OSVERSIONINFO osvi = new Microsoft.Win32.Win32Native.OSVERSIONINFO(); 1131Microsoft.Win32.Win32Native.OSVERSIONINFOEX osviEx = new Microsoft.Win32.Win32Native.OSVERSIONINFOEX(); 1216internal static extern bool GetVersion(Microsoft.Win32.Win32Native.OSVERSIONINFO osVer); 1221internal static extern bool GetVersionEx(Microsoft.Win32.Win32Native.OSVERSIONINFOEX osVer); 1365return Win32Native.DoesWin32MethodExist(Win32Native.KERNEL32, "IsWow64Process") 1366&& Win32Native.IsWow64Process(Win32Native.GetCurrentProcess(), out isWow64) 1399if (Win32Native.GetUserName(sb, ref size)) 1422IntPtr hwinsta = Win32Native.GetProcessWindowStation(); 1425Win32Native.USEROBJECTFLAGS flags = new Win32Native.USEROBJECTFLAGS(); 1426if (Win32Native.GetUserObjectInformation(hwinsta, Win32Native.UOI_FLAGS, flags, Marshal.SizeOf(flags),ref lengthNeeded)) { 1427if ((flags.dwFlags & Win32Native.WSF_VISIBLE) == 0) { 1506int hresult = Win32Native.SHGetFolderPath(IntPtr.Zero, /* hwndOwner: [in] Reserved */ 1509Win32Native.SHGFP_TYPE_CURRENT, /* dwFlags: [in] retrieve current path */ 1571byte ret = Win32Native.GetUserNameEx(Win32Native.NameSamCompatible, domainName, ref domainNameLen); 1581bool success = Win32Native.LookupAccountName(null, UserName, sid, ref sidLen, domainName, ref domainNameLen, out peUse); 1584throw new InvalidOperationException(Win32Native.GetMessage(errorCode)); 1593Create = Win32Native.CSIDL_FLAG_CREATE, 1594DoNotVerify = Win32Native.CSIDL_FLAG_DONT_VERIFY, 1613ApplicationData = Win32Native.CSIDL_APPDATA, 1618CommonApplicationData = Win32Native.CSIDL_COMMON_APPDATA, 1623LocalApplicationData = Win32Native.CSIDL_LOCAL_APPDATA, 1628Cookies = Win32Native.CSIDL_COOKIES, 1629Desktop = Win32Native.CSIDL_DESKTOP, 1634Favorites = Win32Native.CSIDL_FAVORITES, 1639History = Win32Native.CSIDL_HISTORY, 1644InternetCache = Win32Native.CSIDL_INTERNET_CACHE, 1649Programs = Win32Native.CSIDL_PROGRAMS, 1650MyComputer = Win32Native.CSIDL_DRIVES, 1651MyMusic = Win32Native.CSIDL_MYMUSIC, 1652MyPictures = Win32Native.CSIDL_MYPICTURES, 1654MyVideos = Win32Native.CSIDL_MYVIDEO, 1659Recent = Win32Native.CSIDL_RECENT, 1663SendTo = Win32Native.CSIDL_SENDTO, 1667StartMenu = Win32Native.CSIDL_STARTMENU, 1673Startup = Win32Native.CSIDL_STARTUP, 1677System = Win32Native.CSIDL_SYSTEM, 1682Templates = Win32Native.CSIDL_TEMPLATES, 1688DesktopDirectory = Win32Native.CSIDL_DESKTOPDIRECTORY, 1692Personal = Win32Native.CSIDL_PERSONAL, 1696MyDocuments = Win32Native.CSIDL_PERSONAL, 1700ProgramFiles = Win32Native.CSIDL_PROGRAM_FILES, 1704CommonProgramFiles = Win32Native.CSIDL_PROGRAM_FILES_COMMON, 1709AdminTools = Win32Native.CSIDL_ADMINTOOLS, 1713CDBurning = Win32Native.CSIDL_CDBURN_AREA, 1717CommonAdminTools = Win32Native.CSIDL_COMMON_ADMINTOOLS, 1721CommonDocuments = Win32Native.CSIDL_COMMON_DOCUMENTS, 1725CommonMusic = Win32Native.CSIDL_COMMON_MUSIC, 1729CommonOemLinks = Win32Native.CSIDL_COMMON_OEM_LINKS, 1733CommonPictures = Win32Native.CSIDL_COMMON_PICTURES, 1737CommonStartMenu = Win32Native.CSIDL_COMMON_STARTMENU, 1741CommonPrograms = Win32Native.CSIDL_COMMON_PROGRAMS, 1745CommonStartup = Win32Native.CSIDL_COMMON_STARTUP, 1749CommonDesktopDirectory = Win32Native.CSIDL_COMMON_DESKTOPDIRECTORY, 1753CommonTemplates = Win32Native.CSIDL_COMMON_TEMPLATES, 1757CommonVideos = Win32Native.CSIDL_COMMON_VIDEO, 1761Fonts = Win32Native.CSIDL_FONTS, 1765NetworkShortcuts = Win32Native.CSIDL_NETHOOD, 1769PrinterShortcuts = Win32Native.CSIDL_PRINTHOOD, 1773UserProfile = Win32Native.CSIDL_PROFILE, 1777CommonProgramFilesX86 = Win32Native.CSIDL_PROGRAM_FILES_COMMONX86, 1781ProgramFilesX86 = Win32Native.CSIDL_PROGRAM_FILESX86, 1785Resources = Win32Native.CSIDL_RESOURCES, 1789LocalizedResources = Win32Native.CSIDL_RESOURCES_LOCALIZED, 1793SystemX86 = Win32Native.CSIDL_SYSTEMX86, 1797Windows = Win32Native.CSIDL_WINDOWS,
system\globalization\compareinfo.cs (10)
603GetNativeCompareFlags(options) | Win32Native.FIND_STARTSWITH | ((source.IsAscii() && prefix.IsAscii()) ? RESERVED_FIND_ASCII_STRING : 0), 654GetNativeCompareFlags(options) | Win32Native.FIND_ENDSWITH | ((source.IsAscii() && suffix.IsAscii()) ? RESERVED_FIND_ASCII_STRING : 0), 800GetNativeCompareFlags(options) | Win32Native.FIND_FROMSTART | ((source.IsAscii() && (value <= '\x007f')) ? RESERVED_FIND_ASCII_STRING : 0), 853GetNativeCompareFlags(options) | Win32Native.FIND_FROMSTART | ((source.IsAscii() && value.IsAscii()) ? RESERVED_FIND_ASCII_STRING : 0), 1001GetNativeCompareFlags(options) | Win32Native.FIND_FROMEND | ((source.IsAscii() && (value <= '\x007f')) ? RESERVED_FIND_ASCII_STRING : 0), 1056GetNativeCompareFlags(options) | Win32Native.FIND_FROMEND | ((source.IsAscii() && value.IsAscii()) ? RESERVED_FIND_ASCII_STRING : 0), 1327Win32Native.NlsVersionInfoEx v = new Win32Native.NlsVersionInfoEx(); 1328v.dwNLSVersionInfoSize = Marshal.SizeOf(typeof(Win32Native.NlsVersionInfoEx)); 1342private static extern bool InternalGetNlsVersionEx(IntPtr handle, IntPtr handleOrigin, String localeName, ref Win32Native.NlsVersionInfoEx lpNlsVersionInformation);
system\globalization\textinfo.cs (2)
288if (TryFastFindStringOrdinalIgnoreCase(Microsoft.Win32.Win32Native.FIND_FROMSTART, source, startIndex, value, count, ref ret)) 334if (TryFastFindStringOrdinalIgnoreCase(Microsoft.Win32.Win32Native.FIND_FROMEND, source, startIndex, value, count, ref ret))
system\guid.cs (1)
1152Marshal.ThrowExceptionForHR(Win32Native.CoCreateGuid(out guid), new IntPtr(-1));
system\io\__consolestream.cs (18)
57_isPipe = Win32Native.GetFileType(handle) == Win32Native.FILE_TYPE_PIPE; 136if (Win32Native.ERROR_SUCCESS != errCode) 162if (Win32Native.ERROR_SUCCESS != errCode) 188return Win32Native.ERROR_SUCCESS; 205readSuccess = (0 != Win32Native.ReadFile(hFile, p + offset, count, out bytesRead, IntPtr.Zero)); 213readSuccess = Win32Native.ReadConsoleW(hFile, p + offset, count / BytesPerWChar, out charsRead, IntPtr.Zero); 221return Win32Native.ERROR_SUCCESS; 228if (errorCode == Win32Native.ERROR_NO_DATA || errorCode == Win32Native.ERROR_BROKEN_PIPE) 229return Win32Native.ERROR_SUCCESS; 245return Win32Native.ERROR_SUCCESS; 255writeSuccess = (0 != Win32Native.WriteFile(hFile, p + offset, count, out numBytesWritten, IntPtr.Zero)); 268writeSuccess = Win32Native.WriteConsoleW(hFile, p + offset, count / BytesPerWChar, out charsWritten, IntPtr.Zero); 275return Win32Native.ERROR_SUCCESS; 282if (errorCode == Win32Native.ERROR_NO_DATA || errorCode == Win32Native.ERROR_BROKEN_PIPE) 283return Win32Native.ERROR_SUCCESS;
system\io\__error.cs (27)
22using Win32Native = Microsoft.Win32.Win32Native; 137bool isInvalidPath = errorCode == Win32Native.ERROR_INVALID_NAME || errorCode == Win32Native.ERROR_BAD_PATHNAME; 141case Win32Native.ERROR_FILE_NOT_FOUND: 147case Win32Native.ERROR_PATH_NOT_FOUND: 153case Win32Native.ERROR_ACCESS_DENIED: 159case Win32Native.ERROR_ALREADY_EXISTS: 162throw new IOException(Environment.GetResourceString("IO.IO_AlreadyExists_Name", str), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); 164case Win32Native.ERROR_FILENAME_EXCED_RANGE: 167case Win32Native.ERROR_INVALID_DRIVE: 170case Win32Native.ERROR_INVALID_PARAMETER: 171throw new IOException(Win32Native.GetMessage(errorCode), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); 173case Win32Native.ERROR_SHARING_VIOLATION: 175throw new IOException(Environment.GetResourceString("IO.IO_SharingViolation_NoFileName"), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); 177throw new IOException(Environment.GetResourceString("IO.IO_SharingViolation_File", str), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); 179case Win32Native.ERROR_FILE_EXISTS: 182throw new IOException(Environment.GetResourceString("IO.IO_FileExists_Name", str), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); 184case Win32Native.ERROR_OPERATION_ABORTED: 188throw new IOException(Win32Native.GetMessage(errorCode), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); 203case Win32Native.ERROR_PATH_NOT_FOUND: 204case Win32Native.ERROR_INVALID_DRIVE: 222internal const int ERROR_FILE_NOT_FOUND = Win32Native.ERROR_FILE_NOT_FOUND; 223internal const int ERROR_PATH_NOT_FOUND = Win32Native.ERROR_PATH_NOT_FOUND; 224internal const int ERROR_ACCESS_DENIED = Win32Native.ERROR_ACCESS_DENIED; 225internal const int ERROR_INVALID_PARAMETER = Win32Native.ERROR_INVALID_PARAMETER;
system\io\directory.cs (60)
305Win32Native.SECURITY_ATTRIBUTES secAttrs = null; 308secAttrs = new Win32Native.SECURITY_ATTRIBUTES(); 329r = Win32Native.CreateDirectory(name, secAttrs); 340if (currentError != Win32Native.ERROR_ALREADY_EXISTS) 345if (File.InternalExists(name) || (!InternalExists(name, out currentError) && currentError == Win32Native.ERROR_ACCESS_DENIED)) 366__Error.WinIOError(Win32Native.ERROR_PATH_NOT_FOUND, InternalGetDirectoryRoot(path)); 434int lastError = Win32Native.ERROR_SUCCESS; 444Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 448&& ((data.fileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY) != 0); 464Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(creationTimeUtc.ToFileTimeUtc()); 465bool r = Win32Native.SetFileTime(handle, &fileTime, null, null); 501Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(lastWriteTimeUtc.ToFileTimeUtc()); 502bool r = Win32Native.SetFileTime(handle, null, null, &fileTime); 538Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(lastAccessTimeUtc.ToFileTimeUtc()); 539bool r = Win32Native.SetFileTime(handle, null, &fileTime, null); 1022int drives = Win32Native.GetLogicalDrives(); 1109if (Win32Native.GetCurrentDirectory(sb.Capacity, sb) == 0) 1117int r = Win32Native.GetLongPathName(currentDirectory, sb, sb.Capacity); 1122errorCode = Win32Native.ERROR_FILENAME_EXCED_RANGE; 1123if (errorCode != Win32Native.ERROR_FILE_NOT_FOUND && 1124errorCode != Win32Native.ERROR_PATH_NOT_FOUND && 1125errorCode != Win32Native.ERROR_INVALID_FUNCTION && // by design - enough said. 1126errorCode != Win32Native.ERROR_ACCESS_DENIED) 1143while ((result = Win32Native.GetCurrentDirectoryW(buffer.CharCapacity, buffer.GetHandle())) > buffer.CharCapacity) 1191if (!Win32Native.SetCurrentDirectory(fulldestDirName)) { 1196if (errorCode == Win32Native.ERROR_FILE_NOT_FOUND) 1197errorCode = Win32Native.ERROR_PATH_NOT_FOUND; 1263if (!Win32Native.MoveFile(sourceDirName, destDirName)) 1266if (hr == Win32Native.ERROR_FILE_NOT_FOUND) // Source dir not found 1268hr = Win32Native.ERROR_PATH_NOT_FOUND; 1272if (hr == Win32Native.ERROR_ACCESS_DENIED) // WinNT throws IOException. This check is for Win9x. We can't change it for backcomp. 1273throw new IOException(Environment.GetResourceString("UnauthorizedAccess_IODenied_Path", sourceDirName), Win32Native.MakeHRFromErrorCode(hr)); 1333Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 1337if (dataInitialised == Win32Native.ERROR_FILE_NOT_FOUND) 1338dataInitialised = Win32Native.ERROR_PATH_NOT_FOUND; 1345Win32Native.WIN32_FIND_DATA findData = new Win32Native.WIN32_FIND_DATA(); 1355private static void DeleteHelper(String fullPath, String userPath, bool recursive, bool throwOnTopLevelDirectoryNotFound, ref Win32Native.WIN32_FIND_DATA data) 1372using (SafeFindHandle hnd = Win32Native.FindFirstFile(fullPath + Path.DirectorySeparatorCharAsString + "*", ref data)) { 1379bool isDir = (0!=(data.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY)); 1408if (data.dwReserved0 == Win32Native.IO_REPARSE_TAG_MOUNT_POINT) { 1411r = Win32Native.DeleteVolumeMountPoint(mountPoint); 1414if (hr != Win32Native.ERROR_PATH_NOT_FOUND) { 1430r = Win32Native.RemoveDirectory(reparsePoint); 1433if (hr != Win32Native.ERROR_PATH_NOT_FOUND) { 1448r = Win32Native.DeleteFile(Path.CombineNoChecks(fullPath, fileName)); 1451if (hr != Win32Native.ERROR_FILE_NOT_FOUND) { 1463} while (Win32Native.FindNextFile(hnd, ref data)); 1471if (hr!=0 && hr!=Win32Native.ERROR_NO_MORE_FILES) 1475r = Win32Native.RemoveDirectory(fullPath); 1479if (hr == Win32Native.ERROR_FILE_NOT_FOUND) // A dubious error code. 1480hr = Win32Native.ERROR_PATH_NOT_FOUND; 1482if (hr == Win32Native.ERROR_ACCESS_DENIED) 1487if (hr == Win32Native.ERROR_PATH_NOT_FOUND && !throwOnTopLevelDirectoryNotFound) 1508SafeFileHandle handle = Win32Native.SafeCreateFile (
system\io\directoryinfo.cs (5)
296return _data.fileAttributes != -1 && (_data.fileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY) != 0; 677if (!Win32Native.MoveFile(FullPath, destDirName)) 680if (hr == Win32Native.ERROR_FILE_NOT_FOUND) // A dubious error code 682hr = Win32Native.ERROR_PATH_NOT_FOUND; 686if (hr == Win32Native.ERROR_ACCESS_DENIED) // We did this for Win9x. We can't change it for backcomp.
system\io\driveinfo.cs (28)
109return (DriveType) Win32Native.GetDriveType(Name); 124int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); 126bool r = Win32Native.GetVolumeInformation(Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileSystemNameLen); 133Win32Native.SetErrorMode(oldMode); 154int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); 156bool r = Win32Native.GetDiskFreeSpaceEx(Name, out userBytes, out totalBytes, out freeBytes); 161Win32Native.SetErrorMode(oldMode); 173int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); 175bool r = Win32Native.GetDiskFreeSpaceEx(Name, out userBytes, out totalBytes, out freeBytes); 180Win32Native.SetErrorMode(oldMode); 194int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); 196bool r = Win32Native.GetDiskFreeSpaceEx(Name, out userBytes, out totalBytes, out freeBytes); 201Win32Native.SetErrorMode(oldMode); 241int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); 243bool r = Win32Native.GetVolumeInformation(Name, volumeName, volNameLen, out serialNumber, out maxFileNameLen, out fileSystemFlags, fileSystemName, fileSystemNameLen); 248if (errorCode == Win32Native.ERROR_INVALID_DATA) 249errorCode = Win32Native.ERROR_INVALID_DRIVE; 254Win32Native.SetErrorMode(oldMode); 265int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); 267bool r = Win32Native.SetVolumeLabel(Name, value); 271if (errorCode == Win32Native.ERROR_ACCESS_DENIED) 277Win32Native.SetErrorMode(oldMode);
system\io\file.cs (55)
22using Win32Native = Microsoft.Win32.Win32Native; 168bool r = Win32Native.CopyFile(fullSourceFileName, fullDestFileName, !overwrite); 174if (errorCode != Win32Native.ERROR_FILE_EXISTS) { 178using(SafeFileHandle handle = Win32Native.UnsafeCreateFile(fullSourceFileName, FileStream.GENERIC_READ, FileShare.Read, null, FileMode.Open, 0, IntPtr.Zero)) { 183if (errorCode == Win32Native.ERROR_ACCESS_DENIED) { 185throw new IOException(Environment.GetResourceString("Arg_FileIsDirectory_Name", destFileName), Win32Native.ERROR_ACCESS_DENIED, fullDestFileName); 303bool r = Win32Native.DeleteFile(fullPath); 306if (hr==Win32Native.ERROR_FILE_NOT_FOUND) 330bool r = Win32Native.DecryptFile(fullPath, 0); 333if (errorCode == Win32Native.ERROR_ACCESS_DENIED) { 361bool r = Win32Native.EncryptFile(fullPath); 364if (errorCode == Win32Native.ERROR_ACCESS_DENIED) { 458Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 462&& ((data.fileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY) == 0); 497Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(creationTimeUtc.ToFileTimeUtc()); 498bool r = Win32Native.SetFileTime(handle, &fileTime, null, null); 539Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 561Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(lastAccessTimeUtc.ToFileTimeUtc()); 562bool r = Win32Native.SetFileTime(handle, null, &fileTime, null); 603Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 625Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(lastWriteTimeUtc.ToFileTimeUtc()); 626bool r = Win32Native.SetFileTime(handle, null, null, &fileTime); 667Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 688Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 709bool r = Win32Native.SetFileAttributes(fullPath, (int) fileAttributes); 1263__Error.WinIOError(Win32Native.ERROR_FILE_NOT_FOUND, fullSourceFileName); 1265if (!Win32Native.MoveFile(fullSourceFileName, fullDestFileName)) 1341int flags = Win32Native.REPLACEFILE_WRITE_THROUGH; 1343flags |= Win32Native.REPLACEFILE_IGNORE_MERGE_ERRORS; 1345bool r = Win32Native.ReplaceFile(fullDestPath, fullSrcPath, fullBackupPath, flags, IntPtr.Zero, IntPtr.Zero); 1356internal static int FillAttributeInfo(String path, ref Win32Native.WIN32_FILE_ATTRIBUTE_DATA data, bool tryagain, bool returnErrorOnNotFound) 1361Win32Native.WIN32_FIND_DATA findData; 1362findData = new Win32Native.WIN32_FIND_DATA (); 1371int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); 1374SafeFindHandle handle = Win32Native.FindFirstFile(tempPath, ref findData); 1380if (dataInitialised == Win32Native.ERROR_FILE_NOT_FOUND || 1381dataInitialised == Win32Native.ERROR_PATH_NOT_FOUND || 1382dataInitialised == Win32Native.ERROR_NOT_READY) // floppy device not ready 1408Win32Native.SetErrorMode(oldMode); 1422int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); 1424success = Win32Native.GetFileAttributesEx(path, GetFileExInfoStandard, ref data); 1427Win32Native.SetErrorMode(oldMode); 1432if (dataInitialised != Win32Native.ERROR_FILE_NOT_FOUND && 1433dataInitialised != Win32Native.ERROR_PATH_NOT_FOUND && 1434dataInitialised != Win32Native.ERROR_NOT_READY) // floppy device not ready
system\io\fileinfo.cs (7)
25using Win32Native = Microsoft.Win32.Win32Native; 174if ((_data.fileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY) != 0) 175__Error.WinIOError(Win32Native.ERROR_FILE_NOT_FOUND, DisplayPath); 347bool r = Win32Native.DeleteFile(FullPath); 350if (hr==Win32Native.ERROR_FILE_NOT_FOUND) 390return (_data.fileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY) == 0; 475if (!Win32Native.MoveFile(FullPath, fullDestFileName))
system\io\filestream.cs (46)
381bool r = Win32Native.CancelIoEx(_handle, _overlapped); 388if (errorCode != Win32Native.ERROR_NOT_FOUND) 567Win32Native.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(share, fileSecurity, out pinningHandle); 584Win32Native.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(share); 594Win32Native.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(share); 603Win32Native.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(share); 612Win32Native.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(share); 620private void Init(String path, FileMode mode, FileAccess access, int rights, bool useRights, FileShare share, int bufferSize, FileOptions options, Win32Native.SECURITY_ATTRIBUTES secAttrs, String msgPath, bool bFromProxy, bool useLongPath, bool checkHost) 837flagsAndAttributes|= (Win32Native.SECURITY_SQOS_PRESENT | Win32Native.SECURITY_ANONYMOUS); 840int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); 845_handle = Win32Native.SafeCreateFile(tempPath, fAccess, share, secAttrs, mode, flagsAndAttributes, IntPtr.Zero); 886Win32Native.SetErrorMode(oldMode); 893int fileType = Win32Native.GetFileType(_handle); 894if (fileType != Win32Native.FILE_TYPE_DISK) { 1024int handleType = Win32Native.GetFileType(_handle); 1025Contract.Assert(handleType == Win32Native.FILE_TYPE_DISK || handleType == Win32Native.FILE_TYPE_PIPE || handleType == Win32Native.FILE_TYPE_CHAR, "FileStream was passed an unknown file type!"); 1029_canSeek = handleType == Win32Native.FILE_TYPE_DISK; 1035_isPipe = handleType == Win32Native.FILE_TYPE_PIPE; 1063if (handleType != Win32Native.FILE_TYPE_PIPE) 1079private static Win32Native.SECURITY_ATTRIBUTES GetSecAttrs(FileShare share) 1081Win32Native.SECURITY_ATTRIBUTES secAttrs = null; 1083secAttrs = new Win32Native.SECURITY_ATTRIBUTES(); 1095private unsafe static Win32Native.SECURITY_ATTRIBUTES GetSecAttrs(FileShare share, FileSecurity fileSecurity, out Object pinningHandle) 1098Win32Native.SECURITY_ATTRIBUTES secAttrs = null; 1100secAttrs = new Win32Native.SECURITY_ATTRIBUTES(); 1150if (hr == Win32Native.ERROR_INVALID_HANDLE) 1181lo = Win32Native.GetFileSize(_handle, out hi); 1350if (!Win32Native.FlushFileBuffers(_handle)) 1481if (!Win32Native.SetEndOfFile(_handle)) { 1696ret = Win32Native.SetFilePointer(_handle, offset, origin, out hr); 1716if (hr == Win32Native.ERROR_INVALID_HANDLE) 2444if (!Win32Native.LockFile(_handle, positionLow, positionHigh, lengthLow, lengthHigh)) 2460if (!Win32Native.UnlockFile(_handle, positionLow, positionHigh, lengthLow, lengthHigh)) 2511r = Win32Native.ReadFile(handle, p + offset, count, IntPtr.Zero, overlapped); 2513r = Win32Native.ReadFile(handle, p + offset, count, out numBytesRead, IntPtr.Zero); 2522if (hr == ERROR_BROKEN_PIPE || hr == Win32Native.ERROR_PIPE_NOT_CONNECTED) { 2531if (hr == Win32Native.ERROR_INVALID_HANDLE) 2568r = Win32Native.WriteFile(handle, p + offset, count, IntPtr.Zero, overlapped); 2570r = Win32Native.WriteFile(handle, p + offset, count, out numBytesWritten, IntPtr.Zero); 2588if (hr == Win32Native.ERROR_INVALID_HANDLE) 2770if (asyncResult.ErrorCode == Win32Native.ERROR_OPERATION_ABORTED) 2806if (asyncResult.ErrorCode == Win32Native.ERROR_OPERATION_ABORTED)
system\io\filesystemenumerable.cs (36)
201oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); 270Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA(); 273_hnd = Win32Native.FindFirstFile(searchPath, ref data); 278if (hr != Win32Native.ERROR_FILE_NOT_FOUND && hr != Win32Native.ERROR_NO_MORE_FILES) 376Win32Native.SetErrorMode(oldMode); 384Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA(); 429_hnd = Win32Native.FindFirstFile(searchPath, ref data); 433if (hr == Win32Native.ERROR_FILE_NOT_FOUND || hr == Win32Native.ERROR_NO_MORE_FILES || hr == Win32Native.ERROR_PATH_NOT_FOUND) 466while (Win32Native.FindNextFile(_hnd, ref data)) 489if ((hr != 0) && (hr != Win32Native.ERROR_NO_MORE_FILES) 490&& (hr != Win32Native.ERROR_FILE_NOT_FOUND)) 529Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA(); 533hnd = Win32Native.FindFirstFile(searchPath, ref data); 542if (hr == Win32Native.ERROR_FILE_NOT_FOUND || hr == Win32Native.ERROR_NO_MORE_FILES || hr == Win32Native.ERROR_PATH_NOT_FOUND) 570} while (Win32Native.FindNextFile(hnd, ref data)); 654internal abstract bool IsResultIncluded(ref Win32Native.WIN32_FIND_DATA findData); 657internal abstract TSource CreateObject(Directory.SearchData searchData, ref Win32Native.WIN32_FIND_DATA findData); 672internal override bool IsResultIncluded(ref Win32Native.WIN32_FIND_DATA findData) 676internal override string CreateObject(Directory.SearchData searchData, ref Win32Native.WIN32_FIND_DATA findData) 683internal override bool IsResultIncluded(ref Win32Native.WIN32_FIND_DATA findData) => findData.IsFile; 686internal override FileInfo CreateObject(Directory.SearchData searchData, ref Win32Native.WIN32_FIND_DATA findData) 692internal static FileInfo CreateFileInfo(Directory.SearchData searchData, ref Win32Native.WIN32_FIND_DATA findData) 712internal override bool IsResultIncluded(ref Win32Native.WIN32_FIND_DATA findData) => findData.IsNormalDirectory; 715internal override DirectoryInfo CreateObject(Directory.SearchData searchData, ref Win32Native.WIN32_FIND_DATA findData) 721internal static DirectoryInfo CreateDirectoryInfo(Directory.SearchData searchData, ref Win32Native.WIN32_FIND_DATA findData) 741internal override bool IsResultIncluded(ref Win32Native.WIN32_FIND_DATA findData) => findData.IsFile || findData.IsNormalDirectory; 744internal override FileSystemInfo CreateObject(Directory.SearchData searchData, ref Win32Native.WIN32_FIND_DATA findData)
system\io\filesysteminfo.cs (8)
45internal Win32Native.WIN32_FILE_ATTRIBUTE_DATA _data; // Cache the file information 86internal void InitializeFrom(ref Win32Native.WIN32_FIND_DATA findData) 88_data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 175_data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 219_data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 262_data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 300_data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 314bool r = Win32Native.SetFileAttributes(FullPath, (int) value);
system\io\isolatedstorage\isolatedstoragefile.cs (7)
2460Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA(); 2463SafeFindHandle hnd = Win32Native.FindFirstFile(Path.AddLongPathPrefix(fullPath), ref data); 2467if (hr==Win32Native.ERROR_FILE_NOT_FOUND) 2491} while (Win32Native.FindNextFile(hnd, ref data)); 2496if (hr!=0 && hr!=Win32Native.ERROR_NO_MORE_FILES) 2502if (!file && numEntries==1 && (0!=(data.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY))) {
system\io\isolatedstorage\isolatedstoragefilestream.cs (1)
397return Win32Native.INVALID_HANDLE_VALUE;
system\io\longpath.cs (54)
20using Win32Native = Microsoft.Win32.Win32Native; 216bool r = Win32Native.CopyFile(fullSourceFileName, fullDestFileName, !overwrite); 222if (errorCode != Win32Native.ERROR_FILE_EXISTS) { 226using(SafeFileHandle handle = Win32Native.UnsafeCreateFile(fullSourceFileName, FileStream.GENERIC_READ, FileShare.Read, null, FileMode.Open, 0, IntPtr.Zero)) { 231if (errorCode == Win32Native.ERROR_ACCESS_DENIED) { 233throw new IOException(Environment.GetResourceString("Arg_FileIsDirectory_Name", destFileName), Win32Native.ERROR_ACCESS_DENIED, fullDestFileName); 264bool r = Win32Native.DeleteFile(tempPath); 267if (hr==Win32Native.ERROR_FILE_NOT_FOUND) 333Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 353Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 373Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 405__Error.WinIOError(Win32Native.ERROR_FILE_NOT_FOUND, fullSourceFileName); 410if (!Win32Native.MoveFile(tempSourceFileName, tempDestFileName)) 426Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 431if ((data.fileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY) != 0) 432__Error.WinIOError(Win32Native.ERROR_FILE_NOT_FOUND, path); 539Win32Native.SECURITY_ATTRIBUTES secAttrs = null; 542secAttrs = new Win32Native.SECURITY_ATTRIBUTES(); 565r = Win32Native.CreateDirectory(PathInternal.EnsureExtendedPrefix(name), secAttrs); 577if (currentError != Win32Native.ERROR_ALREADY_EXISTS) 582if (LongPathFile.InternalExists(name) || (!InternalExists(name, out currentError) && currentError == Win32Native.ERROR_ACCESS_DENIED)) 605__Error.WinIOError(Win32Native.ERROR_PATH_NOT_FOUND, InternalGetDirectoryRoot(path)); 655if (!Win32Native.MoveFile(tempSourceDirName, tempDestDirName)) 658if (hr == Win32Native.ERROR_FILE_NOT_FOUND) // Source dir not found 660hr = Win32Native.ERROR_PATH_NOT_FOUND; 664if (hr == Win32Native.ERROR_ACCESS_DENIED) // WinNT throws IOException. This check is for Win9x. We can't change it for backcomp. 665throw new IOException(Environment.GetResourceString("UnauthorizedAccess_IODenied_Path", sourceDirName), Win32Native.MakeHRFromErrorCode(hr)); 699Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA(); 704if (dataInitialised == Win32Native.ERROR_FILE_NOT_FOUND) 705dataInitialised = Win32Native.ERROR_PATH_NOT_FOUND; 738Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA(); 751using (SafeFindHandle hnd = Win32Native.FindFirstFile(searchPath, ref data)) 761bool isDir = (0 != (data.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY)); 793if (data.dwReserved0 == Win32Native.IO_REPARSE_TAG_MOUNT_POINT) 797r = Win32Native.DeleteVolumeMountPoint(mountPoint); 801if (hr != Win32Native.ERROR_PATH_NOT_FOUND) 821r = Win32Native.RemoveDirectory(reparsePoint); 825if (hr != Win32Native.ERROR_PATH_NOT_FOUND) 845r = Win32Native.DeleteFile(fileName); 849if (hr != Win32Native.ERROR_FILE_NOT_FOUND) 865} while (Win32Native.FindNextFile(hnd, ref data)); 873if (hr != 0 && hr != Win32Native.ERROR_NO_MORE_FILES) 877r = Win32Native.RemoveDirectory(fullPath); 882if (hr == Win32Native.ERROR_FILE_NOT_FOUND) // A dubious error code. 883hr = Win32Native.ERROR_PATH_NOT_FOUND; 885if (hr == Win32Native.ERROR_ACCESS_DENIED) 890if (hr == Win32Native.ERROR_PATH_NOT_FOUND && !throwOnTopLevelDirectoryNotFound) 937int lastError = Win32Native.ERROR_SUCCESS;
system\io\path.cs (4)
20using Win32Native = Microsoft.Win32.Win32Native; 915errorCode = Win32Native.ERROR_BAD_PATHNAME; 1066uint r = Win32Native.GetTempPath(MAX_PATH, sb); 1152uint r = Win32Native.GetTempFileName(path, "tmp", 0, sb);
system\io\pathhelper.cs (10)
158int result = Win32Native.GetFullPathName(m_arrayPtr, Path.MaxPath + 1, finalBuffer, IntPtr.Zero); 166result = Win32Native.GetFullPathName(m_arrayPtr, result, finalBuffer, IntPtr.Zero); 196int result = Win32Native.GetFullPathName(m_sb.ToString(), m_capacity + 1, finalBuffer, IntPtr.Zero); 203result = Win32Native.GetFullPathName(m_sb.ToString(), result, finalBuffer, IntPtr.Zero); 238int r = Win32Native.GetLongPathName(buffer, shortFileNameBuffer, Path.MaxPath); 256if (lastErr == Win32Native.ERROR_FILE_NOT_FOUND || lastErr == Win32Native.ERROR_PATH_NOT_FOUND) 283int r = Win32Native.GetLongPathName(tempName, sb, m_capacity); 295if (Win32Native.ERROR_FILE_NOT_FOUND == lastErr || Win32Native.ERROR_PATH_NOT_FOUND == lastErr)
system\resources\manifestbasedresourcegroveler.cs (2)
568if (hr != Win32Native.MakeHRFromErrorCode(Win32Native.ERROR_ACCESS_DENIED))
system\runtime\interopservices\comexception.cs (1)
53: base(Win32Native.GetMessage(hresult))
system\runtime\interopservices\marshal.cs (39)
32using Win32Native = Microsoft.Win32.Win32Native; 133int nb = Win32Native.lstrlenA(ptr); 419[DllImport(Win32Native.SHIM, EntryPoint="ND_RU1")] 447[DllImport(Win32Native.SHIM, EntryPoint="ND_RI2")] 488[DllImport(Win32Native.SHIM, EntryPoint="ND_RI4"), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] 566[DllImport(Win32Native.SHIM, EntryPoint="ND_RI8"), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] 634[DllImport(Win32Native.SHIM, EntryPoint="ND_WU1")] 673[DllImport(Win32Native.SHIM, EntryPoint="ND_WI2")] 732[DllImport(Win32Native.SHIM, EntryPoint="ND_WI4")] 807[DllImport(Win32Native.SHIM, EntryPoint="ND_WI8")] 1192IntPtr pNewMem = Win32Native.LocalAlloc_NoSafeHandle(LMEM_FIXED, unchecked(numBytes)); 1212if (IntPtr.Zero != Win32Native.LocalFree(hglobal)) { 1222IntPtr pNewMem = Win32Native.LocalReAlloc(pv, cb, LMEM_MOVEABLE); 1249IntPtr hglobal = Win32Native.LocalAlloc_NoSafeHandle(LMEM_FIXED, len); 1280IntPtr hglobal = Win32Native.LocalAlloc_NoSafeHandle(LMEM_FIXED, len); 1856IntPtr pNewMem = Win32Native.CoTaskMemAlloc(new UIntPtr((uint)cb)); 1879IntPtr hglobal = Win32Native.CoTaskMemAlloc(new UIntPtr((uint)nb)); 1918IntPtr hglobal = Win32Native.CoTaskMemAlloc(new UIntPtr((uint)nb)); 1936Win32Native.CoTaskMemFree(ptr); 1943IntPtr pNewMem = Win32Native.CoTaskMemRealloc(pv, new UIntPtr((uint)cb)); 2192Win32Native.SysFreeString(ptr); 2206IntPtr bstr = Win32Native.SysAllocStringLen(s, s.Length); 2216return PtrToStringUni(ptr, (int)Win32Native.SysStringLen(ptr)); 2425[DllImport(Microsoft.Win32.Win32Native.OLE32, PreserveSig = false)] 2431[DllImport(Microsoft.Win32.Win32Native.OLE32, PreserveSig = false)] 2437[DllImport(Microsoft.Win32.Win32Native.OLE32, PreserveSig = false)] 2443[DllImport(Microsoft.Win32.Win32Native.OLE32, PreserveSig = false)] 2449[DllImport(Microsoft.Win32.Win32Native.OLE32, PreserveSig = false)] 2455[DllImport(Microsoft.Win32.Win32Native.OLEAUT32, PreserveSig = false)] 2695Win32Native.ZeroMemory(s, (UIntPtr)(Win32Native.SysStringLen(s) * 2)); 2703Win32Native.ZeroMemory(s, (UIntPtr)(Win32Native.lstrlenA(s))); 2710Win32Native.ZeroMemory(s, (UIntPtr)(Win32Native.lstrlenW(s) * 2)); 2736Win32Native.ZeroMemory(s, (UIntPtr)(Win32Native.lstrlenA(s))); 2742Win32Native.ZeroMemory(s, (UIntPtr)(Win32Native.lstrlenW(s) * 2));
system\runtime\interopservices\registrationservices.cs (1)
1109[DllImport(Win32Native.OLE32,CharSet=CharSet.Auto,PreserveSig=false)]
system\runtime\memoryfailpoint.cs (12)
257void * pMemory = Win32Native.VirtualAlloc(null, numBytes, Win32Native.MEM_COMMIT, Win32Native.PAGE_READWRITE); 259bool r = Win32Native.VirtualFree(pMemory, UIntPtr.Zero, Win32Native.MEM_RELEASE); 323Win32Native.MEMORYSTATUSEX memory = new Win32Native.MEMORYSTATUSEX(); 324r = Win32Native.GlobalMemoryStatusEx(ref memory); 370Win32Native.MEMORY_BASIC_INFORMATION memInfo = new Win32Native.MEMORY_BASIC_INFORMATION(); 374UIntPtr r = Win32Native.VirtualQuery(address, ref memInfo, sizeOfMemInfo); 379if (memInfo.State == Win32Native.MEM_FREE) {
system\runtime\remoting\objref.cs (1)
30using Win32Native = Microsoft.Win32.Win32Native;
system\runtime\versioning\resourceattributes.cs (1)
134safeName.Append(Win32Native.GetCurrentProcessId());
system\security\accesscontrol\eventwaithandlesecurity.cs (3)
141case Win32Native.ERROR_INVALID_NAME: 142case Win32Native.ERROR_INVALID_HANDLE: 143case Win32Native.ERROR_FILE_NOT_FOUND:
system\security\accesscontrol\filesecurity.cs (3)
349case Win32Native.ERROR_INVALID_NAME: 353case Win32Native.ERROR_INVALID_HANDLE: 357case Win32Native.ERROR_FILE_NOT_FOUND:
system\security\accesscontrol\mutexsecurity.cs (3)
141case Win32Native.ERROR_INVALID_NAME: 142case Win32Native.ERROR_INVALID_HANDLE: 143case Win32Native.ERROR_FILE_NOT_FOUND:
system\security\accesscontrol\nativeobjectsecurity.cs (16)
123if ( error != Win32Native.ERROR_SUCCESS ) 134if ( error == Win32Native.ERROR_ACCESS_DENIED ) 138else if ( error == Win32Native.ERROR_INVALID_OWNER ) 142else if ( error == Win32Native.ERROR_INVALID_PRIMARY_GROUP ) 146else if ( error == Win32Native.ERROR_INVALID_PARAMETER ) 150else if ( error == Win32Native.ERROR_INVALID_NAME ) 156else if ( error == Win32Native.ERROR_FILE_NOT_FOUND ) 160else if ( error == Win32Native.ERROR_NO_SECURITY_ON_OBJECT ) 268if ( error != Win32Native.ERROR_SUCCESS ) 279if ( error == Win32Native.ERROR_ACCESS_DENIED ) 283else if ( error == Win32Native.ERROR_INVALID_OWNER ) 287else if ( error == Win32Native.ERROR_INVALID_PRIMARY_GROUP ) 291else if ( error == Win32Native.ERROR_INVALID_NAME ) 297else if ( error == Win32Native.ERROR_INVALID_HANDLE ) 301else if ( error == Win32Native.ERROR_FILE_NOT_FOUND ) 305else if (error == Win32Native.ERROR_NO_SECURITY_ON_OBJECT)
system\security\accesscontrol\privilege.cs (36)
32using Luid = Microsoft.Win32.Win32Native.LUID; 119if ( false == Win32Native.LookupPrivilegeValue( null, privilege, ref luid )) 123if ( error == Win32Native.ERROR_NOT_ENOUGH_MEMORY ) 127else if ( error == Win32Native.ERROR_ACCESS_DENIED ) 131else if ( error == Win32Native.ERROR_NO_SUCH_PRIVILEGE ) 205if ( false == Win32Native.OpenProcessToken( 206Win32Native.GetCurrentProcess(), 245if ( error != Win32Native.ERROR_NO_TOKEN ) 255if ( false == Win32Native.DuplicateTokenEx( 259Win32Native.SECURITY_IMPERSONATION_LEVEL.Impersonation, 303if ( error == Win32Native.ERROR_NOT_ENOUGH_MEMORY ) 307else if ( error == Win32Native.ERROR_ACCESS_DENIED || 308error == Win32Native.ERROR_CANT_OPEN_ANONYMOUS ) 508Win32Native.TOKEN_PRIVILEGE newState = new Win32Native.TOKEN_PRIVILEGE(); 511newState.Privilege.Attributes = enable ? Win32Native.SE_PRIVILEGE_ENABLED : Win32Native.SE_PRIVILEGE_DISABLED; 513Win32Native.TOKEN_PRIVILEGE previousState = new Win32Native.TOKEN_PRIVILEGE(); 520if ( false == Win32Native.AdjustTokenPrivileges( 530else if ( Win32Native.ERROR_NOT_ALL_ASSIGNED == Marshal.GetLastWin32Error()) 532error = Win32Native.ERROR_NOT_ALL_ASSIGNED; 540this.initialState = (( previousState.Privilege.Attributes & Win32Native.SE_PRIVILEGE_ENABLED ) != 0 ); 564if ( error == Win32Native.ERROR_NOT_ALL_ASSIGNED ) 568if ( error == Win32Native.ERROR_NOT_ENOUGH_MEMORY ) 572else if ( error == Win32Native.ERROR_ACCESS_DENIED || 573error == Win32Native.ERROR_CANT_OPEN_ANONYMOUS ) 629Win32Native.TOKEN_PRIVILEGE newState = new Win32Native.TOKEN_PRIVILEGE(); 632newState.Privilege.Attributes = ( this.initialState ? Win32Native.SE_PRIVILEGE_ENABLED : Win32Native.SE_PRIVILEGE_DISABLED ); 634Win32Native.TOKEN_PRIVILEGE previousState = new Win32Native.TOKEN_PRIVILEGE(); 637if ( false == Win32Native.AdjustTokenPrivileges( 659if ( error == Win32Native.ERROR_NOT_ENOUGH_MEMORY ) 663else if ( error == Win32Native.ERROR_ACCESS_DENIED )
system\security\accesscontrol\registrysecurity.cs (13)
34QueryValues = Win32Native.KEY_QUERY_VALUE, // 0x0001 query the values of a registry key 35SetValue = Win32Native.KEY_SET_VALUE, // 0x0002 create, delete, or set a registry value 36CreateSubKey = Win32Native.KEY_CREATE_SUB_KEY, // 0x0004 required to create a subkey of a specific key 37EnumerateSubKeys = Win32Native.KEY_ENUMERATE_SUB_KEYS, // 0x0008 required to enumerate sub keys of a key 38Notify = Win32Native.KEY_NOTIFY, // 0x0010 needed to request change notifications 39CreateLink = Win32Native.KEY_CREATE_LINK, // 0x0020 reserved for system use 47ReadKey = Win32Native.STANDARD_RIGHTS_READ | QueryValues | EnumerateSubKeys | Notify, 48WriteKey = Win32Native.STANDARD_RIGHTS_WRITE | SetValue | CreateSubKey, 53FullControl = 0xF003F | Win32Native.STANDARD_RIGHTS_READ | Win32Native.STANDARD_RIGHTS_WRITE 164case Win32Native.ERROR_FILE_NOT_FOUND: 168case Win32Native.ERROR_INVALID_NAME: 172case Win32Native.ERROR_INVALID_HANDLE:
system\security\accesscontrol\securitydescriptor.cs (12)
238if ( error == Win32Native.ERROR_INVALID_PARAMETER || 239error == Win32Native.ERROR_UNKNOWN_REVISION ) 248else if ( error != Win32Native.ERROR_SUCCESS ) 649if ( TRUE != Win32Native.ConvertStringSdToSd( 657if ( error == Win32Native.ERROR_INVALID_PARAMETER || 658error == Win32Native.ERROR_INVALID_ACL || 659error == Win32Native.ERROR_INVALID_SECURITY_DESCR || 660error == Win32Native.ERROR_UNKNOWN_REVISION ) 666else if ( error == Win32Native.ERROR_NOT_ENOUGH_MEMORY ) 670else if ( error == Win32Native.ERROR_INVALID_SID ) 676else if ( error != Win32Native.ERROR_SUCCESS ) 698Win32Native.LocalFree( byteArray );
system\security\accesscontrol\win32.cs (23)
38if ( TRUE != Win32Native.ConvertSdToStringSd( binaryForm, ( uint )requestedRevision, ( uint )si, out ByteArray, ref ByteArraySize )) 54Win32Native.LocalFree( ByteArray ); 62if ( errorCode == Win32Native.ERROR_NOT_ENOUGH_MEMORY ) 142errorCode = ( int )Win32Native.GetSecurityInfoByName( name, ( uint )resourceType, ( uint )SecurityInfos, out SidOwner, out SidGroup, out Dacl, out Sacl, out ByteArray ); 154errorCode = ( int )Win32Native.GetSecurityInfoByHandle( handle, ( uint )resourceType, ( uint )SecurityInfos, out SidOwner, out SidGroup, out Dacl, out Sacl, out ByteArray ); 163if ( errorCode == Win32Native.ERROR_SUCCESS && IntPtr.Zero.Equals(ByteArray) ) 171else if (errorCode == Win32Native.ERROR_NOT_ALL_ASSIGNED || 172errorCode == Win32Native.ERROR_PRIVILEGE_NOT_HELD) 176else if ( errorCode == Win32Native.ERROR_ACCESS_DENIED || 177errorCode == Win32Native.ERROR_CANT_OPEN_ANONYMOUS ) 182if ( errorCode != Win32Native.ERROR_SUCCESS ) 208uint Length = Win32Native.GetSecurityDescriptorLength( ByteArray ); 214Win32Native.LocalFree( ByteArray ); 218return Win32Native.ERROR_SUCCESS; 222if ( errorCode == Win32Native.ERROR_NOT_ENOUGH_MEMORY ) 320errorCode = ( int )Win32Native.SetSecurityInfoByName( name, ( uint )type, ( uint )securityInformation, OwnerBinary, GroupBinary, DaclBinary, SaclBinary ); 332errorCode = ( int )Win32Native.SetSecurityInfoByHandle( handle, ( uint )type, ( uint )securityInformation, OwnerBinary, GroupBinary, DaclBinary, SaclBinary ); 342if (errorCode == Win32Native.ERROR_NOT_ALL_ASSIGNED || 343errorCode == Win32Native.ERROR_PRIVILEGE_NOT_HELD) 347else if ( errorCode == Win32Native.ERROR_ACCESS_DENIED || 348errorCode == Win32Native.ERROR_CANT_OPEN_ANONYMOUS ) 352else if ( errorCode != Win32Native.ERROR_SUCCESS ) 378if ( errorCode == Win32Native.ERROR_NOT_ENOUGH_MEMORY )
system\security\cryptography\crypto.cs (1)
113Win32Native.GetMessage(hr)) {
system\security\cryptography\cryptoconfig.cs (3)
64uint policyReadStatus = Win32Native.BCryptGetFipsAlgorithmMode(out fipsEnabled); 66bool readPolicy = policyReadStatus == Win32Native.STATUS_SUCCESS || 67policyReadStatus == Win32Native.STATUS_OBJECT_NAME_NOT_FOUND;
system\security\cryptography\utils.cs (11)
268if (error == Win32Native.ERROR_SUCCESS && (rawSecurityDescriptor == null || rawSecurityDescriptor.Length == 0)) 270if (error == Win32Native.ERROR_NOT_ENOUGH_MEMORY) 272if (error == Win32Native.ERROR_ACCESS_DENIED) 274if (error == Win32Native.ERROR_PRIVILEGE_NOT_HELD) 276if (error != Win32Native.ERROR_SUCCESS) 323if (error == Win32Native.ERROR_ACCESS_DENIED || error == Win32Native.ERROR_INVALID_OWNER || error == Win32Native.ERROR_INVALID_PRIMARY_GROUP) 325else if (error == Win32Native.ERROR_PRIVILEGE_NOT_HELD) 327else if (error == Win32Native.ERROR_INVALID_HANDLE) 329else if (error != Win32Native.ERROR_SUCCESS)
system\security\cryptography\x509certificates\x509certificate.cs (4)
684Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME(); 698Win32Native.FILE_TIME fileTime = new Win32Native.FILE_TIME();
system\security\cryptography\x509certificates\x509utils.cs (2)
373internal static extern void _GetDateNotAfter(SafeCertContextHandle safeCertContext, ref Win32Native.FILE_TIME fileTime); 377internal static extern void _GetDateNotBefore(SafeCertContextHandle safeCertContext, ref Win32Native.FILE_TIME fileTime);
system\security\principal\ntaccount.cs (27)
274Win32Native.UNICODE_STRING[] Names = new Win32Native.UNICODE_STRING[ sourceAccounts.Count ]; 316ReturnCode = Win32Native.LsaLookupNames2( LsaHandle, 0, sourceAccounts.Count, Names, ref ReferencedDomainsPtr, ref SidsPtr ); 320ReturnCode = Win32Native.LsaLookupNames( LsaHandle, sourceAccounts.Count, Names, ref ReferencedDomainsPtr, ref SidsPtr ); 328if ( ReturnCode == Win32Native.STATUS_NO_MEMORY || 329ReturnCode == Win32Native.STATUS_INSUFFICIENT_RESOURCES ) 333else if ( ReturnCode == Win32Native.STATUS_ACCESS_DENIED ) 337else if ( ReturnCode == Win32Native.STATUS_NONE_MAPPED || 338ReturnCode == Win32Native.STATUS_SOME_NOT_MAPPED ) 344int win32ErrorCode = Win32Native.LsaNtStatusToWinError(unchecked((int)ReturnCode)); 346if (win32ErrorCode != Win32Native.ERROR_TRUSTED_RELATIONSHIP_FAILURE) 351throw new SystemException(Win32Native.GetMessage(win32ErrorCode)); 360if ( ReturnCode == 0 || ReturnCode == Win32Native.STATUS_SOME_NOT_MAPPED ) 364SidsPtr.Initialize((uint)sourceAccounts.Count, (uint)Marshal.SizeOf(typeof(Win32Native.LSA_TRANSLATED_SID2))); 366Win32Native.LSA_TRANSLATED_SID2[] translatedSids = new Win32Native.LSA_TRANSLATED_SID2[sourceAccounts.Count]; 371Win32Native.LSA_TRANSLATED_SID2 Lts = translatedSids[i]; 396SidsPtr.Initialize((uint)sourceAccounts.Count, (uint)Marshal.SizeOf(typeof(Win32Native.LSA_TRANSLATED_SID))); 398Win32Native.LSA_REFERENCED_DOMAIN_LIST rdl = ReferencedDomainsPtr.Read<Win32Native.LSA_REFERENCED_DOMAIN_LIST>(0); 403Win32Native.LSA_TRUST_INFORMATION ti = ( Win32Native.LSA_TRUST_INFORMATION )Marshal.PtrToStructure( new IntPtr(( long )rdl.Domains + i * Marshal.SizeOf( typeof( Win32Native.LSA_TRUST_INFORMATION ))), typeof( Win32Native.LSA_TRUST_INFORMATION )); 408Win32Native.LSA_TRANSLATED_SID[] translatedSids = new Win32Native.LSA_TRANSLATED_SID[sourceAccounts.Count]; 413Win32Native.LSA_TRANSLATED_SID Lts = translatedSids[i];
system\security\principal\sid.cs (35)
414if ( Error == Win32Native.ERROR_INVALID_SID ) 418else if ( Error == Win32Native.ERROR_NOT_ENOUGH_MEMORY ) 422else if ( Error != Win32Native.ERROR_SUCCESS ) 425throw new SystemException(Win32Native.GetMessage(Error)); 516if ( ErrorCode == Win32Native.ERROR_INSUFFICIENT_BUFFER ) { 519else if ( ErrorCode == Win32Native.ERROR_NON_ACCOUNT_SID ) 524else if ( ErrorCode != Win32Native.ERROR_SUCCESS ) 527throw new SystemException(Win32Native.GetMessage(ErrorCode)); 543if ( Error == Win32Native.ERROR_INVALID_PARAMETER ) 545throw new ArgumentException( Win32Native.GetMessage(Error), "sidType/domainSid" ); 547else if ( Error != Win32Native.ERROR_SUCCESS ) 550throw new SystemException( Win32Native.GetMessage( Error )); 747if ( Error == Win32Native.ERROR_INSUFFICIENT_BUFFER ) 751else if ( Error == Win32Native.ERROR_NON_ACCOUNT_SID ) 755else if ( Error != Win32Native.ERROR_SUCCESS ) 758throw new SystemException(Win32Native.GetMessage(Error)); 973ReturnCode = Win32Native.LsaLookupSids( LsaHandle, sourceSids.Count, SidArrayPtr, ref ReferencedDomainsPtr, ref NamesPtr ); 980if ( ReturnCode == Win32Native.STATUS_NO_MEMORY || 981ReturnCode == Win32Native.STATUS_INSUFFICIENT_RESOURCES ) 985else if ( ReturnCode == Win32Native.STATUS_ACCESS_DENIED ) 989else if ( ReturnCode == Win32Native.STATUS_NONE_MAPPED || 990ReturnCode == Win32Native.STATUS_SOME_NOT_MAPPED ) 996int win32ErrorCode = Win32Native.LsaNtStatusToWinError(unchecked((int)ReturnCode)); 999throw new SystemException(Win32Native.GetMessage(win32ErrorCode)); 1003NamesPtr.Initialize((uint)sourceSids.Count, (uint)Marshal.SizeOf(typeof(Win32Native.LSA_TRANSLATED_NAME))); 1012if ( ReturnCode == 0 || ReturnCode == Win32Native.STATUS_SOME_NOT_MAPPED ) 1018Win32Native.LSA_REFERENCED_DOMAIN_LIST rdl = ReferencedDomainsPtr.Read<Win32Native.LSA_REFERENCED_DOMAIN_LIST>(0); 1023Win32Native.LSA_TRUST_INFORMATION ti = ( Win32Native.LSA_TRUST_INFORMATION )Marshal.PtrToStructure( new IntPtr(( long )rdl.Domains + i * Marshal.SizeOf( typeof( Win32Native.LSA_TRUST_INFORMATION ))), typeof( Win32Native.LSA_TRUST_INFORMATION )); 1027Win32Native.LSA_TRANSLATED_NAME[] translatedNames = new Win32Native.LSA_TRANSLATED_NAME[sourceSids.Count]; 1032Win32Native.LSA_TRANSLATED_NAME Ltn = translatedNames[i];
system\security\principal\win32.cs (26)
55Win32Native.OSVERSIONINFO osvi = new Win32Native.OSVERSIONINFO(); 82Win32Native.OSVERSIONINFOEX osviex = new Win32Native.OSVERSIONINFOEX(); 127Win32Native.LSA_OBJECT_ATTRIBUTES Loa; 129Loa.Length = Marshal.SizeOf( typeof( Win32Native.LSA_OBJECT_ATTRIBUTES )); 136if ( 0 == ( ReturnCode = Win32Native.LsaOpenPolicy( systemName, ref Loa, ( int )rights, out Result ))) 140else if ( ReturnCode == Win32Native.STATUS_ACCESS_DENIED ) 144else if ( ReturnCode == Win32Native.STATUS_INSUFFICIENT_RESOURCES || 145ReturnCode == Win32Native.STATUS_NO_MEMORY ) 151int win32ErrorCode = Win32Native.LsaNtStatusToWinError(unchecked((int) ReturnCode)); 153throw new SystemException(Win32Native.GetMessage(win32ErrorCode)); 216if ( TRUE != Win32Native.ConvertStringSidToSid( stringSid, out ByteArray )) 230Win32Native.LocalFree( ByteArray ); 237return Win32Native.ERROR_SUCCESS; 272if ( FALSE != Win32Native.CreateWellKnownSid(( int )sidType, domainSid == null ? null : domainSid.BinaryForm, resultSid, ref length )) 274return Win32Native.ERROR_SUCCESS; 312return ( Win32Native.IsEqualDomainSid( BinaryForm1, BinaryForm2, out result ) == FALSE ? false : result ); 327referencedDomains.Initialize((uint)Marshal.SizeOf(typeof(Win32Native.LSA_REFERENCED_DOMAIN_LIST))); 328Win32Native.LSA_REFERENCED_DOMAIN_LIST domainList = referencedDomains.Read<Win32Native.LSA_REFERENCED_DOMAIN_LIST>(0); 343Win32Native.LSA_TRUST_INFORMATION* pTrustInformation = (Win32Native.LSA_TRUST_INFORMATION*)domainList.Domains; 387if ( FALSE != Win32Native.GetWindowsAccountDomainSid( BinaryForm, resultSidBinary, ref sidLength )) 391return Win32Native.ERROR_SUCCESS; 421if ( FALSE == Win32Native.IsWellKnownSid( BinaryForm, ( int )type ))
system\security\principal\windowsidentity.cs (130)
176bool result = Win32Native.GetTokenInformation(userToken, (uint) TokenInformationClass.TokenType, 178if (Marshal.GetLastWin32Error() == Win32Native.ERROR_INVALID_HANDLE) 181if (!Win32Native.DuplicateHandle(Win32Native.GetCurrentProcess(), 183Win32Native.GetCurrentProcess(), 187Win32Native.DUPLICATE_SAME_ACCESS)) 188throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error())); 307Win32Native.LUID authId = GetLogonAuthId(m_safeTokenHandle); 308if (authId.LowPart == Win32Native.ANONYMOUS_LOGON_LUID) 313int status = Win32Native.LsaGetLogonSessionData(ref authId, ref pLogonSessionData); 317pLogonSessionData.Initialize((uint)Marshal.SizeOf(typeof(Win32Native.SECURITY_LOGON_SESSION_DATA))); 319Win32Native.SECURITY_LOGON_SESSION_DATA logonSessionData = pLogonSessionData.Read<Win32Native.SECURITY_LOGON_SESSION_DATA>(0); 377new int[] { Win32Native.SECURITY_AUTHENTICATED_USER_RID })) ? 1 : 0; 409if (!Win32Native.DuplicateTokenEx(m_safeTokenHandle, 415throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error())); 420if (!Win32Native.CheckTokenMembership((til != TokenImpersonationLevel.None ? m_safeTokenHandle : token), 423throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error())); 450new int[] { Win32Native.SECURITY_BUILTIN_DOMAIN_RID, (int)WindowsBuiltInRole.Guest })); 466new int[] {Win32Native.SECURITY_LOCAL_SYSTEM_RID}); 478new int[] {Win32Native.SECURITY_ANONYMOUS_LOGON_RID}); 571Win32Native.TOKEN_GROUPS tokenGroups = pGroups.Read<Win32Native.TOKEN_GROUPS>(0); 572Win32Native.SID_AND_ATTRIBUTES[] groupDetails = new Win32Native.SID_AND_ATTRIBUTES[tokenGroups.GroupCount]; 574pGroups.ReadArray((uint)Marshal.OffsetOf(typeof(Win32Native.TOKEN_GROUPS), "Groups").ToInt32(), 579foreach (Win32Native.SID_AND_ATTRIBUTES group in groupDetails) 582uint mask = Win32Native.SE_GROUP_ENABLED | Win32Native.SE_GROUP_LOGON_ID | Win32Native.SE_GROUP_USE_FOR_DENY_ONLY; 583if ((group.Attributes & mask) == Win32Native.SE_GROUP_ENABLED) { 732throw new SecurityException(Win32Native.GetMessage(hr)); 748Environment.FailFast(Win32Native.GetMessage(hr)); 755Environment.FailFast(Win32Native.GetMessage(hr)); 810throw new SecurityException(Win32Native.GetMessage(hr)); 836if ((uint) status == Win32Native.STATUS_ACCESS_DENIED) 839if ((uint) status == Win32Native.STATUS_INSUFFICIENT_RESOURCES || (uint) status == Win32Native.STATUS_NO_MEMORY) 842int win32ErrorCode = Win32Native.LsaNtStatusToWinError(status); 843return new SecurityException(Win32Native.GetMessage(win32ErrorCode)); 852if (safeTokenHandle == null && hr == GetHRForWin32Error(Win32Native.ERROR_NO_TOKEN)) { 867if (!Win32Native.OpenProcessToken(Win32Native.GetCurrentProcess(), desiredAccess, out safeTokenHandle)) 915if (hr == GetHRForWin32Error(Win32Native.ERROR_ACCESS_DENIED)) { 920if (hr == GetHRForWin32Error(Win32Native.ERROR_NO_TOKEN)) { 930private static Win32Native.LUID GetLogonAuthId (SafeAccessTokenHandle safeTokenHandle) { 932Win32Native.TOKEN_STATISTICS statistics = pStatistics.Read<Win32Native.TOKEN_STATISTICS>(0); 941bool result = Win32Native.GetTokenInformation(tokenHandle, 948case Win32Native.ERROR_BAD_LENGTH: 950case Win32Native.ERROR_INSUFFICIENT_BUFFER: 954safeLocalAllocHandle = Win32Native.LocalAlloc(Win32Native.LMEM_FIXED, ptrLength); 959result = Win32Native.GetTokenInformation(tokenHandle, 965throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error())); 967case Win32Native.ERROR_INVALID_HANDLE: 970throw new SecurityException(Win32Native.GetMessage(dwErrorCode)); 987using (SafeLocalAllocHandle pSourceName = Win32Native.LocalAlloc(Win32Native.LPTR, ptrLength)) { 993Win32Native.UNICODE_INTPTR_STRING Name = new Win32Native.UNICODE_INTPTR_STRING(sourceName.Length, 1013status = Win32Native.LsaRegisterLogonProcess(ref Name, ref logonHandle, ref dummy); 1014if (Win32Native.ERROR_ACCESS_DENIED == Win32Native.LsaNtStatusToWinError(status)) { 1016status = Win32Native.LsaConnectUntrusted(ref logonHandle); 1033byte[] arrayPackageName = new byte[Win32Native.MICROSOFT_KERBEROS_NAME.Length + 1]; 1034Encoding.ASCII.GetBytes(Win32Native.MICROSOFT_KERBEROS_NAME, 0, Win32Native.MICROSOFT_KERBEROS_NAME.Length, arrayPackageName, 0); 1038using (SafeLocalAllocHandle pPackageName = Win32Native.LocalAlloc(Win32Native.LMEM_FIXED, ptrLength)) { 1044Win32Native.UNICODE_INTPTR_STRING PackageName = new Win32Native.UNICODE_INTPTR_STRING(Win32Native.MICROSOFT_KERBEROS_NAME.Length, 1047status = Win32Native.LsaLookupAuthenticationPackage(logonHandle, ref PackageName, ref packageId); 1052Win32Native.TOKEN_SOURCE sourceContext = new Win32Native.TOKEN_SOURCE(); 1053if (!Win32Native.AllocateLocallyUniqueId(ref sourceContext.SourceIdentifier)) 1054throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error())); 1059Win32Native.LUID logonId = new Win32Native.LUID(); 1060Win32Native.QUOTA_LIMITS quotas = new Win32Native.QUOTA_LIMITS(); 1072Contract.Assert(Marshal.SizeOf(typeof(Win32Native.KERB_S4U_LOGON)) % IntPtr.Size == 0, "Potential allignment issue setting up S4U logon buffer"); 1073uint logonInfoSize = (uint) (Marshal.SizeOf(typeof(Win32Native.KERB_S4U_LOGON)) + upnBytes.Length); 1074using (SafeLocalAllocHandle logonInfoBuffer = Win32Native.LocalAlloc(Win32Native.LPTR, new UIntPtr(logonInfoSize))) { 1082ulong upnOffset = (ulong)Marshal.SizeOf(typeof(Win32Native.KERB_S4U_LOGON)); 1096Win32Native.KERB_S4U_LOGON logonInfo = new Win32Native.KERB_S4U_LOGON(); 1101logonInfo.ClientUpn = new Win32Native.UNICODE_INTPTR_STRING(upnBytes.Length, 1107status = Win32Native.LsaLogonUser(logonHandle, 1123if (status == Win32Native.STATUS_ACCOUNT_RESTRICTION && subStatus < 0) 1334IntPtr pSidAndAttributes = new IntPtr((long)safeAllocHandle.DangerousGetHandle() + (long)Marshal.OffsetOf(typeof(Win32Native.TOKEN_GROUPS), "Groups")); 1339Win32Native.SID_AND_ATTRIBUTES group = (Win32Native.SID_AND_ATTRIBUTES)Marshal.PtrToStructure(pSidAndAttributes, typeof(Win32Native.SID_AND_ATTRIBUTES)); 1340uint mask = Win32Native.SE_GROUP_ENABLED | Win32Native.SE_GROUP_LOGON_ID | Win32Native.SE_GROUP_USE_FOR_DENY_ONLY; 1342if ((group.Attributes & mask) == Win32Native.SE_GROUP_ENABLED) 1349else if ((group.Attributes & mask) == Win32Native.SE_GROUP_USE_FOR_DENY_ONLY) 1357pSidAndAttributes = new IntPtr((long)pSidAndAttributes + Win32Native.SID_AND_ATTRIBUTES.SizeOf); 1383Win32Native.TOKEN_PRIMARY_GROUP primaryGroup = (Win32Native.TOKEN_PRIMARY_GROUP)Marshal.PtrToStructure(safeAllocHandlePrimaryGroup.DangerousGetHandle(), typeof(Win32Native.TOKEN_PRIMARY_GROUP)); 1392IntPtr pSidAndAttributes = new IntPtr((long)safeAllocHandle.DangerousGetHandle() + (long)Marshal.OffsetOf(typeof(Win32Native.TOKEN_GROUPS), "Groups")); 1395Win32Native.SID_AND_ATTRIBUTES group = (Win32Native.SID_AND_ATTRIBUTES)Marshal.PtrToStructure(pSidAndAttributes, typeof(Win32Native.SID_AND_ATTRIBUTES)); 1396uint mask = Win32Native.SE_GROUP_ENABLED | Win32Native.SE_GROUP_LOGON_ID | Win32Native.SE_GROUP_USE_FOR_DENY_ONLY; 1399if ((group.Attributes & mask) == Win32Native.SE_GROUP_ENABLED) 1410else if ((group.Attributes & mask) == Win32Native.SE_GROUP_USE_FOR_DENY_ONLY) 1420pSidAndAttributes = new IntPtr((long)pSidAndAttributes + Win32Native.SID_AND_ATTRIBUTES.SizeOf); 1445Win32Native.SID_AND_ATTRIBUTES user = (Win32Native.SID_AND_ATTRIBUTES)Marshal.PtrToStructure(safeAllocHandle.DangerousGetHandle(), typeof(Win32Native.SID_AND_ATTRIBUTES)); 1446uint mask = Win32Native.SE_GROUP_USE_FOR_DENY_ONLY; 1454else if ((user.Attributes & mask) == Win32Native.SE_GROUP_USE_FOR_DENY_ONLY) 1479Win32Native.CLAIM_SECURITY_ATTRIBUTES_INFORMATION claimAttributes = (Win32Native.CLAIM_SECURITY_ATTRIBUTES_INFORMATION)Marshal.PtrToStructure(safeAllocHandle.DangerousGetHandle(), typeof(Win32Native.CLAIM_SECURITY_ATTRIBUTES_INFORMATION)); 1489Win32Native.CLAIM_SECURITY_ATTRIBUTE_V1 windowsClaim = (Win32Native.CLAIM_SECURITY_ATTRIBUTE_V1)Marshal.PtrToStructure(pAttribute, typeof(Win32Native.CLAIM_SECURITY_ATTRIBUTE_V1)); 1494case Win32Native.CLAIM_SECURITY_ATTRIBUTE_TYPE_STRING: 1504case Win32Native.CLAIM_SECURITY_ATTRIBUTE_TYPE_INT64: 1515case Win32Native.CLAIM_SECURITY_ATTRIBUTE_TYPE_UINT64: 1525case Win32Native.CLAIM_SECURITY_ATTRIBUTE_TYPE_BOOLEAN:
system\security\principal\windowsimpersonationcontext.cs (10)
48if (!Win32Native.DuplicateHandle(Win32Native.GetCurrentProcess(), 50Win32Native.GetCurrentProcess(), 54Win32Native.DUPLICATE_SAME_ACCESS)) 55throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error())); 70Environment.FailFast(Win32Native.GetMessage(hr)); 74Environment.FailFast(Win32Native.GetMessage(hr)); 77throw new SecurityException(Win32Native.GetMessage(hr)); 103Environment.FailFast(Win32Native.GetMessage(hr)); 114Environment.FailFast(Win32Native.GetMessage(hr));
system\security\principal\windowsprincipal.cs (5)
217new int[] {Win32Native.SECURITY_BUILTIN_DOMAIN_RID, rid}); 241if (!Win32Native.DuplicateTokenEx(m_identity.AccessToken, 247throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error())); 252if (!Win32Native.CheckTokenMembership((m_identity.ImpersonationLevel != TokenImpersonationLevel.None ? m_identity.AccessToken : token), 255throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error()));
system\security\safesecurityhandles.cs (7)
41return Win32Native.CloseHandle(handle); 63return Win32Native.LsaDeregisterLogonProcess(handle) >= 0; 83return Win32Native.LsaFreeMemory(handle) == 0; 103return Win32Native.LsaClose(handle) == 0; 124return Win32Native.LsaFreeReturnBuffer(handle) >= 0; 146return Win32Native.CloseHandle(handle); 164return Win32Native.CloseHandle(handle);
system\security\securestring.cs (27)
27const int BlockSize = (int)Win32Native.CRYPTPROTECTMEMORY_BLOCK_SIZE /2; // a char is two bytes 29const uint ProtectionScope = Win32Native.CRYPTPROTECTMEMORY_SAME_PROCESS; 41Win32Native.SystemFunction041( 42SafeBSTRHandle.Allocate(null , (int)Win32Native.CRYPTPROTECTMEMORY_BLOCK_SIZE), 43Win32Native.CRYPTPROTECTMEMORY_BLOCK_SIZE, 44Win32Native.CRYPTPROTECTMEMORY_SAME_PROCESS); 400return Win32Native.WideCharToMultiByte( 429Win32Native.WideCharToMultiByte( 462int status = Win32Native.SystemFunction040(m_buffer, (uint)m_buffer.Length * 2, ProtectionScope); 467throw new CryptographicException(Win32Native.LsaNtStatusToWinError(status)); 493ptr = Win32Native.SysAllocStringLen(null, length); 514Win32Native.ZeroMemory(ptr, (UIntPtr)(length * 2)); 515Win32Native.SysFreeString(ptr); 571Win32Native.ZeroMemory(ptr, (UIntPtr)(length * 2)); 634Win32Native.ZeroMemory(ptr, (UIntPtr)byteCount); 664int status = Win32Native.SystemFunction041(m_buffer, (uint)m_buffer.Length * 2, ProtectionScope); 670throw new CryptographicException(Win32Native.LsaNtStatusToWinError(status)); 692[DllImport(Win32Native.OLEAUT32, CharSet = CharSet.Unicode)] 699Win32Native.ZeroMemory(handle, (UIntPtr) (Win32Native.SysStringLen(handle) * 2)); 700Win32Native.SysFreeString(handle); 711Win32Native.ZeroMemory((IntPtr)bufferPtr, (UIntPtr) (Win32Native.SysStringLen((IntPtr)bufferPtr) * 2)); 723return (int) Win32Native.SysStringLen(this); 735Contract.Assert(Win32Native.SysStringLen((IntPtr)targetPtr) >= Win32Native.SysStringLen((IntPtr)sourcePtr), "Target buffer is not large enough!"); 737Buffer.Memcpy(targetPtr, sourcePtr, (int) Win32Native.SysStringLen((IntPtr)sourcePtr) * 2);
system\security\securitycontext.cs (2)
679Environment.FailFast(Win32Native.GetMessage(hr)); 688Environment.FailFast(Win32Native.GetMessage(hr));
system\string.cs (1)
1453nb = Win32Native.WideCharToMultiByte(
system\stubhelpers.cs (11)
125Win32Native.CoTaskMemFree(pNative); 184Win32Native.CoTaskMemFree(pNative); 285ptrToFirstChar = (byte *)Win32Native.SysAllocStringByteLen(null, lengthInBytes).ToPointer(); 317uint length = Win32Native.SysStringByteLen(bstr); 358Win32Native.SysFreeString(pNative); 424Win32Native.CoTaskMemFree((IntPtr)(((long)pNative) - sizeof(uint))); 452return Win32Native.SysAllocStringByteLen(bytes, (uint)nb); 476Win32Native.SysFreeString(pNative); 1306((StringBuilder)pManagedHome).ReplaceBufferAnsiInternal(ptr, Win32Native.lstrlenA(pNativeHome)); 1313((StringBuilder)pManagedHome).ReplaceBufferInternal(ptr, Win32Native.lstrlenW(pNativeHome)); 1331Win32Native.CoTaskMemFree(pNativeHome);
system\text\basecodepageencoding.cs (1)
167base(codepage == 0? Microsoft.Win32.Win32Native.GetACP(): codepage)
system\text\encoding.cs (2)
21using Win32Native = Microsoft.Win32.Win32Native; 1402int codePage = Win32Native.GetACP();
system\text\encodingnls.cs (1)
16using Win32Native = Microsoft.Win32.Win32Native;
system\threading\eventwaithandle.cs (16)
69_handle = Win32Native.CreateEvent(null, true, initialState, name); 72_handle = Win32Native.CreateEvent(null, false, initialState, name); 84if(null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) 110Win32Native.SECURITY_ATTRIBUTES secAttrs = null; 114secAttrs = new Win32Native.SECURITY_ATTRIBUTES(); 139_handle = Win32Native.CreateEvent(secAttrs, isManualReset, initialState, name); 146if(null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) 151createdNew = errorCode != Win32Native.ERROR_ALREADY_EXISTS; 190__Error.WinIOError(Win32Native.ERROR_PATH_NOT_FOUND, ""); 243SafeWaitHandle myHandle = Win32Native.OpenEvent((int) rights, false, name); 252if(Win32Native.ERROR_FILE_NOT_FOUND == errorCode || Win32Native.ERROR_INVALID_NAME == errorCode) 254if (Win32Native.ERROR_PATH_NOT_FOUND == errorCode) 256if(null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) 267bool res = Win32Native.ResetEvent(safeWaitHandle); 275bool res = Win32Native.SetEvent(safeWaitHandle);
system\threading\mutex.cs (26)
68Win32Native.SECURITY_ATTRIBUTES secAttrs = null; 73secAttrs = new Win32Native.SECURITY_ATTRIBUTES(); 90internal Mutex(bool initiallyOwned, String name, out bool createdNew, Win32Native.SECURITY_ATTRIBUTES secAttrs) 119internal void CreateMutexWithGuaranteedCleanup(bool initiallyOwned, String name, out bool createdNew, Win32Native.SECURITY_ATTRIBUTES secAttrs) 144Win32Native.SECURITY_ATTRIBUTES m_secAttrs; 149internal MutexTryCodeHelper(bool initiallyOwned,MutexCleanupInfo cleanupInfo, String name, Win32Native.SECURITY_ATTRIBUTES secAttrs, Mutex mutex) 193if(null != m_name && 0 != m_name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) 197m_newMutex = errorCode != Win32Native.ERROR_ALREADY_EXISTS; 216Win32Native.ReleaseMutex(cleanupInfo.mutexHandle); 321__Error.WinIOError(Win32Native.ERROR_PATH_NOT_FOUND, name); 381SafeWaitHandle myHandle = Win32Native.OpenMutex((int) rights, false, name); 391if(Win32Native.ERROR_FILE_NOT_FOUND == errorCode || Win32Native.ERROR_INVALID_NAME == errorCode) 393if (Win32Native.ERROR_PATH_NOT_FOUND == errorCode) 395if (null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) 413if (Win32Native.ReleaseMutex(safeWaitHandle)) 434static int CreateMutexHandle(bool initiallyOwned, String name, Win32Native.SECURITY_ATTRIBUTES securityAttribute, out SafeWaitHandle mutexHandle) { 439mutexHandle = Win32Native.CreateMutex(securityAttribute, initiallyOwned, name); 445if( errorCode == Win32Native.ERROR_ACCESS_DENIED) { 463mutexHandle = Win32Native.OpenMutex(Win32Native.MUTEX_MODIFY_STATE | Win32Native.SYNCHRONIZE, false, name); 466errorCode = Win32Native.ERROR_ALREADY_EXISTS; 484if( errorCode != Win32Native.ERROR_FILE_NOT_FOUND) { 485if( errorCode == Win32Native.ERROR_SUCCESS) { 486errorCode = Win32Native.ERROR_ALREADY_EXISTS;
system\threading\Tasks\Task.cs (7)
7067Win32Native.SYSTEM_INFO sysInfo = new Win32Native.SYSTEM_INFO(); 7068Win32Native.GetSystemInfo(ref sysInfo); 7073Win32Native.MEMORY_BASIC_INFORMATION stackInfo = new Win32Native.MEMORY_BASIC_INFORMATION(); 7088Win32Native.VirtualQuery(currentAddr.ToPointer(), ref stackInfo, (UIntPtr)(sizeof(Win32Native.MEMORY_BASIC_INFORMATION)));
system\threading\threadpool.cs (1)
937return Win32Native.INVALID_HANDLE_VALUE;
system\threading\timer.cs (2)
88bool result = Win32Native.QueryUnbiasedInterruptTime(out time100ns); 690Win32Native.SetEvent(m_notifyWhenNoCallbacksRunning.SafeWaitHandle);
system\threading\waithandle.cs (2)
31using Win32Native = Microsoft.Win32.Win32Native; 55return Win32Native.INVALID_HANDLE_VALUE;
system\timezoneinfo.cs (35)
234Win32Native.TimeZoneInformation timeZoneInformation = new Win32Native.TimeZoneInformation(); 236if (result == Win32Native.TIME_ZONE_ID_INVALID) 1086private TimeZoneInfo(Win32Native.TimeZoneInformation zone, Boolean dstDisabled) { 1098Win32Native.RegistryTimeZoneInformation regZone = new Win32Native.RegistryTimeZoneInformation(zone); 1307static private Boolean CheckDaylightSavingTimeNotSupported(Win32Native.TimeZoneInformation timeZone) { 1365static private AdjustmentRule CreateAdjustmentRuleFromTimeZoneInformation(Win32Native.RegistryTimeZoneInformation timeZoneInformation, DateTime startDate, DateTime endDate, int defaultBaseUtcOffset) { 1424static private String FindIdFromTimeZoneInformation(Win32Native.TimeZoneInformation timeZone, out Boolean dstDisabled) { 1823Win32Native.DynamicTimeZoneInformation dynamicTimeZoneInformation = 1824new Win32Native.DynamicTimeZoneInformation(); 1828if (result == Win32Native.TIME_ZONE_ID_INVALID) { 1833Win32Native.TimeZoneInformation timeZoneInformation = 1834new Win32Native.TimeZoneInformation(dynamicTimeZoneInformation); 1911static private TimeZoneInfo GetLocalTimeZoneFromWin32Data(Win32Native.TimeZoneInformation timeZoneInformation, Boolean dstDisabled) { 2100static private bool TransitionTimeFromTimeZoneInformation(Win32Native.RegistryTimeZoneInformation timeZoneInformation, out TransitionTime transitionTime, bool readStartDate) { 2306static private bool TryCreateAdjustmentRules(string id, Win32Native.RegistryTimeZoneInformation defaultTimeZoneInformation, out AdjustmentRule[] rules, out Exception e, int defaultBaseUtcOffset) { 2352Win32Native.RegistryTimeZoneInformation dtzi; 2358dtzi = new Win32Native.RegistryTimeZoneInformation(regValue); 2394dtzi = new Win32Native.RegistryTimeZoneInformation(regValue); 2406dtzi = new Win32Native.RegistryTimeZoneInformation(regValue); 2456static private Boolean TryCompareStandardDate(Win32Native.TimeZoneInformation timeZone, Win32Native.RegistryTimeZoneInformation registryTimeZoneInfo) { 2479static private Boolean TryCompareTimeZoneInformationToRegistry(Win32Native.TimeZoneInformation timeZone, string id, out Boolean dstDisabled) { 2502Win32Native.RegistryTimeZoneInformation registryTimeZoneInfo; 2505registryTimeZoneInfo = new Win32Native.RegistryTimeZoneInformation(regValue); 2611StringBuilder fileMuiPath = StringBuilderCache.Acquire(Win32Native.MAX_PATH); 2612fileMuiPath.Length = Win32Native.MAX_PATH; 2613int fileMuiPathLength = Win32Native.MAX_PATH; 2618Win32Native.MUI_PREFERRED_UI_LANGUAGES, 2648UnsafeNativeMethods.LoadLibraryEx(filePath, IntPtr.Zero, Win32Native.LOAD_LIBRARY_AS_DATAFILE)) { 2651StringBuilder localizedResource = StringBuilderCache.Acquire(Win32Native.LOAD_STRING_MAX_LENGTH); 2652localizedResource.Length = Win32Native.LOAD_STRING_MAX_LENGTH; 2788Win32Native.RegistryTimeZoneInformation defaultTimeZoneInformation; 2795defaultTimeZoneInformation = new Win32Native.RegistryTimeZoneInformation(regValue);