communicate with usb (MTP) device and IOCTL
-
Hey :-), i study technical computer science and now i want to start with my first driver under WINXP and WINDDK. I have written two programs to display all connected devices to the computer and a real life detection of adding and removing to the system on two different ways. /***************/ first: i build a console application like "usb view" from microsoft to list all devices connected to the pc. After detecting the descriptor i want to start with reading and writing. To get the usb device i used the IOCTL commands from <a href="http://msdn.microsoft.com/en-us/library/aa476229.aspx">http://msdn.microsoft.com/en-us/library/aa476229.aspx</a>[<a href="http://msdn.microsoft.com/en-us/library/aa476229.aspx" target="_blank" title="New Window">^</a>] 1.) detect host controller (worked) 2.) connect to root hub (worked) 3.) list all ports and connected devices (worked) 4.) fill structe with device desciptor and more usefull data with this code IOCTL_USB_GET_NODE_CONNECTION_INFORMATION (worked) 5.) create handle to usb device (problems) i dont know on which way i can detect the full device path like \\\\?\\USB#Vid_####&Pid_#####879fe23a000000e83230303630313130#{a5dcbf10-6530-11d2-901f-00c04fb951ed} or detect a direct handle, i have only the handle to the root hub and the port number. this is my structure ------------------------------------------ <code> typedef struct _USB_DEVICES { HANDLE hDeviceHandle; //RotHubHandle HANDLE hUSBDeviceHandle; //USBDeviceHandle -> ??? DWORD dwPort; //Port UCHAR CurrentConfigurationValue; UCHAR DeviceAddress[2]; UCHAR NumberOfOpenPipes[4]; UCHAR ConnectionStatus[4]; BOOLEAN LowSpeed; BOOLEAN DeviceIsHub; USB_PIPE_INFO PipeList[32]; USB_DEVICE_DESCRIPTOR DeviceDescriptor; USB_CONNECTION_STATUS DeviceStatus; USB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; USB_INTERFACE_DESCRIPTOR InterfaceDescriptor; } Ts_UsbDevices; </code> ------------------------------------------ and now my code ------------------------------------------ <code> ...... //get information aber the connected device connected on "dwPort" ConnectionInformation.ConnectionIndex = s_UsbDevice[dwActiveDevice].dwPort; bSuccess = DeviceIoControl(s_UsbDevice[dwActiveDevice]
-
Hey :-), i study technical computer science and now i want to start with my first driver under WINXP and WINDDK. I have written two programs to display all connected devices to the computer and a real life detection of adding and removing to the system on two different ways. /***************/ first: i build a console application like "usb view" from microsoft to list all devices connected to the pc. After detecting the descriptor i want to start with reading and writing. To get the usb device i used the IOCTL commands from <a href="http://msdn.microsoft.com/en-us/library/aa476229.aspx">http://msdn.microsoft.com/en-us/library/aa476229.aspx</a>[<a href="http://msdn.microsoft.com/en-us/library/aa476229.aspx" target="_blank" title="New Window">^</a>] 1.) detect host controller (worked) 2.) connect to root hub (worked) 3.) list all ports and connected devices (worked) 4.) fill structe with device desciptor and more usefull data with this code IOCTL_USB_GET_NODE_CONNECTION_INFORMATION (worked) 5.) create handle to usb device (problems) i dont know on which way i can detect the full device path like \\\\?\\USB#Vid_####&Pid_#####879fe23a000000e83230303630313130#{a5dcbf10-6530-11d2-901f-00c04fb951ed} or detect a direct handle, i have only the handle to the root hub and the port number. this is my structure ------------------------------------------ <code> typedef struct _USB_DEVICES { HANDLE hDeviceHandle; //RotHubHandle HANDLE hUSBDeviceHandle; //USBDeviceHandle -> ??? DWORD dwPort; //Port UCHAR CurrentConfigurationValue; UCHAR DeviceAddress[2]; UCHAR NumberOfOpenPipes[4]; UCHAR ConnectionStatus[4]; BOOLEAN LowSpeed; BOOLEAN DeviceIsHub; USB_PIPE_INFO PipeList[32]; USB_DEVICE_DESCRIPTOR DeviceDescriptor; USB_CONNECTION_STATUS DeviceStatus; USB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; USB_INTERFACE_DESCRIPTOR InterfaceDescriptor; } Ts_UsbDevices; </code> ------------------------------------------ and now my code ------------------------------------------ <code> ...... //get information aber the connected device connected on "dwPort" ConnectionInformation.ConnectionIndex = s_UsbDevice[dwActiveDevice].dwPort; bSuccess = DeviceIoControl(s_UsbDevice[dwActiveDevice]