Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy

Search Results for "NativeOverlapped" in [All]

Structures

.

public struct NativeOverlapped

.

This structure is already defined as System.Threading.NativeOverlapped in the .NET Framework. It is not supported for the .NET Compact Framework.

kernel32

.

   [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

        [In] ref NativeOverlapped lpOverlapped);

.

        [In] ref System.Threading.NativeOverlapped Overlapped

.

    <[In]()> ByRef lpOverlapped As NativeOverlapped) As Boolean

.

    ByRef Overlapped As System.Threading.NativeOverlapped) As Boolean

.

lpOverlapped - Main use in asynchronous deviceIoControl. NativeOverlapped is the managed version of the structure and use is the same. The difference between NativeOverlapped and Overlapped is managed Struct vs managed Class respectively. NativeOverlapped was more condusive for one-way device driver communication. Convert from Overlapped to NativeOverlapped to make the call, since NativeOverlapped is explicitly defined to mimic the unmanaged Overlapped structure.

.

Pin your NativeOverlapped structure, DeviceIoControl is asynchronous and will write into the overlapped structure upon completion of IO requested. If you NativeOverlapped structure has been moved by garbage collection it will write into the wrong area causing heap corruption.

.

If you want x64 proccessor support, you CANNOT use the System.Threading.NativeOverlapped structure as a ref parameter described above. The overlap structure must be allocated in global memory space. See the section "DeviceIoControl w/x64 support":

.

public bool DeviceIoControl( IntPtr hDevice, uint dwIoControlCode, ref long buffer, int bufferSize, ref NativeOverlapped pOverlapped)

.

        mPtrOverlapped = Marshal.AllocHGlobal(Marshal.SizeOf(typeof (NativeOverlapped)));

.

        // Find the structural starting positions in the NativeOverlapped structure.

.

        mFieldOffset_InternalLow = Marshal.OffsetOf(typeof (NativeOverlapped), "InternalLow").ToInt32();

.

        mFieldOffset_InternalHigh = Marshal.OffsetOf(typeof (NativeOverlapped), "InternalHigh").ToInt32();

.

        mFieldOffset_OffsetLow = Marshal.OffsetOf(typeof (NativeOverlapped), "OffsetLow").ToInt32();

.

        mFieldOffset_OffsetHigh = Marshal.OffsetOf(typeof (NativeOverlapped), "OffsetHigh").ToInt32();

.

        mFieldOffset_EventHandle = Marshal.OffsetOf(typeof (NativeOverlapped), "EventHandle").ToInt32();

.

   [In] ref System.Threading.NativeOverlapped lpOverlapped,

.

Private Shared Function GetOverlappedResult(ByVal hFile As IntPtr, <[In]()> ByRef lpOverlapped As System.Threading.NativeOverlapped, ByRef lpNumberOfBytesTransferred As UInteger, ByVal bWait As Boolean) As Boolean

.

        NativeOverlapped lpOverlapped = new NativeOverlapped();

.

   [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

https://msdn.microsoft.com/en-us/library/system.threading.nativeoverlapped(v=vs.110).aspx

.

   [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

  IntPtr numBytesRead, NativeOverlapped* overlapped);

.

   out uint lpNumberOfBytesRead, [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

    NativeOverlapped *lpOverlapped // should be fixed, if not IntPtr.Zero

.

    ByRef Overlapped As System.Threading.NativeOverlapped) As SafeFileHandle

.
Warning
using IntPtr to pass in a zero leaks memory. Use the NativeOverlapped versions and pass in a null.
.

   uint nNumberOfBytesToRead, [In] ref System.Threading.NativeOverlapped lpOverlapped,

.

   [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

   [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

   [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

  int numBytesToWrite, IntPtr numBytesWritten, NativeOverlapped* lpOverlapped);

.

     [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

     [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

  "Overlapped" = If the file is asynchronous (overlapped), this is an threading.NativeOverlappedStructure specifying where to begin writing at. If the file is synchronous (not overlapped), this must be 0.

.

    ByRef Overlapped As System.Threading.NativeOverlapped) As <MarshalAs(UnmanagedType.Bool)> Boolean

.

If you are passing a System.Threading.NativeOverlapped struct in (for lpOverlapped) then there's no need to also call SetFilePointer or SetFilePointerEx. The offset in the OVERLAPPED structure trumps wherever the file position was previouly set to.

.

   uint nNumberOfBytesToWrite, [In] ref System.Threading.NativeOverlapped lpOverlapped,

.

    UInt32 dwNumberOfBytesTransfered, ref NativeOverlapped lpOverlapped);

.

    uint nNumberOfBytesToWrite, [In] ref NativeOverlapped lpOverlapped,

.

    NativeOverlapped ol = new NativeOverlapped();

.

  private static void callback(UInt32 dwErrorCode, UInt32 dwNumberOfBytesTransfered, ref NativeOverlapped lpOverlapped)

.

   [In] ref System.Threading.NativeOverlapped lpOverlapped);

.

  IntPtr lpReserved, System.Threading.NativeOverlapped* lpOverlapped);

iphlpapi

.

static extern int EnableRouter(IntPtr pHandle, ref System.Threading.NativeOverlapped pOverlapped);

.

static extern int UnenableRouter(ref System.Threading.NativeOverlapped pOverlapped, IntPtr lpdwEnableCount);


 
Access PInvoke.net directly from VS: