Ejemplo n.º 1
0
        /// <summary>
        /// Clones the specified <see cref="source" />.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <returns><see cref="Native.NdisApi.ETH_REQUEST" />.</returns>
        public Native.NdisApi.ETH_REQUEST CloneEthRequest(ref Native.NdisApi.ETH_REQUEST source)
        {
            var destination = CreateEthRequest();

            CloneEthRequest(ref source, ref destination);
            return(destination);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends the packet to MSTCP or adapter.
        /// </summary>
        /// <param name="ethRequest">The ether request.</param>
        /// <returns><c>true</c> if successful, <c>false</c> otherwise.</returns>
        public bool SendPacket(ref Native.NdisApi.ETH_REQUEST ethRequest)
        {
            unsafe
            {
                var buffer = (Native.NdisApi.INTERMEDIATE_BUFFER_U *)ethRequest._ethPacket._buffer;

                if (buffer->m_dwDeviceFlags == Native.NdisApi.PACKET_FLAG.PACKET_FLAG_ON_SEND)
                {
                    return(SendPacketToAdapter(ref ethRequest));
                }
            }

            return(SendPacketToMstcp(ref ethRequest));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Clones the specified request.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        public void CloneEthRequest(ref Native.NdisApi.ETH_REQUEST source, ref Native.NdisApi.ETH_REQUEST destination)
        {
            destination.hAdapterHandle = source.hAdapterHandle;

            Kernel32.CopyMemory(destination._ethPacket._buffer, source._ethPacket._buffer, (uint)Native.NdisApi.IntermediateBufferSize);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Disposes the specified object.
 /// </summary>
 /// <param name="obj">The object.</param>
 public void DisposeObject(Native.NdisApi.ETH_REQUEST obj)
 {
     _pinnedManagedArrayAllocator.FreeArray(obj._ethPacket._buffer);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Zeroes the specified request.
 /// </summary>
 /// <param name="request">The request.</param>
 public void ZeroEthRequest(ref Native.NdisApi.ETH_REQUEST request)
 {
     request.hAdapterHandle = IntPtr.Zero;
     Kernel32.ZeroMemory(request._ethPacket._buffer, Native.NdisApi.IntermediateBufferSize);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Sends the packet to MSTCP.
 /// </summary>
 /// <param name="ethRequest">The ether request.</param>
 /// <returns><c>true</c> if successful, <c>false</c> otherwise.</returns>
 public bool SendPacketToMstcp(ref Native.NdisApi.ETH_REQUEST ethRequest)
 {
     return(Native.NdisApi.SendPacketToMstcp(Handle, ref ethRequest));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Reads the packet to the specified <see cref="ethRequest" />.
 /// </summary>
 /// <param name="ethRequest">The ether request.</param>
 /// <remarks>The adapter handle needs to be set.</remarks>
 /// <returns><c>true</c> if successful, <c>false</c> otherwise.</returns>
 public bool ReadPacket(ref Native.NdisApi.ETH_REQUEST ethRequest)
 {
     return(Native.NdisApi.ReadPacket(Handle, ref ethRequest));
 }