/// <summary> /// This function is equivalent to /// <seealso cref="WinDivertRecv(IntPtr, WinDivertBuffer, ref WinDivertAddress)" /> except /// that it supports overlapped I/O via the lpOverlapped parameter. /// </summary> /// <param name="handle"> /// A valid WinDivert handle created by <seealso cref="WinDivertOpen(string, WinDivertLayer, short, WinDivertOpenFlags)" /> /// </param> /// <param name="packet"> /// A buffer for the captured packet. /// </param> /// <param name="flags"> /// Reserved, set to zero. /// </param> /// <param name="address"> /// The <seealso cref="WinDivertAddress" /> of the captured packet. /// </param> /// <param name="lpOverlapped"> /// An optional <seealso cref="NativeOverlapped" /> instance. /// </param> /// <returns> /// TRUE if a packet was successfully received, or FALSE otherwise. Use /// <seealso cref="Marshal.GetLastWin32Error" /> to get the reason. The error code /// ERROR_IO_PENDING indicates that the overlapped operation has been successfully initiated /// and that completion will be indicated at a later time. All other codes indicate an error. /// </returns> public static bool WinDivertRecvEx(IntPtr handle, WinDivertBuffer packet, uint flags, ref WinDivertAddress address, ref NativeOverlapped lpOverlapped) { fixed(WinDivertAddress *pAddress = &address) { uint readLen = 0; // Presently, flags is simply "reserved" var result = WinDivertNative.WinDivertRecvEx(handle, packet.BufferPointer, (uint)packet.Length, 0, ref address, ref readLen, ref lpOverlapped); return(result); } }
/// <summary> /// This function is equivalent to /// <seealso cref="WinDivertRecv(IntPtr, WinDivertBuffer, ref WinDivertAddress, ref uint)" /> /// except that it supports overlapped I/O via the lpOverlapped parameter. /// </summary> /// <param name="handle"> /// A valid WinDivert handle created by <seealso cref="WinDivertOpen(string, WinDivertLayer, short, WinDivertOpenFlags)" /> /// </param> /// <param name="packet"> /// A buffer for the captured packet. /// </param> /// <param name="flags"> /// Reserved, set to zero. /// </param> /// <param name="address"> /// The <seealso cref="WinDivertAddress" /> of the captured packet. /// </param> /// <param name="readLen"> /// The total number of bytes written to packet. /// </param> /// <param name="lpOverlapped"> /// An optional <seealso cref="NativeOverlapped" /> instance. /// </param> /// <returns> /// TRUE if a packet was successfully received, or FALSE otherwise. Use /// <seealso cref="Marshal.GetLastWin32Error" /> to get the reason. The error code /// ERROR_IO_PENDING indicates that the overlapped operation has been successfully initiated /// and that completion will be indicated at a later time. All other codes indicate an error. /// </returns> public static bool WinDivertRecvEx(IntPtr handle, ref WinDivertBuffer packet, uint flags, ref WinDivertAddress address, ref NativeOverlapped lpOverlapped) { return WinDivertNative.WinDivertRecvEx(handle, packet.BufferPointer, packet.Length, flags, ref address, ref packet.Length, ref lpOverlapped); }