骆海深 发表于 2012-12-24 10:53

USB API函数

   为了开发一个解密软件,只花了半日的时间写USB API函数,调试总是有问题。年尾近了。大量工作,烦得要命。 Public Declare Function CloseHandle _    Lib "kernel32" _    (ByVal hObject As Long) _As Long关闭设备 Public Declare Function CreateFile _    Lib "kernel32" _    Alias "CreateFileA" _    (ByVal lpFileName As String, _    ByVal dwDesiredAccess As Long, _    ByVal dwShareMode As Long, _    ByRef lpSecurityAttributes As Long, _    ByVal dwCreationDisposition As Long, _    ByVal dwFlagsAndAttributes As Long, _    ByVal hTemplateFile As Long) _As Long取得设备表示代号Public Declare Function FormatMessage _    Lib "kernel32" _    Alias "FormatMessageA" _    (ByVal dwFlags As Long, _    ByRef lpSource As Any, _    ByVal dwMessageId As Long, _    ByVal dwLanguageZId As Long, _    ByVal lpBuffer As String, _    ByVal nSize As Long, _    ByVal Arguments As Long) _As Long Public Declare Function HidD_FreePreparsedData _    Lib "hid.dll" _    (ByRef PreparsedData As Long) _As Long释放缓冲区 Public Declare Function HidD_GetAttributes _    Lib "hid.dll" _    (ByVal HidDeviceObject As Long, _    ByRef Attributes As HIDD_ATTRIBUTES) _As Long'取得厂商与产品的ID Public Declare Function HidD_GetHidGuid _Lib "hid.dll"_ (ByRef HidGuid As GUID) _As Long取得HID群组的GUID Public Declare Function HidD_GetPreparsedData _    Lib "hid.dll" _    (ByVal HidDeviceObject As Long, _    ByRef PreparsedData As Long) _As Long取得包含设备能力的缓冲区指针Public Declare Function HidP_GetCaps _    Lib "hid.dll" _    (ByVal PreparsedData As Long, _    ByRef Capabilities As HIDP_CAPS) _As Long取得设备的能力Public Declare Function HidP_GetValueCaps _    Lib "hid.dll" _    (ByVal ReportType As Integer, _    ByRef ValueCaps As Byte, _    ByRef ValueCapsLength As Integer, _    ByVal PreparsedData As Long) _As Long取得数值的能力       Public Declare Function ReadFile _    Lib "kernel32" _    (ByVal hFile As Long, _    ByRef lpBuffer As Byte, _    ByVal nNumberOfBytesToRead As Long, _    ByRef lpNumberOfBytesRead As Long, _    ByVal lpOverlapped As Long) _As Long从设备读取输入报告Public Declare Function RtlMoveMemory _    Lib "kernel32" _    (dest As Any, _    src As Any, _    ByVal Count As Long) _As Long Public Declare Function SetupDiDestroyDeviceInfoList _    Lib "setupapi.dll" _    (ByVal DeviceInfoSet As Long) _As Long释放hDevInfo数组Public Declare Function SetupDiEnumDeviceInterfaces _    Lib "setupapi.dll" _    (ByVal DeviceInfoSet As Long, _    ByVal DeviceInfoData As Long, _    ByRef InterfaceClassGuid As GUID, _    ByVal MemberIndex As Long, _    ByRef DeviceInterfaceData As SP_DEVICE_INTERFACE_DATA) _As Long识别每个HID接口Public Declare Function SetupDiGetClassDevs _    Lib "setupapi.dll" _    Alias "SetupDiGetClassDevsA" _    (ByRef ClassGuid As GUID, _    ByVal Enumerator As String, _    ByVal hwndParent As Long, _    ByVal Flags As Long) _As Long取得所有HID信息的结构数组Public Declare Function SetupDiGetDeviceInterfaceDetail _   Lib "setupapi.dll" _   Alias "SetupDiGetDeviceInterfaceDetailA" _   (ByVal DeviceInfoSet As Long, _   ByRef DeviceInterfaceData As SP_DEVICE_INTERFACE_DATA, _   ByVal DeviceInterfaceDetailData As Long, _   ByVal DeviceInterfaceDetailDataSize As Long, _   ByRef RequiredSize As Long, _   ByVal DeviceInfoData As Long) _As Long   取得设备的详细信息 Public Declare Function WriteFile _    Lib "kernel32" _    (ByVal hFile As Long, _    ByRef lpBuffer As Byte, _    ByVal nNumberOfBytesToWrite As Long, _    ByRef lpNumberOfBytesWritten As Long, _    ByVal lpOverlapped As Long) _As Long传送输出报告给设备 Declare Function DeviceIoControl Lib "kernel32" Alias "DeviceIoContro
(ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, lpOverlapped As OVERLAPPED) As Long       对设备执行指定的操作 HidD_GetInputReport(IN HANDLEHidDeviceObject,         OUT PVOID ReportBuffer, IN ULONG ReportBufferLength);通过控制端点0读取报告的函数 HidD_SetOutputReport(IN HANDLEHidDeviceObject,         OUT PVOID ReportBuffer, IN ULONG ReportBufferLength);通过控制端点0发送报告的函数l

神棍二师兄 发表于 2012-12-24 11:21

{:soso_e179:}

希莱恩 发表于 2012-12-24 15:31

你公开代码矛怕被人偷啊?

现象 发表于 2012-12-24 16:23

骆哥有什么好用的软件共享下

骆海深 发表于 2012-12-24 16:35

我爱桃子 发表于 2012-12-24 16:23 static/image/common/back.gif
骆哥有什么好用的软件共享下

软件不适合你用

骆海深 发表于 2012-12-24 16:36

希莱恩 发表于 2012-12-24 15:31 static/image/common/back.gif
你公开代码矛怕被人偷啊?

没有完成公开。。。。。。。。
页: [1]
查看完整版本: USB API函数