資源簡介
使用STM32的固件庫進行USB-HID組合設備進行開發,3個HID接口。通過bus hound 來抓包分析發現 PC 發送set idle命令下去后,從設備沒有響應,所以PC變為stall狀態。通過分析源代碼和HID協議,修補漏洞之后可以在任何電腦上枚舉成功。里面有具體的參考文件及修改好的代碼,有什么問題歡迎咨詢我。謝謝。
代碼片段和文件信息
/*?Includes?------------------------------------------------------------------*/
#include?“hw_config.h“?
#include?“usb_lib.h“
#include?“usb_conf.h“
#include?“usb_prop.h“
#include?“usb_desc.h“
#include?“usb_pwr.h“
/*?Private?typedef?-----------------------------------------------------------*/?
/*?Private?define?------------------------------------------------------------*/
/*?Private?macro?-------------------------------------------------------------*/
/*?Private?variables?---------------------------------------------------------*/
uint32_t?ProtocolValue;
__IO?uint8_t?EXTI_Enable;
__IO?uint8_t?Request?=?0;
uint8_t?Report_Buf[2];???
/*?--------------------------------------------------------------------------?*/
/*??Structures?initializations?*/
/*?--------------------------------------------------------------------------?*/
DEVICE?Device_Table?=
??{
????EP_NUM
????1
??};
DEVICE_PROP?Device_Property?=
??{
????CustomHID_init
????CustomHID_Reset
????CustomHID_Status_In
????CustomHID_Status_Out
????CustomHID_Data_Setup
????CustomHID_NoData_Setup
????CustomHID_Get_Interface_Setting
????CustomHID_GetDeviceDescriptor
????CustomHID_GetConfigDescriptor
????CustomHID_GetStringDescriptor
????0
????0x40?/*MAX?PACKET?SIZE*/
??};
USER_STANDARD_REQUESTS?User_Standard_Requests?=
??{
????CustomHID_GetConfiguration
????CustomHID_SetConfiguration
????CustomHID_GetInterface
????CustomHID_SetInterface
????CustomHID_GetStatus
????CustomHID_ClearFeature
????CustomHID_SetEndPointFeature
????CustomHID_SetDeviceFeature
????CustomHID_SetDeviceAddress
??};
ONE_DEscriptOR?Device_Descriptor?=??????????????????//用于獲得設備描述符
??{
????(uint8_t*)CustomHID_DeviceDescriptor
????CUSTOMHID_SIZ_DEVICE_DESC
??};
ONE_DEscriptOR?Config_Descriptor?=?????????????????//用于獲得配置描述符
??{
????(uint8_t*)CustomHID_ConfigDescriptor
????CUSTOMHID_SIZ_CONFIG_DESC
??};
/************分別獲取3個HID的報告描述符****************/
//ONE_DEscriptOR?ALL_HID_Report_Descriptor[3]?=???????????//用于獲得報告描述符
//??{
//????{(uint8_t?*)mouse_ReportDescriptormouse_SIZ_REPORT_DESC}
//????{(uint8_t?*)pen_Report_Descriptorpen_SIZ_REPORT_DESC}
//????{(uint8_t?*)HID_driver_Report_DescriptorHID_driver_SIZ_REPORT_DESC}
//??};
ONE_DEscriptOR?mouse_Report_Descriptor?=???????????//用于獲得報告描述符
??{
????(uint8_t?*)mouse_ReportDescriptor
????mouse_SIZ_REPORT_DESC
??};
ONE_DEscriptOR?pen_Report_Descriptor?=??????????????
??{
????(uint8_t?*)pen_ReportDescriptor
????pen_SIZ_REPORT_DESC
??};
ONE_DEscriptOR?HID_driver_Report_Descriptor?=???????
??{
????(uint8_t?*)HID_driver_ReportDescriptor
????HID_driver_SIZ_REPORT_DESC
??};
/************分別獲取3個HID的配置描述符中的HID描述****************/
//mouse_OFF_HID_DESC/pen_OFF_HID_DESC/HID_driver_OFF_HID_DESC
//是HID描述在配置描述符中的偏移量
ONE_DEscriptOR?mouse_Hid_Descriptor?=??????????????
??{
????(uint8_t*)CustomHID_ConfigDescriptor?+?mouse_OFF_HID_DESC??
????CUSTOMHID_SIZ_HID_DESC
??};
ONE_DESCRIP
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-03-23?15:34??1_ST_USB\
?????文件?????1002149??2019-03-21?11:27??1_ST_USB\11_STM32F10xxx?USB開發工具包.pdf
?????文件??????494974??2018-09-28?14:58??1_ST_USB\6_STM32_USB_資源匯總.pdf
?????文件???????18687??2019-03-23?15:21??1_ST_USB\usb_prop.c
?????文件?????3111285??2019-03-23?14:04??1_ST_USB\USB培訓_Part1?協議.pdf
?????文件?????2871158??2019-03-23?14:09??1_ST_USB\USB培訓_Part2?USB?IP及其庫的使用?.pdf
?????文件?????1507218??2019-03-23?14:09??1_ST_USB\USB培訓_Part3?USB?OTG?IP及其庫的使用.pdf
?????文件?????4267324??2019-03-23?14:07??1_ST_USB\USB進階培訓_Part1_USB類的介紹.pdf
?????文件??????989598??2019-03-23?14:08??1_ST_USB\USB進階培訓_Part2_USB復合設備的概念及CDC?MSC的講解.pdf
?????文件?????1578416??2019-03-23?14:08??1_ST_USB\USB進階培訓_Part3_HandsOn_一步一步跟著我,從CubeMX生成CDC?MSC復合設備.pdf.pdf
評論
共有 條評論