A scant 7 days (and 8ish hours) from now I will hopefully be tripping the fiber light fantastic. I've been dying to get my hands on FiOS for a long while. More so after my wife had her business cable line installed at the house (she's a virtual worker for an insurance company); a 26Mbps down, 5Mbps up Mississippi River of Internet goodness...*tingly shiver*.
Okay enough babbling, I had mentioned two posts ago about how UMDF didn't allow for you to use specific functions for completion routines. I figured if you read through my missive about FiOS you should get a cookie or something. Since I haven't mastered my cookie teleportation device and projectile cookie delivery is still a bug I have to work out of my product-a-pult system, I'll drop some more sample code for you guys and gals and Wookiees to chew on.
A few notes here;
I'm using the context to just throw the I/O Control code around for giggles. There is a method within the IWDFIoRequest interface to get the control code if you want to use the context value for something else.
Since IWDFIoRequest has pretty much all the data buffers I would generally need for completion anyway, the context parameter really was just there to be used for something. And in some weird effort to just make things run a little bit faster, I avoided maybe one clock tick by not calling GetDeviceIoControlParameters. Yes, I'm crazy.
void CVDevParallelQueue::OnCompletion ( __in IWDFIoRequest* pWdfRequest, __in IWDFIoTarget* pIoTarget, __in IWDFRequestCompletionParams* pParams, __in PVOID pContext) /*++ Routine Description: Base request completion and completion dispatch routine. Arguments: pWdfRequest - current request. pIoTarget - current I/O Target. pParams - Completion params. pContext - completion context. Return Value: VOID --*/ { ULONG ControlCode; HRESULT hr = pParams->GetCompletionStatus (); UNREFERENCED_PARAMETER (pIoTarget); if (FAILED (hr)) { pWdfRequest->Complete (hr); return; } if (NULL != pContext) { ControlCode = (ULONG) pContext; switch (ControlCode) { // // These are place holder functions to demonstrate // a method for dispatching to specific completion routines // case IOCTL_ALLOCATE_ADDRESS_RANGE: { this->OnAllocateAddrRangeCompletion (pWdfRequest, pParams); } break; case IOCTL_FREE_ADDRESS_RANGE: { this->OnFreeAddrRangeCompletion (pWdfRequest, pParams); } break; default: { pWdfRequest->Complete (hr); } break; } // switch } else { // // if we get here, we should just complete the request // with its current status. // pWdfRequest->Complete (hr); } return; }
*Currently playing - Buddy Holly, Well... All Right (Alt. Ver. 1)