none
UMDF loop execution RRS feed

  • Question

  • Hi All:

    I have a problem that the request will loop execution as follow:

    I just set the start request to cancel because of the STATUS_PENDING. 

    00000011 winxp 2952 2096 0 1 01\01\1601-08:13:00:393 CMyDevice::CreateInstanceAndInitialize Entry
    00000012 winxp 2952 2096 0 2 01\01\1601-08:13:00:393 CMyDevice::Initialize Entry
    00000013 winxp 2952 2096 0 3 01\01\1601-08:13:00:393 CMyDevice::Initialize Exit
    00000014 winxp 2952 2096 0 4 01\01\1601-08:13:00:393 CMyDevice::CreateInstanceAndInitialize Exit
    00000015 winxp 2952 2096 0 5 01\01\1601-08:13:00:393 CMyDevice::Configure Entry
    00000016 winxp 2952 2096 0 6 01\01\1601-08:13:00:393 CMyIoQueue::CreateInstanceAndInitialize Entry
    00000017 winxp 2952 2096 0 7 01\01\1601-08:13:00:393 CMyIoQueue::Initialize Entry
    00000018 winxp 2952 2096 0 8 01\01\1601-08:13:00:393 CMyIoQueue::Initialize Exit
    00000019 winxp 2952 2096 0 9 01\01\1601-08:13:00:393 CMyIoQueue::CreateInstanceAndInitialize Exit
    00000020 winxp 2952 2096 0 10 01\01\1601-08:13:00:393 CMyDevice::Configure Exit
    00000002 winxp 2952 2096 1 11 01\01\1601-08:13:00:399 CMyDevice::OnPrepareHardware Entry
    00000003 winxp 2952 2096 1 12 01\01\1601-08:13:00:399 CMyDevice::OnPrepareHardware Device name \\.\UMDFCtrlDev-5884b906-3374-11e2-ba3a-001d60b59a58
    00000004 winxp 2952 2096 1 13 01\01\1601-08:13:00:399 CMyDevice::CreateUsbIoTargets Entry
    00000005 winxp 2952 2096 1 14 01\01\1601-08:13:00:399 CMyDevice::CreateUsbIoTargets Exit
    00000006 winxp 2952 2096 1 15 01\01\1601-08:13:00:399 CMyDevice::SendControlTransferSynchronously Entry
    00000007 winxp 2952 2096 1 16 01\01\1601-08:13:00:400 CMyDevice::SendControlTransferSynchronously Entry
    00000021 winxp 2952 2096 0 17 01\01\1601-08:13:00:404 CMyDevice::OnPrepareHardware Exit
    00000022 winxp 2952 3524 0 18 01\01\1601-08:13:00:405 CMyDevice::OnReaderCompletion Entry
    00000023 winxp 2952 3988 0 19 01\01\1601-08:13:00:406 CMyIoQueue::OnDeviceIoControl Entry
    00000024 winxp 2952 3988 0 20 01\01\1601-08:13:00:406 CMyIoQueue::OnDeviceIoControl Exit
    00000025 winxp 2952 3472 0 21 01\01\1601-08:13:00:406 CMyIoQueue::OnDeviceIoControl Entry
    00000008 winxp 2952 3472 1 22 01\01\1601-08:13:00:406 CMyIoQueue::OnDeviceIoControl Exit
    00000026 winxp 2952 3988 0 23 01\01\1601-08:13:00:406 CMyIoQueue::OnDeviceIoControl Entry
    00000027 winxp 2952 3988 0 24 01\01\1601-08:13:00:406 CMyIoQueue::OnDeviceIoControl Exit
    00000028 winxp 2952 3472 0 25 01\01\1601-08:13:00:406 CMyIoQueue::OnDeviceIoControl Entry
    00000029 winxp 2952 3472 0 26 01\01\1601-08:13:00:406 CMyIoQueue::OnDeviceIoControl Exit
    00000009 winxp 2952 3988 1 27 01\01\1601-08:13:00:408 CMyIoQueue::OnDeviceIoControl Entry
    00000010 winxp 2952 3988 1 28 01\01\1601-08:13:00:408 CMyIoQueue::OnDeviceIoControl Exit
    00000030 winxp 2148 2204 1 29 01\01\1601-08:13:01:394 CMyDevice::CreateInstanceAndInitialize Entry
    00000031 winxp 2148 2204 1 30 01\01\1601-08:13:01:394 CMyDevice::Initialize Entry
    00000041 winxp 2148 2204 0 31 01\01\1601-08:13:01:394 CMyDevice::Initialize Exit
    00000042 winxp 2148 2204 0 32 01\01\1601-08:13:01:394 CMyDevice::CreateInstanceAndInitialize Exit
    00000043 winxp 2148 2204 0 33 01\01\1601-08:13:01:394 CMyDevice::Configure Entry
    00000044 winxp 2148 2204 0 34 01\01\1601-08:13:01:394 CMyIoQueue::CreateInstanceAndInitialize Entry
    00000045 winxp 2148 2204 0 35 01\01\1601-08:13:01:394 CMyIoQueue::Initialize Entry
    00000046 winxp 2148 2204 0 36 01\01\1601-08:13:01:394 CMyIoQueue::Initialize Exit
    00000047 winxp 2148 2204 0 37 01\01\1601-08:13:01:394 CMyIoQueue::CreateInstanceAndInitialize Exit
    00000048 winxp 2148 2204 0 38 01\01\1601-08:13:01:394 CMyDevice::Configure Exit
    00000032 winxp 2148 2204 1 39 01\01\1601-08:13:01:430 CMyDevice::OnPrepareHardware Entry
    00000033 winxp 2148 2204 1 40 01\01\1601-08:13:01:430 CMyDevice::OnPrepareHardware Device name \\.\UMDFCtrlDev-5884b909-3374-11e2-ba3a-001d60b59a58
    00000034 winxp 2148 2204 1 41 01\01\1601-08:13:01:430 CMyDevice::CreateUsbIoTargets Entry
    00000035 winxp 2148 2204 1 42 01\01\1601-08:13:01:430 CMyDevice::CreateUsbIoTargets Exit
    00000036 winxp 2148 2204 1 43 01\01\1601-08:13:01:430 CMyDevice::SendControlTransferSynchronously Entry
    00000037 winxp 2148 2204 1 44 01\01\1601-08:13:01:431 CMyDevice::SendControlTransferSynchronously Entry
    00000049 winxp 2148 2204 0 45 01\01\1601-08:13:01:435 CMyDevice::OnPrepareHardware Exit
    00000038 winxp 2148 3572 1 46 01\01\1601-08:13:01:437 CMyIoQueue::OnDeviceIoControl Entry
    00000039 winxp 2148 3572 1 47 01\01\1601-08:13:01:437 CMyIoQueue::OnDeviceIoControl Exit
    00000050 winxp 2148 3332 0 48 01\01\1601-08:13:01:437 CMyIoQueue::OnDeviceIoControl Entry
    00000051 winxp 2148 3332 0 49 01\01\1601-08:13:01:437 CMyIoQueue::OnDeviceIoControl Exit
    00000052 winxp 2148 3572 0 50 01\01\1601-08:13:01:437 CMyIoQueue::OnDeviceIoControl Entry
    00000053 winxp 2148 3572 0 51 01\01\1601-08:13:01:437 CMyIoQueue::OnDeviceIoControl Exit
    00000054 winxp 2148 3332 0 52 01\01\1601-08:13:01:437 CMyIoQueue::OnDeviceIoControl Entry
    00000055 winxp 2148 3332 0 53 01\01\1601-08:13:01:437 CMyIoQueue::OnDeviceIoControl Exit
    00000056 winxp 2148 3572 0 54 01\01\1601-08:13:01:438 CMyIoQueue::OnDeviceIoControl Entry
    00000057 winxp 2148 3572 0 55 01\01\1601-08:13:01:438 CMyIoQueue::OnDeviceIoControl Exit
    00000040 winxp 2148 3036 1 56 01\01\1601-08:13:01:440 CMyDevice::OnReaderCompletion Entry
    00000072 winxp 2000 2672 0 57 01\01\1601-08:13:02:402 CMyDevice::CreateInstanceAndInitialize Entry
    00000073 winxp 2000 2672 0 58 01\01\1601-08:13:02:402 CMyDevice::Initialize Entry
    00000074 winxp 2000 2672 0 59 01\01\1601-08:13:02:402 CMyDevice::Initialize Exit
    00000075 winxp 2000 2672 0 60 01\01\1601-08:13:02:402 CMyDevice::CreateInstanceAndInitialize Exit
    00000076 winxp 2000 2672 0 61 01\01\1601-08:13:02:402 CMyDevice::Configure Entry
    00000077 winxp 2000 2672 0 62 01\01\1601-08:13:02:402 CMyIoQueue::CreateInstanceAndInitialize Entry
    00000078 winxp 2000 2672 0 63 01\01\1601-08:13:02:402 CMyIoQueue::Initialize Entry
    00000079 winxp 2000 2672 0 64 01\01\1601-08:13:02:402 CMyIoQueue::Initialize Exit
    00000080 winxp 2000 2672 0 65 01\01\1601-08:13:02:402 CMyIoQueue::CreateInstanceAndInitialize Exit
    00000081 winxp 2000 2672 0 66 01\01\1601-08:13:02:402 CMyDevice::Configure Exit
    00000058 winxp 2000 2672 1 67 01\01\1601-08:13:02:437 CMyDevice::OnPrepareHardware Entry
    00000059 winxp 2000 2672 1 68 01\01\1601-08:13:02:437 CMyDevice::OnPrepareHardware Device name \\.\UMDFCtrlDev-5884b90c-3374-11e2-ba3a-001d60b59a58
    00000060 winxp 2000 2672 1 69 01\01\1601-08:13:02:437 CMyDevice::CreateUsbIoTargets Entry
    00000061 winxp 2000 2672 1 70 01\01\1601-08:13:02:437 CMyDevice::CreateUsbIoTargets Exit
    00000062 winxp 2000 2672 1 71 01\01\1601-08:13:02:437 CMyDevice::SendControlTransferSynchronously Entry
    00000082 winxp 2000 2672 0 72 01\01\1601-08:13:02:438 CMyDevice::SendControlTransferSynchronously Entry
    00000063 winxp 2000 2672 1 73 01\01\1601-08:13:02:442 CMyDevice::OnPrepareHardware Exit
    00000064 winxp 2000 340 1 74 01\01\1601-08:13:02:444 CMyIoQueue::OnDeviceIoControl Entry
    00000065 winxp 2000 340 1 75 01\01\1601-08:13:02:444 CMyIoQueue::OnDeviceIoControl Exit
    00000083 winxp 2000 3116 0 76 01\01\1601-08:13:02:444 CMyIoQueue::OnDeviceIoControl Entry
    00000084 winxp 2000 3116 0 77 01\01\1601-08:13:02:444 CMyIoQueue::OnDeviceIoControl Exit
    00000066 winxp 2000 340 1 78 01\01\1601-08:13:02:444 CMyIoQueue::OnDeviceIoControl Entry
    00000067 winxp 2000 340 1 79 01\01\1601-08:13:02:444 CMyIoQueue::OnDeviceIoControl Exit
    00000085 winxp 2000 3116 0 80 01\01\1601-08:13:02:444 CMyIoQueue::OnDeviceIoControl Entry
    00000068 winxp 2000 3116 1 81 01\01\1601-08:13:02:444 CMyIoQueue::OnDeviceIoControl Exit
    00000069 winxp 2000 340 1 82 01\01\1601-08:13:02:445 CMyIoQueue::OnDeviceIoControl Entry
    00000070 winxp 2000 340 1 83 01\01\1601-08:13:02:445 CMyIoQueue::OnDeviceIoControl Exit

    Wednesday, November 21, 2012 2:51 AM

