ReactOS  0.4.15-dev-5500-g82cf6c2
disk.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (C) Microsoft Corporation, 1991 - 2010
4 
5 Module Name:
6 
7  disk.c
8 
9 Abstract:
10 
11  SCSI disk class driver
12 
13 Environment:
14 
15  kernel mode only
16 
17 Notes:
18 
19 Revision History:
20 
21 --*/
22 
23 #include "ntddk.h"
24 #include "scsi.h"
25 #include <wmidata.h>
26 #include "classpnp.h"
27 
28 #include <wmistr.h>
29 #include "ntstrsafe.h"
30 
31 //
32 // Set component ID for DbgPrintEx calls
33 //
34 #ifndef DEBUG_COMP_ID
35 #define DEBUG_COMP_ID DPFLTR_DISK_ID
36 #endif
37 
38 //
39 // Include header file and setup GUID for tracing
40 //
41 #include <storswtr.h>
42 #define WPP_GUID_DISK (945186BF, 3DD6, 4f3f, 9C8E, 9EDD3FC9D558)
43 #ifndef WPP_CONTROL_GUIDS
44 #define WPP_CONTROL_GUIDS WPP_CONTROL_GUIDS_NORMAL_FLAGS(WPP_GUID_DISK)
45 #endif
46 
47 
48 #ifdef ExAllocatePool
49 #undef ExAllocatePool
50 #define ExAllocatePool #NT_ASSERT(FALSE)
51 #endif
52 
53 #define DISK_TAG_GENERAL ' DcS' // "ScD " - generic tag
54 #define DISK_TAG_SMART 'aDcS' // "ScDa" - SMART allocations
55 #define DISK_TAG_INFO_EXCEPTION 'ADcS' // "ScDA" - Info Exceptions
56 #define DISK_TAG_DISABLE_CACHE 'CDcS' // "ScDC" - disable cache paths
57 #define DISK_TAG_CCONTEXT 'cDcS' // "ScDc" - disk allocated completion context
58 #define DISK_TAG_DISK_GEOM 'GDcS' // "ScDG" - disk geometry buffer
59 #define DISK_TAG_UPDATE_GEOM 'gDcS' // "ScDg" - update disk geometry paths
60 #define DISK_TAG_SENSE_INFO 'IDcS' // "ScDI" - sense info buffers
61 #define DISK_TAG_PNP_ID 'iDcS' // "ScDp" - pnp ids
62 #define DISK_TAG_MODE_DATA 'MDcS' // "ScDM" - mode data buffer
63 #define DISK_CACHE_MBR_CHECK 'mDcS' // "ScDM" - mbr checksum code
64 #define DISK_TAG_NAME 'NDcS' // "ScDN" - disk name code
65 #define DISK_TAG_READ_CAP 'PDcS' // "ScDP" - read capacity buffer
66 #define DISK_TAG_PART_LIST 'pDcS' // "ScDp" - disk partition lists
67 #define DISK_TAG_SRB 'SDcS' // "ScDS" - srb allocation
68 #define DISK_TAG_START 'sDcS' // "ScDs" - start device paths
69 #define DISK_TAG_UPDATE_CAP 'UDcS' // "ScDU" - update capacity path
70 #define DISK_TAG_WI_CONTEXT 'WDcS' // "ScDW" - work-item context
71 
72 #ifdef __REACTOS__
73 #undef MdlMappingNoExecute
74 #define MdlMappingNoExecute 0
75 #define NonPagedPoolNx NonPagedPool
76 #define NonPagedPoolNxCacheAligned NonPagedPoolCacheAligned
77 #undef POOL_NX_ALLOCATION
78 #define POOL_NX_ALLOCATION 0
79 #endif
80 
81 
82 #if defined(_X86_) || defined(_AMD64_)
83 
84 //
85 // Disk device data
86 //
87 
88 typedef enum _DISK_GEOMETRY_SOURCE {
89  DiskGeometryUnknown,
90  DiskGeometryFromBios,
91  DiskGeometryFromPort,
92  DiskGeometryFromNec98,
93  DiskGeometryGuessedFromBios,
94  DiskGeometryFromDefault,
95  DiskGeometryFromNT4
96 } DISK_GEOMETRY_SOURCE, *PDISK_GEOMETRY_SOURCE;
97 #endif
98 
99 //
100 // Context for requests that can be combined and sent down
101 //
102 
103 typedef struct _DISK_GROUP_CONTEXT
104 {
105  //
106  // Queue of requests whose representative is currently outstanding at the port driver
107  //
109 
110  //
111  // The representative for the above queue
112  //
114 
115  //
116  // Queue of requests whose representative is waiting to go down
117  //
119 
120  //
121  // The representative for the above queue
122  //
124 
125  //
126  // The srb associated with this group
127  //
128 #if (NTDDI_VERSION >= NTDDI_WIN8)
129 
130  union {
134  } Srb;
135 
136 #else
138 #endif
139 
140  //
141  // The spinlock that will synchronize access to this context
142  //
144 
145  //
146  // This event will allow for the requests to be sent down synchronously
147  //
149 
150 
151 #if DBG
152 
153  //
154  // This counter maintains the number of requests currently tagged
155  // to the request that is waiting to go down
156  //
157  ULONG DbgTagCount;
158 
159  //
160  // This counter maintains the number of requests that were avoided
161  //
162  ULONG DbgSavCount;
163 
164  //
165  // This counter maintains the total number of times that we combined
166  // requests and the respective number of requests that were tagged
167  //
168  ULONG DbgRefCount[64];
169 
170 #endif
171 
173 
174 //
175 // Write cache setting as defined by the user
176 //
178 {
182 
184 
185 typedef struct _DISK_DATA {
186 
187  //
188  // This field is the ordinal of a partition as it appears on a disk.
189  //
190 
192 
193  //
194  // How has this disk been partitioned? Either EFI or MBR.
195  //
196 
198 
199  union {
200 
201  struct {
202 
203  //
204  // Disk signature (from MBR)
205  //
206 
208 
209  //
210  // MBR checksum
211  //
212 
214 
215  //
216  // Number of hidden sectors for BPB.
217  //
218 
220 
221  //
222  // Partition type of this device object
223  //
224  // This field is set by:
225  //
226  // 1. Initially set according to the partition list entry
227  // partition type returned by IoReadPartitionTable.
228  //
229  // 2. Subsequently set by the
230  // IOCTL_DISK_SET_PARTITION_INFORMATION I/O control
231  // function when IoSetPartitionInformation function
232  // successfully updates the partition type on the disk.
233  //
234 
236 
237  //
238  // Boot indicator - indicates whether this partition is a
239  // bootable (active) partition for this device
240  //
241  // This field is set according to the partition list entry boot
242  // indicator returned by IoReadPartitionTable.
243  //
244 
246 
247  } Mbr;
248 
249  struct {
250 
251  //
252  // The DiskGUID field from the EFI partition header.
253  //
254 
256 
257  //
258  // Partition type of this device object.
259  //
260 
262 
263  //
264  // Unique partition identifier for this partition.
265  //
266 
268 
269  //
270  // EFI partition attributes for this partition.
271  //
272 
274 
275  //
276  // EFI partition name of this partition.
277  //
278 
280 
281  } Efi;
282 
283 #ifdef _MSC_VER
284 #pragma warning(suppress: 4201) //this is intended to be an unnamed union
285 #endif
286  };
287 
288  struct {
289  //
290  // This flag is set when the well known name is created (through
291  // DiskCreateSymbolicLinks) and cleared when destroying it
292  // (by calling DiskDeleteSymbolicLinks).
293  //
294 
295  unsigned int WellKnownNameCreated : 1;
296 
297  //
298  // This flag is set when the PhysicalDriveN link is created (through
299  // DiskCreateSymbolicLinks) and is cleared when destroying it (through
300  // DiskDeleteSymbolicLinks)
301  //
302 
303  unsigned int PhysicalDriveLinkCreated : 1;
304 
305  } LinkStatus;
306 
307  //
308  // ReadyStatus - STATUS_SUCCESS indicates that the drive is ready for
309  // use. Any error status is to be returned as an explaination for why
310  // a request is failed.
311  //
312  // This was done solely for the zero-length partition case of having no
313  // media in a removable disk drive. When that occurs, and a read is sent
314  // to the zero-length non-partition-zero PDO that was created, we had to
315  // be able to fail the request with a reasonable value. This may not have
316  // been the best way to do this, but it works.
317  //
318 
320 
321  //
322  // SCSI address used for SMART operations.
323  //
324 
326 
327  //
328  // What type of failure prediction mechanism is available
329  //
330 
333 
334  //
335  // Indicates that the SCSI Informational Exceptions mode page is supported.
336  // Note that this only indicates *support* and does not necessarily
337  // indicate that Informational Exception reporting via sense code is
338  // actually enabled.
339  //
341 
342  //
343  // Indicates if failure prediction is actually enabled (via whatever)
344  // method is applicable as indicated by FailurePredictionCapability.
345  //
347 
348 #if defined(_X86_) || defined(_AMD64_)
349  //
350  // This flag indiciates that a non-default geometry for this drive has
351  // already been determined by the disk driver. This field is ignored
352  // for removable media drives.
353  //
354 
355  DISK_GEOMETRY_SOURCE GeometrySource;
356 
357  //
358  // If GeometryDetermined is TRUE this will contain the geometry which was
359  // reported by the firmware or by the BIOS. For removable media drives
360  // this will contain the last geometry used when media was present.
361  //
362 
363  DISK_GEOMETRY RealGeometry;
364 #endif
365 
366  //
367  // This mutex prevents more than one IOCTL_DISK_VERIFY from being
368  // sent down to the disk. This greatly reduces the possibility of
369  // a Denial-of-Service attack
370  //
371 
373 
374  //
375  // This allows for parallel flush requests to be combined into one so as to
376  // reduce the number of outstanding requests that are sent down to the disk
377  //
378 
380 
381  //
382  // The user-specified disk write cache setting
383  //
384 
386 
387 
389 
390 //
391 // Define a general structure of identfing disk controllers with bad
392 // hardware.
393 //
394 
395 #define HackDisableTaggedQueuing (0x01)
396 #define HackDisableSynchronousTransfers (0x02)
397 #define HackDisableSpinDown (0x04)
398 #define HackDisableWriteCache (0x08)
399 #define HackCauseNotReportableHack (0x10)
400 #define HackRequiresStartUnitCommand (0x20)
401 
402 
403 #define DiskDeviceParameterSubkey L"Disk"
404 #define DiskDeviceUserWriteCacheSetting L"UserWriteCacheSetting"
405 #define DiskDeviceCacheIsPowerProtected L"CacheIsPowerProtected"
406 
407 
408 #define FUNCTIONAL_EXTENSION_SIZE sizeof(FUNCTIONAL_DEVICE_EXTENSION) + sizeof(DISK_DATA)
409 
410 #define MODE_DATA_SIZE 192
411 #define VALUE_BUFFER_SIZE 2048
412 #define SCSI_DISK_TIMEOUT 10
413 #define PARTITION0_LIST_SIZE 4
414 
415 #define MAX_MEDIA_TYPES 4
416 typedef struct _DISK_MEDIA_TYPES_LIST {
417  PCCHAR VendorId;
418  PCCHAR ProductId;
419  PCCHAR Revision;
424 
425 //
426 // WMI reregistration structures used for reregister work item
427 //
428 typedef struct
429 {
434 
435 #define MAX_SECTORS_PER_VERIFY 0x100
436 
437 //
438 // This is based off 100ns units
439 //
440 #define ONE_MILLI_SECOND ((ULONGLONG)10 * 1000)
441 
442 //
443 // Context for the work-item
444 //
446 {
450 
452 
453 //
454 // Poll for Failure Prediction every hour
455 //
456 #define DISK_DEFAULT_FAILURE_POLLING_PERIOD 1 * 60 * 60
457 
458 #define CHECK_IRQL() \
459  if (KeGetCurrentIrql() >= DISPATCH_LEVEL) { \
460  NT_ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL); \
461  return STATUS_INVALID_LEVEL; \
462  }
463 
464 //
465 // Static global lookup tables.
466 //
467 
471 
472 #if defined(__REACTOS__) && defined(_MSC_VER)
473 # pragma section("PAGECONS", read)
474 # pragma section("PAGEDATA", read,write)
475 #endif
476 //
477 // Macros
478 //
479 
480 //
481 // Routine prototypes.
482 //
483 
484 
485 DRIVER_INITIALIZE DriverEntry;
486 
487 VOID
488 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
489 DiskUnload(
491  );
492 
493 NTSTATUS
494 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
498  );
499 
500 NTSTATUS
501 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
504  );
505 
506 NTSTATUS
507 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
510  );
511 
512 NTSTATUS
513 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
516  IN UCHAR Type
517  );
518 
519 NTSTATUS
520 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
523  IN UCHAR Type
524  );
525 
526 NTSTATUS
527 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
530  IN PIRP Irp
531  );
532 
533 NTSTATUS
534 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
537  IN PIRP Irp
538  );
539 
540 VOID
541 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
545  NTSTATUS *Status,
546  BOOLEAN *Retry
547  );
548 
549 NTSTATUS
550 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
553  IN PIRP Irp
554  );
555 
556 NTSTATUS
557 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
560  IN PDISK_CACHE_INFORMATION CacheInfo
561  );
562 
563 NTSTATUS
564 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
567  IN PDISK_CACHE_INFORMATION CacheInfo
568  );
569 
570 VOID
573  IN PDISK_CACHE_INFORMATION CacheInfo,
575  );
576 
577 NTSTATUS
580  IN PIRP Irp
581  );
582 
583 NTSTATUS
586  IN PIRP Irp
587  );
588 
589 IO_WORKITEM_ROUTINE DisableWriteCache;
590 
591 IO_WORKITEM_ROUTINE DiskIoctlVerifyThread;
592 
593 VOID
596  IN PDISK_GROUP_CONTEXT FlushContext
597  );
598 
599 IO_COMPLETION_ROUTINE DiskFlushComplete;
600 
601 
602 NTSTATUS
605  _In_reads_bytes_(Length) PCHAR ModeSelectBuffer,
606  IN ULONG Length,
607  IN BOOLEAN SavePage
608  );
609 
610 //
611 // We need to validate that the self test subcommand is valid and
612 // appropriate. Right now we allow subcommands 0, 1 and 2 which are non
613 // captive mode tests. Once we figure out a way to know if it is safe to
614 // run a captive test then we can allow captive mode tests. Also if the
615 // atapi 5 spec is ever updated to denote that bit 7 is the captive
616 // mode bit, we can allow any request that does not have bit 7 set. Until
617 // that is done we want to be sure
618 //
619 #define DiskIsValidSmartSelfTest(Subcommand) \
620  ( ((Subcommand) == SMART_OFFLINE_ROUTINE_OFFLINE) || \
621  ((Subcommand) == SMART_SHORT_SELFTEST_OFFLINE) || \
622  ((Subcommand) == SMART_EXTENDED_SELFTEST_OFFLINE) )
623 
624 
625 NTSTATUS
628  IN ULONG SrbControlCode,
629  IN UCHAR Command,
630  IN UCHAR Feature,
632  IN UCHAR SectorNumber,
633  IN OUT PSRB_IO_CONTROL SrbControl,
635  );
636 
637 NTSTATUS
640  OUT PMODE_INFO_EXCEPTIONS ReturnPageData
641  );
642 
643 NTSTATUS
646  IN PMODE_INFO_EXCEPTIONS PageData
647  );
648 
649 #if (NTDDI_VERSION >= NTDDI_WINBLUE)
650 NTSTATUS
655  _In_ PMODE_PARAMETER_HEADER ModeData,
656  _Inout_ PULONG ModeDataSize,
657  _Out_ PVOID* PageData
658  );
659 
660 NTSTATUS
664  );
665 #endif // (NTDDI_VERSION >= NTDDI_WINBLUE)
666 
667 NTSTATUS
670  PFAILURE_PREDICTION_METHOD FailurePredictCapability,
671  BOOLEAN ScsiAddressAvailable
672  );
673 
674 NTSTATUS
679  IN BOOLEAN DasdAccessOnly
680  );
681 
682 VOID
683 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
687  );
688 
689 VOID
690 ResetBus(
692  );
693 
694 NTSTATUS
697  OUT PCCHAR *RawName
698  );
699 
700 VOID
703  );
704 
705 VOID
708  );
709 
710 
711 NTSTATUS
712 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
715  OUT ULONG *RegFlags,
717  );
718 
719 NTSTATUS
720 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
723  OUT ULONG *RegFlags,
725  OUT PUNICODE_STRING MofName
726  );
727 
728 NTSTATUS
729 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
732  IN PIRP Irp,
736  );
737 
738 NTSTATUS
739 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
742  IN PIRP Irp,
746  );
747 
748 NTSTATUS
749 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
752  IN PIRP Irp,
757  );
758 
759 NTSTATUS
760 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
763  IN PIRP Irp,
765  IN ULONG MethodId,
769  );
770 
771 NTSTATUS
772 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
775  IN PIRP Irp,
779  );
780 
781 NTSTATUS
784  PSTORAGE_FAILURE_PREDICT_STATUS DiskSmartStatus
785  );
786 
787 NTSTATUS
790  PSTORAGE_FAILURE_PREDICT_DATA DiskSmartData
791  );
792 
793 NTSTATUS
797  );
798 
799 NTSTATUS
802  BOOLEAN Enable,
803  ULONG PollTimeInSeconds
804  );
805 
807  VOID
808  );
809 
811 
812 #if defined(_X86_) || defined(_AMD64_)
813 NTSTATUS
816  );
817 #else
818 #define DiskReadDriveCapacity(Fdo) ClassReadDriveCapacity(Fdo)
819 #endif
820 
821 
822 #if defined(_X86_) || defined(_AMD64_)
823 
824 NTSTATUS
825 DiskSaveDetectInfo(
827  );
828 
829 VOID
830 DiskCleanupDetectInfo(
832  );
833 
834 VOID
835 DiskDriverReinitialization (
837  IN PVOID Nothing,
838  IN ULONG Count
839  );
840 
841 #endif
842 
843 #if defined(_X86_) || defined(_AMD64_)
844 NTSTATUS
847  OUT PDISK_DETECTION_INFO DetectInfo
848  );
849 
850 NTSTATUS
851 DiskReadSignature(
853  );
854 
855 BOOLEAN
856 DiskIsNT4Geometry(
858  );
859 
860 #else
861 #define DiskGetDetectInfo(FdoExtension, DetectInfo) (STATUS_UNSUCCESSFUL)
862 #endif
863 
864 
865 #define DiskHashGuid(Guid) (((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0])
866 
867 
868 NTSTATUS
871  IN PIRP Irp,
872  IN UCHAR MediumType,
873  IN UCHAR DensityCode,
876  );
877 
878 NTSTATUS
881  IN PIRP Irp
882  );
883 
884 NTSTATUS
887  IN OUT PIRP Irp
888  );
889 
890 NTSTATUS
893  IN PIRP Irp
894  );
895 
896 NTSTATUS
899  IN OUT PIRP Irp
900  );
901 
902 NTSTATUS
905  IN OUT PIRP Irp
906  );
907 
908 NTSTATUS
911  IN OUT PIRP Irp
912  );
913 
914 NTSTATUS
917  IN OUT PIRP Irp
918  );
919 
920 NTSTATUS
923  IN OUT PIRP Irp
924  );
925 
926 NTSTATUS
929  IN OUT PIRP Irp
930  );
931 
932 NTSTATUS
935  IN OUT PIRP Irp
936  );
937 
938 NTSTATUS
941  IN OUT PIRP Irp
942  );
943 
944 NTSTATUS
947  IN OUT PIRP Irp
948  );
949 
950 NTSTATUS
953  IN OUT PIRP Irp
954  );
955 
956 NTSTATUS
959  IN OUT PIRP Irp
960  );
961 
962 NTSTATUS
965  IN OUT PIRP Irp
966  );
967 
968 NTSTATUS
971  IN OUT PIRP Irp
972  );
973 
974 NTSTATUS
977  IN OUT PIRP Irp
978  );
979 
980 NTSTATUS
983  IN OUT PIRP Irp
984  );
985 
986 NTSTATUS
989  IN OUT PIRP Irp
990  );
991 
992 FORCEINLINE // __REACTOS__
993 PCDB
996  _In_opt_ PUCHAR CdbLength8,
997  _In_opt_ PULONG CdbLength32,
998  _In_opt_ PUCHAR ScsiStatus,
999  _In_opt_ PVOID *SenseInfoBuffer,
1001  )
1002 /*++
1003 
1004 Routine Description:
1005 
1006  Helper function to retrieve SCSI related fields from an extended SRB. If SRB is
1007  not a SRB_FUNCTION_EXECUTE_SCSI or not an extended SRB, default values will be returned.
1008 
1009 Arguments:
1010 
1011  SrbEx - Pointer to extended SRB.
1012 
1013  CdbLength8 - Pointer to buffer to hold CdbLength field value for
1014  SRBEX_DATA_SCSI_CDB16 or SRBEX_DATA_SCSI_CDB32
1015 
1016  CdbLength32 - Pointer to buffer to hold CdbLength field value for
1017  SRBEX_DATA_SCSI_CDB_VAR
1018 
1019  ScsiStatus - Pointer to buffer to hold ScsiStatus field value.
1020 
1021  SenseInfoBuffer - Pointer to buffer to hold SenseInfoBuffer value.
1022 
1023  SenseInfoBufferLength - Pointer to buffer to hold SenseInfoBufferLength value.
1024 
1025 Return Value:
1026 
1027  Pointer to Cdb field or NULL if SRB is not a SRB_FUNCTION_EXECUTE_SCSI.
1028 
1029 --*/
1030 {
1031  PCDB Cdb = NULL;
1032  ULONG i;
1033  PSRBEX_DATA SrbExData = NULL;
1034  BOOLEAN FoundEntry = FALSE;
1035 
1036  if ((SrbEx->Function == SRB_FUNCTION_STORAGE_REQUEST_BLOCK) &&
1037  (SrbEx->SrbFunction == SRB_FUNCTION_EXECUTE_SCSI)) {
1038  NT_ASSERT(SrbEx->NumSrbExData > 0);
1039 
1040  for (i = 0; i < SrbEx->NumSrbExData; i++) {
1041 
1042  // Skip any invalid offsets
1043  if ((SrbEx->SrbExDataOffset[i] < sizeof(STORAGE_REQUEST_BLOCK)) ||
1044  (SrbEx->SrbExDataOffset[i] > SrbEx->SrbLength)){
1045  // Catch any invalid offsets
1046  NT_ASSERT(FALSE);
1047  continue;
1048  }
1049 
1050  SrbExData = (PSRBEX_DATA)((PUCHAR)SrbEx + SrbEx->SrbExDataOffset[i]);
1051 
1052  switch (SrbExData->Type) {
1053 
1055  if (SrbEx->SrbExDataOffset[i] + sizeof(SRBEX_DATA_SCSI_CDB16) <= SrbEx->SrbLength) {
1056  FoundEntry = TRUE;
1057  if (CdbLength8) {
1058  *CdbLength8 = ((PSRBEX_DATA_SCSI_CDB16) SrbExData)->CdbLength;
1059  }
1060 
1061  if (((PSRBEX_DATA_SCSI_CDB16) SrbExData)->CdbLength > 0) {
1062  Cdb = (PCDB)((PSRBEX_DATA_SCSI_CDB16) SrbExData)->Cdb;
1063  }
1064 
1065  if (ScsiStatus) {
1066  *ScsiStatus =
1067  ((PSRBEX_DATA_SCSI_CDB16) SrbExData)->ScsiStatus;
1068  }
1069 
1070  if (SenseInfoBuffer) {
1071  *SenseInfoBuffer =
1072  ((PSRBEX_DATA_SCSI_CDB16) SrbExData)->SenseInfoBuffer;
1073  }
1074 
1075  if (SenseInfoBufferLength) {
1077  ((PSRBEX_DATA_SCSI_CDB16) SrbExData)->SenseInfoBufferLength;
1078  }
1079 
1080  } else {
1081  // Catch invalid offset
1082  NT_ASSERT(FALSE);
1083  }
1084  break;
1085 
1087  if (SrbEx->SrbExDataOffset[i] + sizeof(SRBEX_DATA_SCSI_CDB32) <= SrbEx->SrbLength) {
1088  FoundEntry = TRUE;
1089  if (CdbLength8) {
1090  *CdbLength8 = ((PSRBEX_DATA_SCSI_CDB32) SrbExData)->CdbLength;
1091  }
1092 
1093  if (((PSRBEX_DATA_SCSI_CDB32) SrbExData)->CdbLength > 0) {
1094  Cdb = (PCDB)((PSRBEX_DATA_SCSI_CDB32) SrbExData)->Cdb;
1095  }
1096 
1097  if (ScsiStatus) {
1098  *ScsiStatus =
1099  ((PSRBEX_DATA_SCSI_CDB32) SrbExData)->ScsiStatus;
1100  }
1101 
1102  if (SenseInfoBuffer) {
1103  *SenseInfoBuffer =
1104  ((PSRBEX_DATA_SCSI_CDB32) SrbExData)->SenseInfoBuffer;
1105  }
1106 
1107  if (SenseInfoBufferLength) {
1109  ((PSRBEX_DATA_SCSI_CDB32) SrbExData)->SenseInfoBufferLength;
1110  }
1111 
1112  } else {
1113  // Catch invalid offset
1114  NT_ASSERT(FALSE);
1115  }
1116  break;
1117 
1119  if (SrbEx->SrbExDataOffset[i] + sizeof(SRBEX_DATA_SCSI_CDB_VAR) <= SrbEx->SrbLength) {
1120  FoundEntry = TRUE;
1121  if (CdbLength32) {
1122  *CdbLength32 = ((PSRBEX_DATA_SCSI_CDB_VAR) SrbExData)->CdbLength;
1123  }
1124 
1125  if (((PSRBEX_DATA_SCSI_CDB_VAR) SrbExData)->CdbLength > 0) {
1126  Cdb = (PCDB)((PSRBEX_DATA_SCSI_CDB_VAR) SrbExData)->Cdb;
1127  }
1128 
1129  if (ScsiStatus) {
1130  *ScsiStatus =
1131  ((PSRBEX_DATA_SCSI_CDB_VAR) SrbExData)->ScsiStatus;
1132  }
1133 
1134  if (SenseInfoBuffer) {
1135  *SenseInfoBuffer =
1136  ((PSRBEX_DATA_SCSI_CDB_VAR) SrbExData)->SenseInfoBuffer;
1137  }
1138 
1139  if (SenseInfoBufferLength) {
1141  ((PSRBEX_DATA_SCSI_CDB_VAR) SrbExData)->SenseInfoBufferLength;
1142  }
1143 
1144  } else {
1145  // Catch invalid offset
1146  NT_ASSERT(FALSE);
1147  }
1148  break;
1149  }
1150 
1151  if (FoundEntry) {
1152  break;
1153  }
1154  }
1155 
1156  } else {
1157 
1158  if (CdbLength8) {
1159  *CdbLength8 = 0;
1160  }
1161 
1162  if (CdbLength32) {
1163  *CdbLength32 = 0;
1164  }
1165 
1166  if (ScsiStatus) {
1167  *ScsiStatus = 0;
1168  }
1169 
1170  if (SenseInfoBuffer) {
1171  *SenseInfoBuffer = NULL;
1172  }
1173 
1174  if (SenseInfoBufferLength) {
1175  *SenseInfoBufferLength = 0;
1176  }
1177  }
1178 
1179  return Cdb;
1180 }
1181 
1182 FORCEINLINE // __REACTOS__
1183 VOID
1186  _In_ UCHAR CdbLength8,
1187  _In_ ULONG CdbLength32,
1188  _In_ UCHAR ScsiStatus,
1189  _In_opt_ PVOID SenseInfoBuffer,
1191  )
1192 /*++
1193 
1194 Routine Description:
1195 
1196  Helper function to set SCSI related fields from an extended SRB. If SRB is
1197  not a SRB_FUNCTION_EXECUTE_SCSI or not an extended SRB, no modifications will
1198  be made
1199 
1200 Arguments:
1201 
1202  SrbEx - Pointer to extended SRB.
1203 
1204  CdbLength8 - CdbLength field value for SRBEX_DATA_SCSI_CDB16
1205  or SRBEX_DATA_SCSI_CDB32
1206 
1207  CdbLength32 - CdbLength field value for SRBEX_DATA_SCSI_CDB_VAR
1208 
1209  ScsiStatus - ScsiStatus field value.
1210 
1211  SenseInfoBuffer - SenseInfoBuffer value.
1212 
1213  SenseInfoBufferLength - SenseInfoBufferLength value.
1214 
1215 Return Value:
1216 
1217  None
1218 
1219 --*/
1220 {
1221  ULONG i;
1222  PSRBEX_DATA SrbExData = NULL;
1223  BOOLEAN FoundEntry = FALSE;
1224 
1225  if ((SrbEx->Function == SRB_FUNCTION_STORAGE_REQUEST_BLOCK) &&
1226  (SrbEx->SrbFunction == SRB_FUNCTION_EXECUTE_SCSI)) {
1227  NT_ASSERT(SrbEx->NumSrbExData > 0);
1228 
1229  for (i = 0; i < SrbEx->NumSrbExData; i++) {
1230 
1231  // Skip any invalid offsets
1232  if ((SrbEx->SrbExDataOffset[i] < sizeof(STORAGE_REQUEST_BLOCK)) ||
1233  (SrbEx->SrbExDataOffset[i] > SrbEx->SrbLength)){
1234  // Catch any invalid offsets
1235  NT_ASSERT(FALSE);
1236  continue;
1237  }
1238 
1239  SrbExData = (PSRBEX_DATA)((PUCHAR)SrbEx + SrbEx->SrbExDataOffset[i]);
1240 
1241  switch (SrbExData->Type) {
1242 
1244  if (SrbEx->SrbExDataOffset[i] + sizeof(SRBEX_DATA_SCSI_CDB16) <= SrbEx->SrbLength) {
1245  FoundEntry = TRUE;
1246  ((PSRBEX_DATA_SCSI_CDB16) SrbExData)->CdbLength = CdbLength8;
1247  ((PSRBEX_DATA_SCSI_CDB16) SrbExData)->ScsiStatus = ScsiStatus;
1248  ((PSRBEX_DATA_SCSI_CDB16) SrbExData)->SenseInfoBuffer = SenseInfoBuffer;
1249  ((PSRBEX_DATA_SCSI_CDB16) SrbExData)->SenseInfoBufferLength = SenseInfoBufferLength;
1250  } else {
1251  // Catch invalid offset
1252  NT_ASSERT(FALSE);
1253  }
1254  break;
1255 
1257  if (SrbEx->SrbExDataOffset[i] + sizeof(SRBEX_DATA_SCSI_CDB32) <= SrbEx->SrbLength) {
1258  FoundEntry = TRUE;
1259  ((PSRBEX_DATA_SCSI_CDB32) SrbExData)->CdbLength = CdbLength8;
1260  ((PSRBEX_DATA_SCSI_CDB32) SrbExData)->ScsiStatus = ScsiStatus;
1261  ((PSRBEX_DATA_SCSI_CDB32) SrbExData)->SenseInfoBuffer = SenseInfoBuffer;
1262  ((PSRBEX_DATA_SCSI_CDB32) SrbExData)->SenseInfoBufferLength = SenseInfoBufferLength;
1263  } else {
1264  // Catch invalid offset
1265  NT_ASSERT(FALSE);
1266  }
1267  break;
1268 
1270  if (SrbEx->SrbExDataOffset[i] + sizeof(SRBEX_DATA_SCSI_CDB_VAR) <= SrbEx->SrbLength) {
1271  FoundEntry = TRUE;
1272  ((PSRBEX_DATA_SCSI_CDB_VAR) SrbExData)->CdbLength = CdbLength32;
1273  ((PSRBEX_DATA_SCSI_CDB_VAR) SrbExData)->ScsiStatus = ScsiStatus;
1274  ((PSRBEX_DATA_SCSI_CDB_VAR) SrbExData)->SenseInfoBuffer = SenseInfoBuffer;
1275  ((PSRBEX_DATA_SCSI_CDB_VAR) SrbExData)->SenseInfoBufferLength = SenseInfoBufferLength;
1276  } else {
1277  // Catch invalid offset
1278  NT_ASSERT(FALSE);
1279  }
1280  break;
1281  }
1282 
1283  if (FoundEntry) {
1284  break;
1285  }
1286  }
1287 
1288  }
1289 
1290  return;
1291 }
1292 
signed char * PCHAR
Definition: retypes.h:7
struct _DISK_GROUP_CONTEXT * PDISK_GROUP_CONTEXT
GUID PartitionId
Definition: disk.h:267
NTSTATUS DiskIoctlSmartGetVersion(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:5540
NTSTATUS DiskInitializeReregistration(VOID)
Definition: diskwmi.c:1560
#define IN
Definition: typedefs.h:39
struct _DISK_VERIFY_WORKITEM_CONTEXT * PDISK_VERIFY_WORKITEM_CONTEXT
VOID DiskLogCacheInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PDISK_CACHE_INFORMATION CacheInfo, IN NTSTATUS Status)
Definition: disk.c:2856
struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB32 SRBEX_DATA_SCSI_CDB32
struct _DISK_DATA::@1016::@1020 Efi
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ size_t _In_ UCHAR PageMode
Definition: cdrom.h:1325
#define _In_opt_
Definition: ms_sal.h:309
NTSTATUS DiskEnableDisableFailurePrediction(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN Enable)
Definition: diskwmi.c:1126
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1154
NTSTATUS DiskIoctlReassignBlocks(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:4648
#define _Inout_
Definition: ms_sal.h:378
_In_ PSCSI_REQUEST_BLOCK Srb
Definition: cdrom.h:989
struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB_VAR SRBEX_DATA_SCSI_CDB_VAR
FORCEINLINE PCDB GetSrbScsiData(_In_ PSTORAGE_REQUEST_BLOCK SrbEx, _In_opt_ PUCHAR CdbLength8, _In_opt_ PULONG CdbLength32, _In_opt_ PUCHAR ScsiStatus, _In_opt_ PVOID *SenseInfoBuffer, _In_opt_ PUCHAR SenseInfoBufferLength)
Definition: disk.h:994
Definition: ntbasedef.h:628
GUIDREGINFO DiskWmiFdoGuidList[]
Definition: diskwmi.c:92
#define _Out_
Definition: ms_sal.h:345
#define TRUE
Definition: types.h:120
VOID DiskDeleteSymbolicLinks(IN PDEVICE_OBJECT DeviceObject)
Definition: pnp.c:780
struct SRB_ALIGN _SRBEX_DATA * PSRBEX_DATA
BOOLEAN BootIndicator
Definition: disk.h:245
NTSTATUS DiskIoctlSetCacheInformation(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:3917
unsigned char * PUCHAR
Definition: retypes.h:3
NTSTATUS ReadyStatus
Definition: disk.h:319
PDEVICE_OBJECT DeviceObject
Definition: disk.h:431
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
SCSI_ADDRESS ScsiAddress
Definition: disk.h:325
ULONG64 Attributes
Definition: disk.h:273
NTSTATUS DiskIoctlPredictFailure(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:4268
_In_ ULONG const _In_ FEATURE_NUMBER const Feature
Definition: cdrom.h:1075
LIST_ENTRY CurrList
Definition: disk.h:108
ULONG HiddenSectors
Definition: disk.h:219
KSPIN_LOCK Spinlock
Definition: disk.h:143
WCHAR PartitionName[36]
Definition: disk.h:279
Definition: shell.h:41
GUID PartitionType
Definition: disk.h:261
UCHAR SrbExBuffer[CLASS_SRBEX_SCSI_CDB16_BUFFER_SIZE]
Definition: disk.h:133
NTSTATUS NTAPI DiskStopDevice(IN PDEVICE_OBJECT DeviceObject, IN UCHAR Type)
Definition: pnp.c:600
NTSTATUS NTAPI DiskInitFdo(IN PDEVICE_OBJECT Fdo)
Definition: pnp.c:202
BOOLEAN AllowFPPerfHit
Definition: disk.h:332
ULONG PartitionOrdinal
Definition: disk.h:191
NTSTATUS NTAPI DiskStartFdo(IN PDEVICE_OBJECT Fdo)
Definition: pnp.c:911
enum _STORAGE_MEDIA_TYPE STORAGE_MEDIA_TYPE
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSTATUS DiskIoctlIsWritable(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:5063
NTSTATUS DiskIoctlGetMediaTypesEx(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:3994
NTSTATUS DiskDetermineMediaTypes(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN UCHAR MediumType, IN UCHAR DensityCode, IN BOOLEAN MediaPresent, IN BOOLEAN IsWritable)
Definition: disk.c:655
VOID DiskCreateSymbolicLinks(IN PDEVICE_OBJECT DeviceObject)
Definition: pnp.c:676
NTSTATUS NTAPI DiskRemoveDevice(IN PDEVICE_OBJECT DeviceObject, IN UCHAR Type)
Definition: pnp.c:843
struct _DISK_DATA DISK_DATA
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_DISK_USER_WRITE_CACHE_SETTING
Definition: disk.h:177
NTSTATUS DiskGetModePage(_In_ PDEVICE_OBJECT Fdo, _In_ UCHAR PageMode, _In_ UCHAR PageControl, _In_ PMODE_PARAMETER_HEADER ModeData, _Inout_ PULONG ModeDataSize, _Out_ PVOID *PageData)
Definition: diskwmi.c:903
struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB16 SRBEX_DATA_SCSI_CDB16
struct DISKREREGREQUEST * PDISKREREGREQUEST
_In_ ULONG _In_ UCHAR _In_ UCHAR PageControl
Definition: cdrom.h:1316
NTSTATUS NTAPI DiskFdoQueryWmiDataBlock(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG BufferAvail, OUT PUCHAR Buffer)
Definition: diskwmi.c:2638
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
struct _DISK_DATA::@1018 LinkStatus
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
BOOLEAN FailurePredictionEnabled
Definition: disk.h:346
NTSTATUS DiskEnableInfoExceptions(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ BOOLEAN Enable)
Definition: diskwmi.c:979
#define CLASS_SRBEX_SCSI_CDB16_BUFFER_SIZE
Definition: classpnp.h:695
ULONG DeviceCount
Definition: mpu401.c:26
NTSTATUS NTAPI DiskAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
Definition: pnp.c:53
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:64
NTSTATUS DiskIoctlReassignBlocksEx(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:4855
struct _DISK_VERIFY_WORKITEM_CONTEXT DISK_VERIFY_WORKITEM_CONTEXT
unsigned char BOOLEAN
_Out_ ULONG * RegFlags
Definition: classpnp.h:403
struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB16 * PSRBEX_DATA_SCSI_CDB16
* PSTORAGE_REQUEST_BLOCK
Definition: srb.h:652
DISK_USER_WRITE_CACHE_SETTING WriteCacheOverride
Definition: disk.h:385
const ULONG NumberOfTypes
Definition: disk.h:420
KEVENT Event
Definition: disk.h:148
UCHAR PartitionType
Definition: disk.h:235
union _CDB * PCDB
FORCEINLINE VOID SetSrbScsiData(_In_ PSTORAGE_REQUEST_BLOCK SrbEx, _In_ UCHAR CdbLength8, _In_ ULONG CdbLength32, _In_ UCHAR ScsiStatus, _In_opt_ PVOID SenseInfoBuffer, _In_ UCHAR SenseInfoBufferLength)
Definition: disk.h:1184
#define _In_
Definition: ms_sal.h:308
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:418
Definition: bufpool.h:45
NTSTATUS DiskEnableDisableFailurePredictPolling(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN Enable, ULONG PollTimeInSeconds)
Definition: diskwmi.c:1193
NTSTATUS DiskIoctlVerify(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:4526
CLASSPNP_SCAN_FOR_SPECIAL_INFO DiskBadControllers[]
Definition: data.c:42
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
const STORAGE_MEDIA_TYPE MediaTypes[MAX_MEDIA_TYPES]
Definition: disk.h:422
PARTITION_STYLE PartitionStyle
Definition: disk.h:197
Status
Definition: gdiplustypes.h:24
IO_WORKITEM_ROUTINE DisableWriteCache
Definition: disk.h:589
_In_ ULONG DataItemId
Definition: wdfwmi.h:123
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
int Count
Definition: noreturn.cpp:7
NTSTATUS DiskIoctlGetDriveGeometryEx(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS DiskGetInfoExceptionInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, OUT PMODE_INFO_EXCEPTIONS ReturnPageData)
NTSTATUS DiskIoctlSmartSendDriveCommand(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:5890
PSCSI_REQUEST_BLOCK Srb
Definition: disk.h:448
ULONG Signature
Definition: disk.h:207
NTSTATUS DiskIoctlGetCacheInformation(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:3840
NTSTATUS NTAPI DiskGetCacheInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PDISK_CACHE_INFORMATION CacheInfo)
Definition: disk.c:3019
NTSTATUS DiskIoctlUpdateDriveSize(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:5362
STORAGE_REQUEST_BLOCK SrbEx
Definition: disk.h:132
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
VOID NTAPI DiskSetSpecialHacks(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN ULONG_PTR Data)
Definition: disk.c:2602
struct _DISK_MEDIA_TYPES_LIST DISK_MEDIA_TYPES_LIST
VOID NTAPI DiskUnload(IN PDRIVER_OBJECT DriverObject)
Definition: disk.c:281
NTSTATUS NTAPI DiskFdoSetWmiDataItem(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG DataItemId, IN ULONG BufferSize, IN PUCHAR Buffer)
Definition: diskwmi.c:2975
NTSTATUS DiskModeSelect(IN PDEVICE_OBJECT DeviceObject, _In_reads_bytes_(Length) PCHAR ModeSelectBuffer, IN ULONG Length, IN BOOLEAN SavePage)
Definition: disk.c:1802
enum FAILURE_PREDICTION_METHOD * PFAILURE_PREDICTION_METHOD
_In_ UCHAR SenseInfoBufferLength
Definition: scsi.h:3705
Type
Definition: Type.h:6
_In_opt_ WDFREQUEST _In_ ULONG _In_ BOOLEAN _In_ PCDB Cdb
Definition: scratch.h:156
NTSTATUS DiskIoctlGetVolumeDiskExtents(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:5461
struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB32 * PSRBEX_DATA_SCSI_CDB32
NTSTATUS NTAPI DiskReadWriteVerification(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: disk.c:546
_In_ ULONG MethodId
Definition: wdfwmi.h:142
#define MAX_MEDIA_TYPES
Definition: disk.h:415
BOOLEAN ScsiInfoExceptionsSupported
Definition: disk.h:340
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
IO_COMPLETION_ROUTINE DiskFlushComplete
Definition: disk.h:599
unsigned __int64 ULONG64
Definition: imports.h:198
#define SRB_FUNCTION_STORAGE_REQUEST_BLOCK
Definition: srb.h:99
unsigned char UCHAR
Definition: xmlstorage.h:181
NTSTATUS DiskIoctlEnableFailurePrediction(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:4419
NTSTATUS DiskReadFailurePredictData(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PSTORAGE_FAILURE_PREDICT_DATA DiskSmartData)
Definition: diskwmi.c:1327
VOID DiskFlushDispatch(IN PDEVICE_OBJECT Fdo, IN PDISK_GROUP_CONTEXT FlushContext)
Definition: disk.c:1534
NTSTATUS NTAPI DiskSetCacheInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PDISK_CACHE_INFORMATION CacheInfo)
Definition: disk.c:3167
NTSTATUS NTAPI DiskFdoSetWmiDataBlock(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG BufferSize, IN PUCHAR Buffer)
Definition: diskwmi.c:2869
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:310
SINGLE_LIST_ENTRY Next
Definition: disk.h:430
CLASSENABLEDISABLEFUNCTION
Definition: classpnp.h:228
NTSTATUS DiskCreateFdo(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT LowerDeviceObject, IN PULONG DeviceCount, IN BOOLEAN DasdAccessOnly)
Definition: disk.c:307
_In_z_ PCCHAR _In_ PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:982
NTSTATUS NTAPI DiskFdoExecuteWmiMethod(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG MethodId, IN ULONG InBufferSize, IN ULONG OutBufferSize, IN PUCHAR Buffer)
Definition: diskwmi.c:3045
enum _PARTITION_STYLE PARTITION_STYLE
const DISK_MEDIA_TYPES_LIST DiskMediaTypesExclude[]
Definition: data.c:74
FAILURE_PREDICTION_METHOD FailurePredictionCapability
Definition: disk.h:331
const ULONG NumberOfSides
Definition: disk.h:421
_In_ PIRP _In_ ULONG _In_ ULONG BufferAvail
Definition: classpnp.h:418
#define DiskGetDetectInfo(FdoExtension, DetectInfo)
Definition: disk.h:861
struct _DISK_MEDIA_TYPES_LIST * PDISK_MEDIA_TYPES_LIST
Definition: typedefs.h:119
NTSTATUS DiskSetInfoExceptionInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMODE_INFO_EXCEPTIONS PageData)
Definition: disk.c:2985
NTSTATUS NTAPI DiskShutdownFlush(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: disk.c:1122
NTSTATUS DiskIoctlSetVerify(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:5264
ULONG SectorCount
Definition: part_xbox.c:31
NTSTATUS DiskIoctlGetCacheSetting(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: disk.c:3347
IO_WORKITEM_ROUTINE DiskIoctlVerifyThread
Definition: disk.h:591
LIST_ENTRY NextList
Definition: disk.h:118
unsigned int WellKnownNameCreated
Definition: disk.h:295
DISK_GROUP_CONTEXT FlushContext
Definition: disk.h:379
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS DiskGenerateDeviceName(IN ULONG DeviceNumber, OUT PCCHAR *RawName)
Definition: pnp.c:612
STORAGE_REQUEST_BLOCK
Definition: srb.h:652
NTSTATUS DiskDetectFailurePrediction(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PFAILURE_PREDICTION_METHOD FailurePredictCapability, BOOLEAN ScsiAddressAvailable)
Definition: diskwmi.c:2230
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define FORCEINLINE
Definition: wdftypes.h:67
struct _DISK_DATA::@1016::@1019 Mbr
unsigned int * PULONG
Definition: retypes.h:1
enum _DISK_USER_WRITE_CACHE_SETTING * PDISK_USER_WRITE_CACHE_SETTING
#define NULL
Definition: types.h:112
NTSTATUS DiskReadFailurePredictStatus(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PSTORAGE_FAILURE_PREDICT_STATUS DiskSmartStatus)
Definition: diskwmi.c:1251
FAILURE_PREDICTION_METHOD
Definition: classpnp.h:233
_Must_inspect_result_ _Out_ PBOOLEAN IsWritable
Definition: fltkernel.h:1743
VOID ResetBus(IN PDEVICE_OBJECT DeviceObject)
Definition: disk.c:2705
struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB_VAR * PSRBEX_DATA_SCSI_CDB_VAR
#define DiskReadDriveCapacity(Fdo)
Definition: disk.h:818
SCSI_REQUEST_BLOCK Srb
Definition: disk.h:131
unsigned int PhysicalDriveLinkCreated
Definition: disk.h:303
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING InstanceName
Definition: fltkernel.h:1162
#define OUT
Definition: typedefs.h:40
NTSTATUS NTAPI DiskFdoQueryWmiRegInfo(IN PDEVICE_OBJECT DeviceObject, OUT ULONG *RegFlags, OUT PUNICODE_STRING InstanceName)
Definition: diskwmi.c:2479
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:315
NTSTATUS NTAPI DiskWmiFunctionControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN CLASSENABLEDISABLEFUNCTION Function, IN BOOLEAN Enable)
Definition: diskwmi.c:2366
PIO_WORKITEM WorkItem
Definition: disk.h:449
NTSTATUS DiskIoctlGetLengthInfo(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS DiskIoctlSetCacheSetting(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: disk.c:3415
ULONG MbrCheckSum
Definition: disk.h:213
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
NTSTATUS DiskPerformSmartCommand(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN ULONG SrbControlCode, IN UCHAR Command, IN UCHAR Feature, IN UCHAR SectorCount, IN UCHAR SectorNumber, IN OUT PSRB_IO_CONTROL SrbControl, OUT PULONG BufferSize)
Definition: diskwmi.c:476
GUID DiskId
Definition: disk.h:255
KMUTEX VerifyMutex
Definition: disk.h:372
NTSTATUS NTAPI DiskFdoQueryWmiRegInfoEx(IN PDEVICE_OBJECT DeviceObject, OUT ULONG *RegFlags, OUT PUNICODE_STRING InstanceName, OUT PUNICODE_STRING MofName)
Definition: diskwmi.c:2577
const DISK_MEDIA_TYPES_LIST DiskMediaTypes[]
Definition: data.c:82
NTSTATUS DiskIoctlGetDriveGeometry(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:3582
DRIVER_INITIALIZE DriverEntry
Definition: disk.h:485
enum _DISK_USER_WRITE_CACHE_SETTING DISK_USER_WRITE_CACHE_SETTING
NTSTATUS DiskIoctlClearVerify(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:5313
struct _DISK_GROUP_CONTEXT DISK_GROUP_CONTEXT
NTSTATUS NTAPI DiskDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
NTSTATUS DiskIoctlSmartReceiveDriveData(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: disk.c:5663
struct _DISK_DATA * PDISK_DATA
#define _In_reads_bytes_(size)
Definition: ms_sal.h:321
VOID NTAPI DiskFdoProcessError(PDEVICE_OBJECT DeviceObject, PSCSI_REQUEST_BLOCK Srb, NTSTATUS *Status, BOOLEAN *Retry)
Definition: disk.c:2276
#define NT_ASSERT
Definition: rtlfuncs.h:3310