Go read about NDIS_BUFFER structures. These are MDLs but the NDIS
documentation (the ‘legacy’ NDIS5 area) has good guidance on how to treat
chains of NDIS_BUFFERs (MDL Chains).
Then, you can forget all that and cheat by calling
TdiCopyBufferToMdl() and TdiCopyMdlToBuffer() ![:slight_smile: :slight_smile:](/images/emoji/twitter/slight_smile.png?v=12)
But really, you ought to understand the underpinnings of the MDL, what it
describes, and how they are chained together in the network world.
NdisQueryBufferSafe() -> MmGetSystemAddressForMdlSafe()
That is pretty much what you need to do it yourself. Keep in mind that the
data may span multiple segments described by MDLs chained together. The
buffer is not necessarily contiguous. Clever parsers will only copy data
to a staging buffer when the data needs to be contiguous and is *not*
already contiguous in a single buffer (described by a single MDL somewhere
in the chain).
Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@g2microsystems.com
Sent: Tuesday, April 07, 2009 9:39 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Reading data out of an MDL in OnReceiveFrom event
Hi all,
Sorry for my ignorance and thanks for the help of everyone on these forums,
but I am successfully getting OnReceiveFrom events and want to read the data
stored in the provided PWSK_DATAGRAM_INDICATION which gives me a WSK_BUF
which in turn has an PMDL.
Now I am uncertain how MDLs work and I’ve learnt I can’t just use
MmGetMdlVirtualAddress() to get a pointer to the data (which is only 3
bytes).
What is the best way copy the 3 bytes out of the MDL into another buffer?
Thanks
Nik
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer