22 types derived from SafeHandle
Infrastructure.Common (1)
SafeKeychainHandle.cs (1)
13public class SafeKeychainHandle : SafeHandle
Microsoft.AspNetCore.Server.HttpSys (1)
NativeInterop\SafeNativeOverlapped.cs (1)
9internal sealed class SafeNativeOverlapped : SafeHandle
Microsoft.AspNetCore.Server.IIS (1)
Core\NativeSafeHandle.cs (1)
9internal sealed class NativeSafeHandle : SafeHandle, IValueTaskSource<object?>
Microsoft.CodeAnalysis.Workspaces (3)
Storage\SQLite\Interop\SafeSqliteBlobHandle.cs (1)
12internal sealed class SafeSqliteBlobHandle : SafeHandle
Storage\SQLite\Interop\SafeSqliteHandle.cs (1)
12internal sealed class SafeSqliteHandle : SafeHandle
Storage\SQLite\Interop\SafeSqliteStatementHandle.cs (1)
12internal sealed class SafeSqliteStatementHandle : SafeHandle
PresentationCore (2)
MS\Win32\UnsafeNativeMethodsTablet.cs (2)
64internal class RecognizerSafeHandle : SafeHandle 98internal class ContextSafeHandle : SafeHandle
ReachFramework (2)
MS\Internal\Printing\Configuration\SafeWinSpoolPrinterHandle.cs (1)
13internal sealed class SafeWinSpoolPrinterHandle : SafeHandle
PrintConfig\PTProvider.cs (1)
40internal sealed class SafePTProviderHandle : System.Runtime.InteropServices.SafeHandle
System.Data.Odbc (2)
Common\System\Data\ProviderBase\DbBuffer.cs (1)
13internal abstract class DbBuffer : SafeHandle
System\Data\Odbc\OdbcHandle.cs (1)
12internal abstract class OdbcHandle : SafeHandle
System.Private.CoreLib (2)
src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeHandleMinusOneIsInvalid.cs (1)
10public abstract class SafeHandleMinusOneIsInvalid : SafeHandle
src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeHandleZeroOrMinusOneIsInvalid.cs (1)
10public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle
System.Security.Cryptography (1)
artifacts\obj\System.Security.Cryptography\Debug\net10.0\System.Security.Cryptography.notsupported.cs (1)
2729public sealed partial class SafeEvpPKeyHandle : System.Runtime.InteropServices.SafeHandle
System.Security.Principal.Windows (1)
artifacts\obj\System.Security.Principal.Windows\Debug\net10.0\System.Security.Principal.Windows.notsupported.cs (1)
9public sealed partial class SafeAccessTokenHandle : System.Runtime.InteropServices.SafeHandle
System.Windows.Forms.Primitives (1)
Microsoft\Win32\SafeHandles\CoTaskMemSafeHandle.cs (1)
8internal sealed class CoTaskMemSafeHandle : SafeHandle
UIAutomationClient (5)
MS\Internal\Automation\SafeHandles.cs (3)
15internal sealed class SafeNodeHandle : SafeHandle 39internal sealed class SafePatternHandle : SafeHandle 62internal sealed class SafeEventHandle : SafeHandle
System\Windows\Automation\Condition.cs (1)
10internal sealed class SafeConditionMemoryHandle : SafeHandle
System\Windows\Automation\Text\TextRange.cs (1)
17internal sealed class SafeTextRangeHandle : SafeHandle
130 references to SafeHandle
Microsoft.AspNetCore.Cryptography.Internal (3)
CryptoUtil.cs (1)
30public static void AssertSafeHandleIsValid(SafeHandle safeHandle)
UnsafeNativeMethods.cs (2)
297SafeHandle pData, 340SafeHandle pData,
Microsoft.AspNetCore.DataProtection (2)
MemoryProtection.cs (2)
17public static void CryptProtectMemory(SafeHandle pBuffer, uint byteCount) 33public static void CryptUnprotectMemory(SafeHandle pBuffer, uint byteCount)
Microsoft.AspNetCore.Server.HttpSys (15)
NativeInterop\HttpApi.cs (11)
17internal static partial uint HttpReceiveRequestEntityBody(SafeHandle requestQueueHandle, ulong requestId, uint flags, IntPtr pEntityBuffer, uint entityBufferLength, out uint bytesReturned, SafeNativeOverlapped pOverlapped); 20internal static unsafe partial uint HttpReceiveClientCertificate(SafeHandle requestQueueHandle, ulong connectionId, uint flags, Windows.Win32.Networking.HttpServer.HTTP_SSL_CLIENT_CERT_INFO* pSslClientCertInfo, uint sslClientCertInfoSize, uint* pBytesReceived, SafeNativeOverlapped pOverlapped); 23internal static unsafe partial uint HttpReceiveHttpRequest(SafeHandle requestQueueHandle, ulong requestId, uint flags, Windows.Win32.Networking.HttpServer.HTTP_REQUEST_V1* pRequestBuffer, uint requestBufferLength, uint* pBytesReturned, NativeOverlapped* pOverlapped); 26internal static unsafe partial uint HttpSendHttpResponse(SafeHandle requestQueueHandle, ulong requestId, uint flags, Windows.Win32.Networking.HttpServer.HTTP_RESPONSE_V2* pHttpResponse, Windows.Win32.Networking.HttpServer.HTTP_CACHE_POLICY* pCachePolicy, uint* pBytesSent, IntPtr pReserved1, uint Reserved2, SafeNativeOverlapped pOverlapped, IntPtr pLogData); 29internal static unsafe partial uint HttpWaitForDisconnectEx(SafeHandle requestQueueHandle, ulong connectionId, uint reserved, NativeOverlapped* overlapped); 32internal static unsafe partial uint HttpSendResponseEntityBody(SafeHandle requestQueueHandle, ulong requestId, uint flags, ushort entityChunkCount, Windows.Win32.Networking.HttpServer.HTTP_DATA_CHUNK* pEntityChunks, uint* pBytesSent, IntPtr pReserved1, uint Reserved2, SafeNativeOverlapped pOverlapped, IntPtr pLogData); 35internal static partial uint CancelIoEx(SafeHandle handle, SafeNativeOverlapped overlapped); 37internal unsafe delegate uint HttpGetRequestPropertyInvoker(SafeHandle requestQueueHandle, ulong requestId, HTTP_REQUEST_PROPERTY propertyId, 40internal unsafe delegate uint HttpSetRequestPropertyInvoker(SafeHandle requestQueueHandle, ulong requestId, HTTP_REQUEST_PROPERTY propertyId, 55internal static unsafe uint HttpGetRequestProperty(SafeHandle requestQueueHandle, ulong requestId, HTTP_REQUEST_PROPERTY propertyId, 61internal static unsafe uint HttpSetRequestProperty(SafeHandle requestQueueHandle, ulong requestId, HTTP_REQUEST_PROPERTY propertyId,
NativeInterop\RequestQueue.cs (1)
139internal SafeHandle Handle { get; }
RequestProcessing\ClientCertLoader.cs (1)
47internal SafeHandle RequestQueueHandle => _requestContext.Server.RequestQueue.Handle;
RequestProcessing\RequestStream.cs (1)
36private SafeHandle RequestQueueHandle => RequestContext.Server.RequestQueue.Handle;
RequestProcessing\ResponseBody.cs (1)
34private SafeHandle RequestQueueHandle => RequestContext.Server.RequestQueue.Handle;
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (1)
DelegateTests.cs (1)
312unsafe void AssertPermissions(SafeHandle handle)
Microsoft.CodeAnalysis.Workspaces (9)
Shared\Extensions\SafeHandleExtensions.cs (5)
15/// Acquires a lease on a safe handle. The lease increments the reference count of the <see cref="SafeHandle"/> 20/// lease will permanently prevent the underlying <see cref="SafeHandle"/> from being released by the garbage 23/// <param name="handle">The <see cref="SafeHandle"/> to lease.</param> 26public static SafeHandleLease Lease(this SafeHandle handle) 34Debug.Assert(success, $"{nameof(SafeHandle.DangerousAddRef)} does not return when {nameof(success)} is false.");
Shared\Extensions\SafeHandleLease.cs (4)
11/// Represents a lease of a <see cref="SafeHandle"/>. 17private readonly SafeHandle? _handle; 19internal SafeHandleLease(SafeHandle handle) 23/// Releases the <see cref="SafeHandle"/> lease. The behavior of this method is unspecified if called more than
Microsoft.DotNet.RemoteExecutor (2)
MiniDump.cs (2)
40SafeHandle hProcess, 42SafeHandle hFile,
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
721[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.SafeHandle))]
netstandard (1)
netstandard.cs (1)
1728[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.SafeHandle))]
PresentationCore (23)
System\Windows\Input\Cursor.cs (3)
91internal Cursor(SafeHandle cursorHandle ) 142internal SafeHandle Handle 343private SafeHandle _cursorHandle;
System\Windows\InterOp\CursorInteropHelper.cs (2)
40public static Cursor Create(SafeHandle cursorHandle) 61internal static Cursor CriticalCreate(SafeHandle cursorHandle)
System\Windows\Media\Effects\BevelBitmapEffect.cs (2)
27protected override unsafe SafeHandle CreateUnmanagedEffect() 36protected override void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect)
System\Windows\Media\Effects\BitmapEffect.cs (6)
41protected abstract void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect); 48protected abstract unsafe SafeHandle CreateUnmanagedEffect(); 58protected static unsafe void SetValue(SafeHandle effect, string propertyName, object value) 67protected static unsafe SafeHandle /* IMILBitmapEffect */ CreateBitmapEffectOuter() 78protected static unsafe void InitializeBitmapEffect(SafeHandle /*IMILBitmapEffect */ outerObject, 79SafeHandle/* IMILBitmapEffectPrimitive */ innerObject)
System\Windows\Media\Effects\BitmapEffectGroup.cs (2)
33protected override void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect) 42protected override unsafe SafeHandle CreateUnmanagedEffect()
System\Windows\Media\Effects\BlurBitmapEffect.cs (2)
27protected override unsafe SafeHandle CreateUnmanagedEffect() 36protected override void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect)
System\Windows\Media\Effects\DropShadowBitmapEffect.cs (2)
30protected override unsafe SafeHandle CreateUnmanagedEffect() 39protected override void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect)
System\Windows\Media\Effects\embossbitmapeffect.cs (2)
30protected override unsafe SafeHandle CreateUnmanagedEffect() 39protected override void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect)
System\Windows\Media\Effects\OuterGlowBitmapEffect.cs (2)
27protected override unsafe SafeHandle CreateUnmanagedEffect() 36protected override void UpdateUnmanagedPropertyState(SafeHandle unmanagedEffect)
ReachFramework (1)
MS\Internal\Printing\Configuration\HGlobalBuffer.cs (1)
48SafeHandle handle = this.Handle;
System.Formats.Tar (2)
src\libraries\Common\src\Interop\Unix\Interop.IOErrors.cs (1)
95where TSafeHandle : SafeHandle
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Stat.cs (1)
59internal static partial int FStat(SafeHandle fd, out FileStatus output);
System.IO.Compression.ZipFile (2)
src\libraries\Common\src\Interop\Unix\Interop.IOErrors.cs (1)
95where TSafeHandle : SafeHandle
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Stat.cs (1)
59internal static partial int FStat(SafeHandle fd, out FileStatus output);
System.IO.FileSystem.Watcher (4)
src\libraries\Common\src\Interop\Unix\Interop.IOErrors.cs (1)
95where TSafeHandle : SafeHandle
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Poll.cs (1)
31internal static unsafe Error Poll(SafeHandle fd, PollEvents events, int timeout, out PollEvents triggered)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Read.cs (1)
21internal static unsafe partial int Read(SafeHandle fd, byte* buffer, int count);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Stat.cs (1)
59internal static partial int FStat(SafeHandle fd, out FileStatus output);
System.IO.Pipes.AccessControl (1)
artifacts\obj\System.IO.Pipes.AccessControl\Debug\net10.0\System.IO.Pipes.AccessControl.notsupported.cs (1)
39protected internal void Persist(System.Runtime.InteropServices.SafeHandle handle) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_AccessControl); }
System.IO.Ports (4)
src\libraries\Common\src\Interop\Unix\Interop.IOErrors.cs (1)
95where TSafeHandle : SafeHandle
src\libraries\Common\src\Interop\Unix\System.IO.Ports.Native\Interop.Serial.cs (3)
33internal static unsafe partial int Read(SafeHandle fd, byte* buffer, int count); 45internal static unsafe partial int Write(SafeHandle fd, byte* buffer, int bufferSize); 66internal static unsafe Error Poll(SafeHandle fd, PollEvents events, int timeout, out PollEvents triggered)
System.Net.HttpListener (1)
src\libraries\Common\src\System\Net\Logging\NetEventSource.Common.cs (1)
147if (value is SafeHandle handle)
System.Net.Mail (1)
src\libraries\Common\src\System\Net\Logging\NetEventSource.Common.cs (1)
147if (value is SafeHandle handle)
System.Net.Ping (1)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReceiveSocketError.cs (1)
13internal static unsafe partial SocketError ReceiveSocketError(SafeHandle socket, MessageHeader* messageHeader);
System.Private.CoreLib (37)
src\libraries\Common\src\Interop\Unix\Interop.IOErrors.cs (1)
95where TSafeHandle : SafeHandle
src\libraries\Common\src\Interop\Unix\System.Native\Interop.LChflags.cs (1)
21internal static partial int FChflags(SafeHandle fd, uint flags);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.LockFileRegion.cs (1)
18internal static partial int LockFileRegion(SafeHandle fd, long offset, long length, LockType lockType);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.PRead.cs (1)
11internal static unsafe partial int PRead(SafeHandle fd, byte* buffer, int bufferSize, long fileOffset);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.PReadV.cs (1)
11internal static unsafe partial long PReadV(SafeHandle fd, IOVector* vectors, int vectorCount, long fileOffset);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.PWrite.cs (1)
11internal static unsafe partial int PWrite(SafeHandle fd, byte* buffer, int bufferSize, long fileOffset);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.PWriteV.cs (1)
11internal static unsafe partial long PWriteV(SafeHandle fd, IOVector* vectors, int vectorCount, long fileOffset);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Read.cs (1)
21internal static unsafe partial int Read(SafeHandle fd, byte* buffer, int count);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Stat.cs (1)
59internal static partial int FStat(SafeHandle fd, out FileStatus output);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.UTimensat.cs (1)
29internal static unsafe partial int FUTimens(SafeHandle fd, TimeSpec* times);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Write.cs (1)
21internal static unsafe partial int Write(SafeHandle fd, byte* buffer, int bufferSize);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshal.cs (3)
1315/// Initializes the underlying handle of a newly created <see cref="SafeHandle" /> to the provided value. 1317/// <param name="safeHandle">The <see cref="SafeHandle"/> instance to update.</param> 1319public static void InitHandle(SafeHandle safeHandle, IntPtr handle)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\SafeHandleMarshaller.cs (7)
9/// A marshaller for <see cref="SafeHandle"/>-derived types that marshals the handle following the lifetime rules for <see cref="SafeHandle"/>s. 11/// <typeparam name="T">The <see cref="SafeHandle"/>-derived type.</typeparam> 15public static class SafeHandleMarshaller<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] T> where T : SafeHandle 18/// Custom marshaller to marshal a <see cref="SafeHandle"/> as its underlying handle value. 54/// Custom marshaller to marshal a <see cref="SafeHandle"/> as its underlying handle value. 148/// Custom marshaller to marshal a <see cref="SafeHandle"/> as its underlying handle value.
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPool.Unix.cs (1)
103public static bool BindHandle(SafeHandle osHandle) =>
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolBoundHandle.Unix.cs (7)
19private readonly SafeHandle _handle; 22private ThreadPoolBoundHandle(SafeHandle handle) 31/// A <see cref="SafeHandle"/> object that holds the bound operating system handle. 33public SafeHandle Handle => _handle; 40/// A <see cref="SafeHandle"/> object that holds the operating system handle. The 72/// it remains the responsibility of the caller to call <see cref="SafeHandle.Dispose()"/>. 74public static ThreadPoolBoundHandle BindHandle(SafeHandle handle)
src\libraries\System.Private.CoreLib\src\System\Threading\WaitHandleExtensions.cs (2)
14/// <returns>A <see cref="Runtime.InteropServices.SafeHandle"/> representing the native operating system handle.</returns> 26/// <param name="value">A <see cref="Runtime.InteropServices.SafeHandle"/> representing the native operating system handle.</param>
src\System\StubHelpers.cs (6)
508internal static IntPtr ConvertSafeHandleToNative(SafeHandle? handle, ref CleanupWorkListElement? cleanupWorkList) 1292public SafeHandleCleanupWorkListElement(SafeHandle handle) 1297private readonly SafeHandle m_handle; 1330internal static IntPtr AddToCleanupList(ref CleanupWorkListElement? pCleanupWorkList, SafeHandle handle) 1418internal static IntPtr SafeHandleAddRef(SafeHandle pHandle, ref bool success) 1430internal static void SafeHandleRelease(SafeHandle pHandle)
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
688[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.SafeHandle))]
System.Runtime.Handles (1)
System.Runtime.Handles.cs (1)
7[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.SafeHandle))]
System.Runtime.InteropServices (1)
artifacts\obj\System.Runtime.InteropServices\Debug\net10.0\System.Runtime.InteropServices.Forwards.cs (1)
135[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.SafeHandle))]
System.Security.AccessControl (9)
artifacts\obj\System.Security.AccessControl\Debug\net10.0\System.Security.AccessControl.notsupported.cs (9)
325protected NativeObjectSecurity(bool isContainer, System.Security.AccessControl.ResourceType resourceType, System.Runtime.InteropServices.SafeHandle? handle, System.Security.AccessControl.AccessControlSections includeSections) : base (default(bool)) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_AccessControl); } 326protected NativeObjectSecurity(bool isContainer, System.Security.AccessControl.ResourceType resourceType, System.Runtime.InteropServices.SafeHandle? handle, System.Security.AccessControl.AccessControlSections includeSections, System.Security.AccessControl.NativeObjectSecurity.ExceptionFromErrorCode? exceptionFromErrorCode, object? exceptionContext) : base (default(bool)) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_AccessControl); } 330protected sealed override void Persist(System.Runtime.InteropServices.SafeHandle handle, System.Security.AccessControl.AccessControlSections includeSections) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_AccessControl); } 331protected void Persist(System.Runtime.InteropServices.SafeHandle handle, System.Security.AccessControl.AccessControlSections includeSections, object? exceptionContext) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_AccessControl); } 334protected internal delegate System.Exception? ExceptionFromErrorCode(int errorCode, string? name, System.Runtime.InteropServices.SafeHandle? handle, object? context); 398protected virtual void Persist(System.Runtime.InteropServices.SafeHandle handle, System.Security.AccessControl.AccessControlSections includeSections) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_AccessControl); } 418protected ObjectSecurity(bool isContainer, System.Security.AccessControl.ResourceType resourceType, System.Runtime.InteropServices.SafeHandle? safeHandle, System.Security.AccessControl.AccessControlSections includeSections) : base (default(bool), default(System.Security.AccessControl.ResourceType)) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_AccessControl); } 419protected ObjectSecurity(bool isContainer, System.Security.AccessControl.ResourceType resourceType, System.Runtime.InteropServices.SafeHandle? safeHandle, System.Security.AccessControl.AccessControlSections includeSections, System.Security.AccessControl.NativeObjectSecurity.ExceptionFromErrorCode? exceptionFromErrorCode, object? exceptionContext) : base (default(bool), default(System.Security.AccessControl.ResourceType)) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_AccessControl); } 429protected internal void Persist(System.Runtime.InteropServices.SafeHandle handle) { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_AccessControl); }
System.Security.Cryptography (2)
artifacts\obj\System.Security.Cryptography\Debug\net10.0\System.Security.Cryptography.notsupported.cs (2)
14protected SafeNCryptHandle(System.IntPtr handle, System.Runtime.InteropServices.SafeHandle parentHandle) : base (default(bool)) { throw new System.PlatformNotSupportedException(System.SR.SystemSecurityCryptography_PlatformNotSupported); } 23public SafeNCryptKeyHandle(System.IntPtr handle, System.Runtime.InteropServices.SafeHandle parentHandle) { throw new System.PlatformNotSupportedException(System.SR.SystemSecurityCryptography_PlatformNotSupported); }
System.ServiceProcess.ServiceController (1)
artifacts\obj\System.ServiceProcess.ServiceController\Debug\net10.0\System.ServiceProcess.ServiceController.notsupported.cs (1)
72public System.Runtime.InteropServices.SafeHandle ServiceHandle { get { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_ServiceController); } }
UIAutomationTypes (4)
src\Microsoft.DotNet.Wpf\src\Shared\MS\Win32\HandleCollector.cs (4)
26internal static SafeHandle Add(SafeHandle handle, int type) { 65internal static SafeHandle Remove(SafeHandle handle, int type) {