Clone of ETH_REQUEST

Home Forums Discussions Support Clone of ETH_REQUEST

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10980
    donnykwan
    Participant

      In example PassThru, after

      while (Ndisapi.ReadPacket(driverPtr, ref request))

      I want to make a copy of request (ETH_REQUEST) and pass it in the following calls:

      if (buffer.m_dwDeviceFlags == Ndisapi.PACKET_FLAG_ON_SEND)
      Ndisapi.SendPacketToAdapter(driverPtr, ref request);
      else
      Ndisapi.SendPacketToMstcp(driverPtr, ref request);

      Here is the my code to make the copy:


      INTERMEDIATE_BUFFER bufferCopy = new INTERMEDIATE_BUFFER();
      bufferCopy.m_8021q = buffer.m_8021q;
      bufferCopy.m_dwDeviceFlags = buffer.m_dwDeviceFlags;
      bufferCopy.m_FilterID = buffer.m_FilterID;
      bufferCopy.m_Flags = buffer.m_Flags;
      bufferCopy.m_IBuffer = buffer.m_IBuffer.ToArray();
      bufferCopy.m_Length = buffer.m_Length;
      bufferCopy.m_qLink = buffer.m_qLink;
      bufferCopy.m_Reserved = buffer.m_Reserved.ToArray();
      var bufferPtrCopy = Marshal.AllocHGlobal(Marshal.SizeOf(bufferCopy));
      var requestCopy = new ETH_REQUEST();
      requestCopy.hAdapterHandle = adapters.m_nAdapterHandle[adapterIndex];
      requestCopy.EthPacket.Buffer = bufferPtrCopy;

      But it does not work. What’s wrong in my code?

      Thank you.

      #10981
      Vadim Smirnov
      Keymaster

        For C# (and other .NET languages) it is recommended to use .NET C++/CLI class library (source code available on GitHub).

        The TestDotNet project (more advanced version of PassThru) demonstrates the usage of the above-mentioned class library.

        #10982
        donnykwan
        Participant

          Thank you Vadim.

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.