///////////////////////////////////////////////////////////////////////// // // CMyQueue::OnDeviceIoControl // // This method is called when an IOCTL is sent to the device // // Parameters: // pQueue - pointer to an IO queue // pRequest - pointer to an IO request // ControlCode - The IOCTL to process // InputBufferSizeInBytes - the size of the input buffer // OutputBufferSizeInBytes - the size of the output buffer // ///////////////////////////////////////////////////////////////////////// STDMETHODIMP_ (void) CMyQueue::OnDeviceIoControl( _In_ IWDFIoQueue* pQueue, _In_ IWDFIoRequest* pRequest, _In_ ULONG ControlCode, SIZE_T InputBufferSizeInBytes, SIZE_T OutputBufferSizeInBytes ) { UNREFERENCED_PARAMETER(pQueue); UNREFERENCED_PARAMETER(InputBufferSizeInBytes); UNREFERENCED_PARAMETER(OutputBufferSizeInBytes); DWORD dwWritten = 0; if (IS_WPD_IOCTL(ControlCode)) { m_pParentDevice->ProcessIoControl( pQueue, pRequest, ControlCode, InputBufferSizeInBytes, OutputBufferSizeInBytes, &dwWritten); } else { // Unsupported request pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0); } }
CDefaultQueue::OnDeviceIoControl( _In_ IWDFIoQueue* pQueue, _In_ IWDFIoRequest* pRequest, ULONG ControlCode, SIZE_T InputBufferSizeInBytes, SIZE_T OutputBufferSizeInBytes ) { CComPtr<WpdBaseDriver> pWpdBaseDriver; CComPtr<IWDFDevice> pDevice; HRESULT hr = S_OK; pQueue->GetDevice(&pDevice); hr = GetWpdBaseDriver(pDevice, &pWpdBaseDriver); CHECK_HR(hr, "Failed to get WpdBaseDriver"); if (hr == S_OK) { if (IS_WPD_IOCTL(ControlCode)) { hr = pRequest->ForwardToIoQueue(pWpdBaseDriver->m_pWpdQueue); CHECK_HR(hr, "Failed to forward to WPD queue"); } else if (pWpdBaseDriver->m_pQueueCallback) { pWpdBaseDriver->m_pQueueCallback->OnDeviceIoControl( pQueue, pRequest, ControlCode, InputBufferSizeInBytes, OutputBufferSizeInBytes ); } else { hr = E_UNEXPECTED; CHECK_HR(hr, "Unable to handle IOCTL code '0x%lx'", ControlCode); } } if (FAILED(hr)) pRequest->Complete(hr); return; }
///////////////////////////////////////////////////////////////////////// // // CMyQueue::OnDeviceIoControl // // This method is called when an IOCTL is sent to the device // // Parameters: // pQueue - pointer to an IO queue // pRequest - pointer to an IO request // ControlCode - The IOCTL to process // InputBufferSizeInBytes - the size of the input buffer // OutputBufferSizeInBytes - the size of the output buffer // ///////////////////////////////////////////////////////////////////////// STDMETHODIMP_ (void) CMyQueue::OnDeviceIoControl( _In_ IWDFIoQueue* pQueue, _In_ IWDFIoRequest* pRequest, _In_ ULONG ControlCode, SIZE_T InputBufferSizeInBytes, SIZE_T OutputBufferSizeInBytes ) { UNREFERENCED_PARAMETER(pQueue); UNREFERENCED_PARAMETER(InputBufferSizeInBytes); UNREFERENCED_PARAMETER(OutputBufferSizeInBytes); //Trace(TRACE_LEVEL_INFORMATION, "%!FUNC! Entry"); DWORD dwWritten = 0; if( IS_WPD_IOCTL( ControlCode ) ) { if (FAILED(EnterProcessing(PROCESSING_IQUEUECALLBACKDEVICEIOCONTROL))) { // Unsupported request pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0); } else { m_pParentDevice->ProcessIoControl( pQueue, pRequest, ControlCode, InputBufferSizeInBytes, OutputBufferSizeInBytes, &dwWritten); } // processing in progress ExitProcessing(PROCESSING_IQUEUECALLBACKDEVICEIOCONTROL); } else { // Unsupported request pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0); } }
CQueue::OnDeviceIoControl( /* [in] */ IWDFIoQueue* pQueue, /* [in] */ IWDFIoRequest* pRequest, /* [in] */ ULONG ControlCode, /* [in] */ SIZE_T InputBufferSizeInBytes, /* [in] */ SIZE_T OutputBufferSizeInBytes ) { // // Handle the WPD IOCTL // if (IS_WPD_IOCTL(ControlCode)) { HRESULT hr = S_OK; DWORD dwWritten = 0; BOOL fCompleteRequest = FALSE; hr = m_parentDevice->ProcessIoControl(pQueue, pRequest, ControlCode, InputBufferSizeInBytes, OutputBufferSizeInBytes, &dwWritten, &fCompleteRequest); if (TRUE == fCompleteRequest) { // Complete the request only if Class Extension is ISideShowClassExtension and not ISideShowClassExtension2. pRequest->CompleteWithInformation(hr, dwWritten); } } else { // // We don't handle any other types of IOCTLs. // pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0); } }
CQueue::OnDeviceIoControl( /* [in] */ IWDFIoQueue* pQueue, /* [in] */ IWDFIoRequest* pRequest, /* [in] */ ULONG ControlCode, /* [in] */ SIZE_T InputBufferSizeInBytes, /* [in] */ SIZE_T OutputBufferSizeInBytes ) { UNREFERENCED_PARAMETER(InputBufferSizeInBytes); UNREFERENCED_PARAMETER(OutputBufferSizeInBytes); HRESULT hr = S_OK; DWORD dwBytesWritten = 0; if(IS_WPD_IOCTL(ControlCode)) { BYTE* pInputBuffer = NULL; SIZE_T cbInputBuffer = 0; BYTE* pOutputBuffer = NULL; SIZE_T cbOutputBuffer = 0; ContextMap* pClientContextMap = NULL; CComPtr<IWDFMemory> pMemoryIn; CComPtr<IWDFMemory> pMemoryOut; CComPtr<IWDFDevice> pDevice; CComPtr<IWDFFile> pFileObject; // // Get input memory buffer, the memory object is always returned even if the // underlying buffer is NULL // pRequest->GetInputMemory(&pMemoryIn); pInputBuffer = (BYTE*) pMemoryIn->GetDataBuffer(&cbInputBuffer); // // Get output memory buffer, the memory object is always returned even if the // underlying buffer is NULL // pRequest->GetOutputMemory(&pMemoryOut); pOutputBuffer = (BYTE*) pMemoryOut->GetDataBuffer(&cbOutputBuffer); // Get the Context map for this client pRequest->GetFileObject(&pFileObject); if (pFileObject != NULL) { hr = pFileObject->RetrieveContext((void**)&pClientContextMap); CHECK_HR(hr, "Failed to get Contextmap from WDF File Object"); } if (hr == S_OK) { // Get the device object pQueue->GetDevice(&pDevice ); hr = ProcessWpdMessage(ControlCode, pClientContextMap, pDevice, pInputBuffer, (DWORD)cbInputBuffer, pOutputBuffer, (DWORD)cbOutputBuffer, &dwBytesWritten); } } else { hr = E_UNEXPECTED; CHECK_HR(hr, "Received invalid/unsupported IOCTL code '0x%lx'",ControlCode); } // Complete the request if (hr == S_OK) { pRequest->CompleteWithInformation(hr, dwBytesWritten); } else { pRequest->Complete(hr); } return; }
///////////////////////////////////////////////////////////////////////// // // CMyQueue::OnDeviceIoControl // // This method is called when an IOCTL is sent to the device // // Parameters: // pQueue - pointer to an IO queue // pRequest - pointer to an IO request // ControlCode - The IOCTL to process // InputBufferSizeInBytes - the size of the input buffer // OutputBufferSizeInBytes - the size of the output buffer // ///////////////////////////////////////////////////////////////////////// STDMETHODIMP_ (void) CMyQueue::OnDeviceIoControl( _In_ IWDFIoQueue* pQueue, _In_ IWDFIoRequest* pRequest, _In_ ULONG ControlCode, SIZE_T InputBufferSizeInBytes, SIZE_T OutputBufferSizeInBytes ) { UNREFERENCED_PARAMETER(pQueue); UNREFERENCED_PARAMETER(InputBufferSizeInBytes); UNREFERENCED_PARAMETER(OutputBufferSizeInBytes); //Trace(TRACE_LEVEL_INFORMATION, "%!FUNC! Entry"); DWORD dwWritten = 0; if (IOCTL_GPS_RADIO_MANAGEMENT_GET_RADIO_STATE == ControlCode || IOCTL_GPS_RADIO_MANAGEMENT_GET_PREVIOUS_RADIO_STATE == ControlCode || IOCTL_GPS_RADIO_MANAGEMENT_SET_RADIO_STATE == ControlCode || IOCTL_GPS_RADIO_MANAGEMENT_SET_PREVIOUS_RADIO_STATE == ControlCode ) { #if (NTDDI_VERSION >= NTDDI_WIN8) if (FAILED(EnterProcessing(PROCESSING_IQUEUECALLBACKDEVICEIOCONTROL))) { // Unsupported request pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0); } else { HRESULT hr = m_pParentDevice->ProcessIoControlRadioManagement(pRequest, ControlCode); pRequest->CompleteWithInformation(hr, sizeof(DEVICE_RADIO_STATE)); } // processing in progress ExitProcessing(PROCESSING_IQUEUECALLBACKDEVICEIOCONTROL); #endif } else if( IS_WPD_IOCTL( ControlCode ) ) { if (FAILED(EnterProcessing(PROCESSING_IQUEUECALLBACKDEVICEIOCONTROL))) { // Unsupported request pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0); } else { m_pParentDevice->ProcessIoControl( pQueue, pRequest, ControlCode, InputBufferSizeInBytes, OutputBufferSizeInBytes, &dwWritten); } // processing in progress ExitProcessing(PROCESSING_IQUEUECALLBACKDEVICEIOCONTROL); } else { // Unsupported request pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0); } }