Επεξεργασία

Κοινή χρήση μέσω


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
public ref class SafeNCryptHandle abstract : System::Runtime::InteropServices::SafeHandle
public abstract class SafeNCryptHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
public abstract class SafeNCryptHandle : System.Runtime.InteropServices.SafeHandle
[System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)]
public abstract class SafeNCryptHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
type SafeNCryptHandle = class
    inherit SafeHandleZeroOrMinusOneIsInvalid
type SafeNCryptHandle = class
    inherit SafeHandle
[<System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)>]
type SafeNCryptHandle = class
    inherit SafeHandleZeroOrMinusOneIsInvalid
Public MustInherit Class SafeNCryptHandle
Inherits SafeHandleZeroOrMinusOneIsInvalid
Public MustInherit Class SafeNCryptHandle
Inherits SafeHandle
Inheritance
Inheritance
SafeNCryptHandle
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()

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

Initializes a new instance of the SafeNCryptHandle class.

SafeNCryptHandle(IntPtr, SafeHandle)

Instantiates a new instance of the SafeNCryptHandle class.

Fields

handle

Specifies the handle to be wrapped.

(Inherited from SafeHandle)

Properties

IsClosed

Gets a value indicating whether the handle is closed.

(Inherited from SafeHandle)
IsInvalid

Gets a value that indicates whether the handle is invalid.

IsInvalid

Gets a value that indicates whether the handle is invalid.

(Inherited from SafeHandleZeroOrMinusOneIsInvalid)

Methods

Close()

Marks the handle for releasing and freeing resources.

(Inherited from SafeHandle)
DangerousAddRef(Boolean)

Manually increments the reference counter on SafeHandle instances.

(Inherited from SafeHandle)
DangerousGetHandle()

Returns the value of the handle field.

(Inherited from SafeHandle)
DangerousRelease()

Manually decrements the reference counter on a SafeHandle instance.

(Inherited from SafeHandle)
Dispose()

Releases all resources used by the SafeHandle class.

(Inherited from SafeHandle)
Dispose(Boolean)

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

(Inherited from SafeHandle)
Equals(Object)

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

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ReleaseHandle()

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

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

ReleaseNativeHandle()

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

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

SetHandle(IntPtr)

Sets the handle to the specified pre-existing handle.

(Inherited from SafeHandle)
SetHandleAsInvalid()

Marks a handle as no longer used.

(Inherited from SafeHandle)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to