I'm trying to get the configuration descriptor for a device I already have a PUSB_NODE_CONNECTION_INFORMATION_EX structure for. I'm working off of the usbview example in the Windows DDK. Here's the relevant portion of the code...
The declarations are here:Code:/****************************************************** * Fill the fields necessary for the request ******************************************************/ // Zero out the request struct len = sizeof(configreqbuf); memset(configreq, 0, len); configreq->ConnectionIndex = conninfo->ConnectionIndex; // descriptor type is high byte, descriptor index is low configreq->SetupPacket.wValue = ((USB_CONFIGURATION_DESCRIPTOR_TYPE << 8) | (unsigned char)0); configreq->SetupPacket.wLength = (unsigned short)(len - sizeof(USB_DESCRIPTOR_REQUEST)); /***************************************************** * Get length, dynamically resize, and get descriptor *****************************************************/ err = DeviceIoControl(rhub, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, configreq, len, configreq, len, &len, NULL); if(!err || configdesc->wTotalLength < sizeof(USB_CONFIGURATION_DESCRIPTOR)) { printf("DEBUG! %d\n\n", GetLastError()); return(NULL); } configdesc = (PUSB_CONFIGURATION_DESCRIPTOR)malloc(len); configreq->ConnectionIndex = conninfo->ConnectionIndex; configreq->SetupPacket.wValue = ((USB_CONFIGURATION_DESCRIPTOR_TYPE << 8) | (unsigned char)0); configreq->SetupPacket.wLength = (unsigned short)(len - sizeof(USB_DESCRIPTOR_REQUEST)); err = DeviceIoControl(rhub, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, configdesc, len, configdesc, len, &len, NULL); if(!err) return(NULL); return(configdesc);
It fails at the following line with error code 2 (ERROR_FILE_NOT_FOUND). Anyone know what I'm doing wrong?Code:HANDLE rhub, ctlr; PUSB_DESCRIPTOR_REQUEST configreq; PUSB_CONFIGURATION_DESCRIPTOR configdesc; char *rhubname, *tmp, *name, *configreqbuf; int numports = -1, i, len = 65536, err, x; PUSB_NODE_CONNECTION_INFORMATION_EX conninfo = (PUSB_NODE_CONNECTION_INFORMATION_EX)malloc(sizeof(unsigned char) * 65536);



LinkBack URL
About LinkBacks


