WdfRequestProbeAndLockUserBufferForRead/Write questions

Hello,

I have two questions about the WdfRequestProbeAndLockUserBufferForRead/Write functions.

  1. Do I always need to use the WdfRequestRetrieveUnsafeUserInput/OutputBuffer functions before using the WdfRequestProbeAndLockUserBufferForRead/Write functions? Or can I use for the “IN PVOID Buffer” parameter any pointer to a userspace buffer. (My IoControl consists more than one user buffer pointer). See my thread “MmProbeAndLockPages STATUS_ACCESS_VIOLATION error”.
  2. Can I Use more than one time the WdfRequestProbeAndLockUserBufferForRead functions in the EvtIoInCallerContext and are al these one’s automaticly unlocked when a request is completed.

Kind regards,

Gerard

  1. only if the IOCTL itself is defined as METHOD_NEITHER. If it is small buffer (under a page at a minimum), the top level descriptive buffer should not be method neither. You can use any PVOID buffer you want.
  2. yes, you can probe and lock as many buffers for read/write that you want as limited by available memory for the WDFMEMORY and available system VA for the buffer. Each one is unlocked and unmapped when the request is freed.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@tue.nl
Sent: Thursday, May 15, 2008 6:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] WdfRequestProbeAndLockUserBufferForRead/Write questions

Hello,

I have two questions about the WdfRequestProbeAndLockUserBufferForRead/Write functions.

  1. Do I always need to use the WdfRequestRetrieveUnsafeUserInput/OutputBuffer functions before using the WdfRequestProbeAndLockUserBufferForRead/Write functions? Or can I use for the “IN PVOID Buffer” parameter any pointer to a userspace buffer. (My IoControl consists more than one user buffer pointer). See my thread “MmProbeAndLockPages STATUS_ACCESS_VIOLATION error”.
  2. Can I Use more than one time the WdfRequestProbeAndLockUserBufferForRead functions in the EvtIoInCallerContext and are al these one’s automaticly unlocked when a request is completed.

Kind regards,

Gerard


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

xxxxx@tue.nl wrote:

Hello,

2. Can I Use more than one time the WdfRequestProbeAndLockUserBufferForRead functions in the EvtIoInCallerContext and are al these one’s automaticly unlocked when a request is completed.

Doron Holan wrote:

  1. yes, you can probe and lock as many buffers for read/write that you want as limited by available memory for the WDFMEMORY and available system VA for the buffer. Each one is unlocked and unmapped when the request is freed.

Can I force the mapping and locking to outlive the request by taking
another reference on the WDFMEMORY object? So, specifically, is the
unlock and unmap part of the WDFMEMORY cleanup, as opposed to being part
of the WDFREQUEST cleanup?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

No you cannot do that. The mapping lives for as long as the request does. This is not a generic mechanism for prolonged mappings that last for the lifetime of a file handle, rather it is scoped only to the lifetime of the request. If you ref the p&l WDFMEMORY and complete the WDFREQUEST, KMDF will bugcheck on you indicating the error

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Monday, May 19, 2008 3:23 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] WdfRequestProbeAndLockUserBufferForRead/Write questions

xxxxx@tue.nl wrote:

Hello,

2. Can I Use more than one time the WdfRequestProbeAndLockUserBufferForRead functions in the EvtIoInCallerContext and are al these one’s automaticly unlocked when a request is completed.

Doron Holan wrote:

  1. yes, you can probe and lock as many buffers for read/write that you want as limited by available memory for the WDFMEMORY and available system VA for the buffer. Each one is unlocked and unmapped when the request is freed.

Can I force the mapping and locking to outlive the request by taking
another reference on the WDFMEMORY object? So, specifically, is the
unlock and unmap part of the WDFMEMORY cleanup, as opposed to being part
of the WDFREQUEST cleanup?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


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