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

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

why WinUsb_WritePipe and WinUsb_ReadPipe fail, but WinUsb_ControlTransfer ok

nektnekt Member Posts: 1

i have write virtual PDO device, for which WinUsb attached as low filter (and then FDO by umdf driver). my PDO basically handle different IOCTL_INTERNAL_USB_SUBMIT_URB requests (URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE, URB_FUNCTION_CONTROL_TRANSFER, URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER, etc)

umdf depending on the vid/pid of my device send data to me or via WinUsb_ControlTransfer or via WinUsb_WritePipe and WinUsb_ReadPipe. in case WinUsb_ControlTransfer all is ok. i got URB_FUNCTION_CONTROL_TRANSFER request in self PDO. but WinUsb_WritePipe (in user mode from winusb.dll) is always fail with STATUS_INVALID_PARAMETER. as i research - request request reaches WinUsb_WritePipe function inside winusb.sys in kernel and here fail on call WinUSB_IsInterruptOrBulkOutPipe - it return false for my endpoint and as result WinUsb_WritePipe function return STATUS_INVALID_PARAMETER

the PipeID (view in debugger) is correct and corresponds to my (USB_ENDPOINT_DESCRIPTOR.bEndpointAddress & USB_ENDPOINT_ADDRESS_MASK) and this is BULK , DIRECTION_OUT endpoint (so all correct), but how i view in code of WinUsb_WritePipe - pointer to object object was in internal structure for my endpoint. and this pointer is 0. because this WinUSB_IsInterruptOrBulkOutPipe return false. but i can not found - where and when this object created for endpoint and why it not created for my bulk endpoints. may be i wrong fill USB_CONFIGURATION_DESCRIPTOR ? or why this happens ? why winusb.sys not allocate some data for my endpoints ? but in this case WinUsb_ControlTransfer is work ? i fill USB_CONFIGURATION_DESCRIPTOR in next way

struct USB_CONFIGURATION_DESCRIPTOR_1_3
{
 USB_CONFIGURATION_DESCRIPTOR ucd;
 USB_INTERFACE_DESCRIPTOR uid;
 USB_ENDPOINT_DESCRIPTOR ued[3];
 USB_CCID_CLASS_DESCRIPTOR uccd;
};

USB_CONFIGURATION_DESCRIPTOR_1_3 g_UCD = {

 {
     .bLength = sizeof(USB_CONFIGURATION_DESCRIPTOR),
         .bDescriptorType = USB_CONFIGURATION_DESCRIPTOR_TYPE,
         .wTotalLength = sizeof(USB_CONFIGURATION_DESCRIPTOR_1_3),
         .bNumInterfaces = 1,
         .bConfigurationValue = 1,
         .iConfiguration = e_iConfiguration,
         .bmAttributes = USB_CONFIG_SELF_POWERED,
         .MaxPower = 0
 },
 {
     .bLength = sizeof(USB_INTERFACE_DESCRIPTOR),
         .bDescriptorType = USB_INTERFACE_DESCRIPTOR_TYPE,
         .bInterfaceNumber = 0,
         .bAlternateSetting = 0,
         .bNumEndpoints = RTL_NUMBER_OF(USB_CONFIGURATION_DESCRIPTOR_1_3::ued),
         .bInterfaceClass = USB_DEVICE_CLASS_SMART_CARD,
         .bInterfaceSubClass = 0,
         .bInterfaceProtocol = 0,
         .iInterface = e_iInterface
     },
     {
         {
             .bLength = sizeof(USB_ENDPOINT_DESCRIPTOR),
                 .bDescriptorType = USB_ENDPOINT_DESCRIPTOR_TYPE,
                 .bEndpointAddress = 1 | USB_ENDPOINT_DIRECTION_MASK,
                 .bmAttributes = USB_ENDPOINT_TYPE_CONTROL,
                 .wMaxPacketSize = USB_ENDPOINT_SUPERSPEED_CONTROL_MAX_PACKET_SIZE,
                 .bInterval = 0
         },
         {
             .bLength = sizeof(USB_ENDPOINT_DESCRIPTOR),
                 .bDescriptorType = USB_ENDPOINT_DESCRIPTOR_TYPE,
                 .bEndpointAddress = 2 | USB_ENDPOINT_DIRECTION_MASK,
                 .bmAttributes = USB_ENDPOINT_TYPE_BULK,
                 .wMaxPacketSize = USB_ENDPOINT_SUPERSPEED_CONTROL_MAX_PACKET_SIZE,
                 .bInterval = 0
         },
         {
             .bLength = sizeof(USB_ENDPOINT_DESCRIPTOR),
                 .bDescriptorType = USB_ENDPOINT_DESCRIPTOR_TYPE,
                 .bEndpointAddress = 3,
                 .bmAttributes = USB_ENDPOINT_TYPE_BULK,
                 .wMaxPacketSize = USB_ENDPOINT_SUPERSPEED_CONTROL_MAX_PACKET_SIZE,
                 .bInterval = 0
             },
     },
     {
         .bLength = sizeof(USB_CCID_CLASS_DESCRIPTOR), 
             .bDescriptorType = 0x21, 
             .bcdCCID = 0x0110, 
             .bMaxSlotIndex = 0, 
             .bVoltageSupport = 1, 
             .dwProtocols = PROTO_T0, 
             .dwDefaultClock = 4000, 
             .dwMaximumClock = 8000, 
             .bNumCockSupported = 0, 
             .dwDataRate = 9600 , 
             .dwMaxDataRate = 9600, 
             .bNumDataRatesSupported = 0, 
             .dwMaxIFSD = 252, 
             .dwSynchProtocols = 0, 
             .dwMechanical = 0, 
             .dwFeatures = 0x000100BA, 
             .dwMaxCCIDMessageLength = 271, 
             .bClassGetResponse = 0xFF, 
             .bClassEnvelope = 0xFF, 
             .wLcdLayout = 0, 
             .bPINSupport = 0, 
             .bMaxCCIDBusySlots = 1, 
     }
};
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 21 Oct 2019 OSR Seminar Space & ONLINE
Internals & Software Drivers 18 Nov 2019 Dulles, VA
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 27 Apr 2020 OSR Seminar Space & ONLINE