/*++ Routine Description: Called by the framework when it receives Write requests. Arguments: Queue - Default queue handle Request - Handle to the read/write request Length - Length of the data buffer associated with the request. The default property of the queue is to not dispatch zero length read & write requests to the driver and complete is with status success. So we will never get a zero length request. --*/ VOID PSDrv_EvtIoWrite(IN WDFQUEUE Queue, IN WDFREQUEST Request, IN size_t Length) { PFILE_CONTEXT fileContext = NULL; WDFUSBPIPE pipe; WDF_USB_PIPE_INFORMATION pipeInfo; PAGED_CODE(); // Get the pipe associate with this request. fileContext = GetFileContext(WdfRequestGetFileObject(Request)); pipe = fileContext->Pipe; if (pipe == NULL) { PSDrv_DbgPrint(1, ("PSDrv_EvtIoWrite: Invalid pipe!\n")); WdfRequestCompleteWithInformation(Request, STATUS_INVALID_PARAMETER, 0); return; } WDF_USB_PIPE_INFORMATION_INIT(&pipeInfo); WdfUsbTargetPipeGetInformation(pipe, &pipeInfo); if((WdfUsbPipeTypeBulk == pipeInfo.PipeType) || (WdfUsbPipeTypeInterrupt == pipeInfo.PipeType)) { ReadWriteBulkEndPoints(Queue, Request, (ULONG)Length, WdfRequestTypeWrite); return; } else if(WdfUsbPipeTypeIsochronous == pipeInfo.PipeType) { ReadWriteIsochEndPoints(Queue, Request, (ULONG)Length, WdfRequestTypeWrite); return; } return; }
VOID Rio500_EvtIoWrite( _In_ WDFQUEUE Queue, _In_ WDFREQUEST Request, _In_ size_t Length ) /*++ Routine Description: Called by the framework when it receives Write requests. Arguments: Queue - Default queue handle Request - Handle to the read/write request Lenght - Length of the data buffer associated with the request. The default property of the queue is to not dispatch zero lenght read & write requests to the driver and complete is with status success. So we will never get a zero length request. Return Value: VOID --*/ { WDFUSBPIPE pipe; WDF_USB_PIPE_INFORMATION pipeInfo; PAGED_CODE(); // // Get the pipe associate with this request. // WDFDEVICE device = WdfIoQueueGetDevice(Queue); PDEVICE_CONTEXT pDevContext = GetDeviceContext(device); pipe = pDevContext->WritePipe; if (pipe == NULL) { Rio500_DbgPrint(1, ("Write pipe handle is NULL\n")); WdfRequestCompleteWithInformation(Request, STATUS_INVALID_PARAMETER, 0); return; } WDF_USB_PIPE_INFORMATION_INIT(&pipeInfo); WdfUsbTargetPipeGetInformation(pipe, &pipeInfo); if (WdfUsbPipeTypeBulk == pipeInfo.PipeType) { ReadWriteBulkEndPoints(Queue, Request, (ULONG)Length, WdfRequestTypeWrite); return; } Rio500_DbgPrint(1, ("ISO transfer is not supported for buffered I/O transfer\n")); WdfRequestCompleteWithInformation(Request, STATUS_INVALID_DEVICE_REQUEST, 0); }