54 lines
1.8 KiB
C
54 lines
1.8 KiB
C
|
|
#include "usb.h"
|
|
#include "usbioctl.h"
|
|
#include "Usbdlib.h"
|
|
|
|
#pragma once
|
|
|
|
// HID Descriptor 타입 정의 (USB 표준)
|
|
#define USB_DESCRIPTOR_TYPE_HID 0x21
|
|
#define MAX_HID_INTERFACES 8
|
|
// HID Descriptor 구조체 정의
|
|
#pragma pack(push, 1)
|
|
typedef struct _USB_HID_DESCRIPTOR {
|
|
UCHAR bLength;
|
|
UCHAR bDescriptorType; // 0x21
|
|
USHORT bcdHID; // HID Spec Version (e.g., 0x0111 for 1.11)
|
|
UCHAR bCountryCode;
|
|
UCHAR bNumDescriptors; // Number of class descriptors (usually 1 for Report Desc)
|
|
struct {
|
|
UCHAR bDescriptorType; // Report Descriptor Type (0x22)
|
|
USHORT wDescriptorLength; // Report Descriptor Length
|
|
} DescriptorList[1];
|
|
} USB_HID_DESCRIPTOR, * PUSB_HID_DESCRIPTOR;
|
|
#pragma pack(pop)
|
|
|
|
typedef struct _HID_INTERFACE_ENTRY {
|
|
UCHAR InterfaceNumber; // 해당 HID가 속한 인터페이스 번호
|
|
PUSB_HID_DESCRIPTOR HidDesc; // HID Descriptor 포인터 (ConfigDesc 내부 위치)
|
|
} HID_INTERFACE_ENTRY, * PHID_INTERFACE_ENTRY;
|
|
|
|
// USB 정보를 담을 구조체 정의
|
|
typedef struct _USB_PARSED_INFO {
|
|
// 1. Device Descriptor (VendorID, ProductID 등)
|
|
USB_DEVICE_DESCRIPTOR DeviceDesc;
|
|
|
|
// 2. String Descriptors (사람이 읽을 수 있는 문자열)
|
|
PWCHAR ManufacturerStr; // 제조사 (NULL일 수 있음)
|
|
PWCHAR ProductStr; // 제품명 (NULL일 수 있음)
|
|
PWCHAR SerialNumberStr; // 시리얼 번호 (NULL일 수 있음)
|
|
|
|
// 3. Configuration Descriptor (Interface, Endpoint 포함된 전체 Blob)
|
|
PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc;
|
|
ULONG ConfigDescSize;
|
|
|
|
ULONG HidInterfaceCount;
|
|
HID_INTERFACE_ENTRY HidEntries[MAX_HID_INTERFACES];
|
|
|
|
} USB_PARSED_INFO, * PUSB_PARSED_INFO;
|
|
|
|
// 함수 원형 선언
|
|
NTSTATUS CollectUsbDeviceInfo(IN PDEVICE_OBJECT DeviceObject, OUT PUSB_PARSED_INFO* ppInfo);
|
|
VOID FreeUsbDeviceInfo(IN PUSB_PARSED_INFO pInfo);
|
|
|