59 writes to handle
Microsoft.AspNetCore.Cryptography.Internal (1)
SafeHandles\SecureLocalAllocHandle.cs (1)
46handle = Marshal.AllocHGlobal(cb); // actually calls LocalAlloc
NuGet.Packaging (1)
Signing\Cms\NativeMethods.cs (1)
172handle = 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)
1504handle = hdc, 1541safeHandle.handle = unsafeHandle; 1562handle = IntPtr.Zero; 1574handle = new IntPtr(dwCookie); 1598handle = 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.Data.OleDb (18)
DbPropSet.cs (5)
33base.handle = Interop.Ole32.CoTaskMemAlloc(countOfBytes); 54hr = properties.GetProperties(propidsetcount, propidset, out this.propertySetCount, out base.handle); 72hr = properties.GetProperties(propidsetcount, propidset, out this.propertySetCount, out base.handle); 90hr = properties.GetProperties(propidsetcount, propidset, out this.propertySetCount, out base.handle); 133base.handle = IntPtr.Zero;
OleDbWrapper.cs (2)
35base.handle = Marshal.GetComInterfaceForObject(unknown, typeof(UnsafeNativeMethods.IDataInitialize)); 364base.handle = idbCreateCommand;
PropertyInfoSet.cs (2)
41hr = idbProperties.GetPropertyInfo(propIDSetCount, propIDSet, out this.setCount, out base.handle, out this.descBuffer); 113base.handle = IntPtr.Zero;
SafeHandles.cs (5)
31hr = dbInfo.GetLiteralInfo(count, literals, out literalCount, out base.handle, out this.handle2); 38hr = columnsInfo.GetColumnInfo(out columnCount, out base.handle, out this.handle2); 45hr = dbSchemaRowset.GetSchemas(out schemaCount, out base.handle, out this.handle2); 52hr = icolumnsRowset.GetAvailableColumns(out cOptColumns, out base.handle); 68base.handle = IntPtr.Zero;
System\Data\ProviderBase\DbBuffer.cs (2)
27base.handle = (IntPtr)Interop.Kernel32.LocalAllocZeroed((uint)initialSize); 348base.handle = IntPtr.Zero;
System\Data\ProviderBase\WrappedIUnknown.cs (2)
30base.handle = Marshal.GetIUnknownForObject(unknown); 71base.handle = IntPtr.Zero;
System.Diagnostics.EventLog (3)
System\Diagnostics\Reader\CoTaskMemSafeHandle.cs (1)
39handle = IntPtr.Zero;
System\Diagnostics\Reader\CoTaskMemUnicodeSafeHandle.cs (1)
45handle = IntPtr.Zero;
System\Diagnostics\Reader\EventLogHandle.cs (1)
36handle = IntPtr.Zero;
System.DirectoryServices.Protocols (3)
System\DirectoryServices\Protocols\Interop\SafeHandles.Linux.cs (3)
15Interop.Ldap.ldap_initialize(out handle, null); 22Interop.Ldap.ldap_initialize(out handle, uri); 47handle = IntPtr.Zero;
System.Drawing.Common (1)
System\Drawing\Printing\PrintController.SafeDeviceModeHandle.cs (1)
39handle = 0;
System.IO.MemoryMappedFiles (1)
Microsoft\Win32\SafeMemoryMappedViewHandle.Unix.cs (1)
19handle = new IntPtr(-1);
System.Net.Security (7)
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.OCSP.cs (2)
108handle = IntPtr.Zero; 123handle = IntPtr.Zero;
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Ssl.cs (1)
549handle = validSslPointer;
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\GssSafeHandles.cs (3)
57Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseName(out _, ref handle); 145Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseCred(out _, ref handle); 170Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.DeleteSecContext(out _, ref handle);
System\Net\Security\Pal.Managed\SafeChannelBindingHandle.cs (1)
39handle = Marshal.AllocHGlobal(SecChannelBindingSize + _cbtPrefixByteArraySize + CertHashMaxSize);
System.Private.CoreLib (2)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeHandle.cs (2)
59handle = invalidHandleValue; 89protected internal void SetHandle(IntPtr handle) => this.handle = handle;
System.Security.Cryptography (5)
Microsoft\Win32\SafeHandles\SafePasswordHandle.cs (3)
29handle = Marshal.StringToHGlobalUni(password); 47handle = Marshal.AllocHGlobal(spanLen * sizeof(char)); 68handle = Marshal.SecureStringToGlobalAllocUnicode(password);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeUnicodeStringHandle.cs (2)
21handle = Marshal.StringToHGlobalUni(s); 36handle = Marshal.AllocHGlobal(cb);
System.Speech (1)
Internal\HGlobalSafeHandle.cs (1)
86handle = IntPtr.Zero;
System.Windows.Forms.Primitives (1)
Microsoft\Win32\SafeHandles\CoTaskMemSafeHandle.cs (1)
19handle = IntPtr.Zero;
UIAutomationTypes (1)
src\wpf\src\Microsoft.DotNet.Wpf\src\Shared\MS\Win32\NativeMethodsOther.cs (1)
251handle = hbitmap,
370 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.Build.Framework (1)
FileSystem\SafeFileHandle.cs (1)
25return WindowsNative.FindClose(handle);
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
Microsoft.Win32.Registry (1)
src\runtime\src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeRegistryHandle.cs (1)
37Interop.Advapi32.RegCloseKey(handle) == Interop.Errors.ERROR_SUCCESS;
Microsoft.Win32.SystemEvents (1)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs (1)
19return Interop.Kernel32.FreeLibrary(handle);
NuGet.Packaging (4)
Signing\Cms\NativeMethods.cs (4)
135public override bool IsInvalid => handle == IntPtr.Zero; 154return NativeMethods.CryptMsgClose(handle); 160public override bool IsInvalid { get { return handle == IntPtr.Zero; } } 170Marshal.FreeHGlobal(handle);
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)
1363return NativeMethods.FindClose(handle); 1407return NativeMethods.DeleteDC(handle); 1415return NativeMethods.ReleaseDC(_hwnd.Value, handle) == 1; 1450hPtr = hdc.handle; 1517return NativeMethods.DeleteObject(handle); 1527Status s = NativeMethods.GdiplusShutdown(this.handle); 1597int 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.Data.OleDb (47)
DbPropSet.cs (5)
34if (IntPtr.Zero != base.handle) 36SafeNativeMethods.ZeroMemory(base.handle, (int)countOfBytes); 39if (IntPtr.Zero == base.handle) 125return (IntPtr.Zero == base.handle); 132IntPtr ptr = base.handle;
OleDbTransaction.cs (2)
109if (_mustComplete && (IntPtr.Zero != base.handle)) 111NativeOledbWrapper.ITransactionAbort(base.handle);
OleDbWrapper.cs (11)
40IntPtr vtable = Marshal.ReadIntPtr(base.handle, 0); 72hr = GetDataSource(base.handle, IntPtr.Zero, ODB.CLSCTX_ALL, connectionStringPtr, riid, &handle); 138IntPtr vtable = Marshal.ReadIntPtr(base.handle, 0); 155vtable = Marshal.ReadIntPtr(base.handle, 0); 170hr = Initialize(base.handle); 178hr = (OleDbHResult)QueryInterface(base.handle, riid, &idbCreateSession); 338IntPtr vtable = Marshal.ReadIntPtr(base.handle, 0); 345hresult = QueryInterface(base.handle, riid, &idbCreateCommand); 363IntPtr ptr = base.handle; 383IntPtr vtable = Marshal.ReadIntPtr(base.handle, 0); 423hr = CreateCommand(base.handle, IntPtr.Zero, riid, &nativeICommandText);
PropertyIDSet.cs (6)
25IntPtr ptr = ADP.IntPtrOffset(base.handle, PropertyIDSetSize); 26Marshal.WriteIntPtr(base.handle, 0, ptr); 28Marshal.WriteInt32(base.handle, IntPtr.Size, /*propertyid count*/1); 30ptr = ADP.IntPtrOffset(base.handle, ODB.OffsetOf_tagDBPROPIDSET_PropertySet); 34Marshal.WriteInt32(base.handle, PropertyIDSetSize, propertyID); 43IntPtr ptr = ADP.IntPtrOffset(base.handle, (i * PropertyIDSetSize) + ODB.OffsetOf_tagDBPROPIDSET_PropertySet);
PropertyInfoSet.cs (5)
43if ((0 <= hr) && (IntPtr.Zero != handle)) 53return ((IntPtr.Zero == base.handle) && (IntPtr.Zero == this.descBuffer)); 66if (IntPtr.Zero != this.handle) 70IntPtr setPtr = this.handle; 112IntPtr ptr = base.handle;
RowBinding.cs (6)
260Marshal.WriteIntPtr(base.handle, offset, ptr); 261Marshal.WriteIntPtr(base.handle, offset + IntPtr.Size, ptr); 286pinnedValue = ADP.IntPtrOffset(base.handle, _emptyStringOffset); 299Marshal.WriteIntPtr(base.handle, offset, pinnedValue); // parameter input value 300Marshal.WriteIntPtr(base.handle, offset + IntPtr.Size, pinnedValue); // original parameter value 596IntPtr buffer = base.handle;
SafeHandles.cs (7)
32literalInfo = base.handle; 39columnInfos = base.handle; 46schemaGuids = base.handle; 59return (((IntPtr.Zero == base.handle)) && (IntPtr.Zero == this.handle2)); 67IntPtr ptr = base.handle; 165if ((IntPtr.Zero != base.handle) && (IntPtr.Zero != chapter)) 167NativeOledbWrapper.IChapteredRowsetReleaseChapter(base.handle, chapter);
System\Data\ProviderBase\DbBuffer.cs (3)
29if (IntPtr.Zero == base.handle) 46return (IntPtr.Zero == base.handle); 347void* ptr = (void*)base.handle;
System\Data\ProviderBase\WrappedIUnknown.cs (2)
39return (IntPtr.Zero == base.handle); 70IntPtr ptr = base.handle;
System.Diagnostics.EventLog (11)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs (1)
19return Interop.Kernel32.FreeLibrary(handle);
System\Diagnostics\Reader\CoTaskMemSafeHandle.cs (3)
25return handle; 32return IsClosed || handle == IntPtr.Zero; 38Marshal.FreeCoTaskMem(handle);
System\Diagnostics\Reader\CoTaskMemUnicodeSafeHandle.cs (3)
31return handle; 38return IsClosed || handle == IntPtr.Zero; 44Marshal.ZeroFreeCoTaskMemUnicode(handle);
System\Diagnostics\Reader\EventLogHandle.cs (2)
29return IsClosed || handle == IntPtr.Zero; 35NativeWrapper.EvtClose(handle);
System\Diagnostics\SafeEventLogReadHandle.cs (1)
12return Interop.Advapi32.CloseEventLog(handle);
System\Diagnostics\SafeEventLogWriteHandle.cs (1)
13return Interop.Advapi32.DeregisterEventSource(handle);
System.Diagnostics.PerformanceCounter (2)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafePerfProviderHandle.cs (1)
16uint Status = Interop.PerfCounter.PerfStopProvider(handle);
src\runtime\src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeRegistryHandle.cs (1)
37Interop.Advapi32.RegCloseKey(handle) == Interop.Errors.ERROR_SUCCESS;
System.DirectoryServices (6)
src\runtime\src\libraries\Common\src\Interop\Windows\Secur32\Interop.LsaLogonProcessSafeHandle.cs (1)
20protected override bool ReleaseHandle() => LsaDeregisterLogonProcess(handle) == 0;
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs (1)
19return Interop.Kernel32.FreeLibrary(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLsaPolicyHandle.cs (1)
20return Interop.Advapi32.LsaClose(handle) == 0;
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeTokenHandle.cs (3)
30{ return handle == new IntPtr(0) || handle == new IntPtr(-1); } 35return Interop.Kernel32.CloseHandle(handle);
System.DirectoryServices.AccountManagement (8)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLsaMemoryHandle.cs (1)
21return Interop.Advapi32.LsaFreeMemory(handle) == 0;
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLsaPolicyHandle.cs (1)
20return Interop.Advapi32.LsaClose(handle) == 0;
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeTokenHandle.cs (3)
30{ return handle == new IntPtr(0) || handle == new IntPtr(-1); } 35return Interop.Kernel32.CloseHandle(handle);
System\DirectoryServices\AccountManagement\AuthZSet.cs (3)
534get { return (handle == IntPtr.Zero); } 539if (handle != IntPtr.Zero) 540Marshal.FreeHGlobal(handle);
System.DirectoryServices.Protocols (6)
System\DirectoryServices\Protocols\Interop\SafeHandles.cs (2)
20if (handle != _dummyPointer) 22Marshal.FreeHGlobal(handle);
System\DirectoryServices\Protocols\Interop\SafeHandles.Linux.cs (4)
44Interop.Ldap.ldap_unbind_ext_s(handle, ref nullPointer, ref nullPointer); 57if (handle == IntPtr.Zero) 73if (handle == IntPtr.Zero) 81Interop.Ldap.ber_free(handle, 1);
System.Drawing.Common (4)
System\Drawing\Printing\PrintController.SafeDeviceModeHandle.cs (4)
30public override bool IsInvalid => handle == 0; 36PInvokeCore.GlobalFree((HGLOBAL)handle); 45return (handle is null) ? 0 : handle.handle; 54=> (handle is null) ? HGLOBAL.Null : (HGLOBAL)handle.handle;
System.IO.Compression (10)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeZstdHandle.cs (8)
20Interop.Zstd.ZSTD_freeCCtx(handle); 84public override bool IsInvalid => handle == IntPtr.Zero; 95Interop.Zstd.ZSTD_freeDCtx(handle); 159public override bool IsInvalid => handle == IntPtr.Zero; 170Interop.Zstd.ZSTD_freeCDict(handle); 175public override bool IsInvalid => handle == IntPtr.Zero; 186Interop.Zstd.ZSTD_freeDDict(handle); 191public override bool IsInvalid => handle == IntPtr.Zero;
src\runtime\src\libraries\Common\src\System\IO\Compression\ZLibNative.cs (2)
183/// <see cref="ZLibStreamHandle" /> does not actually use its <see cref="SafeHandle.handle" /> field. 249get { return handle == new IntPtr(-1); }
System.IO.Compression.Brotli (4)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeBrotliHandle.cs (4)
15Interop.Brotli.BrotliEncoderDestroyInstance(handle); 19public override bool IsInvalid => handle == IntPtr.Zero; 28Interop.Brotli.BrotliDecoderDestroyInstance(handle); 32public override bool IsInvalid => handle == IntPtr.Zero;
System.IO.FileSystem.AccessControl (3)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeFindHandle.Windows.cs (3)
15return Interop.Kernel32.FindClose(handle); 22return handle == IntPtr.Zero || handle == new IntPtr(-1);
System.IO.MemoryMappedFiles (2)
Microsoft\Win32\SafeMemoryMappedFileHandle.Unix.cs (1)
89public override bool IsInvalid => (long)handle <= 0;
Microsoft\Win32\SafeMemoryMappedViewHandle.Unix.cs (1)
18IntPtr addr = handle;
System.IO.Pipes (4)
Microsoft\Win32\SafeHandles\SafePipeHandle.Unix.cs (4)
63return (long)handle >= 0 ? 64Interop.Sys.Close(handle) == 0 : 71get { return (long)handle < 0 && _pipeSocket == null; } 84socket = SetPipeSocketInterlocked(new Socket(new SafeSocketHandle(handle, ownsHandle)), ownsHandle);
System.IO.Ports (2)
System\IO\Ports\SafeSerialDeviceHandle.Unix.cs (2)
39Interop.Serial.Shutdown(handle, SocketShutdown.Both); 40int result = Interop.Serial.SerialPortClose(handle);
System.Management (1)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs (1)
19return Interop.Kernel32.FreeLibrary(handle);
System.Net.Http.WinHttpHandler (3)
src\runtime\src\libraries\Common\src\Interop\Windows\WinHttp\Interop.SafeWinHttpHandle.cs (1)
56return Interop.WinHttp.WinHttpCloseHandle(handle);
System\Net\Http\WinHttpChannelBinding.cs (2)
61Marshal.Copy(this.handle, bytes, 0, _size); 70Marshal.FreeHGlobal(this.handle);
System.Net.Quic (21)
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.X509Stack.cs (2)
73Interop.Crypto.RecursiveFreeX509Stack(handle); 80get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.X509StoreCtx.cs (2)
86Interop.Crypto.X509StoreCtxDestroy(handle); 93get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\Asn1SafeHandles.Unix.cs (4)
18Interop.Crypto.Asn1ObjectFree(handle); 25get { return handle == IntPtr.Zero; } 38Interop.Crypto.Asn1OctetStringFree(handle); 45get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeBioHandle.Unix.cs (2)
22IntPtr h = handle; 44return handle == IntPtr.Zero || (_parent != null && _parent.IsInvalid);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeInteriorHandle.cs (1)
38return handle == IntPtr.Zero || (_parent != null && _parent.IsInvalid);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeX509Handles.Unix.cs (7)
23Console.WriteLine($"0x{handle.ToInt64():x} {_stacktrace?.ToString() ?? "no stacktrace..."}"); 37Interop.Crypto.X509Destroy(handle); 44get { return handle == IntPtr.Zero; } 57Interop.Crypto.X509CrlDestroy(handle); 64get { return handle == IntPtr.Zero; } 77Interop.Crypto.X509StoreDestroy(handle); 84get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\X509ExtensionSafeHandles.Unix.cs (2)
19Interop.Crypto.X509ExtensionDestroy(handle); 26get { return handle == IntPtr.Zero; }
System\Net\Quic\Internal\MsQuicSafeHandle.cs (1)
28public override bool IsInvalid => handle == IntPtr.Zero;
System.Net.Security (38)
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.OCSP.cs (2)
107Interop.Crypto.OcspRequestDestroy(handle); 122Interop.Crypto.OcspResponseDestroy(handle);
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Ssl.cs (5)
484get { return handle == IntPtr.Zero; } 509Interop.Ssl.SslSetData(handle, IntPtr.Zero); 514IntPtr h = handle; 525int retVal = Interop.Ssl.SslShutdown(handle); 533retVal = Interop.Ssl.SslShutdown(handle);
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.SslCtx.cs (3)
103get { return handle == IntPtr.Zero; } 145Interop.Ssl.SslCtxSetData(handle, IntPtr.Zero); 161Interop.Ssl.SslCtxDestroy(handle);
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.X509Stack.cs (2)
73Interop.Crypto.RecursiveFreeX509Stack(handle); 80get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.X509StoreCtx.cs (2)
86Interop.Crypto.X509StoreCtxDestroy(handle); 93get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\Asn1SafeHandles.Unix.cs (4)
18Interop.Crypto.Asn1ObjectFree(handle); 25get { return handle == IntPtr.Zero; } 38Interop.Crypto.Asn1OctetStringFree(handle); 45get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\GssSafeHandles.cs (3)
52get { return handle == IntPtr.Zero; } 140get { return handle == IntPtr.Zero; } 165get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeBioHandle.Unix.cs (2)
22IntPtr h = handle; 44return handle == IntPtr.Zero || (_parent != null && _parent.IsInvalid);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeInteriorHandle.cs (1)
38return handle == IntPtr.Zero || (_parent != null && _parent.IsInvalid);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeX509Handles.Unix.cs (7)
23Console.WriteLine($"0x{handle.ToInt64():x} {_stacktrace?.ToString() ?? "no stacktrace..."}"); 37Interop.Crypto.X509Destroy(handle); 44get { return handle == IntPtr.Zero; } 57Interop.Crypto.X509CrlDestroy(handle); 64get { return handle == IntPtr.Zero; } 77Interop.Crypto.X509StoreDestroy(handle); 84get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\X509ExtensionSafeHandles.Unix.cs (2)
19Interop.Crypto.X509ExtensionDestroy(handle); 26get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\System\Net\Security\Unix\SafeDeleteContext.cs (1)
26get { return (IntPtr.Zero == handle); }
System\Net\Security\Pal.Managed\SafeChannelBindingHandle.cs (4)
40IntPtr cbtPrefixPtr = handle + SecChannelBindingSize; 56Marshal.StructureToPtr(channelBindings, handle, true); 59public override bool IsInvalid => handle == IntPtr.Zero; 63Marshal.FreeHGlobal(handle);
System.Net.Sockets (17)
System\Net\Sockets\SafeSocketHandle.cs (4)
127Debug.Fail($"handle:{handle}, error:{exception}"); 141if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"handle:{handle}"); 158Debug.Assert(ExceptionCheck.IsFatal(exception), $"handle:{handle}, error:{exception}"); 166Debug.Assert(ret, $"ReleaseHandle failed. handle:{handle}");
System\Net\Sockets\SafeSocketHandle.Unix.cs (13)
216int fdFlags = Interop.Sys.Fcntl.GetFD(handle); 225Interop.Error err = Interop.Sys.GetSockOpt(handle, SocketOptionLevel.Socket, SocketOptionName.Type, (byte*)&type, &optLen); 232Interop.Sys.Disconnect(handle); 236Interop.Sys.Shutdown(handle, SocketShutdown.Both); 249return SocketPal.GetSocketErrorForErrorCode(CloseHandle(handle)); 254return SocketPal.GetSocketErrorForErrorCode(CloseHandle(handle)); 262if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"handle:{handle} Following 'non-abortive' branch."); 265errorCode = CloseHandle(handle); 273if (Interop.Sys.Fcntl.DangerousSetIsNonBlocking(handle, 0) == 0) 276return SocketPal.GetSocketErrorForErrorCode(CloseHandle(handle)); 289errorCode = Interop.Sys.SetLingerOption(handle, &linger); 293if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"handle:{handle}, setsockopt():{errorCode}"); 301errorCode = CloseHandle(handle);
System.Net.WebSockets (2)
src\runtime\src\libraries\Common\src\System\IO\Compression\ZLibNative.cs (2)
183/// <see cref="ZLibStreamHandle" /> does not actually use its <see cref="SafeHandle.handle" /> field. 249get { return handle == new IntPtr(-1); }
System.Private.CoreLib (16)
src\runtime\src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs (3)
166Interop.Sys.FLock(handle, Interop.Sys.LockOperations.LOCK_UN); // ignore any errors 171return Interop.Sys.Close(handle) == 0; 178long h = (long)handle;
src\runtime\src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeHandleMinusOneIsInvalid.cs (1)
16public override bool IsInvalid => handle == new IntPtr(-1);
src\runtime\src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeHandleZeroOrMinusOneIsInvalid.cs (2)
16public override bool IsInvalid => handle == IntPtr.Zero || handle == new IntPtr(-1);
src\runtime\src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeWaitHandle.Unix.cs (1)
12WaitSubsystem.DeleteHandle(handle);
src\runtime\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\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeHandle.cs (1)
91public IntPtr DangerousGetHandle() => handle;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Security\SecureString.cs (2)
467new Span<byte>((void*)handle, _byteLength).Clear(); 468Marshal.FreeHGlobal(handle);
System.Security.AccessControl (3)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeTokenHandle.cs (3)
30{ return handle == new IntPtr(0) || handle == new IntPtr(-1); } 35return Interop.Kernel32.CloseHandle(handle);
System.Security.Cryptography (34)
Microsoft\Win32\SafeHandles\NCryptSafeHandles.cs (2)
163holderRawHandle == handle && 339ErrorCode errorCode = Interop.NCrypt.NCryptFreeObject(handle);
Microsoft\Win32\SafeHandles\SafePasswordHandle.cs (3)
52Span<char> dest = new Span<char>((void*)handle, spanLen); 77Marshal.ZeroFreeGlobalAllocUnicode(handle); 102return new ReadOnlySpan<char>((char*)handle, Length);
src\runtime\src\libraries\Common\src\Interop\Windows\Advapi32\SafeHashHandle.cs (1)
53bool successfullyFreed = Interop.Advapi32.CryptDestroyHash(handle);
src\runtime\src\libraries\Common\src\Interop\Windows\Advapi32\SafeKeyHandle.cs (1)
88bool successfullyFreed = Interop.Advapi32.CryptDestroyKey(handle);
src\runtime\src\libraries\Common\src\Interop\Windows\Advapi32\SafeProvHandle.cs (1)
118bool successfullyFreed = Interop.Advapi32.CryptReleaseContext(handle, 0);
src\runtime\src\libraries\Common\src\Interop\Windows\BCrypt\Cng.cs (2)
154uint ntStatus = BCryptCloseAlgorithmProvider(handle, 0); 186uint ntStatus = BCryptDestroyKey(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeBCryptAlgorithmHandle.cs (1)
20NTSTATUS ntStatus = Interop.BCrypt.BCryptCloseAlgorithmProvider(handle, 0);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeBCryptHandle.cs (1)
23return handle == IntPtr.Zero;
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeBCryptHashHandle.cs (1)
20NTSTATUS ntStatus = Interop.BCrypt.BCryptDestroyHash(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeBCryptKeyHandle.cs (1)
20NTSTATUS ntStatus = Interop.BCrypt.BCryptDestroyKey(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeBCryptSecretHandle.cs (1)
12NTSTATUS ntStatus = Interop.BCrypt.BCryptDestroySecret(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeCertContextHandle.cs (5)
32SetHandle(_parent.handle); 44CertFreeCertificateContext(handle); 53get { return (CERT_CONTEXT*)handle; } 59CERT_CONTEXT* pCertContext = (CERT_CONTEXT*)handle; 81return CertDuplicateCertificateContext(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeCertContextHandleWithKeyContainerDeletion.cs (1)
18using (SafeCertContextHandle certContext = Interop.Crypt32.CertDuplicateCertificateContext(handle))
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeCertStoreHandle.cs (1)
13bool success = Interop.Crypt32.CertCloseStore(handle, 0);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeChainEngineHandle.cs (1)
29Interop.Crypt32.CertFreeCertificateChainEngine(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeCrypt32Handle.cs (1)
21get { return handle == IntPtr.Zero; }
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeCryptMsgHandle.cs (1)
13bool success = Interop.Crypt32.CryptMsgClose(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeUnicodeStringHandle.cs (3)
38Span<char> dest = new Span<char>(handle.ToPointer(), cch); 48return handle == IntPtr.Zero; 54Marshal.FreeHGlobal(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeX509ChainHandle.cs (1)
25return ChainPal.ReleaseSafeX509ChainHandle(handle);
System\Security\Cryptography\FixedMemoryKeyBox.cs (4)
20internal ReadOnlySpan<byte> DangerousKeySpan => new ReadOnlySpan<byte>((void*)handle, _length); 24CryptographicOperations.ZeroMemory(new Span<byte>((void*)handle, _length)); 25NativeMemory.Free((void*)handle); 29public override bool IsInvalid => handle == IntPtr.Zero;
System\Security\Cryptography\X509Certificates\SafeLocalAllocHandle.cs (1)
23Marshal.FreeHGlobal(handle);
System.Security.Cryptography.Pkcs (12)
Microsoft\Win32\SafeHandles\SafeCertContextHandle.cs (2)
26get { return handle == IntPtr.Zero; } 31Interop.Crypt32.CertFreeCertificateContext(handle); // CertFreeCertificateContext always returns TRUE so no point in checking.
Microsoft\Win32\SafeHandles\SafeCryptMsgHandle.cs (2)
19get { return handle == IntPtr.Zero; } 24bool success = Interop.Crypt32.CryptMsgClose(handle);
Microsoft\Win32\SafeHandles\SafeHeapAllocHandle.cs (2)
42byte* p = (byte*)handle; 49bool success = Interop.Kernel32.HeapFree(s_hHeap, HeapAllocFlags.None, handle);
Microsoft\Win32\SafeHandles\SafeProvOrNCryptKeyHandle.cs (1)
30return handle == IntPtr.Zero;
Microsoft\Win32\SafeHandles\SafeProvOrNCryptKeyHandleUwp.cs (2)
48ErrorCode errorCode = Interop.NCrypt.NCryptFreeObject(handle); 53bool success = Interop.Advapi32.CryptReleaseContext(handle, 0);
src\runtime\src\libraries\Common\src\Interop\Windows\Advapi32\SafeHashHandle.cs (1)
53bool successfullyFreed = Interop.Advapi32.CryptDestroyHash(handle);
src\runtime\src\libraries\Common\src\Interop\Windows\Advapi32\SafeKeyHandle.cs (1)
88bool successfullyFreed = Interop.Advapi32.CryptDestroyKey(handle);
src\runtime\src\libraries\Common\src\Interop\Windows\Advapi32\SafeProvHandle.cs (1)
118bool successfullyFreed = Interop.Advapi32.CryptReleaseContext(handle, 0);
System.Security.Principal.Windows (9)
Microsoft\Win32\SafeHandles\SafeAccessTokenHandle.cs (3)
35return handle == IntPtr.Zero || handle == new IntPtr(-1); 41return Interop.Kernel32.CloseHandle(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLocalAllocHandle.cs (1)
39Marshal.FreeHGlobal(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLsaHandle.cs (2)
19int ntStatus = Interop.SspiCli.LsaDeregisterLogonProcess(handle); 27return handle == IntPtr.Zero;
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLsaMemoryHandle.cs (1)
21return Interop.Advapi32.LsaFreeMemory(handle) == 0;
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLsaPolicyHandle.cs (1)
20return Interop.Advapi32.LsaClose(handle) == 0;
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeLsaReturnBufferHandle.cs (1)
23return Interop.SspiCli.LsaFreeReturnBuffer(handle) >= 0;
System.ServiceProcess.ServiceController (1)
Microsoft\Win32\SafeHandles\SafeServiceHandle.cs (1)
30return Interop.Advapi32.CloseServiceHandle(handle);
System.Speech (5)
Internal\HGlobalSafeHandle.cs (5)
46SetHandle(Marshal.ReAllocHGlobal(handle, (IntPtr)size)); 53return handle; 63return handle == IntPtr.Zero; 76if (handle != IntPtr.Zero) 85Marshal.FreeHGlobal(handle);
System.Text.Encoding.CodePages (2)
Microsoft\Win32\SafeHandles\SafeAllocHHandle.cs (2)
26if (handle != IntPtr.Zero) 28Marshal.FreeHGlobal(handle);
System.Windows.Extensions (7)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeCertContextHandle.cs (5)
32SetHandle(_parent.handle); 44CertFreeCertificateContext(handle); 53get { return (CERT_CONTEXT*)handle; } 59CERT_CONTEXT* pCertContext = (CERT_CONTEXT*)handle; 81return CertDuplicateCertificateContext(handle);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeCertStoreHandle.cs (1)
13bool success = Interop.Crypt32.CertCloseStore(handle, 0);
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeCrypt32Handle.cs (1)
21get { return handle == IntPtr.Zero; }
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\wpf\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);