DO_DIRECT_IO and MDLs

Hello,

I am writing a device driver which maintains a buffer in nonpaged memory
and uses DO_DIRECT_IO to access user buffers, but I don’t understand how
to use the memory management routines to copy the data over to
Irp->MdlAddress.

I’ve been reading the DDK documentation, Walter Oney’s Windows Driver
Model book, and Jerry Lozano/Art Baker’s Windows 2000 Device Driver book,
but I’m still confused.

Do I really need to user MapTransfer, even though at the stage I’m
servicing the read request I don’t need to talk to a device? If so, how
do I do that?

Any help would be greatly appreciated. (Be kind… I’m a newbie)

L

You would call MmGetSystemAddressForMdlSafe() on the MDL to map it into
system address space. You can then use RtlCopyMemory to copy the data
from your driver’s buffer to the system mapped user-buffer. When you
complete the IRP the buffer will be unmapped for you (since it’s the MDL
the IO system created to go with the IRP)

-p

This posting is provided “AS IS” with no warranties, and confers no
rights

-----Original Message-----
From: Linda Marcellus [mailto:xxxxx@novatel.ca]
Sent: Friday, April 25, 2003 3:35 PM
To: NT Developers Interest List

Hello,

I am writing a device driver which maintains a buffer in nonpaged memory
and uses DO_DIRECT_IO to access user buffers, but I don’t understand how
to use the memory management routines to copy the data over to
Irp->MdlAddress.

I’ve been reading the DDK documentation, Walter Oney’s Windows Driver
Model book, and Jerry Lozano/Art Baker’s Windows 2000 Device Driver
book, but I’m still confused.

Do I really need to user MapTransfer, even though at the stage I’m
servicing the read request I don’t need to talk to a device? If so, how
do I do that?

Any help would be greatly appreciated. (Be kind… I’m a newbie)

L


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks! That worked great.

> I am writing a device driver which maintains a buffer in nonpaged
memory

and uses DO_DIRECT_IO to access user buffers, but I don’t understand
how
to use the memory management routines to copy the data over to
Irp->MdlAddress.

MmGetSystemAddressForMdlSafe, then RtlCopyMemory.

Max

Can I use the same functions in Buffered I/O for the same purpose?

thanks in advance

For buffered IO, the IO system allocates memory in system address space
and copies the data to and from the user-buffers for you. So you don’t
need to call MmGetSystemAddressForMdlSafe since (a) there’s no MDL
involved and (b) you already have a system address.

You can just use RtlCopyMemory to copy the data to or from the system
buffer.

-p

This posting is provided “AS IS” with no warranties, and confers no
rights

-----Original Message-----
From: Sanjeev Manral [mailto:xxxxx@indiatimes.com]
Sent: Monday, April 28, 2003 2:31 AM
To: NT Developers Interest List

Can I use the same functions in Buffered I/O for the same purpose?

thanks in advance


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com