SafeNCryptHandle 类

定义

提供了可被下一代加密技术 (CNG) 对象使用的安全句柄。Provides a safe handle that can be used by Cryptography Next Generation (CNG) objects.

此 API 支持产品基础结构,不能在代码中直接使用。

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
继承
派生
属性

注解

此类会将逻辑打包, 以正确复制和释放这些句柄, 以模拟本机复制。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. 相反, 它依赖于所有重复的句柄来完成, 并将 ref 计数递减为零。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.

构造函数

SafeNCryptHandle()

初始化 SafeNCryptHandle 类的新实例。Initializes a new instance of the SafeNCryptHandle class.

SafeNCryptHandle(IntPtr, SafeHandle)

实例化 SafeNCryptHandle 类的新实例。Instantiates a new instance of the SafeNCryptHandle class.

字段

handle

指定要包装的句柄。Specifies the handle to be wrapped.

(继承自 SafeHandle)

属性

IsClosed

获取一个值,该值指示句柄是否已关闭。Gets a value indicating whether the handle is closed.

(继承自 SafeHandle)
IsInvalid

方法

Close()

标记句柄,以便释放资源。Marks the handle for releasing and freeing resources.

(继承自 SafeHandle)
DangerousAddRef(Boolean)

手动递增 SafeHandle 实例中的引用计数器。Manually increments the reference counter on SafeHandle instances.

(继承自 SafeHandle)
DangerousGetHandle()

返回 handle 字段的值。Returns the value of the handle field.

(继承自 SafeHandle)
DangerousRelease()

手动递减 SafeHandle 实例中的引用计数器。Manually decrements the reference counter on a SafeHandle instance.

(继承自 SafeHandle)
Dispose()

释放 SafeHandle 类使用的所有资源。Releases all resources used by the SafeHandle class.

(继承自 SafeHandle)
Dispose(Boolean)

释放 SafeHandle 类所使用的非托管资源,并指定是否执行常规释放 (Dispose) 操作。Releases the unmanaged resources used by the SafeHandle class specifying whether to perform a normal dispose operation.

(继承自 SafeHandle)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ReleaseHandle()

释放由下一代加密技术 (CNG) 对象使用的句柄。Releases a handle used by a Cryptography Next Generation (CNG) object.

ReleaseNativeHandle()

释放由下一代加密技术 (CNG) 对象使用的本机句柄。Releases a native handle used by a Cryptography Next Generation (CNG) object.

SetHandle(IntPtr)

将句柄设置为预先存在的指定句柄。Sets the handle to the specified pre-existing handle.

(继承自 SafeHandle)
SetHandleAsInvalid()

将句柄标记为不再使用。Marks a handle as no longer used.

(继承自 SafeHandle)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

安全性

SecurityPermission
用于调用非托管代码的权限。for permission to call unmanaged code. 安全操作: InheritanceDemandSecurity action: InheritanceDemand. 关联的枚举:UnmanagedCodeAssociated enumeration: UnmanagedCode

适用于