SafeHandle.DangerousGetHandle-Methode: ()
Veröffentlicht: Oktober 2016
Gibt den Wert des handle-Felds zurück.
Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Syntax
public IntPtr DangerousGetHandle()
public:
IntPtr DangerousGetHandle()
member DangerousGetHandle : unit -> nativeint
Public Function DangerousGetHandle As IntPtr
Rückgabewert
Type: System.IntPtr
Ein IntPtr, der den Wert des handle-Felds darstellt. Wenn das Handle mit SetHandleAsInvalid als ungültig markiert ist, gibt diese Methode dennoch den ursprünglichen Handlewert zurück, bei dem es sich um einen veralteten Wert handeln kann.
Hinweise
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.
Achtung
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.
Sicherheit
for permission to call unmanaged code. Security action: F:System.Security.Permissions.SecurityAction.LinkDemand. Associated enumeration: F:System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode
Versionsinformationen
Universelle Windows-Plattform
Verfügbar seit 8
.NET Framework
Verfügbar seit 2.0
Portierbare Klassenbibliothek
Unterstützt in: portierbare .NET-Plattformen
Silverlight
Verfügbar seit 2.0
Windows Phone Silverlight
Verfügbar seit 7.0
Windows Phone
Verfügbar seit 8.1
Siehe auch
SafeHandle-Klasse
System.Runtime.InteropServices-Namespace
Zurück zum Anfang