Whenever possible, drivers should use framework interfaces for creating, sending, and completing I/O requests, using I/O targets, and interacting with USB devices. The framework interfaces provide additional error checking and parameter validation and implement additional features-such as I/O target state monitoring-that are particularly useful to drivers.
If your driver creates I/O requests, follow these guidelines for accessing the memory objects and underlying buffers in those requests:
Do not attempt to reference the buffer underlying a memory object after the associated I/O request object has been completed.
Allocate I/O buffers at the same time as WDF memory objects for use in asynchronous I/O requests.
Do not complete an I/O request that your driver creates.
KMDF KMDF drivers can reuse WDF request objects. The following additional guidelines apply to reusing such objects:
If the driver reuses a WDF request object, the driver must reinitialize the object by calling WdfRequestReuse before calling a format method to use the object for a new I/O request.
If a KMDF driver reuses a WDF request object that contains a WDF memory object that the driver retrieved from a different request, the driver must call WdfRequestReuse after the new request has completed back to the driver, but before the driver completes the request from which it retrieved the memory object.