// wdfmemory.h
PVOID WdfMemoryGetBuffer(
[in] WDFMEMORY Memory,
[out, optional] size_t *BufferSize
);
View the official Windows Driver Kit DDI reference
No description available.
[Applies to KMDF and UMDF]
The WdfMemoryGetBuffer method returns a pointer to the buffer that is associated with a specified memory object.
Memory
[in]A handle to a framework memory object.
BufferSize
[out, optional]A pointer to a location that receives the size, in bytes, of the memory buffer. This parameter is optional and can be NULL.
WdfMemoryGetBuffer returns a pointer to the memory buffer.
A bug check occurs if the driver supplies an invalid object handle.
For more information about framework memory objects, see Using Memory Buffers.
WdfMemoryGetBuffer can be called at any IRQL.
The following code example is based on the EvtUsbTargetPipeReadComplete callback function in the kmdf_fx2 sample driver. The example obtains the buffer that is associated with the memory object that the callback function receives. The example copies data from the buffer into device object context space that the driver has defined.
VOID
OsrFxEvtUsbInterruptPipeReadComplete(
WDFUSBPIPE Pipe,
WDFMEMORY Buffer,
size_t NumBytesTransferred,
WDFCONTEXT Context
)
{
PUCHAR switchState = NULL;
WDFDEVICE device;
PDEVICE_CONTEXT pDeviceContext = Context;
device = WdfObjectContextGetObject(pDeviceContext);
switchState = WdfMemoryGetBuffer(Buffer, NULL);
pDeviceContext->CurrentSwitchState = *switchState;
}