368f390619b8957420e95d5dff7fa7cd92e43124
[reactos.git] / reactos / include / ddk / classpnp.h
1
2 #pragma once
3
4 #define _CLASS_
5
6 #include <ntdddisk.h>
7 #include <ntddcdrm.h>
8 #include <ntddtape.h>
9 #include <ntddscsi.h>
10 #include <ntddstor.h>
11
12 #include <stdio.h>
13
14 #include <scsi.h>
15
16 #define SRB_CLASS_FLAGS_LOW_PRIORITY 0x10000000
17 #define SRB_CLASS_FLAGS_PERSISTANT 0x20000000
18 #define SRB_CLASS_FLAGS_PAGING 0x40000000
19 #define SRB_CLASS_FLAGS_FREE_MDL 0x80000000
20
21 #define ASSERT_FDO(x) \
22 ASSERT(((PCOMMON_DEVICE_EXTENSION) (x)->DeviceExtension)->IsFdo)
23
24 #define ASSERT_PDO(x) \
25 ASSERT(!(((PCOMMON_DEVICE_EXTENSION) (x)->DeviceExtension)->IsFdo))
26
27 #define IS_CLEANUP_REQUEST(majorFunction) \
28 ((majorFunction == IRP_MJ_CLOSE) || \
29 (majorFunction == IRP_MJ_CLEANUP) || \
30 (majorFunction == IRP_MJ_SHUTDOWN))
31
32 #define DO_MCD(fdoExtension) \
33 (((fdoExtension)->MediaChangeDetectionInfo != NULL) && \
34 ((fdoExtension)->MediaChangeDetectionInfo->MediaChangeDetectionDisableCount == 0))
35
36 #define IS_SCSIOP_READ(opCode) \
37 ((opCode == SCSIOP_READ6) || \
38 (opCode == SCSIOP_READ) || \
39 (opCode == SCSIOP_READ12) || \
40 (opCode == SCSIOP_READ16))
41
42 #define IS_SCSIOP_WRITE(opCode) \
43 ((opCode == SCSIOP_WRITE6) || \
44 (opCode == SCSIOP_WRITE) || \
45 (opCode == SCSIOP_WRITE12) || \
46 (opCode == SCSIOP_WRITE16))
47
48 #define IS_SCSIOP_READWRITE(opCode) (IS_SCSIOP_READ(opCode) || IS_SCSIOP_WRITE(opCode))
49
50 #define ADJUST_FUA_FLAG(fdoExt) { \
51 if (TEST_FLAG(fdoExt->DeviceFlags, DEV_WRITE_CACHE) && \
52 !TEST_FLAG(fdoExt->DeviceFlags, DEV_POWER_PROTECTED) && \
53 !TEST_FLAG(fdoExt->ScanForSpecialFlags, CLASS_SPECIAL_FUA_NOT_SUPPORTED) ) { \
54 fdoExt->CdbForceUnitAccess = TRUE; \
55 } else { \
56 fdoExt->CdbForceUnitAccess = FALSE; \
57 } \
58 }
59
60 #define FREE_POOL(_PoolPtr) \
61 if (_PoolPtr != NULL) { \
62 ExFreePool(_PoolPtr); \
63 _PoolPtr = NULL; \
64 }
65
66 #ifdef POOL_TAGGING
67 #undef ExAllocatePool
68 #undef ExAllocatePoolWithQuota
69 #define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,'nUcS')
70 //#define ExAllocatePool(a,b) #assert(0)
71 #define ExAllocatePoolWithQuota(a,b) ExAllocatePoolWithQuotaTag(a,b,'nUcS')
72 #endif
73
74 #define CLASS_TAG_AUTORUN_DISABLE 'ALcS'
75 #define CLASS_TAG_FILE_OBJECT_EXTENSION 'FLcS'
76 #define CLASS_TAG_MEDIA_CHANGE_DETECTION 'MLcS'
77 #define CLASS_TAG_MOUNT 'mLcS'
78 #define CLASS_TAG_RELEASE_QUEUE 'qLcS'
79 #define CLASS_TAG_POWER 'WLcS'
80 #define CLASS_TAG_WMI 'wLcS'
81 #define CLASS_TAG_FAILURE_PREDICT 'fLcS'
82 #define CLASS_TAG_DEVICE_CONTROL 'OIcS'
83 #define CLASS_TAG_MODE_DATA 'oLcS'
84 #define CLASS_TAG_MULTIPATH 'mPcS'
85
86 #define MAXIMUM_RETRIES 4
87
88 #define CLASS_DRIVER_EXTENSION_KEY ((PVOID) ClassInitialize)
89
90 #define NO_REMOVE 0
91 #define REMOVE_PENDING 1
92 #define REMOVE_COMPLETE 2
93
94 #define ClassAcquireRemoveLock(devobj, tag) \
95 ClassAcquireRemoveLockEx(devobj, tag, __FILE__, __LINE__)
96
97 #ifdef TRY
98 #undef TRY
99 #endif
100 #ifdef LEAVE
101 #undef LEAVE
102 #endif
103
104 #ifdef FINALLY
105 #undef FINALLY
106 #endif
107
108 #define TRY
109 #define LEAVE goto __tryLabel;
110 #define FINALLY __tryLabel:
111
112 #if defined DebugPrint
113 #undef DebugPrint
114 #endif
115
116 #if DBG
117 #define DebugPrint(x) ClassDebugPrint x
118 #else
119 #define DebugPrint(x)
120 #endif
121
122 #define DEBUG_BUFFER_LENGTH 256
123
124 #define START_UNIT_TIMEOUT (60 * 4)
125
126 #define MEDIA_CHANGE_DEFAULT_TIME 1
127 #define MEDIA_CHANGE_TIMEOUT_TIME 300
128
129 #define MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS 0x3b9aca00
130
131 #ifdef ALLOCATE_SRB_FROM_POOL
132
133 #define ClasspAllocateSrb(ext)
134 ExAllocatePoolWithTag(NonPagedPool, \
135 sizeof(SCSI_REQUEST_BLOCK), \
136 'sBRS')
137
138 #define ClasspFreeSrb(ext, srb) ExFreePool((srb));
139
140 #else /* ALLOCATE_SRB_FROM_POOL */
141
142 #define ClasspAllocateSrb(ext) \
143 ExAllocateFromNPagedLookasideList( \
144 &((ext)->CommonExtension.SrbLookasideList))
145
146 #define ClasspFreeSrb(ext, srb) \
147 ExFreeToNPagedLookasideList( \
148 &((ext)->CommonExtension.SrbLookasideList), \
149 (srb))
150
151 #endif /* ALLOCATE_SRB_FROM_POOL */
152
153 #define SET_FLAG(Flags, Bit) ((Flags) |= (Bit))
154 #define CLEAR_FLAG(Flags, Bit) ((Flags) &= ~(Bit))
155 #define TEST_FLAG(Flags, Bit) (((Flags) & (Bit)) != 0)
156
157 #define CLASS_WORKING_SET_MAXIMUM 2048
158
159 #define CLASS_INTERPRET_SENSE_INFO2_MAXIMUM_HISTORY_COUNT 30000
160
161 #define CLASS_SPECIAL_DISABLE_SPIN_DOWN 0x00000001
162 #define CLASS_SPECIAL_DISABLE_SPIN_UP 0x00000002
163 #define CLASS_SPECIAL_NO_QUEUE_LOCK 0x00000008
164 #define CLASS_SPECIAL_DISABLE_WRITE_CACHE 0x00000010
165 #define CLASS_SPECIAL_CAUSE_NOT_REPORTABLE_HACK 0x00000020
166 #if ((NTDDI_VERSION == NTDDI_WIN2KSP3) || (OSVER(NTDDI_VERSION) == NTDDI_WINXP))
167 #define CLASS_SPECIAL_DISABLE_WRITE_CACHE_NOT_SUPPORTED 0x00000040
168 #endif
169 #define CLASS_SPECIAL_MODIFY_CACHE_UNSUCCESSFUL 0x00000040
170 #define CLASS_SPECIAL_FUA_NOT_SUPPORTED 0x00000080
171 #define CLASS_SPECIAL_VALID_MASK 0x000000FB
172 #define CLASS_SPECIAL_RESERVED (~CLASS_SPECIAL_VALID_MASK)
173
174 #define DEV_WRITE_CACHE 0x00000001
175 #define DEV_USE_SCSI1 0x00000002
176 #define DEV_SAFE_START_UNIT 0x00000004
177 #define DEV_NO_12BYTE_CDB 0x00000008
178 #define DEV_POWER_PROTECTED 0x00000010
179 #define DEV_USE_16BYTE_CDB 0x00000020
180
181 #define GUID_CLASSPNP_QUERY_REGINFOEX {0x00e34b11, 0x2444, 0x4745, {0xa5, 0x3d, 0x62, 0x01, 0x00, 0xcd, 0x82, 0xf7}}
182 #define GUID_CLASSPNP_SENSEINFO2 {0x509a8c5f, 0x71d7, 0x48f6, {0x82, 0x1e, 0x17, 0x3c, 0x49, 0xbf, 0x2f, 0x18}}
183 #define GUID_CLASSPNP_WORKING_SET {0x105701b0, 0x9e9b, 0x47cb, {0x97, 0x80, 0x81, 0x19, 0x8a, 0xf7, 0xb5, 0x24}}
184
185 #define DEFAULT_FAILURE_PREDICTION_PERIOD 60 * 60 * 1
186
187 static inline ULONG CountOfSetBitsUChar(UCHAR _X)
188 { ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
189 static inline ULONG CountOfSetBitsULong(ULONG _X)
190 { ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
191 static inline ULONG CountOfSetBitsULong32(ULONG32 _X)
192 { ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
193 static inline ULONG CountOfSetBitsULong64(ULONG64 _X)
194 { ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
195 static inline ULONG CountOfSetBitsUlongPtr(ULONG_PTR _X)
196 { ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
197
198 typedef enum _MEDIA_CHANGE_DETECTION_STATE {
199 MediaUnknown,
200 MediaPresent,
201 MediaNotPresent,
202 MediaUnavailable
203 } MEDIA_CHANGE_DETECTION_STATE, *PMEDIA_CHANGE_DETECTION_STATE;
204
205 typedef enum _CLASS_DEBUG_LEVEL {
206 ClassDebugError = 0,
207 ClassDebugWarning = 1,
208 ClassDebugTrace = 2,
209 ClassDebugInfo = 3,
210 ClassDebugMediaLocks = 8,
211 ClassDebugMCN = 9,
212 ClassDebugDelayedRetry = 10,
213 ClassDebugSenseInfo = 11,
214 ClassDebugRemoveLock = 12,
215 ClassDebugExternal4 = 13,
216 ClassDebugExternal3 = 14,
217 ClassDebugExternal2 = 15,
218 ClassDebugExternal1 = 16
219 } CLASS_DEBUG_LEVEL, *PCLASS_DEBUG_LEVEL;
220
221 typedef enum {
222 EventGeneration,
223 DataBlockCollection
224 } CLASSENABLEDISABLEFUNCTION;
225
226 typedef enum {
227 FailurePredictionNone = 0,
228 FailurePredictionIoctl,
229 FailurePredictionSmart,
230 FailurePredictionSense
231 } FAILURE_PREDICTION_METHOD, *PFAILURE_PREDICTION_METHOD;
232
233 typedef enum {
234 PowerDownDeviceInitial,
235 PowerDownDeviceLocked,
236 PowerDownDeviceStopped,
237 PowerDownDeviceOff,
238 PowerDownDeviceUnlocked
239 } CLASS_POWER_DOWN_STATE;
240
241 typedef enum {
242 PowerDownDeviceInitial2,
243 PowerDownDeviceLocked2,
244 PowerDownDeviceFlushed2,
245 PowerDownDeviceStopped2,
246 PowerDownDeviceOff2,
247 PowerDownDeviceUnlocked2
248 } CLASS_POWER_DOWN_STATE2;
249
250 typedef enum {
251 PowerUpDeviceInitial,
252 PowerUpDeviceLocked,
253 PowerUpDeviceOn,
254 PowerUpDeviceStarted,
255 PowerUpDeviceUnlocked
256 } CLASS_POWER_UP_STATE;
257
258 struct _CLASS_INIT_DATA;
259 typedef struct _CLASS_INIT_DATA CLASS_INIT_DATA, *PCLASS_INIT_DATA;
260
261 struct _CLASS_PRIVATE_FDO_DATA;
262 typedef struct _CLASS_PRIVATE_FDO_DATA CLASS_PRIVATE_FDO_DATA, *PCLASS_PRIVATE_FDO_DATA;
263
264 struct _CLASS_PRIVATE_PDO_DATA;
265 typedef struct _CLASS_PRIVATE_PDO_DATA CLASS_PRIVATE_PDO_DATA, *PCLASS_PRIVATE_PDO_DATA;
266
267 struct _CLASS_PRIVATE_COMMON_DATA;
268 typedef struct _CLASS_PRIVATE_COMMON_DATA CLASS_PRIVATE_COMMON_DATA, *PCLASS_PRIVATE_COMMON_DATA;
269
270 struct _MEDIA_CHANGE_DETECTION_INFO;
271 typedef struct _MEDIA_CHANGE_DETECTION_INFO MEDIA_CHANGE_DETECTION_INFO, *PMEDIA_CHANGE_DETECTION_INFO;
272
273 typedef struct _DICTIONARY {
274 ULONGLONG Signature;
275 struct _DICTIONARY_HEADER* List;
276 KSPIN_LOCK SpinLock;
277 } DICTIONARY, *PDICTIONARY;
278
279 typedef struct _CLASSPNP_SCAN_FOR_SPECIAL_INFO {
280 PCHAR VendorId;
281 PCHAR ProductId;
282 PCHAR ProductRevision;
283 ULONG_PTR Data;
284 } CLASSPNP_SCAN_FOR_SPECIAL_INFO, *PCLASSPNP_SCAN_FOR_SPECIAL_INFO;
285
286 typedef VOID
287 (NTAPI *PCLASS_ERROR)(
288 PDEVICE_OBJECT DeviceObject,
289 PSCSI_REQUEST_BLOCK Srb,
290 NTSTATUS *Status,
291 BOOLEAN *Retry);
292
293 typedef NTSTATUS
294 (NTAPI *PCLASS_ADD_DEVICE)(
295 PDRIVER_OBJECT DriverObject,
296 PDEVICE_OBJECT Pdo);
297
298 typedef NTSTATUS
299 (NTAPI *PCLASS_POWER_DEVICE)(
300 PDEVICE_OBJECT DeviceObject,
301 PIRP Irp);
302
303 typedef NTSTATUS
304 (NTAPI *PCLASS_START_DEVICE)(
305 PDEVICE_OBJECT DeviceObject);
306
307 typedef NTSTATUS
308 (NTAPI *PCLASS_STOP_DEVICE)(
309 PDEVICE_OBJECT DeviceObject,
310 UCHAR Type);
311
312 typedef NTSTATUS
313 (NTAPI *PCLASS_INIT_DEVICE)(
314 PDEVICE_OBJECT DeviceObject);
315
316 typedef NTSTATUS
317 (NTAPI *PCLASS_ENUM_DEVICE)(
318 PDEVICE_OBJECT DeviceObject);
319
320 typedef NTSTATUS
321 (NTAPI *PCLASS_READ_WRITE)(
322 PDEVICE_OBJECT DeviceObject,
323 PIRP Irp);
324
325 typedef NTSTATUS
326 (NTAPI *PCLASS_DEVICE_CONTROL)(
327 PDEVICE_OBJECT DeviceObject,
328 PIRP Irp);
329
330 typedef NTSTATUS
331 (NTAPI *PCLASS_SHUTDOWN_FLUSH)(
332 PDEVICE_OBJECT DeviceObject,
333 PIRP Irp);
334
335 typedef NTSTATUS
336 (NTAPI *PCLASS_CREATE_CLOSE)(
337 PDEVICE_OBJECT DeviceObject,
338 PIRP Irp);
339
340 typedef NTSTATUS
341 (NTAPI *PCLASS_QUERY_ID)(
342 PDEVICE_OBJECT DeviceObject,
343 BUS_QUERY_ID_TYPE IdType,
344 PUNICODE_STRING IdString);
345
346 typedef NTSTATUS
347 (NTAPI *PCLASS_REMOVE_DEVICE)(
348 PDEVICE_OBJECT DeviceObject,
349 UCHAR Type);
350
351 typedef VOID
352 (NTAPI *PCLASS_UNLOAD)(
353 PDRIVER_OBJECT DriverObject);
354
355 typedef NTSTATUS
356 (NTAPI *PCLASS_QUERY_PNP_CAPABILITIES)(
357 PDEVICE_OBJECT PhysicalDeviceObject,
358 PDEVICE_CAPABILITIES Capabilities);
359
360 typedef VOID
361 (NTAPI *PCLASS_TICK)(
362 PDEVICE_OBJECT DeviceObject);
363
364 typedef NTSTATUS
365 (NTAPI *PCLASS_QUERY_WMI_REGINFO_EX)(
366 PDEVICE_OBJECT DeviceObject,
367 ULONG *RegFlags,
368 PUNICODE_STRING Name,
369 PUNICODE_STRING MofResouceName);
370
371 typedef NTSTATUS
372 (NTAPI *PCLASS_QUERY_WMI_REGINFO)(
373 PDEVICE_OBJECT DeviceObject,
374 ULONG *RegFlags,
375 PUNICODE_STRING Name);
376
377 typedef NTSTATUS
378 (NTAPI *PCLASS_QUERY_WMI_DATABLOCK)(
379 PDEVICE_OBJECT DeviceObject,
380 PIRP Irp,
381 ULONG GuidIndex,
382 ULONG BufferAvail,
383 PUCHAR Buffer);
384
385 typedef NTSTATUS
386 (NTAPI *PCLASS_SET_WMI_DATABLOCK)(
387 PDEVICE_OBJECT DeviceObject,
388 PIRP Irp,
389 ULONG GuidIndex,
390 ULONG BufferSize,
391 PUCHAR Buffer);
392
393 typedef NTSTATUS
394 (NTAPI *PCLASS_SET_WMI_DATAITEM)(
395 PDEVICE_OBJECT DeviceObject,
396 PIRP Irp,
397 ULONG GuidIndex,
398 ULONG DataItemId,
399 ULONG BufferSize,
400 PUCHAR Buffer);
401
402 typedef NTSTATUS
403 (NTAPI *PCLASS_EXECUTE_WMI_METHOD)(
404 PDEVICE_OBJECT DeviceObject,
405 PIRP Irp,
406 ULONG GuidIndex,
407 ULONG MethodId,
408 ULONG InBufferSize,
409 ULONG OutBufferSize,
410 PUCHAR Buffer);
411
412 typedef NTSTATUS
413 (NTAPI *PCLASS_WMI_FUNCTION_CONTROL)(
414 PDEVICE_OBJECT DeviceObject,
415 PIRP Irp,
416 ULONG GuidIndex,
417 CLASSENABLEDISABLEFUNCTION Function,
418 BOOLEAN Enable);
419
420 typedef struct _SRB_HISTORY_ITEM {
421 LARGE_INTEGER TickCountSent;
422 LARGE_INTEGER TickCountCompleted;
423 ULONG MillisecondsDelayOnRetry;
424 SENSE_DATA NormalizedSenseData;
425 UCHAR SrbStatus;
426 UCHAR ClassDriverUse;
427 } SRB_HISTORY_ITEM, *PSRB_HISTORY_ITEM;
428
429 typedef struct _SRB_HISTORY {
430 ULONG_PTR ClassDriverUse[4];
431 ULONG TotalHistoryCount;
432 ULONG UsedHistoryCount;
433 SRB_HISTORY_ITEM History[1];
434 } SRB_HISTORY, *PSRB_HISTORY;
435
436 typedef BOOLEAN
437 (NTAPI *PCLASS_INTERPRET_SENSE_INFO)(
438 PDEVICE_OBJECT Fdo,
439 PIRP OriginalRequest,
440 PSCSI_REQUEST_BLOCK Srb,
441 UCHAR MajorFunctionCode,
442 ULONG IoDeviceCode,
443 ULONG PreviousRetryCount,
444 SRB_HISTORY *RequestHistory,
445 NTSTATUS *Status,
446 LONGLONG *RetryIn100nsUnits);
447
448 typedef VOID
449 (NTAPI *PCLASS_COMPRESS_RETRY_HISTORY_DATA)(
450 PDEVICE_OBJECT DeviceObject,
451 PSRB_HISTORY RequestHistory);
452
453 typedef struct {
454 GUID Guid;
455 ULONG InstanceCount;
456 ULONG Flags;
457 } GUIDREGINFO, *PGUIDREGINFO;
458
459 typedef struct _CLASS_WMI_INFO {
460 ULONG GuidCount;
461 PGUIDREGINFO GuidRegInfo;
462 PCLASS_QUERY_WMI_REGINFO ClassQueryWmiRegInfo;
463 PCLASS_QUERY_WMI_DATABLOCK ClassQueryWmiDataBlock;
464 PCLASS_SET_WMI_DATABLOCK ClassSetWmiDataBlock;
465 PCLASS_SET_WMI_DATAITEM ClassSetWmiDataItem;
466 PCLASS_EXECUTE_WMI_METHOD ClassExecuteWmiMethod;
467 PCLASS_WMI_FUNCTION_CONTROL ClassWmiFunctionControl;
468 } CLASS_WMI_INFO, *PCLASS_WMI_INFO;
469
470 typedef struct _CLASS_DEV_INFO {
471 ULONG DeviceExtensionSize;
472 DEVICE_TYPE DeviceType;
473 UCHAR StackSize;
474 ULONG DeviceCharacteristics;
475 PCLASS_ERROR ClassError;
476 PCLASS_READ_WRITE ClassReadWriteVerification;
477 PCLASS_DEVICE_CONTROL ClassDeviceControl;
478 PCLASS_SHUTDOWN_FLUSH ClassShutdownFlush;
479 PCLASS_CREATE_CLOSE ClassCreateClose;
480 PCLASS_INIT_DEVICE ClassInitDevice;
481 PCLASS_START_DEVICE ClassStartDevice;
482 PCLASS_POWER_DEVICE ClassPowerDevice;
483 PCLASS_STOP_DEVICE ClassStopDevice;
484 PCLASS_REMOVE_DEVICE ClassRemoveDevice;
485 PCLASS_QUERY_PNP_CAPABILITIES ClassQueryPnpCapabilities;
486 CLASS_WMI_INFO ClassWmiInfo;
487 } CLASS_DEV_INFO, *PCLASS_DEV_INFO;
488
489 struct _CLASS_INIT_DATA {
490 ULONG InitializationDataSize;
491 CLASS_DEV_INFO FdoData;
492 CLASS_DEV_INFO PdoData;
493 PCLASS_ADD_DEVICE ClassAddDevice;
494 PCLASS_ENUM_DEVICE ClassEnumerateDevice;
495 PCLASS_QUERY_ID ClassQueryId;
496 PDRIVER_STARTIO ClassStartIo;
497 PCLASS_UNLOAD ClassUnload;
498 PCLASS_TICK ClassTick;
499 };
500
501 typedef struct _FILE_OBJECT_EXTENSION {
502 PFILE_OBJECT FileObject;
503 PDEVICE_OBJECT DeviceObject;
504 ULONG LockCount;
505 ULONG McnDisableCount;
506 } FILE_OBJECT_EXTENSION, *PFILE_OBJECT_EXTENSION;
507
508 typedef struct _CLASS_WORKING_SET {
509 ULONG Size;
510 ULONG XferPacketsWorkingSetMaximum;
511 ULONG XferPacketsWorkingSetMinimum;
512 } CLASS_WORKING_SET, *PCLASS_WORKING_SET;
513
514 typedef struct _CLASS_INTERPRET_SENSE_INFO2 {
515 ULONG Size;
516 ULONG HistoryCount;
517 PCLASS_COMPRESS_RETRY_HISTORY_DATA Compress;
518 PCLASS_INTERPRET_SENSE_INFO Interpret;
519 } CLASS_INTERPRET_SENSE_INFO2, *PCLASS_INTERPRET_SENSE_INFO2;
520
521 C_ASSERT((MAXULONG - sizeof(SRB_HISTORY)) / 30000 >= sizeof(SRB_HISTORY_ITEM));
522
523 typedef struct _CLASS_DRIVER_EXTENSION {
524 UNICODE_STRING RegistryPath;
525 CLASS_INIT_DATA InitData;
526 ULONG DeviceCount;
527 #if (NTDDI_VERSION >= NTDDI_WINXP)
528 PCLASS_QUERY_WMI_REGINFO_EX ClassFdoQueryWmiRegInfoEx;
529 PCLASS_QUERY_WMI_REGINFO_EX ClassPdoQueryWmiRegInfoEx;
530 #endif
531 #if (NTDDI_VERSION >= NTDDI_VISTA)
532 REGHANDLE EtwHandle;
533 PDRIVER_DISPATCH DeviceMajorFunctionTable[IRP_MJ_MAXIMUM_FUNCTION + 1];
534 PDRIVER_DISPATCH MpDeviceMajorFunctionTable[IRP_MJ_MAXIMUM_FUNCTION + 1];
535 PCLASS_INTERPRET_SENSE_INFO2 InterpretSenseInfo;
536 PCLASS_WORKING_SET WorkingSet;
537 #endif
538 } CLASS_DRIVER_EXTENSION, *PCLASS_DRIVER_EXTENSION;
539
540 typedef struct _COMMON_DEVICE_EXTENSION {
541 ULONG Version;
542 PDEVICE_OBJECT DeviceObject;
543 PDEVICE_OBJECT LowerDeviceObject;
544 struct _FUNCTIONAL_DEVICE_EXTENSION *PartitionZeroExtension;
545 PCLASS_DRIVER_EXTENSION DriverExtension;
546 LONG RemoveLock;
547 KEVENT RemoveEvent;
548 KSPIN_LOCK RemoveTrackingSpinlock;
549 PVOID RemoveTrackingList;
550 LONG RemoveTrackingUntrackedCount;
551 PVOID DriverData;
552 _ANONYMOUS_STRUCT struct {
553 BOOLEAN IsFdo:1;
554 BOOLEAN IsInitialized:1;
555 BOOLEAN IsSrbLookasideListInitialized:1;
556 } DUMMYSTRUCTNAME;
557 UCHAR PreviousState;
558 UCHAR CurrentState;
559 ULONG IsRemoved;
560 UNICODE_STRING DeviceName;
561 struct _PHYSICAL_DEVICE_EXTENSION *ChildList;
562 ULONG PartitionNumber;
563 LARGE_INTEGER PartitionLength;
564 LARGE_INTEGER StartingOffset;
565 PCLASS_DEV_INFO DevInfo;
566 ULONG PagingPathCount;
567 ULONG DumpPathCount;
568 ULONG HibernationPathCount;
569 KEVENT PathCountEvent;
570 #ifndef ALLOCATE_SRB_FROM_POOL
571 NPAGED_LOOKASIDE_LIST SrbLookasideList;
572 #endif
573 UNICODE_STRING MountedDeviceInterfaceName;
574 ULONG GuidCount;
575 PGUIDREGINFO GuidRegInfo;
576 DICTIONARY FileObjectDictionary;
577 #if (NTDDI_VERSION >= NTDDI_WINXP)
578 PCLASS_PRIVATE_COMMON_DATA PrivateCommonData;
579 #else
580 ULONG_PTR Reserved1;
581 #endif
582 #if (NTDDI_VERSION >= NTDDI_VISTA)
583 PDRIVER_DISPATCH *DispatchTable;
584 #else
585 ULONG_PTR Reserved2;
586 #endif
587 ULONG_PTR Reserved3;
588 ULONG_PTR Reserved4;
589 } COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
590
591 typedef struct _PHYSICAL_DEVICE_EXTENSION {
592 _ANONYMOUS_UNION union {
593 _ANONYMOUS_STRUCT struct {
594 ULONG Version;
595 PDEVICE_OBJECT DeviceObject;
596 } DUMMYSTRUCTNAME;
597 COMMON_DEVICE_EXTENSION CommonExtension;
598 } DUMMYUNIONNAME;
599 BOOLEAN IsMissing;
600 BOOLEAN IsEnumerated;
601 #if (NTDDI_VERSION >= NTDDI_WINXP)
602 PCLASS_PRIVATE_PDO_DATA PrivatePdoData;
603 #else
604 ULONG_PTR Reserved1;
605 #endif
606 ULONG_PTR Reserved2;
607 ULONG_PTR Reserved3;
608 ULONG_PTR Reserved4;
609 } PHYSICAL_DEVICE_EXTENSION, *PPHYSICAL_DEVICE_EXTENSION;
610
611 typedef struct _CLASS_POWER_OPTIONS {
612 ULONG PowerDown:1;
613 ULONG LockQueue:1;
614 ULONG HandleSpinDown:1;
615 ULONG HandleSpinUp:1;
616 ULONG Reserved:27;
617 } CLASS_POWER_OPTIONS, *PCLASS_POWER_OPTIONS;
618
619 typedef struct _CLASS_POWER_CONTEXT {
620 union {
621 CLASS_POWER_DOWN_STATE PowerDown;
622 CLASS_POWER_DOWN_STATE2 PowerDown2;
623 CLASS_POWER_UP_STATE PowerUp;
624 } PowerChangeState;
625 CLASS_POWER_OPTIONS Options;
626 BOOLEAN InUse;
627 BOOLEAN QueueLocked;
628 NTSTATUS FinalStatus;
629 ULONG RetryCount;
630 ULONG RetryInterval;
631 PIO_COMPLETION_ROUTINE CompletionRoutine;
632 PDEVICE_OBJECT DeviceObject;
633 PIRP Irp;
634 SCSI_REQUEST_BLOCK Srb;
635 } CLASS_POWER_CONTEXT, *PCLASS_POWER_CONTEXT;
636
637 typedef struct _COMPLETION_CONTEXT {
638 PDEVICE_OBJECT DeviceObject;
639 SCSI_REQUEST_BLOCK Srb;
640 } COMPLETION_CONTEXT, *PCOMPLETION_CONTEXT;
641
642 SCSIPORTAPI
643 ULONG
644 NTAPI
645 ClassInitialize(
646 PVOID Argument1,
647 PVOID Argument2,
648 PCLASS_INIT_DATA InitializationData);
649
650 typedef struct _CLASS_QUERY_WMI_REGINFO_EX_LIST {
651 ULONG Size;
652 PCLASS_QUERY_WMI_REGINFO_EX ClassFdoQueryWmiRegInfoEx;
653 PCLASS_QUERY_WMI_REGINFO_EX ClassPdoQueryWmiRegInfoEx;
654 } CLASS_QUERY_WMI_REGINFO_EX_LIST, *PCLASS_QUERY_WMI_REGINFO_EX_LIST;
655
656 typedef struct _FUNCTIONAL_DEVICE_EXTENSION {
657 _ANONYMOUS_UNION union {
658 _ANONYMOUS_STRUCT struct {
659 ULONG Version;
660 PDEVICE_OBJECT DeviceObject;
661 } DUMMYSTRUCTNAME;
662 COMMON_DEVICE_EXTENSION CommonExtension;
663 } DUMMYUNIONNAME;
664 PDEVICE_OBJECT LowerPdo;
665 PSTORAGE_DEVICE_DESCRIPTOR DeviceDescriptor;
666 PSTORAGE_ADAPTER_DESCRIPTOR AdapterDescriptor;
667 DEVICE_POWER_STATE DevicePowerState;
668 ULONG DMByteSkew;
669 ULONG DMSkew;
670 BOOLEAN DMActive;
671 DISK_GEOMETRY DiskGeometry;
672 PSENSE_DATA SenseData;
673 ULONG TimeOutValue;
674 ULONG DeviceNumber;
675 ULONG SrbFlags;
676 ULONG ErrorCount;
677 LONG LockCount;
678 LONG ProtectedLockCount;
679 LONG InternalLockCount;
680 KEVENT EjectSynchronizationEvent;
681 USHORT DeviceFlags;
682 UCHAR SectorShift;
683 #if (NTDDI_VERSION >= NTDDI_VISTA)
684 UCHAR CdbForceUnitAccess;
685 #else
686 UCHAR ReservedByte;
687 #endif
688 PMEDIA_CHANGE_DETECTION_INFO MediaChangeDetectionInfo;
689 PKEVENT Unused1;
690 HANDLE Unused2;
691 FILE_OBJECT_EXTENSION KernelModeMcnContext;
692 ULONG MediaChangeCount;
693 HANDLE DeviceDirectory;
694 KSPIN_LOCK ReleaseQueueSpinLock;
695 PIRP ReleaseQueueIrp;
696 SCSI_REQUEST_BLOCK ReleaseQueueSrb;
697 BOOLEAN ReleaseQueueNeeded;
698 BOOLEAN ReleaseQueueInProgress;
699 BOOLEAN ReleaseQueueIrpFromPool;
700 BOOLEAN FailurePredicted;
701 ULONG FailureReason;
702 struct _FAILURE_PREDICTION_INFO* FailurePredictionInfo;
703 BOOLEAN PowerDownInProgress;
704 ULONG EnumerationInterlock;
705 KEVENT ChildLock;
706 PKTHREAD ChildLockOwner;
707 ULONG ChildLockAcquisitionCount;
708 ULONG ScanForSpecialFlags;
709 KDPC PowerRetryDpc;
710 KTIMER PowerRetryTimer;
711 CLASS_POWER_CONTEXT PowerContext;
712
713 #if (NTDDI_VERSION <= NTDDI_WIN2K)
714
715 #if (SPVER(NTDDI_VERSION) < 2))
716 ULONG_PTR Reserved1;
717 ULONG_PTR Reserved2;
718 ULONG_PTR Reserved3;
719 ULONG_PTR Reserved4;
720 #else
721 ULONG CompletionSuccessCount;
722 ULONG SavedSrbFlags;
723 ULONG SavedErrorCount;
724 ULONG_PTR Reserved1;
725 #endif
726
727 #else /* (NTDDI_VERSION <= NTDDI_WIN2K) */
728
729 PCLASS_PRIVATE_FDO_DATA PrivateFdoData;
730 ULONG_PTR Reserved2;
731 ULONG_PTR Reserved3;
732 ULONG_PTR Reserved4;
733
734 #endif /* (NTDDI_VERSION <= NTDDI_WIN2K) */
735
736 } FUNCTIONAL_DEVICE_EXTENSION, *PFUNCTIONAL_DEVICE_EXTENSION;
737
738 SCSIPORTAPI
739 ULONG
740 NTAPI
741 ClassInitializeEx(
742 PDRIVER_OBJECT DriverObject,
743 LPGUID Guid,
744 PVOID Data);
745
746 SCSIPORTAPI
747 NTSTATUS
748 NTAPI
749 ClassCreateDeviceObject(
750 PDRIVER_OBJECT DriverObject,
751 PCCHAR ObjectNameBuffer,
752 PDEVICE_OBJECT LowerDeviceObject,
753 BOOLEAN IsFdo,
754 PDEVICE_OBJECT *DeviceObject);
755
756 SCSIPORTAPI
757 NTSTATUS
758 NTAPI
759 ClassReadDriveCapacity(
760 PDEVICE_OBJECT DeviceObject);
761
762 SCSIPORTAPI
763 VOID
764 NTAPI
765 ClassReleaseQueue(
766 PDEVICE_OBJECT DeviceObject);
767
768 SCSIPORTAPI
769 VOID
770 NTAPI
771 ClassSplitRequest(
772 PDEVICE_OBJECT DeviceObject,
773 PIRP Irp,
774 ULONG MaximumBytes);
775
776 SCSIPORTAPI
777 NTSTATUS
778 NTAPI
779 ClassDeviceControl(
780 PDEVICE_OBJECT DeviceObject,
781 PIRP Irp);
782
783 SCSIPORTAPI
784 NTSTATUS
785 NTAPI
786 ClassIoComplete(
787 PDEVICE_OBJECT DeviceObject,
788 PIRP Irp,
789 PVOID Context);
790
791 SCSIPORTAPI
792 NTSTATUS
793 NTAPI
794 ClassIoCompleteAssociated(
795 PDEVICE_OBJECT DeviceObject,
796 PIRP Irp,
797 PVOID Context);
798
799 SCSIPORTAPI
800 BOOLEAN
801 NTAPI
802 ClassInterpretSenseInfo(
803 PDEVICE_OBJECT DeviceObject,
804 PSCSI_REQUEST_BLOCK Srb,
805 UCHAR MajorFunctionCode,
806 ULONG IoDeviceCode,
807 ULONG RetryCount,
808 NTSTATUS *Status,
809 ULONG *RetryInterval);
810
811 VOID
812 NTAPI
813 ClassSendDeviceIoControlSynchronous(
814 ULONG IoControlCode,
815 PDEVICE_OBJECT TargetDeviceObject,
816 PVOID Buffer,
817 ULONG InputBufferLength,
818 ULONG OutputBufferLength,
819 BOOLEAN InternalDeviceIoControl,
820 PIO_STATUS_BLOCK IoStatus);
821
822 SCSIPORTAPI
823 NTSTATUS
824 NTAPI
825 ClassSendIrpSynchronous(
826 PDEVICE_OBJECT TargetDeviceObject,
827 PIRP Irp);
828
829 SCSIPORTAPI
830 NTSTATUS
831 NTAPI
832 ClassForwardIrpSynchronous(
833 PCOMMON_DEVICE_EXTENSION CommonExtension,
834 PIRP Irp);
835
836 SCSIPORTAPI
837 NTSTATUS
838 NTAPI
839 ClassSendSrbSynchronous(
840 PDEVICE_OBJECT DeviceObject,
841 PSCSI_REQUEST_BLOCK Srb,
842 PVOID BufferAddress,
843 ULONG BufferLength,
844 BOOLEAN WriteToDevice);
845
846 SCSIPORTAPI
847 NTSTATUS
848 NTAPI
849 ClassSendSrbAsynchronous(
850 PDEVICE_OBJECT DeviceObject,
851 PSCSI_REQUEST_BLOCK Srb,
852 PIRP Irp,
853 PVOID BufferAddress,
854 ULONG BufferLength,
855 BOOLEAN WriteToDevice);
856
857 SCSIPORTAPI
858 NTSTATUS
859 NTAPI
860 ClassBuildRequest(
861 PDEVICE_OBJECT DeviceObject,
862 PIRP Irp);
863
864 SCSIPORTAPI
865 ULONG
866 NTAPI
867 ClassModeSense(
868 PDEVICE_OBJECT DeviceObject,
869 PCHAR ModeSenseBuffer,
870 ULONG Length,
871 UCHAR PageMode);
872
873 SCSIPORTAPI
874 PVOID
875 NTAPI
876 ClassFindModePage(
877 PCHAR ModeSenseBuffer,
878 ULONG Length,
879 UCHAR PageMode,
880 BOOLEAN Use6Byte);
881
882 SCSIPORTAPI
883 NTSTATUS
884 NTAPI
885 ClassClaimDevice(
886 PDEVICE_OBJECT LowerDeviceObject,
887 BOOLEAN Release);
888
889 SCSIPORTAPI
890 NTSTATUS
891 NTAPI
892 ClassInternalIoControl (
893 PDEVICE_OBJECT DeviceObject,
894 PIRP Irp);
895
896 SCSIPORTAPI
897 VOID
898 NTAPI
899 ClassInitializeSrbLookasideList(
900 PCOMMON_DEVICE_EXTENSION CommonExtension,
901 ULONG NumberElements);
902
903 SCSIPORTAPI
904 VOID
905 NTAPI
906 ClassDeleteSrbLookasideList(
907 PCOMMON_DEVICE_EXTENSION CommonExtension);
908
909 SCSIPORTAPI
910 ULONG
911 NTAPI
912 ClassQueryTimeOutRegistryValue(
913 PDEVICE_OBJECT DeviceObject);
914
915 SCSIPORTAPI
916 NTSTATUS
917 NTAPI
918 ClassGetDescriptor(
919 PDEVICE_OBJECT DeviceObject,
920 PSTORAGE_PROPERTY_ID PropertyId,
921 PSTORAGE_DESCRIPTOR_HEADER *Descriptor);
922
923 SCSIPORTAPI
924 VOID
925 NTAPI
926 ClassInvalidateBusRelations(
927 PDEVICE_OBJECT Fdo);
928
929 SCSIPORTAPI
930 VOID
931 NTAPI
932 ClassMarkChildrenMissing(
933 PFUNCTIONAL_DEVICE_EXTENSION Fdo);
934
935 SCSIPORTAPI
936 BOOLEAN
937 NTAPI
938 ClassMarkChildMissing(
939 PPHYSICAL_DEVICE_EXTENSION PdoExtension,
940 BOOLEAN AcquireChildLock);
941
942 SCSIPORTAPI
943 VOID
944 NTAPI
945 ClassDebugPrint(
946 CLASS_DEBUG_LEVEL DebugPrintLevel,
947 PCCHAR DebugMessage,
948 ...);
949
950 SCSIPORTAPI
951 PCLASS_DRIVER_EXTENSION
952 NTAPI
953 ClassGetDriverExtension(
954 PDRIVER_OBJECT DriverObject);
955
956 SCSIPORTAPI
957 VOID
958 NTAPI
959 ClassCompleteRequest(
960 PDEVICE_OBJECT DeviceObject,
961 PIRP Irp,
962 CCHAR PriorityBoost);
963
964 SCSIPORTAPI
965 VOID
966 NTAPI
967 ClassReleaseRemoveLock(
968 PDEVICE_OBJECT DeviceObject,
969 PIRP Tag);
970
971 SCSIPORTAPI
972 ULONG
973 NTAPI
974 ClassAcquireRemoveLockEx(
975 PDEVICE_OBJECT DeviceObject,
976 PVOID Tag,
977 PCSTR File,
978 ULONG Line);
979
980 SCSIPORTAPI
981 VOID
982 NTAPI
983 ClassUpdateInformationInRegistry(
984 PDEVICE_OBJECT Fdo,
985 PCHAR DeviceName,
986 ULONG DeviceNumber,
987 PINQUIRYDATA InquiryData,
988 ULONG InquiryDataLength);
989
990 SCSIPORTAPI
991 NTSTATUS
992 NTAPI
993 ClassWmiCompleteRequest(
994 PDEVICE_OBJECT DeviceObject,
995 PIRP Irp,
996 NTSTATUS Status,
997 ULONG BufferUsed,
998 CCHAR PriorityBoost);
999
1000 SCSIPORTAPI
1001 NTSTATUS
1002 NTAPI
1003 ClassWmiFireEvent(
1004 PDEVICE_OBJECT DeviceObject,
1005 LPGUID Guid,
1006 ULONG InstanceIndex,
1007 ULONG EventDataSize,
1008 PVOID EventData);
1009
1010 SCSIPORTAPI
1011 VOID
1012 NTAPI
1013 ClassResetMediaChangeTimer(
1014 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
1015
1016 SCSIPORTAPI
1017 VOID
1018 NTAPI
1019 ClassInitializeMediaChangeDetection(
1020 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1021 PUCHAR EventPrefix);
1022
1023 SCSIPORTAPI
1024 NTSTATUS
1025 NTAPI
1026 ClassInitializeTestUnitPolling(
1027 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1028 BOOLEAN AllowDriveToSleep);
1029
1030 SCSIPORTAPI
1031 PVPB
1032 NTAPI
1033 ClassGetVpb(
1034 PDEVICE_OBJECT DeviceObject);
1035
1036 SCSIPORTAPI
1037 NTSTATUS
1038 NTAPI
1039 ClassSpinDownPowerHandler(
1040 PDEVICE_OBJECT DeviceObject,
1041 PIRP Irp);
1042
1043 NTSTATUS
1044 NTAPI
1045 ClassStopUnitPowerHandler(
1046 PDEVICE_OBJECT DeviceObject,
1047 PIRP Irp);
1048
1049 NTSTATUS
1050 NTAPI
1051 ClassSetFailurePredictionPoll(
1052 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1053 FAILURE_PREDICTION_METHOD FailurePredictionMethod,
1054 ULONG PollingPeriod);
1055
1056 VOID
1057 NTAPI
1058 ClassNotifyFailurePredicted(
1059 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1060 PUCHAR Buffer,
1061 ULONG BufferSize,
1062 BOOLEAN LogError,
1063 ULONG UniqueErrorValue,
1064 UCHAR PathId,
1065 UCHAR TargetId,
1066 UCHAR Lun);
1067
1068 SCSIPORTAPI
1069 VOID
1070 NTAPI
1071 ClassAcquireChildLock(
1072 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
1073
1074 SCSIPORTAPI
1075 VOID
1076 NTAPI
1077 ClassReleaseChildLock(
1078 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
1079
1080 NTSTATUS
1081 NTAPI
1082 ClassSignalCompletion(
1083 PDEVICE_OBJECT DeviceObject,
1084 PIRP Irp,
1085 PKEVENT Event);
1086
1087 VOID
1088 NTAPI
1089 ClassSendStartUnit(
1090 PDEVICE_OBJECT DeviceObject);
1091
1092 SCSIPORTAPI
1093 NTSTATUS
1094 NTAPI
1095 ClassRemoveDevice(
1096 PDEVICE_OBJECT DeviceObject,
1097 UCHAR RemoveType);
1098
1099 SCSIPORTAPI
1100 NTSTATUS
1101 NTAPI
1102 ClassAsynchronousCompletion(
1103 PDEVICE_OBJECT DeviceObject,
1104 PIRP Irp,
1105 PVOID Event);
1106
1107 SCSIPORTAPI
1108 VOID
1109 NTAPI
1110 ClassCheckMediaState(
1111 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
1112
1113 SCSIPORTAPI
1114 NTSTATUS
1115 NTAPI
1116 ClassCheckVerifyComplete(
1117 PDEVICE_OBJECT DeviceObject,
1118 PIRP Irp,
1119 PVOID Context);
1120
1121 SCSIPORTAPI
1122 VOID
1123 NTAPI
1124 ClassSetMediaChangeState(
1125 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1126 MEDIA_CHANGE_DETECTION_STATE State,
1127 BOOLEAN Wait);
1128
1129 SCSIPORTAPI
1130 VOID
1131 NTAPI
1132 ClassEnableMediaChangeDetection(
1133 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
1134
1135 SCSIPORTAPI
1136 VOID
1137 NTAPI
1138 ClassDisableMediaChangeDetection(
1139 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
1140
1141 SCSIPORTAPI
1142 VOID
1143 NTAPI
1144 ClassCleanupMediaChangeDetection(
1145 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
1146
1147 VOID
1148 NTAPI
1149 ClassGetDeviceParameter(
1150 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1151 PWSTR SubkeyName,
1152 PWSTR ParameterName,
1153 PULONG ParameterValue);
1154
1155 NTSTATUS
1156 NTAPI
1157 ClassSetDeviceParameter(
1158 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1159 PWSTR SubkeyName,
1160 PWSTR ParameterName,
1161 ULONG ParameterValue);
1162
1163 #if (NTDDI_VERSION >= NTDDI_VISTA)
1164
1165 PFILE_OBJECT_EXTENSION
1166 NTAPI
1167 ClassGetFsContext(
1168 PCOMMON_DEVICE_EXTENSION CommonExtension,
1169 PFILE_OBJECT FileObject);
1170
1171 VOID
1172 NTAPI
1173 ClassSendNotification(
1174 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1175 const GUID *Guid,
1176 ULONG ExtraDataSize,
1177 PVOID ExtraData);
1178
1179 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
1180
1181 static __inline
1182 BOOLEAN
1183 PORT_ALLOCATED_SENSE(
1184 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1185 PSCSI_REQUEST_BLOCK Srb)
1186 {
1187 return ((BOOLEAN)((TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_PORT_DRIVER_ALLOCSENSE) &&
1188 TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER)) &&
1189 (Srb->SenseInfoBuffer != FdoExtension->SenseData)));
1190 }
1191
1192 static __inline
1193 VOID
1194 FREE_PORT_ALLOCATED_SENSE_BUFFER(
1195 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1196 PSCSI_REQUEST_BLOCK Srb)
1197 {
1198 ASSERT(TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_PORT_DRIVER_ALLOCSENSE));
1199 ASSERT(TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER));
1200 ASSERT(Srb->SenseInfoBuffer != FdoExtension->SenseData);
1201
1202 ExFreePool(Srb->SenseInfoBuffer);
1203 Srb->SenseInfoBuffer = FdoExtension->SenseData;
1204 Srb->SenseInfoBufferLength = SENSE_BUFFER_SIZE;
1205 CLEAR_FLAG(Srb->SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER);
1206 return;
1207 }
1208
1209 typedef VOID
1210 (NTAPI *PCLASS_SCAN_FOR_SPECIAL_HANDLER)(
1211 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1212 ULONG_PTR Data);
1213
1214 VOID
1215 NTAPI
1216 ClassScanForSpecial(
1217 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1218 CLASSPNP_SCAN_FOR_SPECIAL_INFO DeviceList[],
1219 PCLASS_SCAN_FOR_SPECIAL_HANDLER Function);