Editar

Compartir vía


Overlapped.UnsafePack Method

Definition

Packs the current instance into a NativeOverlapped structure. Does not propagate the calling stack.

Overloads

UnsafePack(IOCompletionCallback)
Obsolete.
Obsolete.
Obsolete.

Packs the current instance into a NativeOverlapped structure specifying the delegate to invoke when the asynchronous I/O operation is complete. Does not propagate the calling stack.

UnsafePack(IOCompletionCallback, Object)

Packs the current instance into a NativeOverlapped structure, specifying the delegate to invoke when the asynchronous I/O operation is complete and the managed object that serves as a buffer. Does not propagate the calling stack.

UnsafePack(IOCompletionCallback)

Source:
Overlapped.cs
Source:
Overlapped.cs
Source:
Overlapped.cs

Caution

This method is not safe. Use UnsafePack (iocb, userData) instead. https://go.microsoft.com/fwlink/?linkid=14202

Caution

This overload is not safe and has been deprecated. Use UnsafePack(IOCompletionCallback?, object?) instead.

Caution

This method is not safe. Use UnsafePack (iocb, userData) instead. http://go.microsoft.com/fwlink/?linkid=14202

Important

This API is not CLS-compliant.

Packs the current instance into a NativeOverlapped structure specifying the delegate to invoke when the asynchronous I/O operation is complete. Does not propagate the calling stack.

public:
 System::Threading::NativeOverlapped* UnsafePack(System::Threading::IOCompletionCallback ^ iocb);
[System.CLSCompliant(false)]
[System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  https://go.microsoft.com/fwlink/?linkid=14202")]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback? iocb);
[System.CLSCompliant(false)]
[System.Obsolete("This overload is not safe and has been deprecated. Use UnsafePack(IOCompletionCallback?, object?) instead.")]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback? iocb);
[System.CLSCompliant(false)]
[System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb);
[System.CLSCompliant(false)]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb);
[System.CLSCompliant(false)]
[System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
[System.Security.SecurityCritical]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb);
[System.CLSCompliant(false)]
[System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  https://go.microsoft.com/fwlink/?linkid=14202")]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb);
[<System.CLSCompliant(false)>]
[<System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  https://go.microsoft.com/fwlink/?linkid=14202")>]
member this.UnsafePack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
[<System.Obsolete("This overload is not safe and has been deprecated. Use UnsafePack(IOCompletionCallback?, object?) instead.")>]
member this.UnsafePack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
[<System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")>]
member this.UnsafePack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
member this.UnsafePack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
[<System.Obsolete("This method is not safe.  Use UnsafePack (iocb, userData) instead.  http://go.microsoft.com/fwlink/?linkid=14202")>]
[<System.Security.SecurityCritical>]
member this.UnsafePack : System.Threading.IOCompletionCallback -> nativeptr<System.Threading.NativeOverlapped>

Parameters

iocb
IOCompletionCallback

An IOCompletionCallback delegate that represents the callback method invoked when the asynchronous I/O operation completes.

Returns

An unmanaged pointer to a NativeOverlapped structure.

Attributes

Exceptions

The current Overlapped has already been packed.

Remarks

The unmanaged pointer returned by this method can be passed to the operating system in overlapped I/O operations. The NativeOverlapped structure is fixed in physical memory until Unpack is called.

The caller is responsible for pinning the buffer. If the application domain is unloaded, however, the handle to the pinned buffer is destroyed and the buffer is released, leaving the I/O operation to write to the freed address. For this reason, it is better to use the UnsafePack(IOCompletionCallback, Object) method overload, in which the runtime pins the buffer.

Caution

Using the UnsafePack method could inadvertently open up a security hole. Code access security bases its permission checks on the permissions of all the callers on the stack. The UnsafePack method does not propagate the calling stack. Malicious code might be able to exploit this to avoid permission checks.

Applies to

UnsafePack(IOCompletionCallback, Object)

Source:
Overlapped.cs
Source:
Overlapped.cs
Source:
Overlapped.cs

Important

This API is not CLS-compliant.

Packs the current instance into a NativeOverlapped structure, specifying the delegate to invoke when the asynchronous I/O operation is complete and the managed object that serves as a buffer. Does not propagate the calling stack.

public:
 System::Threading::NativeOverlapped* UnsafePack(System::Threading::IOCompletionCallback ^ iocb, System::Object ^ userData);
[System.CLSCompliant(false)]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback? iocb, object? userData);
[System.CLSCompliant(false)]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb, object userData);
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb, object userData);
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public System.Threading.NativeOverlapped* UnsafePack (System.Threading.IOCompletionCallback iocb, object userData);
[<System.CLSCompliant(false)>]
member this.UnsafePack : System.Threading.IOCompletionCallback * obj -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.UnsafePack : System.Threading.IOCompletionCallback * obj -> nativeptr<System.Threading.NativeOverlapped>
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Security.SecurityCritical>]
member this.UnsafePack : System.Threading.IOCompletionCallback * obj -> nativeptr<System.Threading.NativeOverlapped>

Parameters

iocb
IOCompletionCallback

An IOCompletionCallback delegate that represents the callback method invoked when the asynchronous I/O operation completes.

userData
Object

An object or array of objects representing the input or output buffer for the operation. Each object represents a buffer, for example an array of bytes.

Returns

An unmanaged pointer to a NativeOverlapped structure.

Attributes

Exceptions

The caller does not have the required permission.

The current Overlapped is already packed.

Remarks

The unmanaged pointer returned by this method can be passed to the operating system in overlapped I/O operations. The NativeOverlapped structure is fixed in physical memory until Unpack is called.

The buffer or buffers specified in userData must be the same as those passed to the unmanaged operating system function that performs the asynchronous I/O.

The runtime pins the buffer or buffers specified inuserData for the duration of the I/O operation. If the application domain is unloaded, the runtime keeps the memory pinned until the I/O operation completes.

Caution

Using the UnsafePack method could inadvertently open up a security hole. Code access security bases its permission checks on the permissions of all the callers on the stack. The UnsafePack method does not propagate the calling stack. Malicious code might be able to exploit this to avoid permission checks.

Applies to