Closed frankzha closed 5 years ago
NdisApi.RawPacket has a property named Data (array of bytes) and PacketDotNet.Packet has a read only property named Bytes (array of bytes). It is enough to assign one to another. Note to set checksum flags if packet was modified but checksums were not recalculated.
In the example "TestDotNet.csproj", you demoed to get PacketDotNet.Packet from RawPacket by calling:
Packet p = Packet.ParsePacket(LinkLayers.Ethernet, packet.Data);
My scenario is that after I get the RawPacket, i need to modify its content. I would like to use PacketDotNet.Packet to modify the content because PacketDotNet provides definition of various packets, such as TCPPacket, UdpPacket, etc.
So after I have PacketDotNet.Packet instance object ready, how can I construct RawPacket based on PacketDotNet.Packet (TCP, UDP, etc) so that i can send RawPacket to below?
ndisapi.SendPacketToMstcp(adapterList[index - 1].Handle, packet); or ndisapi.SendPacketToAdapter(adapterList[index - 1].Handle, packet);