Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. communicate with usb (MTP) device and IOCTL

communicate with usb (MTP) device and IOCTL

Scheduled Pinned Locked Moved C / C++ / MFC
comquestion
2 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tinf7378
    wrote on last edited by
    #1

    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]

    Z 1 Reply Last reply
    0
    • T Tinf7378

      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]

      Z Offline
      Z Offline
      ZawMinTun
      wrote on last edited by
      #2

      How about trying this? GENERIC_READ || GENERIC_WRITE, FILE_SHARE_READ || FILE_SHARE_WRITE Change those above to: GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups