How to "Lock-Down" user memory

Hello,

Here’s a simple question. I want to have an IOCTL which will take a pointer
to some user memory and a ULONG representing the contiguous size of the
memory region… Now how to I lock down the memory and obtain a logical
memory pointer usable by the DMA controller?

Any help will be greatly appreciated…

Thanks,
Michael Uman
Sr. Software Engineer
Sonic Solutions
mailto:xxxxx@sonic.com

> to some user memory and a ULONG representing the contiguous size of the

memory region… Now how to I lock down the memory and obtain a logical
memory pointer usable by the DMA controller?

IoAllocateMdl,
than MmProbeAndLockPages in a __try/__catch block.
Be sure:

  • your app keeps the file handle always open while it works with the device
    (open once, close once to terminate all device access).
  • your CLEANUP handler will unlock and destroy the MDL in question after
    stopping the card’s DMA engine.
    Otherwise, the kernel can BSOD while deleting the process address space
    which has locked pages.

Max

Try to use MmProbeAndLockPages()
with Irp->RequestorMode as AccessMode.
You must call it inside try-except block
and in the case of exception return
STATUS_INVALID_USER_BUFFER.
A MDL allocate using IoAllocateMdl
and free using IoFreeMdl (it does
neccessary unmapping and unlocking
for you transparently).

Paul

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Michael Uman
Sent: Monday, October 02, 2000 8:48 PM
To: NT Developers Interest List
Subject: [ntdev] How to “Lock-Down” user memory

Hello,

Here’s a simple question. I want to have an IOCTL which will take a
pointer
to some user memory and a ULONG representing the contiguous size of the
memory region… Now how to I lock down the memory and obtain a logical
memory pointer usable by the DMA controller?

Any help will be greatly appreciated…

Thanks,
Michael Uman
Sr. Software Engineer
Sonic Solutions
mailto:xxxxx@sonic.com


You are currently subscribed to ntdev as: xxxxx@compelson.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

Assuming that your data buffer is less than 64MB then you should change the
IOCTL method to METHOD_IN_DIRECT or METHOD_OUT_DIRECT. Redefine the IOCTL
structure to not include a pointer to the data. You can still include the
size. You send the IOCTL structure as the input buffer and a pointer to the
data buffer as the output buffer. The OS will then construct the appropriate
MDL to describe the output buffer. Note that the output buffer for
METHOD_*_DIRECT can be used for data transfer in either direction.
Confusing, but true.

Mark Roddy
xxxxx@hollistech.com
www.hollistech.com
WindowsNT Windows 2000 Consulting Services

-----Original Message-----
From: Michael Uman [mailto:xxxxx@sonic.com]
Sent: Monday, October 02, 2000 2:48 PM
To: NT Developers Interest List
Subject: [ntdev] How to “Lock-Down” user memory

Hello,

Here’s a simple question. I want to have an IOCTL which will
take a pointer
to some user memory and a ULONG representing the contiguous
size of the
memory region… Now how to I lock down the memory and
obtain a logical
memory pointer usable by the DMA controller?

Any help will be greatly appreciated…

Thanks,
Michael Uman
Sr. Software Engineer
Sonic Solutions
mailto:xxxxx@sonic.com


You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

There was an article which exactly talks about this in WDJ March 1996 issue
(this is for NT though)

-----Original Message-----
From: Michael Uman [mailto:xxxxx@sonic.com]
Sent: Monday, October 02, 2000 11:48 AM
To: NT Developers Interest List
Subject: [ntdev] How to “Lock-Down” user memory

Hello,

Here’s a simple question. I want to have an IOCTL which will take a pointer
to some user memory and a ULONG representing the contiguous size of the
memory region… Now how to I lock down the memory and obtain a logical
memory pointer usable by the DMA controller?

Any help will be greatly appreciated…

Thanks,
Michael Uman
Sr. Software Engineer
Sonic Solutions
mailto:xxxxx@sonic.com


You are currently subscribed to ntdev as: xxxxx@ami.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)