Problem forwarding read request to WinUSB from UMDF

Hi,

I have a USB device which has two read bulk endpoints and three write ones.
These consists of an in/out pair for api comms, an in/out pair for debug
and a separate out endpoint for data transfer.

I have a UMDF driver which uses the WinUSB CoInstaller to access my device.
I have got my driver to load for the target device, collect the
endpoint/pipe
information and handle some IOControl requests.

I have created a separate queue to handle WriteFile() call which I use to
send
data to the data out endpoint. I have also created another queue which
handles
IOCTL requests including read/write requests for the other endpoint pairs.
I do not have a queue to handle ReadFile() requests as the device does not
do
data input.

When I issue an DeviceIoControl() call to request a read on one of the ‘in’
endpoints, my driver calls GetOutputMemory() to retrieve the buffer details
and
passes it to a method which does the following (Non-essential comments, etc
removed for clarity):

// Create request
hr = m_Device->CreateRequest(NULL, NULL, &pWdfRequest);
if (SUCCEEDED(hr))
{
// Create memory object
m_Device->GetDriver(&Driver);
hr = Driver->CreatePreallocatedWdfMemory( buffer,
bufferLength, NULL,

pWdfRequest,&Memory );
}

if (SUCCEEDED(hr))
{
// Format request
hr = pUsbTargetPipe->FormatRequestForRead( pWdfRequest,
NULL,

Memory, NULL, NULL);
}

if (SUCCEEDED(hr))
{
// Send it
(void)pWdfRequest->Send( pUsbTargetPipe,

WDF_REQUEST_SEND_OPTION_SYNCHRONOUS, 0);
}

At the point that I issue the Send() command WinDbg throws a WUDF exception
stating that my request was not formatted for IOCTL, which it wasn’t I was
trying to issue a read request so it was formatted as for READ.

Why is this throwing an exception? What is wrong with this method?

If I have to use FormatRequestForIoctl(), what Ioctl code should I use for
the
read request, and also which one shouldI use for a write request?

Do I have to forward the originating request to a manual dispatch queue to
allow me to format for read and pass down the device stack to WinUSB and my
device?

Thanks in advance,

Peter Young


Build a man a fire - he’s warm for a day.
Set a man on fire - he’s warm for the rest of his life!

  • Terry Pratchett

Peter Young wrote:

I have a USB device which has two read bulk endpoints and three write ones.
These consists of an in/out pair for api comms, an in/out pair for debug
and a separate out endpoint for data transfer.

I have a UMDF driver which uses the WinUSB CoInstaller to access my device.
I have got my driver to load for the target device, collect the
endpoint/pipe information and handle some IOControl requests.

I have created a separate queue to handle WriteFile() call which I use to
send data to the data out endpoint. I have also created another queue which
handles IOCTL requests including read/write requests for the other endpoint pairs.
I do not have a queue to handle ReadFile() requests as the device does not
do data input.

At the point that I issue the Send() command WinDbg throws a WUDF exception
stating that my request was not formatted for IOCTL, which it wasn’t I was
trying to issue a read request so it was formatted as for READ.

Why is this throwing an exception? What is wrong with this method?

All USB I/O requests are sent to USBD through an internal ioctl,
IOCTL_INTERNAL_USB_SUBMIT_URB. You create a URB structure that includes
a function code indicating the type of operation to be performed.

If you’re using WinUSB, then why aren’t you using WinUSB calls to do all
of your USB I/O?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.