ÈçºÎΪ USB É豸ÌôÑ¡ÅäÖÃ

¾Ù±¨ »Ø´ð
ÈçºÎΪ USB É豸ÌôÑ¡ÅäÖÃ
ÎÊÔÚÏß¿Í·þ
ɨÂëÎÊÔÚÏß¿Í·þ
  • »Ø´ðÊý

    6

  • ä¯ÀÀÊý

    962

¾Ù±¨ »Ø´ð

6¸ö»Ø´ð ĬÈÏÅÅÐò
  • ĬÈÏÅÅÐò
  • °´Ê±¼äÅÅÐò

ûÕÒµ½ÂúÒâ´ð°¸£¿È¥Îʶ¹°üAIÖÇÄÜÖúÊÖ
È¡Ïû ¸´ÖÆÎÊÌâ
ÒѲÉÄÉ
ҪΪһ¸ö USB É豸ѡÔñÒ»ÖÖÅäÖ㬸ÃÉ豸µÄ¿Í»§¶ËÇý¶¯³ÌÐò±ØÐëÑ¡ÔñÖÁÉÙÒ»ÖÖÖ§³ÖµÄÅäÖ㬲¢Ö¸¶¨ÒªÊ¹ÓõÄÿ¸ö½Ó¿ÚµÄ±¸ÓÃÉèÖ᣿ͻ§¶ËÇý¶¯³ÌÐò½«ÕâЩѡÔñ·â×°ÔÚÒ»¸öÑ¡ÔñÅäÖÃÇëÇóÖв¢½«¸ÃÇëÇó·¢Ë͵½ Microsoft ÌṩµÄ USB Çý¶¯³ÌÐò¶ÑÕ»£¬¾ßÌåÀ´½²¾ÍÊÇ USB ×ÜÏßÇý¶¯³ÌÐò£¨USB ¼¯ÏßÆ÷ PDO£©¡£USB ×ÜÏßÇý¶¯³ÌÐòÔÚÖ¸¶¨µÄÅäÖÃÖÐÑ¡Ôñÿ¸ö½Ó¿Ú£¬²¢Îª½Ó¿ÚÖеÄÿ¸öÖÕ½áµãÉèÖÃÒ»¸öͨÐÅͨµÀ»ò¹ÜµÀ¡£ ÇëÇóÍê³Éºó£¬¿Í»§¶ËÇý¶¯³ÌÐòÊÕµ½ËùÑ¡ÅäÖõÄÒ»¸ö¾ä±ú£¬ÒÔ¼°ÔÚÿ¸ö½Ó¿ÚµÄÓÐЧ±¸ÓÃÉèÖÃÖж¨ÒåµÄÖÕ½áµã¹ÜµÀ¾ä±ú¡£È»ºó¿Í»§¶ËÇý¶¯³ÌÐò¿ÉÒÔʹÓÃËùÊÕµ½µÄ¾ä±úÀ´¸ü¸ÄÅäÖÃÉèÖ㬲¢ÏòÒ»¸öÌض¨ÖÕ½áµã·¢ËÍ I/O ¶ÁºÍдÇëÇó¡£
¿Í»§¶ËÇý¶¯³ÌÐòÔÚÒ»¸ö URB_FUNCTION_SELECT_CONFIGURATION ÀàÐ굀 USB ÇëÇó¿é (URB) Öз¢ËÍÑ¡ÔñÅäÖÃÇëÇó¡£±¾Ö÷ÌâÖеĹý³Ì½éÉÜÁËÈçºÎʹÓà USBD_SelectConfigUrbAllocateAndBuild Àý³ÌÀ´¹¹½¨¸Ã URB¡£¸ÃÀý³ÌΪ URB ·ÖÅäÄڴ棬Õë¶ÔÒ»¸öÑ¡ÔñÅäÖÃÇëÇó¸ñʽ»¯¸Ã URB£¬²¢½«¸Ã URB µÄµØÖ··µ»Øµ½¿Í»§¶ËÇý¶¯³ÌÐò¡£
Ò²¿ÉÒÔ·ÖÅäÒ»¸ö URB ½á¹¹£¬È»ºóÊÖ¶¯»òµ÷Óà UsbBuildSelectConfigurationRequest ºêÀ´¸ñʽ»¯¸Ã URB¡£
ÏȾöÌõ¼þ
ÔÚ Windows 8 ÖУ¬USBD_SelectConfigUrbAllocateAndBuild È¡´úÁË USBD_CreateConfigurationRequestEx¡£
·¢ËÍÒ»¸öÑ¡ÔñÅäÖÃÇëÇó֮ǰ£¬Äã±ØÐëÓÐÒ»¸ö USBD ¾ä±ú£¬ÓÃÓÚ¿Í»§¶ËÇý¶¯³ÌÐòÏò USB Çý¶¯³ÌÐò¶ÑÕ»µÄ×¢²á¡£Òª´´½¨Ò»¸ö USBD ¾ä±ú£¬¿ÉÒÔµ÷ÓÃUSBD_CreateHandle¡£
È·±£Äã»ñµÃÁËҪѡÔñµÄÅäÖõÄÅäÖÃÃèÊö·û£¨USB_CONFIGURATION_DESCRIPTOR ½á¹¹£©¡£Í¨³££¬ÄãÌá½»Ò»¸ö URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE ÀàÐ굀 URB£¨²ÎÔÄ _URB_CONTROL_DESCRIPTOR_REQUEST£©£¬ÒÔ¼ìË÷ÓйØÉ豸ÅäÖõÄÐÅÏ¢¡£
˵Ã÷
²½Öè 1: ´´½¨Ò»¸ö¾ßÓÐ USBD_INTERFACE_LIST_ENTRY ½á¹¹µÄÊý×é¡£
1¡¢»ñÈ¡ÅäÖÃÖеĽӿÚÊýÁ¿¡£´ËÐÅÏ¢°üº¬ÔÚ USB_CONFIGURATION_DESCRIPTOR ½á¹¹µÄ bNumInterfaces ³ÉÔ±ÖС£
2¡¢´´½¨Ò»¸ö USBD_INTERFACE_LIST_ENTRY ½á¹¹µÄÊý×é¡£¸ÃÊý×éÖеÄÔªËØÊýÁ¿±ØÐë±È½Ó¿ÚµÄÊýÁ¿¶àÒ»¸ö¡£µ÷Óà RtlZeroMemory À´³õʼ»¯Êý×é¡£¿Í»§¶ËÇý¶¯³ÌÐòÔÚ¾ßÓÐ USBD_INTERFACE_LIST_ENTRY ½á¹¹µÄÊý×éÖÐÖ¸¶¨Ã¿¸ö½Ó¿ÚÖÐÒªÆôÓõı¸ÓÃÉèÖá£
ÿ¸ö½á¹¹µÄ InterfaceDescriptor ³ÉÔ±Ö¸ÏòÁË°üº¬¸Ã±¸ÓÃÉèÖõĽӿÚÃèÊö·û¡£
ÿ¸ö½á¹¹µÄ Interface ³ÉÔ±Ö¸ÏòÒ»¸ö USBD_INTERFACE_INFORMATION ½á¹¹£¬¸Ã½á¹¹µÄ Pipes ³ÉÔ±Öаüº¬¹ÜµÀÐÅÏ¢¡£Pipes ´æ´¢Óйر¸ÓÃÉèÖÃÖÐÒѶ¨ÒåµÄÿ¸öÖÕ½áµãµÄÐÅÏ¢¡£
3¡¢»ñÈ¡ÅäÖÃÖÐÿ¸ö½Ó¿ÚµÄ½Ó¿ÚÃèÊö·û£¨»òÆ䱸ÓÃÉèÖã©¡£Äã¿ÉÒÔͨ¹ýµ÷Óà USBD_ParseConfigurationDescriptorEx »ñÈ¡ÕâЩ½Ó¿ÚÃèÊö·û¡£
¹ØÓÚ USB ¸´ºÏÉ豸µÄº¯ÊýÇý¶¯³ÌÐò: Èç¹û USB É豸ÊǸ´ºÏÉ豸£¬ÔòÓÉ Microsoft ÌṩµÄ USB ͨÓø¸Çý¶¯³ÌÐò (Usbccgp.sys) À´Ñ¡ÔñÅäÖ᣿ͻ§¶ËÇý¶¯³ÌÐòÊǸ´ºÏÉ豸µÄº¯ÊýÇý¶¯³ÌÐòÖ®Ò»£¬Ëü²»Äܸü¸ÄÅäÖ㬵«ÈÔ¿Éͨ¹ý Usbccgp.sys ·¢ËÍ select-configuration ÇëÇó¡£
·¢Ë͸ÃÇëÇó֮ǰ£¬¿Í»§¶ËÇý¶¯³ÌÐò±ØÐëÌá½» URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE ÇëÇó¡£ÔÚÏìÓ¦ÖУ¬Usbccgp.sys ½«¼ìË÷²¿·ÖÅäÖÃÃèÊö·û£¬ÆäÖÐÖ»°üº¬½Ó¿ÚÃèÊö·ûÒÔ¼°Óë¿Í»§¶ËÇý¶¯³ÌÐòΪÆä¼ÓÔصÄÌض¨º¯ÊýÏà¹ØµÄÃèÊö·û¡£²¿·ÖÅäÖÃÃèÊö·ûµÄ bNumInterfaces ×Ö¶ÎÖб¨¸æµÄ½Ó¿ÚÊýÁ¿Ð¡ÓÚΪÕû¸ö USB ¸´ºÏÉ豸¶¨ÒåµÄ½Ó¿Ú×ÜÊý¡£ÁíÍ⣬ÔÚ²¿·ÖÅäÖÃÃèÊö·ûÖУ¬½Ó¿ÚÃèÊö·ûµÄ bInterfaceNumber ָʾÏà¶ÔÓÚÕû¸öÉ豸µÄʵ¼Ê½Ó¿ÚÊýÁ¿¡£ÀýÈ磬ÔÚ Usbccgp.sys ¿ÉÄܱ¨¸æµÄµÚÒ»¸ö½Ó¿ÚµÄ²¿·ÖÅäÖÃÃèÊö·ûÖУ¬bNumInterfaces ֵΪ 2£¬¶ø bInterfaceNumber ֵΪ 4¡£×¢Òâ½Ó¿ÚÊýÁ¿´óÓÚËù±¨¸æµÄ½Ó¿ÚÊýÁ¿¡£
ÔÚö¾Ù²¿·ÖÅäÖÃÖеĽӿÚʱ£¬Çë±ÜÃâͨ¹ý»ùÓÚ½Ó¿ÚµÄÊýÁ¿¼ÆËã½Ó¿ÚÊýÁ¿À´ËÑË÷½Ó¿Ú¡£ÔÚÉÏÊöʾÀýÖУ¬Èç¹ûÔÚ´ÓÁ㿪ʼ¡¢ÒÔ (bNumInterfaces - 1) ½áÊø£¬²¢ÇÒÔÚÿ´Îµü´úÖа´½Ó¿ÚË÷Òý£¨ÔÚ InterfaceNumber ²ÎÊýÖÐÖ¸¶¨£©µÝÔöµÄÑ­»·Öе÷Óà USBD_ParseConfigurationDescriptorEx£¬Ôò¸ÃÀý³Ì½«ÎÞ·¨»ñÈ¡ÕýÈ·µÄ½Ó¿Ú¡£Ïà·´£¬ÇëÈ·±£Í¨¹ýÔÚ InterfaceNumber Öд«µÝ -1 À´ËÑË÷ÅäÖÃÃèÊö·ûÖеÄËùÓнӿڡ£ÓйØʵÏÖÏêϸÐÅÏ¢£¬Çë²ÎÔı¾²¿·ÖÖеĴúÂëʾÀý¡£ÓÐ¹Ø Usbccgp.sys ÈçºÎ´¦ÀíÓÉ¿Í»§¶ËÇý¶¯³ÌÐò·¢Ë굀 select-configuration ÇëÇóµÄÐÅÏ¢£¬Çë²ÎÔÄÅäÖà Usbccgp.sys ÒÔÑ¡Ôñ·ÇĬÈÏ USB ÅäÖá£
4¡¢¶ÔÓÚÊý×éÖеÄÿ¸öÔªËØ£¨³ýÁË×îºóÒ»¸öÔªËØ£©£¬½« InterfaceDescriptor ³ÉÔ±ÉèÖÃΪһ¸ö½Ó¿ÚÃèÊö·ûµÄµØÖ·¡£¶ÔÓÚÊý×éÖеĵÚÒ»¸öÔªËØ£¬½«InterfaceDescriptor ³ÉÔ±ÉèÖÃΪ±íʾÅäÖÃÖÐÊ׸ö½Ó¿ÚµÄ½Ó¿ÚÃèÊö·ûµÄµØÖ·¡£ÀàËƵأ¬¶ÔÓÚÊý×éÖÐµÄµÚ n ¸öÔªËØ£¬½« InterfaceDescriptor ³ÉÔ±ÉèÖÃΪ±íʾÅäÖÃÖÐµÚ n ¸ö½Ó¿ÚµÄ½Ó¿ÚÃèÊö·ûµÄµØÖ·¡£×îºóÒ»¸öÔªËØµÄ InterfaceDescriptor ³ÉÔ±±ØÐëÉèÖÃΪ NULL¡£
²½Öè 2: »ñµÃ USB Çý¶¯³ÌÐò¶ÑÕ»·ÖÅäµÄÒ»¸ö URB µÄÖ¸Õë¡£
½ÓÏÂÀ´£¬Í¨¹ýÖ¸¶¨ÒªÑ¡ÔñµÄÅäÖúÍÌî³äµÄ USBD_INTERFACE_LIST_ENTRY ½á¹¹Êý×飬µ÷Óà USBD_SelectConfigUrbAllocateAndBuild¡£¸ÃÀý³ÌÖ´ÐÐÒÔÏÂÈÎÎñ£º
´´½¨Ò»¸ö URB ²¢ÏòÆäÖÐÌîÈëÓйØÖ¸¶¨µÄÅäÖá¢ËüµÄ½Ó¿ÚºÍÖÕ½áµãµÄÐÅÏ¢£¬½«ÇëÇóÀàÐÍÉèÖÃΪ URB_FUNCTION_SELECT_CONFIGURATION¡£
Ôڸà URB ÄÚ£¬Îª¿Í»§¶ËÇý¶¯³ÌÐòÖ¸¶¨µÄÿ¸ö½Ó¿ÚÃèÊö·û·ÖÅäÒ»¸ö USBD_INTERFACE_INFORMATION ½á¹¹¡£
½«µ÷Ó÷½ÌṩµÄ USBD_INTERFACE_LIST_ENTRY Êý×éµÄµÚ n ¸öÔªËØµÄ Interface ³ÉÔ±ÉèÖÃΪ URB ÖÐÏàÓ¦USBD_INTERFACE_INFORMATION ½á¹¹µÄµØÖ·¡£
³õʼ»¯ InterfaceNumber¡¢AlternateSetting¡¢NumberOfPipes¡¢Pipes[i].MaximumTransferSize ºÍ Pipes[i].PipeFlags ³ÉÔ±¡£
×¢Òâ ÔÚ Windows 7 ºÍÔçÆÚ°æ±¾ÖУ¬¿Í»§¶ËÇý¶¯³ÌÐòͨ¹ýµ÷Óà USBD_CreateConfigurationRequestEx Ϊ select-configuration ÇëÇó´´½¨ URB¡£ÔÚ Windows 2000 ÖУ¬USBD_CreateConfigurationRequestEx ½« Pipes[i].MaximumTransferSize ³õʼ»¯Îªµ¥¸ö URB ¶Á/дÇëÇóµÄĬÈÏ×î´ó´«Êä´óС¡£¿Í»§¶ËÇý¶¯³ÌÐò¿ÉÒÔÔÚ Pipes[i].MaximumTransferSize ÖÐÖ¸¶¨²»Í¬µÄ×î´ó´«Êä´óС¡£ÔÚ Windows XP¡¢Windows Server 2003 ºÍ¸ü¸ß°æ±¾µÄ²Ù×÷ϵͳÖУ¬USB ¶ÑÕ»½«ºöÂÔ´ËÖµ¡£ÓÐ¹Ø MaximumTransferSize µÄÏêϸÐÅÏ¢£¬Çë²ÎÔÄÉèÖà USB ´«ÊäºÍÊý¾Ý°ü´óС¡£
²½Öè 3: ½« URB Ìá½»µ½ USB Çý¶¯³ÌÐò¶ÑÕ»¡£
Òª½« URB Ìá½»µ½ USB Çý¶¯³ÌÐò¶ÑÕ»£¬¿Í»§¶ËÇý¶¯³ÌÐò±ØÐë·¢ËÍÒ»¸ö IOCTL_INTERNAL_USB_SUBMIT_URB I/O ¿ØÖÆÇëÇó¡£ÓйØÌá½» URB µÄÐÅÏ¢£¬Çë²ÎÔÄÈçºÎÌá½» URB¡£
ÊÕµ½ URB ºó£¬USB Çý¶¯³ÌÐòÌî³äÿ¸ö USBD_INTERFACE_INFORMATION ½á¹¹µÄÊ£Óà³ÉÔ±¡£¾ßÌåÀ´½²£¬»áΪ Pipes Êý×é³ÉÔ±ÌîÈëÓë½Ó¿ÚÖÕ½áµãÏà¹ØÁªµÄ¹ÜµÀµÄÐÅÏ¢¡£
²½Öè 4: ÇëÇóÍê³Éʱ£¬¼ì²é USBD_INTERFACE_INFORMATION ½á¹¹ºÍ URB¡£
USB Çý¶¯³ÌÐò¶ÑÕ»Íê³ÉÇëÇóµÄ IRP ºó£¬¶ÑÕ»ÔÚ USBD_INTERFACE_LIST_ENTRY Êý×éÖзµ»Ø±¸ÓÃÉèÖúÍÏà¹Ø½Ó¿ÚµÄÁÐ±í¡£
1¡¢Ã¿¸ö USBD_INTERFACE_INFORMATION ½á¹¹µÄ Pipes ³ÉÔ±Ö¸ÏòÒ»¸ö USBD_PIPE_INFORMATION ½á¹¹Êý×飬¸ÃÊý×é°üº¬Óë¸ÃÌض¨½Ó¿ÚµÄÿ¸öÖÕ½áµãÏà¹ØÁªµÄ¹ÜµÀµÄÐÅÏ¢¡£¿Í»§¶ËÇý¶¯³ÌÐò¿É´Ó Pipes[i].PipeHandle »ñÈ¡¹ÜµÀ¾ä±ú²¢Ê¹ÓÃËüÃǽ« I/O ÇëÇó·¢Ë͵½Ìض¨¹ÜµÀ¡£Pipes[i].PipeType³ÉÔ±Ö¸¶¨¸Ã¹ÜµÀÖ§³ÖµÄÖÕ½áµãºÍ´«ÊäÀàÐÍ¡£
2¡¢ÔÚ URB µÄ UrbSelectConfiguration ³ÉÔ±ÖУ¬USB Çý¶¯³ÌÐò¶ÑÕ»·µ»ØÒ»¸ö¾ä±ú£¬Äã¿ÉÒÔʹÓøþä±úͨ¹ýÌá½»ÁíÒ»¸ö URB_FUNCTION_SELECT_INTERFACE ÀàÐ굀 URB£¨Ñ¡Ôñ½Ó¿ÚÇëÇó£©À´Ñ¡ÔñÒ»¸ö±¸ÓýӿÚÉèÖá£ÒªÎª¸ÃÇëÇó·ÖÅäºÍ¹¹½¨ URB ½á¹¹£¬¿ÉÒÔµ÷ÓÃUSBD_SelectInterfaceUrbAllocateAndBuild¡£
Èç¹ûûÓÐ×ã¹»µÄ´ø¿íÀ´Ö§³ÖÒÑÆôÓõĽӿÚÖеij£Ê±µÈÁ¿¡¢¿ØÖƺÍÖжÏÖÕ½áµã£¬Ñ¡ÔñÅäÖÃÇëÇóºÍÑ¡Ôñ½Ó¿ÚÇëÇó¿ÉÄÜʧ°Ü¡£ÔÚ´ËÇé¿öÏ£¬USB ×ÜÏßÇý¶¯³ÌÐò½« URB Í·ÎļþµÄ Status ³ÉÔ±ÉèÖÃΪ USBD_STATUS_NO_BANDWIDTH¡£
È¡Ïû ÆÀÂÛ
ÖØÆôһϣ¬ÒÔÇ°³öÏÖÂð£¿
È¡Ïû ÆÀÂÛ
³ß´çºÍ±ãЯÐÔÒ²ÊǸöСÒòËØ¡£Èç¹ûÄã¾­³£ÐèÒª´ø×ųöÃÅ£¬Ð¡ÇÉÇá±ãµÄÉè¼Æ»á¸ü·½±ãЯ´ø¡£ÔÚÂú×ã»ù±¾ÐèÇóµÄÇ°ÌáÏ£¬¸ù¾Ý¸öÈËϲºÃºÍʹÓó¡¾°À´ÌôÑ¡×îÊʺÏ×Ô¼ºµÄÅäÖðÉ
È¡Ïû ÆÀÂÛ
Èç¹ûÊÇ´øÓÐÌØÊ⹦ÄܵÄÉ豸£¨ÈçHDMIת½ÓÆ÷£©£¬¼ÇµÃÈ·ÈÏËüÊÇ·ñ°üº¬ÄãÐèÒªµÄËùÓÐÌØÐÔ£¬²¢²é¿´Óû§ÆÀ¼ÛÒÔÁ˽âʵ¼Ê±íÏÖ
È¡Ïû ÆÀÂÛ
¿¼ÂǼæÈÝÐÔÒ²ºÜÖØÒª¡£È·±£Ä㹺ÂòµÄUSBÅäÖÃÓëÄãµÄµçÄÔ»òÒƶ¯É豸¼æÈÝ£¬±ÜÃâÂòÁËеÄÉ豸ȴÎÞ·¨Ê¹Ó᣼ì²éһϲúƷ˵Ã÷»òÕßÔÚÏß²éѯһÏÂ
È¡Ïû ÆÀÂÛ
Ñ¡ÔñUSBÉ豸ʱ£¬Ê×ÏÈÒª¿´ÄãµÄÉ豸ÐèÇó¡£Èç¹ûÄãÖ÷ÒªÓÃÀ´´«Êä´óÁ¿Êý¾Ý£¬ÈçÓ²ÅÌ»òUÅÌ£¬ÄǾÍÑ¡Ö§³Ö¸ßËÙUSB 0»òÕßType-C½Ó¿ÚµÄ£¬Ëٶȸü¿ì£»Èç¹ûÖ»ÊÇż¶ûÁ¬½ÓÊÖ»ú³äµç£¬Í¨ÓõÄUSB 0¾Í×ã¹»ÁË
È¡Ïû ÆÀÂÛ
ZOLÎÊ´ð > ÈçºÎΪ USB É豸ÌôÑ¡ÅäÖÃ

Ïà¹Ø²úÆ·

¾Ù±¨

¸ÐлÄúΪÉçÇøµÄºÍг¹±Ï×Á¦Á¿ÇëÑ¡Ôñ¾Ù±¨ÀàÐÍ

¾Ù±¨³É¹¦

¾­¹ýºËʵºó½«»á×ö³ö´¦Àí
¸ÐлÄúΪÉçÇøºÍг×ö³ö¹±Ï×

ɨÂë²ÎÓëÐÂÆ·0ÔªÊÔÓÃ
ɹµ¥¡¢¶¥Â¥ºÀÀñµÈÄãÄÃ

ɨһɨ£¬¹Ø×¢ÎÒÃÇ
Ìáʾ

È·¶¨ÒªÈ¡Ïû´Ë´Î±¨Ãû£¬Í˳ö¸Ã»î¶¯£¿