-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnaeusb_os_desc.h
211 lines (179 loc) · 5.39 KB
/
naeusb_os_desc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#pragma once
#define U162ARR(U16) {(U16) & 0xFF, (U16) >> 8}
struct MS_DEV_INT_GUID {
uint8_t data[0x4E];
};
#ifndef USB_DEVICE_NB_INTERFACE
#define USB_DEVICE_NB_INTERFACE 1
#endif
#define MAKE_DEV_INT_GUID(INTERFACE_NUM) \
{.data = {'{', 0x00, \
INTERFACE_NUM+'0', 0x00, 'A', 0x00, 'C', 0x00, 'E', 0x00, \
'2', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, \
'-', 0x00, \
'2', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, \
'-', 0x00, \
'2', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, \
'-', 0x00, \
'2', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, \
'-', 0x00, \
((USB_DEVICE_PRODUCT_ID >> 12 ) & 0x07) + '0', 0x00, ((USB_DEVICE_PRODUCT_ID >> 8 ) & 0x07) + '0', 0x00, \
((USB_DEVICE_PRODUCT_ID >> 4 ) & 0x07) + '0', 0x00, ((USB_DEVICE_PRODUCT_ID >> 0 ) & 0x07) + '0', 0x00, \
INTERFACE_NUM + '0', 0x00, 'A', 0x00, 'C', 0x00, 'E', 0x00, \
'2', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, \
'}', 0x00, 0x00, 0x00 \
}}
#if USB_DEVICE_NB_INTERFACE > 1
struct MS_DEV_GUID_NAME {
uint8_t data[0x2A];
};
#define MAKE_DEV_GUID_NAME \
{.data = {\
'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00,\
'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, 'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00,\
'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 's', 0x00, 0x00, 0x00,\
}}
#define MAKE_NULL_TERM .wNullTerminator={0x00, 0x00}
#define MS_NULL_TERM_SIZE 2
#else
struct MS_DEV_GUID_NAME {
uint8_t data[0x28];
};
#define MAKE_DEV_GUID_NAME \
{.data = {\
'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00,\
'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, 'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00,\
'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 0x00, 0x00,\
}}
#define MAKE_NULL_TERM
#define MS_NULL_TERM_SIZE 0
#endif
struct MS_REG_PROP_DESC_GUID {
uint8_t wLength[2];
uint8_t wDescriptorType[2];
uint8_t wStringType[2];
uint8_t wPropertyNameLength[2];
struct MS_DEV_GUID_NAME PropertyName;
uint8_t wPropertyDataLength[2];
struct MS_DEV_INT_GUID PropertyData;
#if USB_DEVICE_NB_INTERFACE > 1
uint8_t wNullTerminator[2];
#endif
};
#define MAKE_PROP_DESC_GUID(INT) \
{ \
.wLength= U162ARR (sizeof(struct MS_REG_PROP_DESC_GUID)), \
.wDescriptorType = U162ARR(0x04), \
.wStringType = U162ARR(0x07), \
.wPropertyNameLength = U162ARR(sizeof(struct MS_DEV_GUID_NAME)), \
.PropertyName = MAKE_DEV_GUID_NAME, \
.wPropertyDataLength = U162ARR(sizeof(struct MS_DEV_INT_GUID) + MS_NULL_TERM_SIZE), \
.PropertyData = MAKE_DEV_INT_GUID(INT), \
MAKE_NULL_TERM \
}
struct MS_COMP_ID_FEAT_DESC {
uint8_t wLength[2];
uint8_t wDescriptorType[2];
uint8_t CompatibleID[8];
uint8_t SubCompatibleID[8];
struct MS_REG_PROP_DESC_GUID GUID;
};
#define MAKE_FEAT_DESC(INT) \
{ \
.wLength=U162ARR(0x14), \
.wDescriptorType=U162ARR(0x03), \
.CompatibleID={'W', 'I', 'N', 'U', 'S', 'B', '\0', 0x00}, \
.SubCompatibleID={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, \
.GUID=MAKE_PROP_DESC_GUID(INT) \
}
#if USB_DEVICE_NB_INTERFACE > 1
struct MS_FUNC_SUBSET_HEADER {
uint8_t wLength[2];
uint8_t wDescriptorType[2];
uint8_t bFirstInterface;
uint8_t bReserved;
uint8_t wSubsetLength[2];
struct MS_COMP_ID_FEAT_DESC FEAT;
};
#define MAKE_FUNC_SUBSET_HEADER(INT) \
{ \
.wLength=U162ARR(0x08), \
.wDescriptorType=U162ARR(0x02), \
.bFirstInterface=INT, \
.bReserved=0x00, \
.wSubsetLength=U162ARR(sizeof(struct MS_FUNC_SUBSET_HEADER)), \
.FEAT=MAKE_FEAT_DESC(INT) \
}
#else
struct MS_FUNC_SUBSET_HEADER {
struct MS_COMP_ID_FEAT_DESC FEAT;
};
#define MAKE_FUNC_SUBSET_HEADER(X) \
{ \
.FEAT=MAKE_FEAT_DESC(0) \
}
#endif
struct MS_OS_DESC_SET_HEADER {
uint8_t wLength[2];
uint8_t wDescriptorType[2];
uint8_t dwWindowsVersion[4];
uint8_t wTotalLength[2];
struct MS_FUNC_SUBSET_HEADER FUNC[USB_DEVICE_NB_INTERFACE];
// #if USB_DEVICE_NB_INTERFACE > 1
// struct MS_FUNC_SUBSET_HEADER FUNC[2];
// #else
// struct MS_FUNC_SUBSET_HEADER FUNC[1];
// #endif
};
#if USB_DEVICE_NB_INTERFACE > 1
#define MAKE_OS_DESC_SET_HEADER \
{ \
.wLength=U162ARR(0x0A), \
.wDescriptorType=U162ARR(0x00), \
.dwWindowsVersion={0x00, 0x00, 0x03, 0x06}, \
.wTotalLength=U162ARR(sizeof(struct MS_OS_DESC_SET_HEADER)) \
}
#else
#define MAKE_OS_DESC_SET_HEADER \
{ \
.wLength=U162ARR(0x0A), \
.wDescriptorType=U162ARR(0x00), \
.dwWindowsVersion={0x00, 0x00, 0x03, 0x06}, \
.wTotalLength=U162ARR(sizeof(struct MS_OS_DESC_SET_HEADER)), \
.FUNC = {MAKE_FUNC_SUBSET_HEADER(0)} \
}
#endif
static struct MS_OS_DESC_SET_HEADER MS_OS_DESC = MAKE_OS_DESC_SET_HEADER;
struct MS_BOS_DESCRIPTOR {
uint8_t bLength; //5 always
uint8_t bRequestType;
uint8_t wTotalLen[2];
uint8_t bNumPlatDesc;
uint8_t bDescLen;
uint8_t bDescType; //0x10
uint8_t bCapabilityType; //0x05
uint8_t bReserved;
uint8_t MSGUID[16];
uint8_t dwWinVersion[4];
uint8_t wOSDescLen[2];
uint8_t bRequest;
uint8_t bSendRequest; //0x00
};
#define MAKE_BOS_DESC \
{ \
.bLength = 0x05,\
.bRequestType = 0x0F, \
.wTotalLen = U162ARR(sizeof(struct MS_BOS_DESCRIPTOR)), \
.bNumPlatDesc = 0x01, \
.bDescLen = 0x1C, \
.bDescType = 0x10, \
.bCapabilityType = 0x05, \
.bReserved = 0x00, \
.MSGUID = {0xDF, 0x60, 0xDD, 0xD8, 0x89, 0x45, 0xC7, 0x4C, \
0x9C, 0xD2, 0x65, 0x9D, 0x9E, 0x64, 0x8A, 0x9F}, \
.dwWinVersion = {0x00, 0x00, 0x03, 0x06}, \
.wOSDescLen = U162ARR(sizeof(struct MS_OS_DESC_SET_HEADER)), \
.bRequest=0x01, \
.bSendRequest=0x00 \
}
static struct MS_BOS_DESCRIPTOR MS_BOS_PACKET = MAKE_BOS_DESC;