How to lock the user buffer in to physical memory?

My file system driver catched the IRP_MJ_WRITE action. And I got a valid Irp->UserBuffer , which length 4177 bytes. ( the Irp->MdlAddress is NULL )

But I can access only the front 0~4095 byte of the UserBuffer. And BOSD if my code access the bytes behind 4095. In windbg I can see the memory content only 0~4095. Behind that was fill with ‘?’ .

I try to use IoAllocateMdl to build a mdl , and use MmProbeAndLockPages to lock them in to physics memory. But MmProbeAndLockPages threw a exception.

I am sure my irql is PASSIVE_LEVEL , and my AccessMode is UserMode.
I am sure the buffer is correct and valid ( because the .exe is a test application, and i am the writer ).

How can I lock all the buff in to physical memory?

Make a breakpoint in this case. Repro it, stop on a breakpoint, and step down to xxxLockUserBuffer in the FSD. Will it fail? if no - with what arguments it calls MDL-related functions?


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntfsd…
> My file system driver catched the IRP_MJ_WRITE action. And I got a valid Irp->UserBuffer , which length 4177 bytes. ( the Irp->MdlAddress is NULL )
>
> But I can access only the front 0~4095 byte of the UserBuffer. And BOSD if my code access the bytes behind 4095. In windbg I can see the memory content only 0~4095. Behind that was fill with ‘?’ .
>
> I try to use IoAllocateMdl to build a mdl , and use MmProbeAndLockPages to lock them in to physics memory. But MmProbeAndLockPages threw a exception.
>
> I am sure my irql is PASSIVE_LEVEL , and my AccessMode is UserMode.
> I am sure the buffer is correct and valid ( because the .exe is a test application, and i am the writer ).
>
> How can I lock all the buff in to physical memory?
>

:slight_smile:
sorry, my .exe made a mistake. The buffer was not valid.
Thanks Maxim.