15
15
#include <debug.h>
16
16
17
17
18
+ static
18
19
LPCSTR
19
20
USBSTOR_GetDeviceType (
20
- IN PINQUIRYDATA InquiryData ,
21
- IN UCHAR IsFloppy )
21
+ IN PINQUIRYDATA InquiryData )
22
22
{
23
- if (InquiryData -> DeviceType == 0 )
24
- {
25
- if (IsFloppy )
26
- {
27
- // floppy device
28
- return "SFloppy" ;
29
- }
30
-
31
- // direct access device
32
- return "Disk" ;
33
- }
34
-
35
23
switch (InquiryData -> DeviceType )
36
24
{
37
- case 1 :
38
- {
25
+ case DIRECT_ACCESS_DEVICE :
26
+ return "Disk" ;
27
+ case SEQUENTIAL_ACCESS_DEVICE :
39
28
// sequential device, i.e magnetic tape
40
29
return "Sequential" ;
41
- }
42
- case 4 :
43
- {
44
- // write once device
30
+ case WRITE_ONCE_READ_MULTIPLE_DEVICE :
45
31
return "Worm" ;
46
- }
47
- case 5 :
48
- {
49
- // CDROM device
32
+ case READ_ONLY_DIRECT_ACCESS_DEVICE :
50
33
return "CdRom" ;
51
- }
52
- case 7 :
53
- {
54
- // optical memory device
34
+ case OPTICAL_DEVICE :
55
35
return "Optical" ;
56
- }
57
- case 8 :
58
- {
59
- // medium change device
36
+ case MEDIUM_CHANGER :
60
37
return "Changer" ;
61
- }
62
38
default :
63
- {
64
- // other device
65
39
return "Other" ;
66
- }
67
40
}
68
41
}
69
42
43
+ static
70
44
LPCSTR
71
45
USBSTOR_GetGenericType (
72
- IN PINQUIRYDATA InquiryData ,
73
- IN UCHAR IsFloppy )
46
+ IN PINQUIRYDATA InquiryData )
74
47
{
75
- if (InquiryData -> DeviceType == 0 )
76
- {
77
- if (IsFloppy )
78
- {
79
- // floppy device
80
- return "GenSFloppy" ;
81
- }
82
-
83
- // direct access device
84
- return "GenDisk" ;
85
- }
86
-
87
48
switch (InquiryData -> DeviceType )
88
49
{
89
- case 1 :
90
- {
50
+ case DIRECT_ACCESS_DEVICE :
51
+ return "GenDisk" ;
52
+ case SEQUENTIAL_ACCESS_DEVICE :
91
53
// sequential device, i.e magnetic tape
92
54
return "GenSequential" ;
93
- }
94
- case 4 :
95
- {
96
- // write once device
55
+ case WRITE_ONCE_READ_MULTIPLE_DEVICE :
97
56
return "GenWorm" ;
98
- }
99
- case 5 :
100
- {
101
- // CDROM device
57
+ case READ_ONLY_DIRECT_ACCESS_DEVICE :
102
58
return "GenCdRom" ;
103
- }
104
- case 7 :
105
- {
106
- // optical memory device
59
+ case OPTICAL_DEVICE :
107
60
return "GenOptical" ;
108
- }
109
- case 8 :
110
- {
111
- // medium change device
61
+ case MEDIUM_CHANGER :
112
62
return "GenChanger" ;
113
- }
114
63
default :
115
- {
116
- // other device
117
64
return "UsbstorOther" ;
118
- }
119
65
}
120
66
}
121
67
@@ -210,7 +156,7 @@ USBSTOR_PdoHandleQueryDeviceText(
210
156
211
157
DeviceDescription .Length = 0 ;
212
158
DeviceDescription .MaximumLength = (USHORT )(Offset * sizeof (WCHAR ));
213
- DeviceDescription .Buffer = ( LPWSTR ) AllocateItem ( PagedPool , DeviceDescription .MaximumLength );
159
+ DeviceDescription .Buffer = ExAllocatePoolWithTag ( PagedPool , DeviceDescription .MaximumLength , USB_STOR_TAG );
214
160
if (!DeviceDescription .Buffer )
215
161
{
216
162
Irp -> IoStatus .Information = 0 ;
@@ -248,7 +194,7 @@ USBSTOR_PdoHandleQueryDeviceId(
248
194
ASSERT (DeviceExtension -> InquiryData );
249
195
InquiryData = DeviceExtension -> InquiryData ;
250
196
251
- DeviceType = USBSTOR_GetDeviceType (InquiryData , DeviceExtension -> IsFloppy );
197
+ DeviceType = USBSTOR_GetDeviceType (InquiryData );
252
198
253
199
// lets create device string
254
200
Offset = sprintf (& Buffer [Offset ], "USBSTOR\\" );
@@ -265,7 +211,7 @@ USBSTOR_PdoHandleQueryDeviceId(
265
211
// allocate DeviceId string
266
212
DeviceId .Length = 0 ;
267
213
DeviceId .MaximumLength = (USHORT )((strlen ((PCHAR )Buffer ) + 1 ) * sizeof (WCHAR ));
268
- DeviceId .Buffer = ( LPWSTR ) AllocateItem ( PagedPool , DeviceId .MaximumLength );
214
+ DeviceId .Buffer = ExAllocatePoolWithTag ( PagedPool , DeviceId .MaximumLength , USB_STOR_TAG );
269
215
if (!DeviceId .Buffer )
270
216
{
271
217
Irp -> IoStatus .Information = 0 ;
@@ -338,8 +284,8 @@ USBSTOR_PdoHandleQueryHardwareId(
338
284
ASSERT (FDODeviceExtension -> DeviceDescriptor );
339
285
InquiryData = PDODeviceExtension -> InquiryData ;
340
286
341
- DeviceType = USBSTOR_GetDeviceType (InquiryData , PDODeviceExtension -> IsFloppy );
342
- GenericType = USBSTOR_GetGenericType (InquiryData , PDODeviceExtension -> IsFloppy );
287
+ DeviceType = USBSTOR_GetDeviceType (InquiryData );
288
+ GenericType = USBSTOR_GetGenericType (InquiryData );
343
289
344
290
ASSERT (GenericType );
345
291
@@ -418,7 +364,7 @@ USBSTOR_PdoHandleQueryHardwareId(
418
364
419
365
TotalLength = Id1Length + Id2Length + Id3Length + Id4Length + Id5Length + Id6Length + Id7Length + 1 ;
420
366
421
- Buffer = ( LPWSTR ) AllocateItem ( PagedPool , TotalLength * sizeof (WCHAR ));
367
+ Buffer = ExAllocatePoolWithTag ( PagedPool , TotalLength * sizeof (WCHAR ), USB_STOR_TAG );
422
368
if (!Buffer )
423
369
{
424
370
Irp -> IoStatus .Information = 0 ;
@@ -458,13 +404,13 @@ USBSTOR_PdoHandleQueryCompatibleId(
458
404
PDODeviceExtension = (PPDO_DEVICE_EXTENSION )DeviceObject -> DeviceExtension ;
459
405
FDODeviceExtension = (PFDO_DEVICE_EXTENSION )PDODeviceExtension -> LowerDeviceObject -> DeviceExtension ;
460
406
ASSERT (FDODeviceExtension -> DeviceDescriptor );
461
- DeviceType = USBSTOR_GetDeviceType (PDODeviceExtension -> InquiryData , PDODeviceExtension -> IsFloppy );
407
+ DeviceType = USBSTOR_GetDeviceType (PDODeviceExtension -> InquiryData );
462
408
463
409
// format instance id
464
410
Length = sprintf (Buffer , "USBSTOR\\%s" , DeviceType ) + 1 ;
465
411
Length += sprintf (& Buffer [Length ], "USBSTOR\\%s" , "RAW" ) + 2 ;
466
412
467
- InstanceId = ( LPWSTR ) AllocateItem ( PagedPool , Length * sizeof (WCHAR ));
413
+ InstanceId = ExAllocatePoolWithTag ( PagedPool , Length * sizeof (WCHAR ), USB_STOR_TAG );
468
414
if (!InstanceId )
469
415
{
470
416
Irp -> IoStatus .Information = 0 ;
@@ -508,7 +454,7 @@ USBSTOR_PdoHandleQueryInstanceId(
508
454
509
455
Length = wcslen (Buffer ) + 1 ;
510
456
511
- InstanceId = ( LPWSTR ) AllocateItem ( PagedPool , Length * sizeof (WCHAR ));
457
+ InstanceId = ExAllocatePoolWithTag ( PagedPool , Length * sizeof (WCHAR ), USB_STOR_TAG );
512
458
if (!InstanceId )
513
459
{
514
460
Irp -> IoStatus .Information = 0 ;
@@ -542,7 +488,7 @@ USBSTOR_PdoHandleDeviceRelations(
542
488
return Irp -> IoStatus .Status ;
543
489
}
544
490
545
- DeviceRelations = ( PDEVICE_RELATIONS ) AllocateItem ( PagedPool , sizeof (DEVICE_RELATIONS ));
491
+ DeviceRelations = ExAllocatePoolWithTag ( PagedPool , sizeof (DEVICE_RELATIONS ), USB_STOR_TAG );
546
492
if (!DeviceRelations )
547
493
{
548
494
return STATUS_INSUFFICIENT_RESOURCES ;
@@ -953,13 +899,9 @@ USBSTOR_CreatePDO(
953
899
return Status ;
954
900
}
955
901
956
- if (PDODeviceExtension -> InquiryData -> DeviceType == DIRECT_ACCESS_DEVICE || PDODeviceExtension -> InquiryData -> DeviceType == READ_ONLY_DIRECT_ACCESS_DEVICE )
957
- {
958
- PDODeviceExtension -> IsFloppy = FALSE; // TODO: implement the actual check
959
- }
960
- else
902
+ if (PDODeviceExtension -> InquiryData -> DeviceType != DIRECT_ACCESS_DEVICE &&
903
+ PDODeviceExtension -> InquiryData -> DeviceType != READ_ONLY_DIRECT_ACCESS_DEVICE )
961
904
{
962
- // we work only with DIRECT_ACCESS_DEVICE for now
963
905
return STATUS_NOT_SUPPORTED ;
964
906
}
965
907
0 commit comments