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.