SafeNCryptHandle SafeNCryptHandle SafeNCryptHandle SafeNCryptHandle Class

Definition

Provides a safe handle that can be used by Cryptography Next Generation (CNG) objects.

This API supports the product infrastructure and is not intended to be used directly from your code.

public ref class SafeNCryptHandle abstract : Microsoft::Win32::SafeHandles::SafeHandleZeroOrMinusOneIsInvalid
[System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)]
public abstract class SafeNCryptHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
type SafeNCryptHandle = class
    inherit SafeHandleZeroOrMinusOneIsInvalid
Public MustInherit Class SafeNCryptHandle
Inherits SafeHandleZeroOrMinusOneIsInvalid
Inheritance
Derived
Attributes

Remarks

This class wraps up the logic to correctly duplicate and free these handles to simulate a native duplication.

Each open handle object can be thought of as being in one of three states:

  • Owner - Created via the marshaler, traditional style safe handle. Notably, only one owner handle exists for a given native handle.
  • Duplicate - Points at a handle in the Holder state. Releasing a handle in the duplicate state results only in decrementing the reference count of the holder, not in a release of the native handle.
  • Holder - Holds onto a native handle and is referenced by handles in the duplicate state. When all duplicate handles are closed, the holder handle releases the native handle. A holder handle will never be finalized, since this results in a race between the finalizers of the duplicate handles and the holder handle. Instead, it relies upon all of the duplicate handles to be finalized and decrement the ref count to zero. Instances of a holder handle should never be referenced by anything but a duplicate handle.

Constructors

SafeNCryptHandle() SafeNCryptHandle() SafeNCryptHandle() SafeNCryptHandle()

Initializes a new instance of the SafeNCryptHandle class.

SafeNCryptHandle(IntPtr, SafeHandle) SafeNCryptHandle(IntPtr, SafeHandle) SafeNCryptHandle(IntPtr, SafeHandle) SafeNCryptHandle(IntPtr, SafeHandle)

Instantiates a new instance of the SafeNCryptHandle class.

Properties

IsClosed IsClosed IsClosed IsClosed

Gets a value indicating whether the handle is closed.

(Inherited from SafeHandle)
IsInvalid IsInvalid IsInvalid IsInvalid

Methods

Close() Close() Close() Close()

Marks the handle for releasing and freeing resources.

(Inherited from SafeHandle)
DangerousAddRef(Boolean) DangerousAddRef(Boolean) DangerousAddRef(Boolean) DangerousAddRef(Boolean)

Manually increments the reference counter on SafeHandle instances.

(Inherited from SafeHandle)
DangerousGetHandle() DangerousGetHandle() DangerousGetHandle() DangerousGetHandle()

Returns the value of the handle field.

(Inherited from SafeHandle)
DangerousRelease() DangerousRelease() DangerousRelease() DangerousRelease()

Manually decrements the reference counter on a SafeHandle instance.

(Inherited from SafeHandle)
Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the SafeHandle class.

(Inherited from SafeHandle)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the unmanaged resources used by the SafeHandle class specifying whether to perform a normal dispose operation.

(Inherited from SafeHandle)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ReleaseHandle() ReleaseHandle() ReleaseHandle() ReleaseHandle()

Releases a handle used by a Cryptography Next Generation (CNG) object.

ReleaseNativeHandle() ReleaseNativeHandle() ReleaseNativeHandle() ReleaseNativeHandle()

Releases a native handle used by a Cryptography Next Generation (CNG) object.

SetHandle(IntPtr) SetHandle(IntPtr) SetHandle(IntPtr) SetHandle(IntPtr)

Sets the handle to the specified pre-existing handle.

(Inherited from SafeHandle)
SetHandleAsInvalid() SetHandleAsInvalid() SetHandleAsInvalid() SetHandleAsInvalid()

Marks a handle as no longer used.

(Inherited from SafeHandle)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Fields

handle handle handle handle

Specifies the handle to be wrapped.

(Inherited from SafeHandle)

Security

SecurityPermission
for permission to call unmanaged code. Security action: InheritanceDemand. Associated enumeration: UnmanagedCode

Applies to