Answers

  • there is currently no way for you to use smclib in umdf right now. the Microsoft provided driver is umdf+winusb, but that doesn't mean your solution has to/can be umdf at this time.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Doron Holan [MSFT] Wednesday, November 21, 2012 5:06 PM
    • Unmarked as answer by wu330 Thursday, November 22, 2012 1:05 AM
    • Marked as answer by wu330 Thursday, November 22, 2012 1:05 AM
    Wednesday, November 21, 2012 5:06 PM
  • OnCancel is called when the sender cancels the Io. The sender is not canceling in your case. Overall, you need to take a step back. You are grasping at everything and not understanding the differences between wdm and wdf. Start with the kmdf smart card sample, that will gel you understand Io processing differences

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by wu330 Monday, November 26, 2012 1:28 AM
    Friday, November 23, 2012 7:14 PM

All replies

  • Show us your code, but as a guess you are probably not putting the request into a queue or completing it before exiting you OnDeviceIoControl routine.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Wednesday, November 21, 2012 2:54 AM
  • You need to provide your code.  As a guess I suspect you are not queueing your request or completing it in you OnDeviceIoControl routine.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Wednesday, November 21, 2012 2:56 AM
  •  

     Donald D.Burn, Thank you for your reply

    The last hr = STATUS_PENDING 

    My code as follow:

    VOID
    STDMETHODCALLTYPE
    CMyIoQueue::OnDeviceIoControl(
        __in IWDFIoQueue *FxQueue,
        __in IWDFIoRequest *FxRequest,
        __in ULONG ControlCode,
        __in SIZE_T InputBufferSizeInBytes,
        __in SIZE_T OutputBufferSizeInBytes
        )
    {
        UNREFERENCED_PARAMETER(FxQueue);
        UNREFERENCED_PARAMETER(ControlCode);
        UNREFERENCED_PARAMETER(InputBufferSizeInBytes);
        UNREFERENCED_PARAMETER(OutputBufferSizeInBytes);

        HRESULT hr = S_OK;

        TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_QUEUE, "%!FUNC! Entry");

        if (m_MyDevice == NULL) {
            // We don't have pointer to device object
            TraceEvents(TRACE_LEVEL_ERROR, 
                       TRACE_QUEUE, 
                       "%!FUNC!NULL pointer to device object.");
            hr = E_POINTER;
    FxRequest->Complete(hr);
            goto Exit;
        }

    hr = m_MyDevice->MyDeviceControl( FxRequest, 
                                 ControlCode,
     InputBufferSizeInBytes,
     OutputBufferSizeInBytes);

    if( STATUS_PENDING == hr)
    {
       if(ControlCode == IOCTL_SMARTCARD_IS_PRESENT)
    {
           IRequestCallbackCancel *callback;
    m_MyDevice->QueryInterface(__uuidof(IRequestCallbackCancel),(void**)&callback);
    FxRequest->MarkCancelable(callback);
    callback->Release();
    goto exit;
    }
    }
        FxRequest->Complete(hr);

    Exit:

        TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_QUEUE, "%!FUNC! Exit");

        return;

    }


    Wednesday, November 21, 2012 3:10 AM
  • i don't think STATUS_PENDING is a valid HRESULT value.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, November 21, 2012 3:38 AM
  • STATUS_PENDING is the status which MyDeviceControl return. 

    Under WDM, I found when status=STATUS_PENDING(0x00000103) ,the driver will exit. so I FxRequest->MarkCancelable(callback);

    Wednesday, November 21, 2012 3:56 AM
  • you are highly confused. pending is not an error, it means the is in progress and the request is owned by the driver you sent the request to. MarkCancelable does not cancel the sent request, it adds a cancel routine to the request. but this is only valid if you own the request (ie you have not sent it to another driver). post the code for MyDeviceControl()

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, November 21, 2012 4:00 AM
  • HRESULT
    CScardDevice::ScardDeviceControl(IWDFIoRequest *FxRequest,
                                    __in ULONG ControlCode,
    __in SIZE_T InputBufferSizeInBytes,
    __in SIZE_T OutputBufferSizeInBytes)
    {
    UNREFERENCED_PARAMETER(InputBufferSizeInBytes);
    UNREFERENCED_PARAMETER(OutputBufferSizeInBytes);

    HRESULT       hr = S_OK;
    IWDFMemory    *ifxMemory = NULL;
    IWDFMemory    *ofxMemory = NULL;
    PBYTE         pInBuf = NULL;
        SIZE_T        nInBufSize = 0;
    PBYTE         pOutBuf = NULL;
    SIZE_T        nOutBufSize = 0;
    SIZE_T        lReturnLen = 0;

    FxRequest->GetInputMemory( &ifxMemory );
    pInBuf = (BYTE*)ifxMemory->GetDataBuffer( &nInBufSize );
    FxRequest->GetOutputMemory( &ofxMemory );
    pOutBuf = (BYTE*)ofxMemory->GetDataBuffer( &nOutBufSize );

    hr = UmdfDeviceControl(&(m_pdx->SmartcardExtension), ControlCode, pInBuf, nInBufSize,
                               pOutBuf, nOutBufSize, &lReturnLen);

    DriverSafeRelease(ifxMemory);
    DriverSafeRelease(ofxMemory);

    if(hr == STATUS_PENDING)
    {
    lReturnLen = 0;
    if(ControlCode == IOCTL_SMARTCARD_IS_PRESENT)
    {
          return hr;
    }
    }

    FxRequest->CompleteWithInformation(hr, lReturnLen);

    return hr;
    }

    NTSTATUS
    CScardDevice::UmdfDeviceControl(
        PSMARTCARD_EXTENSION SmartcardExtension,
        DWORD dwIoControlCode,
        PBYTE pInBuf,
        DWORD nInBufSize,
        PBYTE pOutBuf,
        DWORD nOutBufSize,
        PDWORD pBytesReturned
        )
    {

        NTSTATUS status = STATUS_SUCCESS;

        ASSERT(SmartcardExtension != NULL);

        if (SmartcardExtension == NULL) 
        {
            return STATUS_INVALID_PARAMETER;
        }

        if (status == STATUS_SUCCESS) 
    {
            if (pBytesReturned) 
            {
                // Default number of bytes returned
                * pBytesReturned = 0;
            }

            switch (dwIoControlCode) 
    {
                //
                // We have to check for _IS_ABSENT and _IS_PRESENT first, 
                // since these are (the only allowed) asynchronous requests
                //
                case IOCTL_SMARTCARD_IS_ABSENT:
                case IOCTL_SMARTCARD_IS_PRESENT:

                    // WinCE: only support synchronous version for now
                    if (dwIoControlCode == IOCTL_SMARTCARD_IS_ABSENT) 
                    {
                        //
                        // If the card is already (or still) absent, we can return immediatly.
                        // Otherwise we must statrt event tracking.
                        // 
                        if (SmartcardExtension->ReaderCapabilities.CurrentState > SCARD_ABSENT) 
                        {
    status = STATUS_PENDING;
                        }
                    } 
                    else 
                    {
                        //
                        // If the card is already (or still) present, we can return immediatly.
                        // Otherwise we must statrt event tracking.
                        // 
                        if (SmartcardExtension->ReaderCapabilities.CurrentState <= SCARD_ABSENT) 
                        {
                            status = STATUS_PENDING;
                        }
                    }
                    break;
                default:
                    // Check if buffers are properly allocated
                    ASSERT(SmartcardExtension->SmartcardRequest.Buffer);
                    ASSERT(SmartcardExtension->SmartcardReply.Buffer);
        
                    // Get major io control code
                    SmartcardExtension->MajorIoControlCode = dwIoControlCode;

                    if (pInBuf) 
                    {
                        //
                        // Transfer minor io control code, even if it doesn't make sense for
                        // this particular major code
                        //
                        SmartcardExtension->MinorIoControlCode = (nInBufSize >= sizeof(ULONG)) ? *(PULONG) (pInBuf) : 0;

                        // Lock memory and save pointer to and length of request buffer
                        // WinCE: dont need to lock
                        SmartcardExtension->IoRequest.RequestBuffer = (PUCHAR) pInBuf;
                        SmartcardExtension->IoRequest.RequestBufferLength = nInBufSize;
                    } 
                    else
                    {
                        SmartcardExtension->IoRequest.RequestBuffer = NULL;
                        SmartcardExtension->IoRequest.RequestBufferLength = 0;
                    }

                    if (pOutBuf) 
                    {
                        // Lock memory an save pointer to and length of reply buffer
                        SmartcardExtension->IoRequest.ReplyBuffer = (PUCHAR) pOutBuf;
                        SmartcardExtension->IoRequest.ReplyBufferLength = nOutBufSize;

                    } 
                    else 
                    {
                        SmartcardExtension->IoRequest.ReplyBuffer = NULL;
                        SmartcardExtension->IoRequest.ReplyBufferLength = 0;
                    }

                    SmartcardExtension->IoRequest.Information = pBytesReturned;
                    
                    // Process the ioctl-request
                    status = SMCDeviceIoControl(SmartcardExtension);   

                    ASSERT (status != STATUS_PENDING);

                    break;
            }
        }                               

        if (status != STATUS_SUCCESS)
        {
            SetLastError(MapNtStatusToWinError(status));
        }
        
        return status;
    }

    Wednesday, November 21, 2012 4:17 AM
  • i see, so you are trying to port the wince version of smclib to work in your umdf driver. unless you have a lot of experience in both umdf and smart cards, you have a very steep learning curve. also, i am 99% sure the licence for wince does NOT allow you to make a derivative work of the source and port it to windows.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, November 21, 2012 5:20 AM
  • So is there any lib that I can use under UMDF which is for SmartCard?

    Because I found after Vista ,the Smartcard driver which microsoft provided is using UMDF+winusb

    Wednesday, November 21, 2012 5:37 AM
  • I really want to develop this UMDF driver. Could you tell me a way that I can do?

    Thank you.

    Wednesday, November 21, 2012 5:49 AM
  • there is currently no way for you to use smclib in umdf right now. the Microsoft provided driver is umdf+winusb, but that doesn't mean your solution has to/can be umdf at this time.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Doron Holan [MSFT] Wednesday, November 21, 2012 5:06 PM
    • Unmarked as answer by wu330 Thursday, November 22, 2012 1:05 AM
    • Marked as answer by wu330 Thursday, November 22, 2012 1:05 AM
    Wednesday, November 21, 2012 5:06 PM
  • As you said "have a lot of experience in both umdf and smartcards", I think I don't have it now. My work is to change our WDM code to UMDF. Under WDM, we used some function which from SMCLIB.

    SmartcardDeviceControl,SmartcardInitializeCardCapabilities,SmartcardInitialize,SmartcardExit. 

    I check many information which downloaded from MSDN, And it say UMDF can used for smartcard reader form v1.9 . 

    And use this project http://www.codeproject.com/Articles/134010/An-UMDF-Driver-for-a-Virtual-Smart-Card-Reader,  I found I can use the API ScardListReaders. ScardConnect. ScardControl. so I thought I can use UMDF for smartcard.

    How do you think about this?

    And can you tell me how to do with status=STATUS_PENDING? I found under KMDF there have a function can pend IRP, and in the book Developing.Drivers.with.the.Windows.Driver.Foundation. It said about this status is just under KMDF.



    • Edited by wu330 Thursday, November 22, 2012 1:26 AM add infor
    Thursday, November 22, 2012 1:07 AM
  • you can't use the scard APIs in the umdf smart card driver, that is an inversion of functionality since your driver provides the data to these APIs.  the example you refer to on codeplex is pretty complete for what you want to do without using smclib at all. rip out all of the pipe stuff and just communicate with your device directly.

    as for STATUS_PENDING, you are highly confused. take a step back and learn to understand the umdf and kmdf architecture. In KMDF/UMDF ALL io is pended and STATUS_PENDING is always returned to the caller. This is why your io dispatch routine returns no value. WDM is not like this, in WDM you have the choice to complete it synchronously OR pend.  In KMDF/UMDF it is always pended and when you want to complete the request, just call the complete API. when you want to keep it pended, do nothing. if you want to keept it pended and cancelable, mark it cancelable. 


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, November 22, 2012 2:15 AM
  • I mean I can develop a application to use ScardListReaders. ScardConnect. ScardControl. And it can send data.

    About the pending status. you mean I can do nothing with the request?

    Sorry maybe I thought error. I think I should set this request to the queue, and then return STATUS_PENDING.
    • Edited by wu330 Thursday, November 22, 2012 2:44 AM
    Thursday, November 22, 2012 2:34 AM
  • the request is already in the queue, pending has already been returned to the caller. all you optionally have to do is set a cancel routine so the caller can cancel the io.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, November 22, 2012 7:54 AM
  • I use this way to pend this request.

    But it also loop execution.


    if(hr == STATUS_PENDING)
    {
    m_RequestForPending = FxRequest;
    IRequestCallbackCancel *callback;
    QueryInterface(__uuidof(IRequestCallbackCancel),(void**)&callback);
    FxRequest->MarkCancelable(callback);
    callback->Release();
    return S_OK;
    }

    And I have a question about the IRequestCallbackCancel, I Query the interface,But it will not do OnCancel routine. Did it match with IRequestCallbackCancel ?

    VOID 
    CScardDevice::OnCancel(
    IWDFIoRequest* FxRequest
    )
    {
    TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DEVICE, "%!FUNC! Entry");
    if (FxRequest == m_RequestForPending) 
    {
       m_RequestForPending=NULL;
    }
        FxRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_CANCELLED), 0);
    return;
    }

    Thursday, November 22, 2012 10:20 AM
  • I forget to say that the STATUS_PENDING is which I return in my function.

    Because In WDM I found this function will return STATUS_PENDING, So I return this status.

    Thursday, November 22, 2012 10:40 AM
  • OnCancel is called when the sender cancels the Io. The sender is not canceling in your case. Overall, you need to take a step back. You are grasping at everything and not understanding the differences between wdm and wdf. Start with the kmdf smart card sample, that will gel you understand Io processing differences

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by wu330 Monday, November 26, 2012 1:28 AM
    Friday, November 23, 2012 7:14 PM
  • Thank you for your reply.

    Monday, November 26, 2012 1:28 AM