ReactOS  0.4.14-dev-554-g2f8d847
pnp.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (C) Microsoft Corporation, 1991 - 1999
4 
5 Module Name:
6 
7  pnp.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 "disk.h"
24 
26 
27 #ifdef ALLOC_PRAGMA
28 
29 #pragma alloc_text(PAGE, DiskAddDevice)
30 #pragma alloc_text(PAGE, DiskInitFdo)
31 #pragma alloc_text(PAGE, DiskInitPdo)
32 #pragma alloc_text(PAGE, DiskStartFdo)
33 #pragma alloc_text(PAGE, DiskStartPdo)
34 #pragma alloc_text(PAGE, DiskQueryId)
35 #pragma alloc_text(PAGE, DiskGenerateDeviceName)
36 #pragma alloc_text(PAGE, DiskCreateSymbolicLinks)
37 #pragma alloc_text(PAGE, DiskDeleteSymbolicLinks)
38 #pragma alloc_text(PAGE, DiskRemoveDevice)
39 
40 #endif
41 
43 NTAPI
47  )
48 
49 /*++
50 
51 Routine Description:
52 
53  This routine gets a port drivers capabilities, obtains the
54  inquiry data, searches the SCSI bus for the port driver and creates
55  the device objects for the disks found.
56 
57 Arguments:
58 
59  DriverObject - Pointer to driver object created by system.
60 
61  Pdo - Device object use to send requests to port driver.
62 
63 Return Value:
64 
65  True is returned if one disk was found and successfully created.
66 
67 --*/
68 
69 {
70  ULONG rootPartitionMountable = FALSE;
71 
72  PCONFIGURATION_INFORMATION configurationInformation;
73  ULONG diskCount;
74 
76 
77  PAGED_CODE();
78 
79  //
80  // See if we should be allowing file systems to mount on partition zero.
81  //
82 
83  TRY {
84  HANDLE deviceKey;
85 
86  UNICODE_STRING diskKeyName;
87  OBJECT_ATTRIBUTES objectAttributes;
88  HANDLE diskKey;
89 
90  RTL_QUERY_REGISTRY_TABLE queryTable[2];
91 
94  KEY_READ,
95  &deviceKey);
96 
97  if(!NT_SUCCESS(status)) {
98  DebugPrint((1, "DiskAddDevice: Error %#08lx opening device key "
99  "for pdo %#08lx\n",
101  LEAVE;
102  }
103 
104  RtlInitUnicodeString(&diskKeyName, L"Disk");
105  InitializeObjectAttributes(&objectAttributes,
106  &diskKeyName,
108  deviceKey,
109  NULL);
110 
111  status = ZwOpenKey(&diskKey, KEY_READ, &objectAttributes);
112  ZwClose(deviceKey);
113 
114  if(!NT_SUCCESS(status)) {
115  DebugPrint((1, "DiskAddDevice: Error %#08lx opening disk key "
116  "for pdo %#08lx device key %#x\n",
117  status, PhysicalDeviceObject, deviceKey));
118  LEAVE;
119  }
120 
121  RtlZeroMemory(queryTable, sizeof(queryTable));
122 
123  queryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
124  queryTable[0].Name = L"RootPartitionMountable";
125  queryTable[0].EntryContext = &(rootPartitionMountable);
126 
128  diskKey,
129  queryTable,
130  NULL,
131  NULL);
132 
133  if(!NT_SUCCESS(status)) {
134  DebugPrint((1, "DiskAddDevice: Error %#08lx reading value from "
135  "disk key %#x for pdo %#08lx\n",
136  status, diskKey, PhysicalDeviceObject));
137  }
138 
139  ZwClose(diskKey);
140 
141  } FINALLY {
142 
143  //
144  // Do nothing.
145  //
146 
147  if(!NT_SUCCESS(status)) {
148  DebugPrint((1, "DiskAddDevice: Will %sallow file system to mount on "
149  "partition zero of disk %#08lx\n",
150  (rootPartitionMountable ? "" : "not "),
152  }
153  }
154 
155  //
156  // Create device objects for disk
157  //
158 
159  diskCount = 0;
160 
162  DriverObject,
164  &diskCount,
165  (BOOLEAN) !rootPartitionMountable
166  );
167 
168  //
169  // Get the number of disks already initialized.
170  //
171 
172  configurationInformation = IoGetConfigurationInformation();
173 
174  if (NT_SUCCESS(status)) {
175 
176  //
177  // Increment system disk device count.
178  //
179 
180  configurationInformation->DiskCount++;
181 
182  }
183 
184  return status;
185 
186 } // end DiskAddDevice()
187 
188 NTSTATUS
189 NTAPI
191  IN PDEVICE_OBJECT Fdo
192  )
193 
194 /*++
195 
196 Routine Description:
197 
198  This routine is called to do one-time initialization of new device objects
199 
200 
201 Arguments:
202 
203  Fdo - a pointer to the functional device object for this device
204 
205 Return Value:
206 
207  status
208 
209 --*/
210 
211 {
212  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
213 
214  PDISK_DATA diskData = (PDISK_DATA) fdoExtension->CommonExtension.DriverData;
215 
216  //ULONG srbFlags = 0;
217 
218  ULONG timeOut = 0;
219 
220  ULONG bytesPerSector;
221  //UCHAR sectorShift;
222 
223  //BOOLEAN dmActive = FALSE;
224  PULONG dmSkew;
225  //ULONG dmByteSkew;
226 
228 
229  PAGED_CODE();
230 
231  //
232  // Build the lookaside list for srb's for the physical disk. Should only
233  // need a couple. If this fails then we don't have an emergency SRB so
234  // fail the call to initialize.
235  //
236 
239 
240  //
241  // Because all requests share a common sense buffer, it is possible
242  // for the buffer to be overwritten if the port driver completes
243  // multiple failed requests that require a request sense before the
244  // class driver's completion routine can consume the data in the buffer.
245  // To prevent this, we allow the port driver to allocate a unique sense
246  // buffer each time it needs one. We are responsible for freeing this
247  // buffer. This also allows the adapter to be configured to support
248  // additional sense data beyond the minimum 18 bytes.
249  //
250 
251  fdoExtension->SrbFlags = SRB_FLAGS_PORT_DRIVER_ALLOCSENSE;
252 
253  //
254  // Initialize the srb flags.
255  //
256 
257  if (fdoExtension->DeviceDescriptor->CommandQueueing &&
258  fdoExtension->AdapterDescriptor->CommandQueueing) {
259 
260  fdoExtension->SrbFlags = SRB_FLAGS_QUEUE_ACTION_ENABLE;
261 
262  }
263 
264  if (!TEST_FLAG(Fdo->Characteristics, FILE_REMOVABLE_MEDIA)) {
265  SET_FLAG(fdoExtension->DeviceFlags, DEV_SAFE_START_UNIT);
266  }
267 
268  //
269  // Look for controllers that require special flags.
270  //
271 
273 
274  //
275  // Look into the registry to see if this device
276  // requires special attention - [ like a hack ]
277  //
278 
279  DiskScanRegistryForSpecial(fdoExtension);
280 
281  //srbFlags = fdoExtension->SrbFlags;
282 
283  //
284  // Clear buffer for drive geometry.
285  //
286 
287  RtlZeroMemory(&(fdoExtension->DiskGeometry),
288  sizeof(DISK_GEOMETRY));
289 
290  //
291  // Allocate request sense buffer.
292  //
293 
294  fdoExtension->SenseData = ExAllocatePoolWithTag(NonPagedPoolCacheAligned,
297 
298  if (fdoExtension->SenseData == NULL) {
299 
300  //
301  // The buffer can not be allocated.
302  //
303 
304  DebugPrint((1, "DiskInitFdo: Can not allocate request sense buffer\n"));
305 
307  return status;
308  }
309 
310  //
311  // Physical device object will describe the entire
312  // device, starting at byte offset 0.
313  //
314 
315  fdoExtension->CommonExtension.StartingOffset.QuadPart = (LONGLONG)(0);
316 
317  //
318  // Set timeout value in seconds.
319  //
320 
321  timeOut = ClassQueryTimeOutRegistryValue(Fdo);
322  if (timeOut) {
323  fdoExtension->TimeOutValue = timeOut;
324  } else {
325  fdoExtension->TimeOutValue = SCSI_DISK_TIMEOUT;
326  }
327 
328  //
329  // If this is a removable drive, build an entry in devicemap\scsi
330  // indicating it's physicaldriveN name, set up the appropriate
331  // update partitions routine and set the flags correctly.
332  // note: only do this after the timeout value is set, above.
333  //
334 
335  if (fdoExtension->DeviceDescriptor->RemovableMedia) {
337  "PhysicalDrive",
338  fdoExtension->DeviceNumber,
339  NULL,
340  0);
341  //
342  // Enable media change notification for removable disks
343  //
345  "Disk");
346 
347  SET_FLAG(Fdo->Characteristics, FILE_REMOVABLE_MEDIA);
349 
350  } else {
351 
352  SET_FLAG(fdoExtension->SrbFlags, SRB_FLAGS_NO_QUEUE_FREEZE);
354 
355  }
356 
357  //
358  // Read the drive capacity. Don't use the disk version of the routine here
359  // since we don't know the disk signature yet - the disk version will
360  // attempt to determine the BIOS reported geometry.
361  //
362 
364 
365  //
366  // If the read capacity failed then just return, unless this is a
367  // removable disk where a device object partition needs to be created.
368  //
369 
370  if (!NT_SUCCESS(status) &&
371  !(Fdo->Characteristics & FILE_REMOVABLE_MEDIA)) {
372 
373  DebugPrint((1,
374  "DiskInitFdo: Can't read capacity for device %p\n",
375  Fdo));
376 
377  if (fdoExtension->DeviceDescriptor->RemovableMedia) {
378  fdoExtension->DiskGeometry.MediaType = RemovableMedia;
379  Fdo->Flags &= ~DO_VERIFY_VOLUME;
380  } else {
381  fdoExtension->DiskGeometry.MediaType = FixedMedia;
382  }
383 
385  }
386 
387  //
388  // Set up sector size fields.
389  //
390  // Stack variables will be used to update
391  // the partition device extensions.
392  //
393  // The device extension field SectorShift is
394  // used to calculate sectors in I/O transfers.
395  //
396  // The DiskGeometry structure is used to service
397  // IOCTls used by the format utility.
398  //
399 
400  bytesPerSector = fdoExtension->DiskGeometry.BytesPerSector;
401 
402  //
403  // Make sure sector size is not zero.
404  //
405 
406  if (bytesPerSector == 0) {
407 
408  //
409  // Default sector size for disk is 512.
410  //
411 
412  bytesPerSector = fdoExtension->DiskGeometry.BytesPerSector = 512;
413  }
414 
415  //sectorShift = fdoExtension->SectorShift;
416 
417  //
418  // Determine is DM Driver is loaded on an IDE drive that is
419  // under control of Atapi - this could be either a crashdump or
420  // an Atapi device is sharing the controller with an IDE disk.
421  //
422 
423  HalExamineMBR(fdoExtension->CommonExtension.DeviceObject,
424  fdoExtension->DiskGeometry.BytesPerSector,
425  (ULONG)0x54,
426  (PVOID*)&dmSkew);
427 
428  if (dmSkew) {
429 
430  //
431  // Update the device extension, so that the call to IoReadPartitionTable
432  // will get the correct information. Any I/O to this disk will have
433  // to be skewed by *dmSkew sectors aka DMByteSkew.
434  //
435 
436  fdoExtension->DMSkew = *dmSkew;
437  fdoExtension->DMActive = TRUE;
438  fdoExtension->DMByteSkew = fdoExtension->DMSkew * bytesPerSector;
439 
440  //
441  // Save away the information that we need, since this deviceExtension will soon be
442  // blown away.
443  //
444 
445  //dmActive = TRUE;
446  //dmByteSkew = fdoExtension->DMByteSkew;
447 
448  }
449 
450 #if defined(_X86_)
451  //
452  // Try to read the signature off the disk and determine the correct drive
453  // geometry based on that. This requires rereading the disk size to get
454  // the cylinder count updated correctly.
455  //
456 
457  if(fdoExtension->DeviceDescriptor->RemovableMedia == FALSE) {
458  DiskReadSignature(Fdo);
460  }
461 #endif
462 
463  //
464  // Register interfaces for this device
465  //
466  {
467  UNICODE_STRING interfaceName;
468 
469  RtlInitUnicodeString(&interfaceName, NULL);
470 
471  status = IoRegisterDeviceInterface(fdoExtension->LowerPdo,
472  (LPGUID) &DiskClassGuid,
473  NULL,
474  &interfaceName);
475 
476  if(NT_SUCCESS(status)) {
477 
478  diskData->DiskInterfaceString = interfaceName;
479  status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
480 
481  } else {
482  interfaceName.Buffer = NULL;
483  }
484 
485  if(!NT_SUCCESS(status)) {
486 
487  DebugPrint((1, "DiskInitFdo: Unable to register or set disk DCA "
488  "for fdo %p [%lx]\n", Fdo, status));
489 
490  RtlFreeUnicodeString(&interfaceName);
492  }
493  }
494 
496 
497  //
498  // Determine the type of disk and enable failure prediction in the hardware
499  // and enable failure prediction polling.
500  //
501 
502  if (InitSafeBootMode == 0)
503  {
504  DiskDetectFailurePrediction(fdoExtension,
505  &diskData->FailurePredictionCapability);
506 
508  {
509  //
510  // Cool, we've got some sort of failure prediction, enable it
511  // at the hardware and then enable polling for it
512  //
513 
514  //
515  // By default we allow performance to be degradeded if failure
516  // prediction is enabled.
517  //
518  // TODO: Make a registry entry ?
519  //
520 
521  diskData->AllowFPPerfHit = TRUE;
522 
523  //
524  // Enable polling only after Atapi and SBP2 add support for the new
525  // SRB flag that indicates that the request should not reset the
526  // drive spin down idle timer.
527  //
528 
530  TRUE,
532 
533  DebugPrint((3, "DiskInitFdo: Failure Prediction Poll enabled as "
534  "%d for device %p\n",
535  diskData->FailurePredictionCapability,
536  Fdo));
537  }
538  } else {
539 
540  //
541  // In safe boot mode we do not enable failure prediction, as perhaps
542  // it is the reason why normal boot does not work
543  //
544 
546 
547  }
548 
549  //
550  // Initialize the verify mutex
551  //
552 
554 
555  return(STATUS_SUCCESS);
556 
557 } // end DiskInitFdo()
558 
559 NTSTATUS
560 NTAPI
563  )
564 
565 /*++
566 
567 Routine Description:
568 
569  This routine will create the well known names for a PDO and register
570  it's device interfaces.
571 
572 --*/
573 
574 {
576  PDISK_DATA diskData = pdoExtension->DriverData;
577 
578  UNICODE_STRING interfaceName;
579 
581 
582  PAGED_CODE();
583 
585 
586  //
587  // Register interfaces for this device
588  //
589 
590  RtlInitUnicodeString(&interfaceName, NULL);
591 
593  (LPGUID) &PartitionClassGuid,
594  NULL,
595  &interfaceName);
596 
597  if(NT_SUCCESS(status)) {
598 
599  diskData->PartitionInterfaceString = interfaceName;
600  status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
601 
602  } else {
603  interfaceName.Buffer = NULL;
604  }
605 
606  if(!NT_SUCCESS(status)) {
607  DebugPrint((1, "DiskInitPdo: Unable to register partition DCA for "
608  "pdo %p [%lx]\n", Pdo, status));
609 
610  RtlFreeUnicodeString(&interfaceName);
612  }
613 
614  return STATUS_SUCCESS;
615 }
616 
617 NTSTATUS
618 NTAPI
621  )
622 
623 /*++
624 
625 Routine Description:
626 
627  This routine will create the well known names for a PDO and register
628  it's device interfaces.
629 
630 --*/
631 
632 {
633  PAGED_CODE();
634 
635  return STATUS_SUCCESS;
636 }
637 
638 NTSTATUS
639 NTAPI
642  IN UCHAR Type
643  )
644 
645 {
647 
648  if(fdo->CommonExtension.IsFdo) {
652  }
653 
654  return STATUS_SUCCESS;
655 }
656 
657 NTSTATUS
658 NTAPI
662  IN PUNICODE_STRING UnicodeIdString
663  )
664 
665 /*++
666 
667 Routine Description:
668 
669  This routine generates the PNP id's for the disk's "children". If the
670  specified ID isn't one that the routine can generate it must return
671  STATUS_NOT_IMPLEMENTED so classpnp will know not to do anything with the
672  PNP request's status.
673 
674  This routine allocates the buffer for the UnicodeIdString. It is the
675  caller's responsibility to free the buffer when it's done.
676 
677 Arguments:
678 
679  Pdo - a pointer to the PDO we are to generate an ID for
680 
681  IdType - the type of ID to be generated
682 
683  UnicodeIdString - a string to put the results into.
684 
685 Return Value:
686 
687  STATUS_SUCCCESS if successful
688 
689  STATUS_NOT_IMPLEMENTED if the IdType is not one supported by this routine
690 
691  error status otherwise.
692 
693 --*/
694 
695 {
696  ANSI_STRING ansiIdString;
697 
698  //NTSTATUS status;
699 
700  PAGED_CODE();
701  ASSERT_PDO(Pdo);
702 
703  if(IdType == BusQueryDeviceID) {
704 
705  if((Pdo->Characteristics & FILE_REMOVABLE_MEDIA) == 0) {
706  RtlInitAnsiString(&ansiIdString, "STORAGE\\Partition");
707  return RtlAnsiStringToUnicodeString(UnicodeIdString, &ansiIdString, TRUE);
708  }
709 
710  RtlInitAnsiString(&ansiIdString,
711  "STORAGE\\RemovableMedia");
712 
713  return RtlAnsiStringToUnicodeString(UnicodeIdString, &ansiIdString, TRUE);
714  }
715 
716  if(IdType == BusQueryInstanceID) {
717 
718  //PPHYSICAL_DEVICE_EXTENSION pdoExtension = Pdo->DeviceExtension;
719  PCOMMON_DEVICE_EXTENSION commonExtension = Pdo->DeviceExtension;
720  PDISK_DATA diskData = commonExtension->PartitionZeroExtension->CommonExtension.DriverData;
721 
722  UCHAR string[64];
723 
724  if((Pdo->Characteristics & FILE_REMOVABLE_MEDIA) == 0) {
725 
726  if (diskData->PartitionStyle == PARTITION_STYLE_MBR) {
727  sprintf(string, "S%08lx_O%I64x_L%I64x",
728  diskData->Mbr.Signature,
729  commonExtension->StartingOffset.QuadPart,
730  commonExtension->PartitionLength.QuadPart);
731  } else {
732  sprintf(string,
733  "S%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02xS_O%I64x_L%I64x",
734  diskData->Efi.DiskId.Data1,
735  diskData->Efi.DiskId.Data2,
736  diskData->Efi.DiskId.Data3,
737  diskData->Efi.DiskId.Data4[0],
738  diskData->Efi.DiskId.Data4[1],
739  diskData->Efi.DiskId.Data4[2],
740  diskData->Efi.DiskId.Data4[3],
741  diskData->Efi.DiskId.Data4[4],
742  diskData->Efi.DiskId.Data4[5],
743  diskData->Efi.DiskId.Data4[6],
744  diskData->Efi.DiskId.Data4[7],
745  commonExtension->StartingOffset.QuadPart,
746  commonExtension->PartitionLength.QuadPart);
747  }
748  } else {
749  sprintf(string, "RM");
750  }
751 
752  RtlInitAnsiString(&ansiIdString, string);
753 
754  return RtlAnsiStringToUnicodeString(UnicodeIdString, &ansiIdString, TRUE);
755  }
756 
758 
759  RtlInitAnsiString(&ansiIdString, "STORAGE\\Volume");
760 
761  UnicodeIdString->MaximumLength = (USHORT) RtlAnsiStringToUnicodeSize(&ansiIdString) + sizeof(UNICODE_NULL);
762 
763  UnicodeIdString->Buffer = ExAllocatePoolWithTag(PagedPool,
764  UnicodeIdString->MaximumLength,
766 
767  if(UnicodeIdString->Buffer == NULL) {
769  }
770 
771  RtlZeroMemory(UnicodeIdString->Buffer, UnicodeIdString->MaximumLength);
772 
773  return RtlAnsiStringToUnicodeString(UnicodeIdString,
774  &ansiIdString,
775  FALSE);
776  }
777 
778  return STATUS_NOT_IMPLEMENTED;
779 }
780 
781 NTSTATUS
782 NTAPI
784  IN BOOLEAN IsFdo,
788  IN OPTIONAL PLARGE_INTEGER PartitionLength,
789  OUT PUCHAR *RawName
790  )
791 
792 /*++
793 
794 Routine Description:
795 
796  This routine will allocate a unicode string buffer and then fill it in
797  with a generated name for the specified device object.
798 
799  It is the responsibility of the user to allocate a UNICODE_STRING structure
800  to pass in and to free UnicodeName->Buffer when done with it.
801 
802 Arguments:
803 
804  DeviceObject - a pointer to the device object
805 
806  UnicodeName - a unicode string to put the name buffer into
807 
808 Return Value:
809 
810  status
811 
812 --*/
813 
814 //#define PDO_NAME_FORMAT "\\Device\\Harddisk%d\\DP(%d)%d"
815 #define PDO_NAME_FORMAT "\\Device\\Harddisk%d\\DP(%d)%#I64x-%#I64x+%lx"
816 #define FDO_NAME_FORMAT "\\Device\\Harddisk%d\\DR%d"
817 
818 //#define PDO_NAME_FORMAT (PDO_BASE_NAME "+%#I64x+%#I64x+%#lx")
819 
820 {
821  UCHAR rawName[64];
822  static ULONG diskDeviceSequenceNumber = 0;
823 
824  PAGED_CODE();
825 
826  if(!IsFdo) {
827 
829  ASSERT(ARGUMENT_PRESENT(PartitionLength));
831 
833  StartingOffset->QuadPart,
834  PartitionLength->QuadPart,
835  diskDeviceSequenceNumber++);
836  } else {
837 
839  ASSERT(!ARGUMENT_PRESENT(PartitionLength));
841 
843  diskDeviceSequenceNumber++);
844 
845  }
846 
847  *RawName = ExAllocatePoolWithTag(PagedPool,
848  strlen(rawName) + 1,
849  DISK_TAG_NAME);
850 
851  if(*RawName == NULL) {
853  }
854 
855  strcpy(*RawName, rawName);
856 
857  DebugPrint((2, "DiskGenerateDeviceName: generated \"%s\"\n", rawName));
858 
859  return STATUS_SUCCESS;
860 }
861 
862 VOID
863 NTAPI
866  )
867 
868 /*++
869 
870 Routine Description:
871 
872  This routine will generate a symbolic link for the specified device object
873  using the well known form \\Device\HarddiskX\PartitionY, where X and Y are
874  filled in using the partition information in the device object's extension.
875 
876  This routine will not try to delete any previous symbolic link for the
877  same generated name - the caller must make sure the symbolic link has
878  been broken before calling this routine.
879 
880 Arguments:
881 
882  DeviceObject - the device object to make a well known name for
883 
884 Return Value:
885 
886  STATUS
887 
888 --*/
889 
890 {
892 
893  PDISK_DATA diskData = commonExtension->DriverData;
894 
895  WCHAR wideSourceName[64];
896  UNICODE_STRING unicodeSourceName;
897 
899 
900  PAGED_CODE();
901 
902  //
903  // Build the destination for the link first using the device name
904  // stored in the device object
905  //
906 
907  ASSERT(commonExtension->DeviceName.Buffer);
908 
909  if(!diskData->LinkStatus.WellKnownNameCreated) {
910  //
911  // Put together the source name using the partition and device number
912  // in the device extension and disk data segment
913  //
914 
915  swprintf(wideSourceName, L"\\Device\\Harddisk%d\\Partition%d",
916  commonExtension->PartitionZeroExtension->DeviceNumber,
917  (commonExtension->IsFdo ?
918  0 :
919  commonExtension->PartitionNumber));
920 
921  RtlInitUnicodeString(&unicodeSourceName, wideSourceName);
922 
923  DebugPrint((1, "DiskCreateSymbolicLink: Linking %wZ to %wZ\n",
924  &unicodeSourceName,
925  &commonExtension->DeviceName));
926 
927  status = IoCreateSymbolicLink(&unicodeSourceName,
928  &commonExtension->DeviceName);
929 
930  #if DBG
931 
934 
935  DebugPrint((1, "DiskCreateSymbolicLink: name %wZ already exists\n",
936  &unicodeSourceName));
937  }
938  #endif
939 
940  if(NT_SUCCESS(status)){
941  diskData->LinkStatus.WellKnownNameCreated = TRUE;
942  }
943  }
944 
945  if((!diskData->LinkStatus.PhysicalDriveLinkCreated) &&
946  (commonExtension->IsFdo)) {
947 
948  //
949  // Create a physical drive N link using the device number we saved
950  // away during AddDevice.
951  //
952 
953  swprintf(wideSourceName,
954  L"\\DosDevices\\PhysicalDrive%d",
955  commonExtension->PartitionZeroExtension->DeviceNumber);
956 
957  RtlInitUnicodeString(&unicodeSourceName, wideSourceName);
958 
959  DebugPrint((1, "DiskCreateSymbolicLink: Linking %wZ to %wZ\n",
960  &unicodeSourceName,
961  &(commonExtension->DeviceName)));
962 
963  status = IoCreateSymbolicLink(&unicodeSourceName,
964  &(commonExtension->DeviceName));
965 
966 #if DBG
967 
970 
971  DebugPrint((1, "DiskCreateSymbolicLink: name %wZ already exists\n",
972  &unicodeSourceName));
973  }
974 #endif
975 
976  if(NT_SUCCESS(status)) {
977  diskData->LinkStatus.PhysicalDriveLinkCreated = TRUE;
978  }
979  } else if(commonExtension->IsFdo == FALSE) {
980  diskData->LinkStatus.PhysicalDriveLinkCreated = FALSE;
981  }
982 
983  return;
984 }
985 
986 VOID
987 NTAPI
990  )
991 
992 /*++
993 
994 Routine Description:
995 
996  This routine will delete the well known name (symlink) for the specified
997  device. It generates the link name using information stored in the
998  device extension
999 
1000 Arguments:
1001 
1002  DeviceObject - the device object we are unlinking
1003 
1004 Return Value:
1005 
1006  status
1007 
1008 --*/
1009 
1010 {
1012  PDISK_DATA diskData = commonExtension->DriverData;
1013 
1014  WCHAR wideLinkName[64];
1015  UNICODE_STRING unicodeLinkName;
1016 
1017  PAGED_CODE();
1018 
1019  if(diskData->LinkStatus.WellKnownNameCreated) {
1020 
1021  swprintf(wideLinkName,
1022  L"\\Device\\Harddisk%d\\Partition%d",
1023  commonExtension->PartitionZeroExtension->DeviceNumber,
1024  (commonExtension->IsFdo ? 0 :
1025  commonExtension->PartitionNumber));
1026 
1027  RtlInitUnicodeString(&unicodeLinkName, wideLinkName);
1028 
1029  IoDeleteSymbolicLink(&unicodeLinkName);
1030 
1031  diskData->LinkStatus.WellKnownNameCreated = FALSE;
1032  }
1033 
1034  if(diskData->LinkStatus.PhysicalDriveLinkCreated) {
1035 
1037 
1038  swprintf(wideLinkName,
1039  L"\\DosDevices\\PhysicalDrive%d",
1040  commonExtension->PartitionZeroExtension->DeviceNumber);
1041 
1042  RtlInitUnicodeString(&unicodeLinkName, wideLinkName);
1043 
1044  IoDeleteSymbolicLink(&unicodeLinkName);
1045 
1046  diskData->LinkStatus.PhysicalDriveLinkCreated = FALSE;
1047  }
1048 
1049  return;
1050 }
1051 
1052 NTSTATUS
1053 NTAPI
1056  IN UCHAR Type
1057  )
1058 
1059 /*++
1060 
1061 Routine Description:
1062 
1063  This routine will release any resources the device may have allocated for
1064  this device object and return.
1065 
1066 Arguments:
1067 
1068  DeviceObject - the device object being removed
1069 
1070 Return Value:
1071 
1072  status
1073 
1074 --*/
1075 
1076 {
1078  PDISK_DATA diskData = commonExtension->DriverData;
1079 
1080  PAGED_CODE();
1081 
1082  //
1083  // Handle query and cancel
1084  //
1085 
1086  if((Type == IRP_MN_QUERY_REMOVE_DEVICE) ||
1088  return STATUS_SUCCESS;
1089  }
1090 
1091  if(commonExtension->IsFdo) {
1092 
1093  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension =
1095 
1096  //
1097  // Purge the cached partition table (if any).
1098  //
1099 
1100  DiskAcquirePartitioningLock(fdoExtension);
1101  DiskInvalidatePartitionTable(fdoExtension, TRUE);
1102  DiskReleasePartitioningLock(fdoExtension);
1103 
1104  //
1105  // Delete our object directory.
1106  //
1107 
1108  if(fdoExtension->AdapterDescriptor) {
1109  ExFreePool(fdoExtension->AdapterDescriptor);
1110  fdoExtension->AdapterDescriptor = NULL;
1111  }
1112 
1113  if(fdoExtension->DeviceDescriptor) {
1114  ExFreePool(fdoExtension->DeviceDescriptor);
1115  fdoExtension->DeviceDescriptor = NULL;
1116  }
1117 
1118  if(fdoExtension->SenseData) {
1119  ExFreePool(fdoExtension->SenseData);
1120  fdoExtension->SenseData = NULL;
1121  }
1122 
1123  if(fdoExtension->DeviceDirectory != NULL) {
1124  ZwMakeTemporaryObject(fdoExtension->DeviceDirectory);
1125  ZwClose(fdoExtension->DeviceDirectory);
1126  fdoExtension->DeviceDirectory = NULL;
1127  }
1128 
1129  if(Type == IRP_MN_REMOVE_DEVICE) {
1131  }
1132 
1133  } else {
1134 
1135  //PPHYSICAL_DEVICE_EXTENSION pdoExtension = DeviceObject->DeviceExtension;
1136 
1137  }
1138 
1140 
1141  //
1142  // Release the mounted device interface if we've set it.
1143  //
1144 
1145  if(diskData->PartitionInterfaceString.Buffer != NULL) {
1149  }
1150  if(diskData->DiskInterfaceString.Buffer != NULL) {
1154  }
1155 
1156  ClassDeleteSrbLookasideList(commonExtension);
1157  return STATUS_SUCCESS;
1158 }
1159 
1160 NTSTATUS
1161 NTAPI
1163  IN PDEVICE_OBJECT Fdo
1164  )
1165 
1166 /*++
1167 
1168 Routine Description:
1169 
1170  This routine will query the underlying device for any information necessary
1171  to complete initialization of the device. This will include physical
1172  disk geometry, mode sense information and such.
1173 
1174  This routine does not perform partition enumeration - that is left to the
1175  re-enumeration routine
1176 
1177  If this routine fails it will return an error value. It does not clean up
1178  any resources - that is left for the Stop/Remove routine.
1179 
1180 Arguments:
1181 
1182  Fdo - a pointer to the functional device object for this device
1183 
1184 Return Value:
1185 
1186  status
1187 
1188 --*/
1189 
1190 {
1191  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
1192  PCOMMON_DEVICE_EXTENSION commonExtension = &(fdoExtension->CommonExtension);
1193  PDISK_DATA diskData = commonExtension->DriverData;
1194  STORAGE_HOTPLUG_INFO hotplugInfo;
1195  ULONG writeCacheOverride = DiskWriteCacheDefault;
1196  DISK_CACHE_INFORMATION cacheInfo;
1197  NTSTATUS status;
1198 
1199  PAGED_CODE();
1200 
1201  //
1202  // Get the hotplug information, so we can turn off write cache if needed
1203  //
1204  // NOTE: Capabilities info is not good enough to determine hotplugedness
1205  // as we cannot determine device relations information and other
1206  // dependencies. Get the hotplug info instead
1207  //
1208 
1209  {
1210  PIRP irp;
1211  KEVENT event;
1212  IO_STATUS_BLOCK statusBlock;
1213 
1215  RtlZeroMemory(&hotplugInfo, sizeof(STORAGE_HOTPLUG_INFO));
1216 
1218  Fdo,
1219  NULL,
1220  0L,
1221  &hotplugInfo,
1222  sizeof(STORAGE_HOTPLUG_INFO),
1223  FALSE,
1224  &event,
1225  &statusBlock);
1226 
1227  if (irp != NULL) {
1228 
1229  // send to self -- classpnp handles this
1230  status = IoCallDriver(Fdo, irp);
1231  if (status == STATUS_PENDING) {
1233  Executive,
1234  KernelMode,
1235  FALSE,
1236  NULL);
1237  status = statusBlock.Status;
1238  }
1239  }
1240  }
1241 
1242  //
1243  // Clear the DEV_WRITE_CACHE flag now and set
1244  // it below only if we read that from the disk
1245  //
1246 
1247  CLEAR_FLAG(fdoExtension->DeviceFlags, DEV_WRITE_CACHE);
1248 
1250  {
1251  //
1252  // This flag overrides the user's setting, because faulty firmware
1253  // may cause the filesystem to refuse to format media on this device
1254  //
1255  DebugPrint((1,
1256  "DiskStartFdo: Shutting off write cache for %p due to %s\n",
1257  Fdo,
1258  "Possible Firmware Issue"));
1259 
1260  writeCacheOverride = DiskWriteCacheDisable;
1261  }
1262  else
1263  {
1264  //
1265  // Look into the registry to see if the user
1266  // has chosen to override the default setting
1267  //
1268  ClassGetDeviceParameter(fdoExtension,
1271  &writeCacheOverride);
1272 
1273  if (writeCacheOverride == DiskWriteCacheDefault)
1274  {
1275  //
1276  // The user has not overridden the default settings
1277  //
1278  if (hotplugInfo.DeviceHotplug && !hotplugInfo.WriteCacheEnableOverride)
1279  {
1280  DebugPrint((1,
1281  "DiskStartFdo: Shutting off write cache for %p due to %s\n",
1282  Fdo,
1283  "Hotplug Device"));
1284 
1285  writeCacheOverride = DiskWriteCacheDisable;
1286  }
1287  else if (hotplugInfo.MediaHotplug)
1288  {
1289  DebugPrint((1,
1290  "DiskStartFdo: Shutting off write cache for %p due to %s\n",
1291  Fdo,
1292  "Hotplug (unlockable) Media"));
1293 
1294  writeCacheOverride = DiskWriteCacheDisable;
1295  }
1296  else
1297  {
1298  //
1299  // We enable write cache if this device has no specific issues
1300  //
1301  writeCacheOverride = DiskWriteCacheEnable;
1302  }
1303  }
1304  }
1305 
1306  //
1307  // Query the disk to see if write cache is enabled
1308  // and set the DEV_WRITE_CACHE flag appropriately
1309  //
1310 
1311  RtlZeroMemory(&cacheInfo, sizeof(DISK_CACHE_INFORMATION));
1312 
1313  status = DiskGetCacheInformation(fdoExtension, &cacheInfo);
1314 
1315  if (NT_SUCCESS(status))
1316  {
1317  if (cacheInfo.WriteCacheEnabled != FALSE)
1318  {
1319  if (writeCacheOverride == DiskWriteCacheDisable)
1320  {
1321  //
1322  // Write cache is currently enabled on this
1323  // device, but we would like to turn it off
1324  //
1325  cacheInfo.WriteCacheEnabled = FALSE;
1326 
1327  status = DiskSetCacheInformation(fdoExtension, &cacheInfo);
1328  }
1329  else
1330  {
1331  //
1332  // The write cache setting either matches
1333  // our needs or we don't care
1334  //
1335  SET_FLAG(fdoExtension->DeviceFlags, DEV_WRITE_CACHE);
1336  }
1337  }
1338  else
1339  {
1340  if (writeCacheOverride == DiskWriteCacheEnable)
1341  {
1342  //
1343  // Write cache is currently disabled on this
1344  // device, but we would like to turn it on
1345  //
1346  cacheInfo.WriteCacheEnabled = TRUE;
1347 
1348  status = DiskSetCacheInformation(fdoExtension, &cacheInfo);
1349 
1350  SET_FLAG(fdoExtension->DeviceFlags, DEV_WRITE_CACHE);
1351  }
1352  }
1353  }
1354 
1355  //
1356  // In the event that there's a cached partition table flush it now.
1357  //
1358 
1359  DiskAcquirePartitioningLock(fdoExtension);
1360  DiskInvalidatePartitionTable(fdoExtension, TRUE);
1361  DiskReleasePartitioningLock(fdoExtension);
1362 
1363  //
1364  // Get the SCSI address if it's available for use with SMART ioctls.
1365  //
1366 
1367  {
1368  PIRP irp;
1369  KEVENT event;
1370  IO_STATUS_BLOCK statusBlock;
1371 
1373 
1375  commonExtension->LowerDeviceObject,
1376  NULL,
1377  0L,
1378  &(diskData->ScsiAddress),
1379  sizeof(SCSI_ADDRESS),
1380  FALSE,
1381  &event,
1382  &statusBlock);
1383 
1384  if(irp != NULL) {
1385 
1386 
1387  status = IoCallDriver(commonExtension->LowerDeviceObject, irp);
1388 
1389  if(status == STATUS_PENDING) {
1391  Executive,
1392  KernelMode,
1393  FALSE,
1394  NULL);
1395  status = statusBlock.Status;
1396  }
1397  }
1398  }
1399 
1400  return STATUS_SUCCESS;
1401 
1402 } // end DiskStartFdo()
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
VOID NTAPI DiskUpdatePartitions(IN PDEVICE_OBJECT Fdo, IN OUT PDRIVE_LAYOUT_INFORMATION_EX PartitionList)
Definition: enum.c:592
#define FINALLY
Definition: classpnp.h:113
#define IRP_MN_CANCEL_REMOVE_DEVICE
LARGE_INTEGER PartitionLength
Definition: classpnp.h:594
struct _DISK_DATA * PDISK_DATA
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
enum _BUS_QUERY_ID_TYPE BUS_QUERY_ID_TYPE
#define IRP_MN_REMOVE_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _DISK_DATA::@1016::@1020 Efi
#define IOCTL_SCSI_GET_ADDRESS
Definition: scsi_port.h:52
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:301
Type
Definition: Type.h:6
NTSTATUS NTAPI DiskCreateFdo(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PULONG DeviceCount, IN BOOLEAN DasdAccessOnly)
Definition: disk.c:375
_In_ PFCB _In_ LONGLONG StartingOffset
Definition: cdprocs.h:282
NTSTATUS NTAPI DiskEnableDisableFailurePredictPolling(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN Enable, ULONG PollTimeInSeconds)
Definition: diskwmi.c:949
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
PCONFIGURATION_INFORMATION NTAPI IoGetConfigurationInformation(VOID)
Definition: iorsrce.c:830
VOID NTAPI ClassDeleteSrbLookasideList(IN PCOMMON_DEVICE_EXTENSION CommonExtension)
Definition: obsolete.c:899
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2738
BOOLEAN DeviceHotplug
Definition: imports.h:248
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:396
#define KEY_READ
Definition: nt_native.h:1023
#define DISK_TAG_PNP_ID
Definition: disk.h:55
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSTATUS NTAPI DiskAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: pnp.c:44
VOID NTAPI DiskSetSpecialHacks(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN ULONG_PTR Data)
Definition: disk.c:4009
CLASSPNP_SCAN_FOR_SPECIAL_INFO DiskBadControllers[]
Definition: data.c:38
unsigned char * PUCHAR
Definition: retypes.h:3
_In_z_ PCCHAR _In_ PDEVICE_OBJECT _In_ BOOLEAN IsFdo
Definition: classpnp.h:789
struct _FUNCTIONAL_DEVICE_EXTENSION * PartitionZeroExtension
Definition: classpnp.h:575
#define STATUS_OBJECT_NAME_EXISTS
Definition: ntstatus.h:114
LONG NTSTATUS
Definition: precomp.h:26
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:695
#define LEAVE
Definition: classpnp.h:112
NTSTATUS NTAPI DiskGenerateDeviceName(IN BOOLEAN IsFdo, IN ULONG DeviceNumber, IN OPTIONAL ULONG PartitionNumber, IN OPTIONAL PLARGE_INTEGER StartingOffset, IN OPTIONAL PLARGE_INTEGER PartitionLength, OUT PUCHAR *RawName)
Definition: pnp.c:783
#define TRY(sps, bps)
#define DISK_DEFAULT_FAILURE_POLLING_PERIOD
Definition: disk.h:382
#define PDO_NAME_FORMAT
#define IOCTL_STORAGE_GET_HOTPLUG_INFO
Definition: imports.h:238
SCSI_ADDRESS ScsiAddress
Definition: disk.h:236
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
NTSTATUS NTAPI DiskInitFdo(IN PDEVICE_OBJECT Fdo)
Definition: pnp.c:190
NTSTATUS NTAPI DiskStopDevice(IN PDEVICE_OBJECT DeviceObject, IN UCHAR Type)
Definition: pnp.c:640
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1122
#define DISK_TAG_START
Definition: disk.h:62
_In_ ULONG _In_ ULONG PartitionNumber
Definition: iofuncs.h:2056
VOID NTAPI ClassUpdateInformationInRegistry(IN PDEVICE_OBJECT Fdo, IN PCHAR DeviceName, IN ULONG DeviceNumber, IN PINQUIRYDATA InquiryData, IN ULONG InquiryDataLength)
Definition: class.c:7322
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define NTSYSAPI
Definition: ntoskrnl.h:14
#define SENSE_BUFFER_SIZE
Definition: cdrw_hw.h:1183
BOOLEAN AllowFPPerfHit
Definition: disk.h:258
#define PAGED_CODE()
Definition: video.h:57
#define DEV_WRITE_CACHE
Definition: class2.h:21
PDISK_UPDATE_PARTITIONS UpdatePartitionRoutine
Definition: disk.h:230
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ASSERT_FDO(x)
Definition: pci.h:35
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define ASSERT_PDO(x)
Definition: pci.h:36
BOOLEAN MediaHotplug
Definition: imports.h:247
UNICODE_STRING PartitionInterfaceString
Definition: disk.h:251
#define DiskDeviceParameterSubkey
Definition: disk.h:317
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
struct _DISK_DATA::@1018 LinkStatus
#define CLASS_SPECIAL_DISABLE_WRITE_CACHE
Definition: classpnp.h:165
#define UNICODE_NULL
#define IRP_MN_QUERY_REMOVE_DEVICE
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
VOID NTAPI ClassScanForSpecial(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN CLASSPNP_SCAN_FOR_SPECIAL_INFO DeviceList[], IN PCLASS_SCAN_FOR_SPECIAL_HANDLER Function)
Definition: utils.c:213
#define CLEAR_FLAG(Flags, Bit)
Definition: classpnp.h:155
VOID NTAPI DiskCreateSymbolicLinks(IN PDEVICE_OBJECT DeviceObject)
Definition: pnp.c:864
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
#define MAX_SECTORS_PER_VERIFY
Definition: disk.h:361
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
NTSTATUS NTAPI DiskInitPdo(IN PDEVICE_OBJECT Pdo)
Definition: pnp.c:561
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
VOID NTAPI ClassGetDeviceParameter(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PWSTR SubkeyName OPTIONAL, IN PWSTR ParameterName, IN OUT PULONG ParameterValue)
Definition: utils.c:52
_In_ BUS_QUERY_ID_TYPE IdType
Definition: classpnp.h:357
#define SCSI_DISK_TIMEOUT
Definition: disk.c:166
UNICODE_STRING DeviceName
Definition: classpnp.h:591
LARGE_INTEGER StartingOffset
Definition: classpnp.h:595
PARTITION_STYLE PartitionStyle
Definition: disk.h:103
#define FDO_NAME_FORMAT
int64_t LONGLONG
Definition: typedefs.h:66
VOID NTAPI ClassInitializeSrbLookasideList(IN PCOMMON_DEVICE_EXTENSION CommonExtension, IN ULONG NumberElements)
Definition: obsolete.c:941
PDEVICE_OBJECT DeviceObject
Definition: pci.h:42
BOOLEAN WriteCacheEnableOverride
Definition: imports.h:249
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define DiskReadDriveCapacity(Fdo)
Definition: disk.h:860
#define ARGUMENT_PRESENT(ArgumentPointer)
NTSTATUS NTAPI DiskDetectFailurePrediction(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PFAILURE_PREDICTION_METHOD FailurePredictCapability)
Definition: diskwmi.c:1778
PSTORAGE_ADAPTER_DESCRIPTOR AdapterDescriptor
Definition: classpnp.h:699
#define swprintf(buf, format,...)
Definition: sprintf.c:56
PSTORAGE_DEVICE_DESCRIPTOR DeviceDescriptor
Definition: classpnp.h:698
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DISK_TAG_NAME
Definition: disk.h:58
NTSTATUS NTAPI DiskRemoveDevice(IN PDEVICE_OBJECT DeviceObject, IN UCHAR Type)
Definition: pnp.c:1054
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
NTSTATUS NTAPI DiskGetCacheInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PDISK_CACHE_INFORMATION CacheInfo)
Definition: disk.c:4314
#define PARTITION0_LIST_SIZE
Definition: disk.c:167
static const WCHAR L[]
Definition: oid.c:1250
#define RTL_REGISTRY_HANDLE
Definition: nt_native.h:168
VOID NTAPI DiskReleasePartitioningLock(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: enum.c:1234
FAILURE_PREDICTION_METHOD FailurePredictionCapability
Definition: disk.h:257
struct _cl_event * event
Definition: glext.h:7739
NTSYSAPI ULONG InitSafeBootMode
Definition: init.c:68
VOID NTAPI DiskScanRegistryForSpecial(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: disk.c:4112
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
ULONG NTAPI ClassQueryTimeOutRegistryValue(IN PDEVICE_OBJECT DeviceObject)
Definition: class.c:6190
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE
Definition: srb.h:405
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSYSAPI DWORD WINAPI RtlAnsiStringToUnicodeSize(const STRING *)
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define DiskDeviceUserWriteCacheSetting
Definition: disk.h:319
VOID NTAPI DiskDeleteSymbolicLinks(IN PDEVICE_OBJECT DeviceObject)
Definition: pnp.c:988
struct _DISK_DATA::@1016::@1019 Mbr
unsigned int * PULONG
Definition: retypes.h:1
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:574
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
VOID NTAPI DiskUpdateRemovablePartitions(IN PDEVICE_OBJECT Fdo, IN OUT PDRIVE_LAYOUT_INFORMATION_EX PartitionList)
Definition: enum.c:364
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:4586
#define DEV_SAFE_START_UNIT
Definition: class2.h:35
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
VOID NTAPI ClassInitializeMediaChangeDetection(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PUCHAR EventPrefix)
Definition: autorun.c:2058
#define OUT
Definition: typedefs.h:39
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI DiskQueryId(IN PDEVICE_OBJECT Pdo, IN BUS_QUERY_ID_TYPE IdType, IN PUNICODE_STRING UnicodeIdString)
Definition: pnp.c:659
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID FASTCALL HalExamineMBR(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN ULONG MbrTypeIdentifier, OUT PVOID *MbrBuffer)
Definition: disksup.c:2726
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSTATUS NTAPI DiskStartFdo(IN PDEVICE_OBJECT Fdo)
Definition: pnp.c:1162
NTSTATUS NTAPI DiskSetCacheInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PDISK_CACHE_INFORMATION CacheInfo)
Definition: disk.c:4432
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1036
KMUTEX VerifyMutex
Definition: disk.h:300
return STATUS_SUCCESS
Definition: btrfs.c:2938
BOOLEAN NTAPI DiskInvalidatePartitionTable(IN PFUNCTIONAL_DEVICE_EXTENSION Fdo, IN BOOLEAN PartitionLockHeld)
Definition: part.c:291
VOID NTAPI DiskAcquirePartitioningLock(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: enum.c:1214
NTSTATUS NTAPI ClassReadDriveCapacity(IN PDEVICE_OBJECT Fdo)
Definition: class.c:1729
static SERVICE_STATUS status
Definition: service.c:31
NTSYSAPI NTSTATUS NTAPI ZwMakeTemporaryObject(_In_ HANDLE Handle)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
UNICODE_STRING DiskInterfaceString
Definition: disk.h:250
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
Definition: srb.h:387
LONGLONG QuadPart
Definition: typedefs.h:112
NTSTATUS NTAPI DiskStartPdo(IN PDEVICE_OBJECT Pdo)
Definition: pnp.c:619
Definition: ps.c:97
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68