Compartir a través de


Método SafeHandle.DangerousGetHandle ()

 

Publicado: octubre de 2016

Devuelve el valor del campo handle.

Espacio de nombres:   System.Runtime.InteropServices
Ensamblado:  mscorlib (en mscorlib.dll)

Sintaxis

public IntPtr DangerousGetHandle()
public:
IntPtr DangerousGetHandle()
member DangerousGetHandle : unit -> nativeint
Public Function DangerousGetHandle As IntPtr

Valor devuelto

Type: System.IntPtr

Un IntPtr que representa el valor del campo handle. Si el identificador se marcó como no válido con SetHandleAsInvalid, este método devolverá el valor del identificador original, que puede ser un valor obsoleto.

Comentarios

You can use this method to retrieve the actual handle value from an instance of the T:System.Runtime.InteropServices.SafeHandle derived class. This method is needed for backwards compatibility because many properties in the .NET Framework return IntPtr handle types. IntPtr handle types are platform-specific types used to represent a pointer or a handle.

Advertencia

Using the M:System.Runtime.InteropServices.SafeHandle.DangerousGetHandle method can pose security risks because, if the handle has been marked as invalid with M:System.Runtime.InteropServices.SafeHandle.SetHandleAsInvalid, M:System.Runtime.InteropServices.SafeHandle.DangerousGetHandle still returns the original, potentially stale handle value. The returned handle can also be recycled at any point. At best, this means the handle might suddenly stop working. At worst, if the handle or the resource that the handle represents is exposed to untrusted code, this can lead to a recycling security attack on the reused or returned handle. For example, an untrusted caller can query data on the handle just returned and receive information for an entirely unrelated resource. See the M:System.Runtime.InteropServices.SafeHandle.DangerousAddRef(System.Boolean@) and the M:System.Runtime.InteropServices.SafeHandle.DangerousRelease methods for more information about using the M:System.Runtime.InteropServices.SafeHandle.DangerousGetHandle methodsafely.

Seguridad

SecurityPermission

for permission to call unmanaged code. Security action: F:System.Security.Permissions.SecurityAction.LinkDemand. Associated enumeration: F:System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode

Información de versión

Plataforma universal de Windows
Disponible desde 8
.NET Framework
Disponible desde 2.0
Biblioteca de clases portable
Se admite en: plataformas portátiles de .NET
Silverlight
Disponible desde 2.0
Windows Phone Silverlight
Disponible desde 7.0
Windows Phone
Disponible desde 8.1

Ver también

Clase SafeHandle
Espacio de nombres System.Runtime.InteropServices

Volver al principio