Windows 7 - NdisQueryMdl - Get data into char buffer for processing

Asked By Devang on 27-Dec-08 05:34 AM
Hi

I want data in NET_BUFFER for further processing in my project.
How can I copy the data in NET_BUFFER to character buffer?


Thanks

Regards,
D V




Pavel A. replied on 27-Dec-08 06:32 PM
So what do you have:  MDL or NET_BUFFER?
MDL is same as NDIS_BUFFER, but NET_BUFFER is different.

Each MDL (or NDIS_BUFFER) is a single array of data,
NdisQueryMdl gets the start address and length of the array.
Once you get the start address and length, just
do memcpy (a.k.a. NdisMoveMemory).
For a NET_BUFFER, you have to follow chain of it's MDLs.

--PA
Devang replied on 07-Jan-09 11:47 PM
Thanks for your reply.
It helped me a lot in understanding Mdl and NET_BUFFER.

Can you help me regarding droping packets (NET_BUFFER_LIST).
If certain criteria does not matches in packets, I want to drop those
packets.
I am using filter driver sample(ndislwf) in WinDDK.
What changes should I make in following functions?

-- FilterSendNetBufferLists
-- FilterReceiveNetBufferLists

Thanks

Regards,
D V
Pavel A. replied on 30-Dec-08 06:09 AM
For outgoing packets: in FilterSendNetBufferLists,
you go thru the list and find packets you want to drop.

AFAIK, each NetBuffer is a L2 packet; also, all NetBuffers
in a single list should be sent by same protocol driver, to same
destination ip and port.

If you find a packet (= NetBuffer) to drop, create a new NBL
(since you can't modify the NBL passed by the protocol driver),
add to it the remaining NBs and send this down.
Suspend the original send operation until the lower
driver completes your NBL, then complete the original send
operation.
Something along these lines.

Regards,
--PA