Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Sending multiple asynchronous read requests from NDIS driver to WDF driver but blocked at first only

Shashi140Shashi140 Member Posts: 4

Hi,

NDIS Driver need to submit multiple WDFReadrequests to wdfdriver. All these requests need to be submitted in asynchronous IO . First request is being received at wdf bus driver.
Below is the behavior observed
1. Wdfrequestsend is blocked and control is not coming back even though it is submitted asynchronously.
2. A bus driver is able to receive the request but its not completed. It will be completed later.
3. Since the call is not returning on NDIS side , no furthermore requests are submitted to queue.

status = WdfIoTargetOpen(Adapter->UsbTarget,&openParams);
if (!NT_SUCCESS(status))
{
    WdfObjectDelete(Adapter->UsbTarget);
    DEBUGP(MP_ERROR,"Failed to open SPB target - %!STATUS!",status);
    goto Exit;
}

//
// Create two requests - one for read and one for write.
//
WDF_OBJECT_ATTRIBUTES_INIT(&requestAttributes);
// requestAttributes.ParentObject = Adapter->UsbTarget;
status = WdfRequestCreate(&requestAttributes, Adapter->UsbTarget, &Request);
if (!NT_SUCCESS(status)) {
DEBUGP(MP_ERROR, "%s %d Failed to create Request\n", func, LINE);
goto Exit;
}

status = WdfMemoryCreatePreallocated(WDF_NO_OBJECT_ATTRIBUTES,pRcb,sizeof(RCB),&InputMem);
if (!NT_SUCCESS(status)) {
DEBUGP(MP_ERROR, "%s %d Failed to create Memory\n", func, LINE);
goto exit_first;
}

status = WdfIoTargetFormatRequestForRead(Adapter->UsbTarget,Request,InputMem,NULL, NULL); // OutputBufferOffset
if (!NT_SUCCESS(status)) {
KdPrint(("WdfIoTargetFormatRequestForRead failed 0x%x\n", status));
goto exit_first;
}

WDF_REQUEST_SEND_OPTIONS_INIT(&sendOptions, 0);
WdfRequestSetCompletionRoutine(Request,ReadRequestCompletionRoutine,Adapter);
WdfObjectReference(Request);
if (!WdfRequestSend(Request, Adapter->UsbTarget, &sendOptions)) {
status = WdfRequestGetStatus(Request);
WdfRequestCompleteWithInformation(Request, status, 0);
DEBUGP(MP_ERROR, "%s %d Failed to send Request status:%x\n", func, LINE, status);
}

Is there anything i am missing ..?

Comments

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,735
    Simplest first step to debug is to break into the debugger and see which function/component is blocking.
    d
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,445

    Just as a side note, your error cleanup is wrong. Never call WdfRequestComplete on a request that you created. After fetching the status, you just do WdfObjectDelete..

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 January 2023 Live, Online
Developing Minifilters 20 March 2023 Live, Online
Internals & Software Drivers 17 April 2023 Live, Online
Writing WDF Drivers 22 May 2023 Live, Online