22 writes to handle
Microsoft.AspNetCore.Cryptography.Internal (1)
SafeHandles\SecureLocalAllocHandle.cs (1)
46handle = Marshal.AllocHGlobal(cb); // actually calls LocalAlloc
Microsoft.AspNetCore.Server.HttpSys (1)
NativeInterop\SafeNativeOverlapped.cs (1)
38IntPtr oldHandle = Interlocked.Exchange(ref handle, IntPtr.Zero);
Microsoft.AspNetCore.Server.IIS (2)
Core\NativeSafeHandle.cs (2)
18this.handle = handle; 23handle = IntPtr.Zero;
PresentationCore (3)
System\Windows\Media\safemediahandle.cs (1)
31UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref handle);
System\Windows\Media\SafeMILHandle.cs (1)
63UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref handle);
System\Windows\Media\SafeReversePInvokeHandle.cs (1)
47UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref handle);
PresentationFramework (5)
System\Windows\Standard\NativeMethods.cs (5)
1502handle = hdc, 1539safeHandle.handle = unsafeHandle; 1560handle = IntPtr.Zero; 1572handle = new IntPtr(dwCookie); 1596handle = IntPtr.Zero;
System.Data.Odbc (6)
Common\System\Data\ProviderBase\DbBuffer.cs (2)
26base.handle = SafeNativeMethods.LocalAlloc((IntPtr)initialSize); 375base.handle = IntPtr.Zero;
System\Data\Odbc\OdbcHandle.cs (4)
31retcode = Interop.Odbc.SQLAllocHandle(handleType, IntPtr.Zero, out base.handle); 39retcode = Interop.Odbc.SQLAllocHandle(handleType, parentHandle, out base.handle); 92retcode = parentHandle.GetStatementAttribute(attribute, out base.handle, out cbActual); 139base.handle = IntPtr.Zero;
System.Private.CoreLib (2)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeHandle.cs (2)
66handle = invalidHandleValue; 96protected internal void SetHandle(IntPtr handle) => this.handle = handle;
System.Windows.Forms.Primitives (1)
Microsoft\Win32\SafeHandles\CoTaskMemSafeHandle.cs (1)
19handle = IntPtr.Zero;
UIAutomationTypes (1)
src\Microsoft.DotNet.Wpf\src\Shared\MS\Win32\NativeMethodsOther.cs (1)
251handle = hbitmap,
111 references to handle
Infrastructure.Common (2)
SafeKeychainHandle.cs (2)
41CFRelease(handle); 46public override bool IsInvalid => handle == IntPtr.Zero;
Microsoft.AspNetCore.Cryptography.Internal (7)
SafeHandles\BCryptAlgorithmHandle.cs (1)
156return (UnsafeNativeMethods.BCryptCloseAlgorithmProvider(handle, dwFlags: 0) == 0);
SafeHandles\BCryptHashHandle.cs (1)
56return (UnsafeNativeMethods.BCryptDestroyHash(handle) == 0);
SafeHandles\BCryptKeyHandle.cs (1)
17return (UnsafeNativeMethods.BCryptDestroyKey(handle) == 0);
SafeHandles\LocalAllocHandle.cs (1)
21Marshal.FreeHGlobal(handle); // actually calls LocalFree
SafeHandles\NCryptDescriptorHandle.cs (1)
39return (UnsafeNativeMethods.NCryptCloseProtectionDescriptor(handle) == 0);
SafeHandles\SafeLibraryHandle.cs (1)
124return UnsafeNativeMethods.FreeLibrary(handle);
SafeHandles\SecureLocalAllocHandle.cs (1)
59UnsafeBufferUtil.SecureZeroMemory((byte*)handle, _cb); // compiler won't optimize this away
Microsoft.AspNetCore.Server.HttpSys (2)
NativeInterop\SafeLibraryHandle.cs (1)
69return UnsafeNativeMethods.FreeLibrary(handle);
NativeInterop\SafeNativeOverlapped.cs (1)
31get { return handle == IntPtr.Zero; }
Microsoft.AspNetCore.Server.IIS (1)
Core\NativeSafeHandle.cs (1)
13public override bool IsInvalid => handle == IntPtr.Zero;
Microsoft.Build.Framework (1)
NativeMethods.cs (1)
279return CloseHandle(handle);
Microsoft.CodeAnalysis.Workspaces (3)
Storage\SQLite\Interop\SafeSqliteBlobHandle.cs (1)
36public override bool IsInvalid => handle == IntPtr.Zero;
Storage\SQLite\Interop\SafeSqliteHandle.cs (1)
33public override bool IsInvalid => handle == IntPtr.Zero;
Storage\SQLite\Interop\SafeSqliteStatementHandle.cs (1)
36public override bool IsInvalid => handle == IntPtr.Zero;
Microsoft.Extensions.Diagnostics.ResourceMonitoring (1)
Windows\Interop\JobObjectInfo.cs (1)
290return UnsafeNativeMethods.CloseHandle(handle);
Microsoft.ML.LightGbm (2)
WrappedLightGbmInterface.cs (2)
79LightGbmInterfaceUtils.Check(DatasetFree(handle)); 174LightGbmInterfaceUtils.Check(BoosterFree(handle));
Microsoft.ML.Transforms (1)
Text\LdaSingleBox.cs (1)
27DestroyEngine(handle);
Microsoft.VisualBasic.Forms (1)
Microsoft\VisualBasic\Helpers\NativeTypes.vb (1)
39Return NativeMethods.CloseHandle(handle) <> 0
PresentationCore (12)
MS\Win32\UnsafeNativeMethodsTablet.cs (6)
84return IsClosed || handle == IntPtr.Zero; 90Debug.Assert(handle != IntPtr.Zero); 91return (MS.Internal.HRESULT.Succeeded(MS.Win32.Recognizer.UnsafeNativeMethods.DestroyRecognizer(handle))); 119return IsClosed || handle == IntPtr.Zero; 130Debug.Assert(handle != IntPtr.Zero); 131int hr = MS.Win32.Recognizer.UnsafeNativeMethods.DestroyContext(handle);
System\Windows\Media\ColorContextHelper.cs (1)
36return UnsafeNativeMethodsMilCoreApi.Mscms.CloseColorProfile(handle);
System\Windows\Media\ColorTransformHelper.cs (1)
35return UnsafeNativeMethods.Mscms.DeleteColorTransform(handle);
System\Windows\Media\Imaging\BitmapSourceSafeMILHandle.cs (1)
59UpdateEstimatedSize(ComputeEstimatedSize(handle));
System\Windows\Media\safemediahandle.cs (1)
30HRESULT.Check(MILMedia.Shutdown(handle));
System\Windows\Media\SafeReversePInvokeHandle.cs (2)
43if (handle != IntPtr.Zero) 45UnsafeNativeMethods.MilCoreApi.MilReleasePInvokePtrBlocking(handle);
PresentationFramework (7)
System\Windows\Standard\NativeMethods.cs (7)
1361return NativeMethods.FindClose(handle); 1405return NativeMethods.DeleteDC(handle); 1413return NativeMethods.ReleaseDC(_hwnd.Value, handle) == 1; 1448hPtr = hdc.handle; 1515return NativeMethods.DeleteObject(handle); 1525Status s = NativeMethods.GdiplusShutdown(this.handle); 1595int dwCookie = handle.ToInt32();
ReachFramework (5)
MS\Internal\Printing\Configuration\SafeModuleHandle.cs (1)
27return UnsafeNativeMethods.FreeLibrary(this.handle);
MS\Internal\Printing\Configuration\SafeWinSpoolPrinterHandle.cs (2)
26return (base.handle == IntPtr.Zero); 34return UnsafeNativeMethods.ClosePrinter(base.handle);
PrintConfig\PTProvider.cs (2)
58return (IsClosed || (handle == IntPtr.Zero)); 68return PTUtility.IsSuccessCode(UnsafeNativeMethods.PTCloseProviderImpl(this.handle));
System.Data.Odbc (12)
Common\System\Data\ProviderBase\DbBuffer.cs (3)
28if (IntPtr.Zero == base.handle) 45return (IntPtr.Zero == base.handle); 374IntPtr ptr = base.handle;
System\Data\Odbc\OdbcConnectionHandle.cs (3)
146ODBC32.SQLRETURN retcode = CompleteTransaction(transactionOperation, base.handle); 214CompleteTransaction(ODBC32.SQL_ROLLBACK, handle); 218Interop.Odbc.SQLDisconnect(handle);
System\Data\Odbc\OdbcHandle.cs (6)
55if (IntPtr.Zero != base.handle) 71if ((ADP.PtrZero == base.handle) || (ODBC32.SQLRETURN.SUCCESS != retcode)) 98if (IntPtr.Zero != base.handle) 111if (ADP.PtrZero == base.handle) 131return (IntPtr.Zero == base.handle); 138IntPtr handle = base.handle;
System.IO.Ports (2)
System\IO\Ports\SafeSerialDeviceHandle.Unix.cs (2)
39Interop.Serial.Shutdown(handle, SocketShutdown.Both); 40int result = Interop.Serial.SerialPortClose(handle);
System.Private.CoreLib (17)
src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs (3)
147Interop.Sys.FLock(handle, Interop.Sys.LockOperations.LOCK_UN); // ignore any errors 152return Interop.Sys.Close(handle) == 0; 159long h = (long)handle;
src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeHandleMinusOneIsInvalid.cs (1)
16public override bool IsInvalid => handle == new IntPtr(-1);
src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeHandleZeroOrMinusOneIsInvalid.cs (2)
16public override bool IsInvalid => handle == IntPtr.Zero || handle == new IntPtr(-1);
src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeWaitHandle.Windows.cs (1)
8protected override bool ReleaseHandle() => Interop.Kernel32.CloseHandle(handle);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeBuffer.cs (6)
161pointer = (byte*)handle; 187byte* ptr = (byte*)handle + byteOffset; 238byte* ptr = (byte*)handle + byteOffset; 274byte* ptr = (byte*)handle + byteOffset; 327byte* ptr = (byte*)handle + byteOffset; 370if ((ulong)(ptr - (byte*)handle) > (_numBytes - sizeInBytes))
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeHandle.cs (2)
98public IntPtr DangerousGetHandle() => handle; 118Internal.Console.WriteLine($"{Environment.NewLine}*** #{count} {GetType()} (0x{handle.ToInt64():x}) finalized! Ctor stack:{Environment.NewLine}{_ctorStackTrace}{Environment.NewLine}");
src\libraries\System.Private.CoreLib\src\System\Security\SecureString.cs (2)
464new Span<byte>((void*)handle, _byteLength).Clear(); 465Marshal.FreeHGlobal(handle);
System.Text.Encoding.CodePages (2)
Microsoft\Win32\SafeHandles\SafeAllocHHandle.cs (2)
26if (handle != IntPtr.Zero) 28Marshal.FreeHGlobal(handle);
System.Windows.Forms.Primitives (2)
Microsoft\Win32\SafeHandles\CoTaskMemSafeHandle.cs (2)
14public override bool IsInvalid => IsClosed || handle == IntPtr.Zero; 18Marshal.FreeCoTaskMem(handle);
UIAutomationClient (14)
MS\Internal\Automation\SafeHandles.cs (6)
28get { return handle == IntPtr.Zero; } 33return UiaCoreApi.UiaNodeRelease(handle); 51get { return handle == IntPtr.Zero; } 56return UiaCoreApi.UiaPatternRelease(handle); 71get { return handle == IntPtr.Zero; } 76UiaCoreApi.UiaRemoveEvent(handle);
MS\Internal\Automation\SafeProcessHandle.cs (1)
33return Misc.CloseHandle(handle);
System\Windows\Automation\Condition.cs (5)
23get { return handle == IntPtr.Zero; } 28Marshal.FreeCoTaskMem(handle); 46Marshal.StructureToPtr(uiaCondition, sh.handle, false); 66IntPtr* pdata = (IntPtr*)sh.handle; 69*pdata++ = conditions[i]._safeHandle.handle;
System\Windows\Automation\Text\TextRange.cs (2)
29get { return handle == IntPtr.Zero; } 34return UiaCoreApi.UiaTextRangeRelease(handle);
UIAutomationClientSideProviders (10)
MS\Internal\AutomationProxies\CommonRemoteMemoryBlock.cs (5)
54return Misc.VirtualFreeEx(_processHandle, handle, UIntPtr.Zero, UnsafeNativeMethods.MEM_RELEASE); 71return handle; 78Misc.WriteProcessMemory(_processHandle, handle, sourceAddress, cbSize, out count); 90Misc.ReadProcessMemory(_processHandle, handle, destAddress, cbSize, out count); 95Misc.ReadProcessMemory(_processHandle, handle, destAddress, cbSize, out count);
MS\Internal\AutomationProxies\SafeCoTaskMem.cs (3)
23return Marshal.PtrToStringAuto(handle); 29return Marshal.PtrToStringUni(handle, length); 34Marshal.FreeCoTaskMem(handle);
MS\Internal\AutomationProxies\SafeProcessHandle.cs (1)
44return Misc.CloseHandle(handle);
MS\Internal\AutomationProxies\SafeThemeHandle.cs (1)
30return !IsInvalid ? CloseThemeData(handle) == (IntPtr)NativeMethods.S_OK : true;
UIAutomationTypes (6)
src\Microsoft.DotNet.Wpf\src\Shared\MS\Win32\NativeMethodsOther.cs (6)
239return UnsafeNativeMethods.DeleteObject(handle); 244return new HandleRef(obj, handle); 264return UnsafeNativeMethods.DestroyIcon(handle); 277return handle; 289return UnsafeNativeMethods.DestroyCursor( handle ); 561 return (LocalFree(base.handle) == IntPtr.Zero);
WindowsFormsIntegration (1)
MS\Win32\DCSafeHandle.cs (1)
14return UnsafeNativeMethods.DeleteDC(handle);