Hi,
My program is a bus driver. In it, there are 2 different ways to process the receiving by URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER requests. For bulk pipes, just processes them directly in the dispatch routine and this way works fine. The other is to create a system thread, by PsCreateSystemThread, and then pass the IRP to the thread. After that, the dispatch routine marks the specified IRP by IoMarkIrpPending and return STATUS_PENDING. The problem is that the created thread can not store the received data to the buffer coming from the IRP. The actual situation is what the client received are all the same, returned from DeviceIoControl, no matter what my program filled. I think the buffer, specified in struct _URB_BULK_OR_INTERRUPT_TRANSFER, should be valid when it was filled because the system was not crashed. The completion is the same for these 2 ways, setting IRP->IoStatus.Status and then calling IoCompleteRequest(IRP,IO_NO_INCREMENT).
Could someone point out what’s wrong in my implementation? Thanks.
Without source code determining the problem would be difficult. You did
of course remember to set the Irp->IoStatus.Information field to the
correct number of bytes transferred, right?
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Wednesday, April 18, 2007 4:18 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem Encountered When Using a System Thread for
Device Polling
Hi,
My program is a bus driver. In it, there are 2 different ways to process
the receiving by URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER requests. For
bulk pipes, just processes them directly in the dispatch routine and
this way works fine. The other is to create a system thread, by
PsCreateSystemThread, and then pass the IRP to the thread. After that,
the dispatch routine marks the specified IRP by IoMarkIrpPending and
return STATUS_PENDING. The problem is that the created thread can not
store the received data to the buffer coming from the IRP. The actual
situation is what the client received are all the same, returned from
DeviceIoControl, no matter what my program filled. I think the buffer,
specified in struct _URB_BULK_OR_INTERRUPT_TRANSFER, should be valid
when it was filled because the system was not crashed. The completion is
the same for these 2 ways, setting IRP->IoStatus.Status and then calling
IoCompleteRequest(IRP,IO_NO_INCREMENT).
Could someone point out what’s wrong in my implementation? Thanks.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Dear Mark,
Instead of storing the number of bytes transferred into Irp->IoStatus.Information for URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER requests, I do it into the field “TransferBufferLength” in struct _URB_BULK_OR_INTERRUPT_TRANSFER. I think I need to do some tests. Thanks for your help.
TransferBufferLength is correct for sending URBs to the USB bus driver. From your description of your problem it was not clear to me if you were talking about the dispatch side or the completion side, and if you were transferring data back to a higher level driver or application via the completion of a read IRP. Code would help.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-283978-
xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Wednesday, April 18, 2007 11:10 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Problem Encountered When Using a System Thread for
Device Polling
Dear Mark,
Instead of storing the number of bytes transferred into Irp-
>IoStatus.Information for URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
requests, I do it into the field “TransferBufferLength” in struct
_URB_BULK_OR_INTERRUPT_TRANSFER. I think I need to do some tests.
Thanks for your help.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Dear Mark,
I solved the problem. When changing the codes and tracing, I found I did not fill the correct TransferBufferLength coming from URBs in the created thread. Thanks.