ReactOS 0.4.16-dev-716-g2b2bdab
partition.c File Reference
#include "partmgr.h"
Include dependency graph for partition.c:

Go to the source code of this file.

Functions

NTSTATUS PartitionCreateDevice (_In_ PDEVICE_OBJECT FDObject, _In_ PPARTITION_INFORMATION_EX PartitionEntry, _In_ UINT32 PdoNumber, _In_ PARTITION_STYLE PartitionStyle, _Out_ PDEVICE_OBJECT *PDO)
 
static NTSTATUS PartitionHandleStartDevice (_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
 
static NTSTATUS VolumeDeleteMountPoints (_In_ PPARTITION_EXTENSION PartExt)
 Notifies MountMgr to delete all mount points associated with the given volume.
 
NTSTATUS PartitionHandleRemove (_In_ PPARTITION_EXTENSION PartExt, _In_ BOOLEAN FinalRemove)
 
static NTSTATUS PartitionHandleDeviceRelations (_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
 
static NTSTATUS PartitionHandleQueryId (_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
 
static NTSTATUS PartitionHandleQueryCapabilities (_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
 
NTSTATUS PartitionHandlePnp (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
NTSTATUS PartitionHandleDeviceControl (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 

Variables

static const WCHAR PartitionSymLinkFormat [] = L"\\Device\\Harddisk%lu\\Partition%lu"
 

Function Documentation

◆ PartitionCreateDevice()

NTSTATUS PartitionCreateDevice ( _In_ PDEVICE_OBJECT  FDObject,
_In_ PPARTITION_INFORMATION_EX  PartitionEntry,
_In_ UINT32  PdoNumber,
_In_ PARTITION_STYLE  PartitionStyle,
_Out_ PDEVICE_OBJECT PDO 
)

Definition at line 15 of file partition.c.

21{
22 PAGED_CODE();
23
24 static UINT32 HarddiskVolumeNextId = 1; // this is 1-based
25
26 WCHAR nameBuf[64];
27 UNICODE_STRING deviceName;
28 UINT32 volumeNum;
29
30 volumeNum = HarddiskVolumeNextId++;
31 swprintf(nameBuf, L"\\Device\\HarddiskVolume%lu", volumeNum);
32 RtlCreateUnicodeString(&deviceName, nameBuf);
33
34 /*
35 * Create the partition/volume device object.
36 *
37 * Due to the fact we are also a (basic) volume manager, this device is
38 * ALSO a volume device. Because of this, we need to assign it a device
39 * name, and a specific device type for IoCreateDevice() to create a VPB
40 * for this device, so that a filesystem can be mounted on it.
41 * Once we get a separate volume manager, this partition DO can become
42 * anonymous, have a different device type, and without any associated VPB.
43 * (The attached volume, on the contrary, would require a VPB.)
44 */
45 PDEVICE_OBJECT partitionDevice;
46 NTSTATUS status = IoCreateDevice(FDObject->DriverObject,
47 sizeof(PARTITION_EXTENSION),
48 &deviceName,
49 FILE_DEVICE_DISK, // FILE_DEVICE_MASS_STORAGE,
51 FALSE,
52 &partitionDevice);
53 if (!NT_SUCCESS(status))
54 {
55 ERR("Unable to create device object %wZ\n", &deviceName);
56 return status;
57 }
58
59 INFO("Created device object %p %wZ\n", partitionDevice, &deviceName);
60
61 PPARTITION_EXTENSION partExt = partitionDevice->DeviceExtension;
62 RtlZeroMemory(partExt, sizeof(*partExt));
63
64 partExt->DeviceObject = partitionDevice;
65 partExt->LowerDevice = FDObject;
66
67 // NOTE: See comment above.
68 // PFDO_EXTENSION fdoExtension = FDObject->DeviceExtension;
69 // partitionDevice->DeviceType = /*fdoExtension->LowerDevice*/FDObject->DeviceType;
70
71 partitionDevice->StackSize = FDObject->StackSize;
72 partitionDevice->Flags |= DO_DIRECT_IO;
73
74 if (PartitionStyle == PARTITION_STYLE_MBR)
75 {
76 partExt->Mbr.PartitionType = PartitionEntry->Mbr.PartitionType;
77 partExt->Mbr.BootIndicator = PartitionEntry->Mbr.BootIndicator;
78 partExt->Mbr.HiddenSectors = PartitionEntry->Mbr.HiddenSectors;
79 }
80 else
81 {
82 partExt->Gpt.PartitionType = PartitionEntry->Gpt.PartitionType;
83 partExt->Gpt.PartitionId = PartitionEntry->Gpt.PartitionId;
84 partExt->Gpt.Attributes = PartitionEntry->Gpt.Attributes;
85
86 RtlCopyMemory(partExt->Gpt.Name, PartitionEntry->Gpt.Name, sizeof(partExt->Gpt.Name));
87 }
88
89 partExt->DeviceName = deviceName;
90 partExt->StartingOffset = PartitionEntry->StartingOffset.QuadPart;
91 partExt->PartitionLength = PartitionEntry->PartitionLength.QuadPart;
92 partExt->OnDiskNumber = PartitionEntry->PartitionNumber; // the "physical" partition number
93 partExt->DetectedNumber = PdoNumber; // counts only partitions with PDO created
94 partExt->VolumeNumber = volumeNum;
95
96 // The device is initialized
97 partitionDevice->Flags &= ~DO_DEVICE_INITIALIZING;
98
99 *PDO = partitionDevice;
100 return status;
101}
#define PAGED_CODE()
unsigned int UINT32
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: precomp.h:57
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define swprintf
Definition: precomp.h:40
#define INFO
Definition: debug.h:89
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
@ PARTITION_STYLE_MBR
Definition: imports.h:201
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define L(x)
Definition: ntvdm.h:50
#define FILE_DEVICE_DISK
Definition: winioctl.h:52
PVOID DeviceExtension
Definition: env_spec_w32.h:418
UINT64 StartingOffset
Definition: partmgr.h:96
PDEVICE_OBJECT LowerDevice
Definition: partmgr.h:93
struct _PARTITION_EXTENSION::@1339::@1341 Gpt
UINT32 DetectedNumber
Definition: partmgr.h:101
UNICODE_STRING DeviceName
Definition: partmgr.h:125
UINT64 PartitionLength
Definition: partmgr.h:97
PDEVICE_OBJECT DeviceObject
Definition: partmgr.h:92
struct _PARTITION_EXTENSION::@1339::@1342 Mbr
Definition: ps.c:97
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by PartMgrUpdatePartitionDevices().

◆ PartitionHandleDeviceControl()

NTSTATUS PartitionHandleDeviceControl ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp 
)

Definition at line 571 of file partition.c.

574{
576 PPARTITION_EXTENSION partExt = DeviceObject->DeviceExtension;
577 PFDO_EXTENSION fdoExtension = partExt->LowerDevice->DeviceExtension;
579
580 ASSERT(!partExt->IsFDO);
581
582 if (!partExt->IsEnumerated)
583 {
584 Irp->IoStatus.Status = STATUS_DEVICE_DOES_NOT_EXIST;
587 }
588
589 switch (ioStack->Parameters.DeviceIoControl.IoControlCode)
590 {
591 // disk stuff
593 {
595 {
597 break;
598 }
599
600 PartMgrAcquireLayoutLock(fdoExtension);
601
602 // not supported on anything other than MBR
603 if (fdoExtension->DiskData.PartitionStyle != PARTITION_STYLE_MBR)
604 {
606 PartMgrReleaseLayoutLock(fdoExtension);
607 break;
608 }
609
610 PPARTITION_INFORMATION partInfo = Irp->AssociatedIrp.SystemBuffer;
611
612 *partInfo = (PARTITION_INFORMATION){
613 .PartitionType = partExt->Mbr.PartitionType,
614 .StartingOffset.QuadPart = partExt->StartingOffset,
615 .PartitionLength.QuadPart = partExt->PartitionLength,
616 .HiddenSectors = partExt->Mbr.HiddenSectors,
617 .PartitionNumber = partExt->DetectedNumber,
618 .BootIndicator = partExt->Mbr.BootIndicator,
619 .RecognizedPartition = partExt->Mbr.RecognizedPartition,
620 .RewritePartition = FALSE,
621 };
622
623 PartMgrReleaseLayoutLock(fdoExtension);
624
625 Irp->IoStatus.Information = sizeof(*partInfo);
627 break;
628 }
630 {
632 {
634 break;
635 }
636
637 PPARTITION_INFORMATION_EX partInfoEx = Irp->AssociatedIrp.SystemBuffer;
638
639 PartMgrAcquireLayoutLock(fdoExtension);
640
641 *partInfoEx = (PARTITION_INFORMATION_EX){
643 .PartitionLength.QuadPart = partExt->PartitionLength,
644 .PartitionNumber = partExt->DetectedNumber,
645 .PartitionStyle = fdoExtension->DiskData.PartitionStyle,
646 .RewritePartition = FALSE,
647 };
648
649 if (fdoExtension->DiskData.PartitionStyle == PARTITION_STYLE_MBR)
650 {
651 partInfoEx->Mbr = (PARTITION_INFORMATION_MBR){
652 .PartitionType = partExt->Mbr.PartitionType,
653 .HiddenSectors = partExt->Mbr.HiddenSectors,
654 .BootIndicator = partExt->Mbr.BootIndicator,
655 .RecognizedPartition = partExt->Mbr.RecognizedPartition,
656 };
657 }
658 else
659 {
660 partInfoEx->Gpt = (PARTITION_INFORMATION_GPT){
661 .PartitionType = partExt->Gpt.PartitionType,
662 .PartitionId = partExt->Gpt.PartitionId,
663 .Attributes = partExt->Gpt.Attributes,
664 };
665
666 RtlCopyMemory(partInfoEx->Gpt.Name,
667 partExt->Gpt.Name,
668 sizeof(partInfoEx->Gpt.Name));
669 }
670
671 PartMgrReleaseLayoutLock(fdoExtension);
672
673 Irp->IoStatus.Information = sizeof(*partInfoEx);
675 break;
676 }
678 {
679 PSET_PARTITION_INFORMATION inputBuffer = Irp->AssociatedIrp.SystemBuffer;
680 if (!VerifyIrpInBufferSize(Irp, sizeof(*inputBuffer)))
681 {
683 break;
684 }
685
686 PartMgrAcquireLayoutLock(fdoExtension);
687
688 // these functions use on disk numbers, not detected ones
690 fdoExtension->DiskData.BytesPerSector,
691 partExt->OnDiskNumber,
692 inputBuffer->PartitionType);
693
694 if (NT_SUCCESS(status))
695 {
696 partExt->Mbr.PartitionType = inputBuffer->PartitionType;
697 }
698
699 PartMgrReleaseLayoutLock(fdoExtension);
700
701 Irp->IoStatus.Information = 0;
702 break;
703 }
705 {
706 PSET_PARTITION_INFORMATION_EX inputBuffer = Irp->AssociatedIrp.SystemBuffer;
707 if (!VerifyIrpInBufferSize(Irp, sizeof(*inputBuffer)))
708 {
710 break;
711 }
712
713 PartMgrAcquireLayoutLock(fdoExtension);
714
715 // these functions use on disk numbers, not detected ones
717 partExt->OnDiskNumber,
718 inputBuffer);
719
720 if (NT_SUCCESS(status))
721 {
722 if (fdoExtension->DiskData.PartitionStyle == PARTITION_STYLE_MBR)
723 {
724 partExt->Mbr.PartitionType = inputBuffer->Mbr.PartitionType;
725 }
726 else
727 {
728 partExt->Gpt.PartitionType = inputBuffer->Gpt.PartitionType;
729 partExt->Gpt.PartitionId = inputBuffer->Gpt.PartitionId;
730 partExt->Gpt.Attributes = inputBuffer->Gpt.Attributes;
731
732 RtlMoveMemory(partExt->Gpt.Name,
733 inputBuffer->Gpt.Name,
734 sizeof(partExt->Gpt.Name));
735 }
736 }
737
738 PartMgrReleaseLayoutLock(fdoExtension);
739
740 Irp->IoStatus.Information = 0;
741 break;
742 }
744 {
745 PGET_LENGTH_INFORMATION lengthInfo = Irp->AssociatedIrp.SystemBuffer;
746 if (!VerifyIrpOutBufferSize(Irp, sizeof(*lengthInfo)))
747 {
749 break;
750 }
751
752 PartMgrAcquireLayoutLock(fdoExtension);
753
754 lengthInfo->Length.QuadPart = partExt->PartitionLength;
755
756 PartMgrReleaseLayoutLock(fdoExtension);
757
759 Irp->IoStatus.Information = sizeof(*lengthInfo);
760 break;
761 }
763 {
764 PVERIFY_INFORMATION verifyInfo = Irp->AssociatedIrp.SystemBuffer;
765 if (!VerifyIrpInBufferSize(Irp, sizeof(*verifyInfo)))
766 {
768 break;
769 }
770
771 // Partition device should just adjust the starting offset
772 verifyInfo->StartingOffset.QuadPart += partExt->StartingOffset;
774 }
776 {
777 fdoExtension->LayoutValid = FALSE;
779
781 break;
782 }
784 {
785 PSTORAGE_DEVICE_NUMBER deviceNumber = Irp->AssociatedIrp.SystemBuffer;
786 if (!VerifyIrpOutBufferSize(Irp, sizeof(*deviceNumber)))
787 {
789 break;
790 }
791
792 PartMgrAcquireLayoutLock(fdoExtension);
793
794 deviceNumber->DeviceType = partExt->DeviceObject->DeviceType;
795 deviceNumber->DeviceNumber = fdoExtension->DiskData.DeviceNumber;
796 deviceNumber->PartitionNumber = partExt->DetectedNumber;
797
798 PartMgrReleaseLayoutLock(fdoExtension);
799
801 Irp->IoStatus.Information = sizeof(*deviceNumber);
802 break;
803 }
805 {
807 }
808 // volume stuff (most of that should be in volmgr.sys once it is implemented)
810 {
811 PVOLUME_DISK_EXTENTS volExts = Irp->AssociatedIrp.SystemBuffer;
812
813 // we fill only one extent entry so sizeof(*volExts) is enough
814 if (!VerifyIrpOutBufferSize(Irp, sizeof(*volExts)))
815 {
817 break;
818 }
819
820 PartMgrAcquireLayoutLock(fdoExtension);
821
822 // the only type of volume we support right now is disk partition
823 // so this structure is simple
824
825 *volExts = (VOLUME_DISK_EXTENTS) {
827 .Extents = {{
828 .DiskNumber = fdoExtension->DiskData.DeviceNumber,
829 .StartingOffset.QuadPart = partExt->StartingOffset,
830 .ExtentLength.QuadPart = partExt->PartitionLength
831 }}
832 };
833
834 PartMgrReleaseLayoutLock(fdoExtension);
835
837 Irp->IoStatus.Information = sizeof(*volExts);
838 break;
839 }
841 {
842 PVOLUME_NUMBER volNum = Irp->AssociatedIrp.SystemBuffer;
843 if (!VerifyIrpOutBufferSize(Irp, sizeof(*volNum)))
844 {
846 break;
847 }
848
849 PartMgrAcquireLayoutLock(fdoExtension);
850
851 volNum->VolumeNumber = partExt->VolumeNumber;
853 L"VOLMGR ", // Must be 8 space-padded characters
854 sizeof(volNum->VolumeManagerName));
855
856 PartMgrReleaseLayoutLock(fdoExtension);
857
859 Irp->IoStatus.Information = sizeof(*volNum);
860 break;
861 }
863 {
864 // The only type of volume we support right now is disk partition
865 // so we just return success. A more robust algorithm would be
866 // to check whether the volume has only one single extent, that
867 // covers the whole partition on which it lies upon. If this is
868 // not the case, return STATUS_UNSUCCESSFUL instead.
870 break;
871 }
873 {
875 break;
876 }
878 {
879 PVOLUME_GET_GPT_ATTRIBUTES_INFORMATION gptAttrs = Irp->AssociatedIrp.SystemBuffer;
880 if (!VerifyIrpOutBufferSize(Irp, sizeof(*gptAttrs)))
881 {
883 break;
884 }
885
886 // not supported on anything other than GPT
887 if (fdoExtension->DiskData.PartitionStyle != PARTITION_STYLE_GPT)
888 {
890 break;
891 }
892
893 gptAttrs->GptAttributes = partExt->Gpt.Attributes;
894
896 Irp->IoStatus.Information = sizeof(*gptAttrs);
897 break;
898 }
899 // mountmgr notifications (these should be in volmgr.sys once it is implemented)
901 {
902 PMOUNTDEV_NAME name = Irp->AssociatedIrp.SystemBuffer;
903
904 if (!VerifyIrpOutBufferSize(Irp, sizeof(USHORT)))
905 {
907 break;
908 }
909
910 name->NameLength = partExt->DeviceName.Length;
911
912 // return NameLength back
913 if (!VerifyIrpOutBufferSize(Irp, sizeof(USHORT) + name->NameLength))
914 {
915 Irp->IoStatus.Information = sizeof(USHORT);
917 break;
918 }
919
920 RtlCopyMemory(name->Name, partExt->DeviceName.Buffer, name->NameLength);
921
923 Irp->IoStatus.Information = sizeof(USHORT) + name->NameLength;
924 break;
925 }
927 {
928 const SIZE_T headerSize = FIELD_OFFSET(MOUNTDEV_UNIQUE_ID, UniqueId);
929 PMOUNTDEV_UNIQUE_ID uniqueId = Irp->AssociatedIrp.SystemBuffer;
931 PUNICODE_STRING InterfaceName;
932
933 // Check whether the minimal header size was provided
934 if (!VerifyIrpOutBufferSize(Irp, headerSize))
935 {
937 break;
938 }
939
940 PartMgrAcquireLayoutLock(fdoExtension);
941
942 InterfaceName = &partExt->VolumeInterfaceName;
943 if (fdoExtension->IsSuperFloppy)
944 InterfaceName = &fdoExtension->DiskInterfaceName;
945
946 // Calculate and return the necessary data size
947 if ((fdoExtension->DiskData.PartitionStyle == PARTITION_STYLE_MBR) &&
948 !fdoExtension->IsSuperFloppy)
949 {
950 uniqueId->UniqueIdLength = sizeof(basicVolId->Mbr);
951 }
952 else if (fdoExtension->DiskData.PartitionStyle == PARTITION_STYLE_GPT)
953 {
954 uniqueId->UniqueIdLength = sizeof(basicVolId->Gpt);
955 }
956 else
957 {
958 if (!InterfaceName->Buffer || !InterfaceName->Length)
959 {
960 PartMgrReleaseLayoutLock(fdoExtension);
962 break;
963 }
964 uniqueId->UniqueIdLength = InterfaceName->Length;
965 }
966
967 // Return UniqueIdLength back
968 if (!VerifyIrpOutBufferSize(Irp, headerSize + uniqueId->UniqueIdLength))
969 {
970 PartMgrReleaseLayoutLock(fdoExtension);
971 Irp->IoStatus.Information = headerSize;
973 break;
974 }
975
976 //
977 // Write the UniqueId
978 //
979 // Format:
980 // - Basic volume on MBR disk: disk Mbr.Signature + partition StartingOffset (length: 0x0C)
981 // - Basic volume on GPT disk: "DMIO:ID:" + Gpt.PartitionGuid (length: 0x18)
982 // - Volume on Basic disk (NT <= 4): 8-byte FTDisk identifier (length: 0x08)
983 // - Volume on Dynamic disk (NT 5+): "DMIO:ID:" + dmio VolumeGuid (length: 0x18)
984 // - Super-floppy (single-partition with StartingOffset == 0),
985 // or Removable media: DiskInterfaceName.
986 // - As fallback, we use the VolumeInterfaceName.
987 //
988 if ((fdoExtension->DiskData.PartitionStyle == PARTITION_STYLE_MBR) &&
989 !fdoExtension->IsSuperFloppy)
990 {
991 basicVolId->Mbr.Signature = fdoExtension->DiskData.Mbr.Signature;
992 basicVolId->Mbr.StartingOffset = partExt->StartingOffset;
993 }
994 else if (fdoExtension->DiskData.PartitionStyle == PARTITION_STYLE_GPT)
995 {
996 basicVolId->Gpt.Signature = DMIO_ID_SIGNATURE;
997 basicVolId->Gpt.PartitionGuid = partExt->Gpt.PartitionId;
998 }
999 else
1000 {
1001 RtlCopyMemory(uniqueId->UniqueId,
1002 InterfaceName->Buffer,
1003 uniqueId->UniqueIdLength);
1004 }
1005
1006 PartMgrReleaseLayoutLock(fdoExtension);
1007
1009 Irp->IoStatus.Information = headerSize + uniqueId->UniqueIdLength;
1010 break;
1011 }
1015#if (NTDDI_VERSION >= NTDDI_WS03)
1016 /* Deprecated Windows 2000/XP versions of IOCTL_MOUNTDEV_LINK_[CREATED|DELETED]
1017 * without access protection, that were updated in Windows 2003 */
1020#endif
1023 {
1024 WARN("Ignored MountMgr notification: 0x%lX\n",
1025 ioStack->Parameters.DeviceIoControl.IoControlCode);
1027 break;
1028 }
1029 default:
1031 }
1032
1033 Irp->IoStatus.Status = status;
1035 return status;
1036}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define WARN(fmt,...)
Definition: precomp.h:61
NTSTATUS FASTCALL IoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN ULONG PartitionNumber, IN ULONG PartitionType)
Definition: ntoskrnl.c:50
#define IOCTL_DISK_VERIFY
Definition: cdrw_usr.h:170
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define IOCTL_DISK_GET_PARTITION_INFO_EX
Definition: ntddk_ex.h:206
NTSTATUS NTAPI IoSetPartitionInformationEx(IN PDEVICE_OBJECT DeviceObject, IN ULONG PartitionNumber, IN PSET_PARTITION_INFORMATION_EX PartitionInfo)
Definition: fstubex.c:2347
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
#define IOCTL_MOUNTDEV_LINK_CREATED
Definition: imports.h:104
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
Definition: imports.h:91
#define IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME
Definition: imports.h:97
#define IOCTL_MOUNTDEV_QUERY_STABLE_GUID
Definition: imports.h:255
struct _PARTITION_INFORMATION_EX PARTITION_INFORMATION_EX
#define IOCTL_DISK_GET_LENGTH_INFO
Definition: imports.h:192
#define MOUNTDEVCONTROLTYPE
Definition: imports.h:76
#define IOCTL_MOUNTDEV_QUERY_UNIQUE_ID
Definition: imports.h:78
#define IOCTL_MOUNTDEV_UNIQUE_ID_CHANGE_NOTIFY
Definition: imports.h:84
struct _PARTITION_INFORMATION_MBR PARTITION_INFORMATION_MBR
@ PARTITION_STYLE_GPT
Definition: imports.h:202
#define IOCTL_MOUNTDEV_LINK_DELETED
Definition: imports.h:110
struct _PARTITION_INFORMATION_GPT PARTITION_INFORMATION_GPT
#define CTL_CODE(DeviceType, Function, Method, Access)
Definition: nt_native.h:586
#define FILE_ANY_ACCESS
Definition: nt_native.h:609
#define METHOD_BUFFERED
Definition: nt_native.h:594
#define IOCTL_DISK_SET_PARTITION_INFO
Definition: ntdddisk.h:214
#define IOCTL_DISK_SET_PARTITION_INFO_EX
Definition: ntdddisk.h:217
struct _PARTITION_INFORMATION PARTITION_INFORMATION
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:106
#define IOCTL_DISK_UPDATE_PROPERTIES
Definition: ntdddisk.h:242
#define IOCTL_STORAGE_GET_DEVICE_NUMBER
Definition: ntddstor.h:143
#define IOCTL_STORAGE_MEDIA_REMOVAL
Definition: ntddstor.h:104
#define IOCTL_VOLUME_QUERY_VOLUME_NUMBER
Definition: ntddvol.h:85
#define IOCTL_VOLUME_GET_GPT_ATTRIBUTES
Definition: ntddvol.h:133
struct _VOLUME_DISK_EXTENTS VOLUME_DISK_EXTENTS
#define IOCTL_VOLUME_ONLINE
Definition: ntddvol.h:63
#define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
Definition: ntddvol.h:44
#define IOCTL_VOLUME_IS_PARTITION
Definition: ntddvol.h:118
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
union _BASIC_VOLUME_UNIQUE_ID * PBASIC_VOLUME_UNIQUE_ID
FORCEINLINE VOID PartMgrReleaseLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
Definition: partmgr.h:212
FORCEINLINE VOID PartMgrAcquireLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
Definition: partmgr.h:202
FORCEINLINE BOOLEAN VerifyIrpInBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
Definition: partmgr.h:187
#define DMIO_ID_SIGNATURE
Definition: partmgr.h:55
FORCEINLINE BOOLEAN VerifyIrpOutBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
Definition: partmgr.h:172
unsigned short USHORT
Definition: pedump.c:61
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:1772
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
PDEVICE_OBJECT PhysicalDiskDO
Definition: partmgr.h:62
struct _FDO_EXTENSION::@1334 DiskData
PDEVICE_OBJECT LowerDevice
Definition: partmgr.h:61
BOOLEAN LayoutValid
Definition: partmgr.h:65
BOOLEAN IsSuperFloppy
Definition: partmgr.h:70
UNICODE_STRING DiskInterfaceName
Definition: partmgr.h:86
LARGE_INTEGER Length
Definition: imports.h:232
struct _IO_STACK_LOCATION::@1584::@1585 DeviceIoControl
union _IO_STACK_LOCATION::@1584 Parameters
USHORT UniqueIdLength
Definition: imports.h:136
UCHAR UniqueId[1]
Definition: imports.h:137
UNICODE_STRING VolumeInterfaceName
Definition: partmgr.h:124
BOOLEAN IsEnumerated
Definition: partmgr.h:103
LARGE_INTEGER StartingOffset
Definition: imports.h:221
PARTITION_INFORMATION_MBR Mbr
Definition: imports.h:226
PARTITION_INFORMATION_GPT Gpt
Definition: imports.h:227
DEVICE_TYPE DeviceType
Definition: ntddstor.h:324
LARGE_INTEGER StartingOffset
Definition: ntdddisk.h:651
ULONG NumberOfDiskExtents
Definition: ntddvol.h:54
WCHAR VolumeManagerName[8]
Definition: ntddvol.h:96
ULONG VolumeNumber
Definition: ntddvol.h:95
Definition: name.c:39
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
struct _BASIC_VOLUME_UNIQUE_ID::@1332 Mbr
struct _BASIC_VOLUME_UNIQUE_ID::@1333 Gpt
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
@ BusRelations
Definition: iotypes.h:2152
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by PartMgrDeviceControl().

◆ PartitionHandleDeviceRelations()

static NTSTATUS PartitionHandleDeviceRelations ( _In_ PPARTITION_EXTENSION  PartExt,
_In_ PIRP  Irp 
)
static

Definition at line 369 of file partition.c.

372{
373 PAGED_CODE();
374
377
379 {
380 // Device relations have one entry built into their size.
381 PDEVICE_RELATIONS deviceRelations =
383
384 if (deviceRelations != NULL)
385 {
386 deviceRelations->Count = 1;
387 deviceRelations->Objects[0] = PartExt->DeviceObject;
388 ObReferenceObject(deviceRelations->Objects[0]);
389
390 Irp->IoStatus.Information = (ULONG_PTR)deviceRelations;
391 return STATUS_SUCCESS;
392 }
393 else
394 {
396 }
397 }
398 else
399 {
400 Irp->IoStatus.Information = 0;
401 return Irp->IoStatus.Status;
402 }
403}
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
#define PagedPool
Definition: env_spec_w32.h:308
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define TAG_PARTMGR
Definition: partmgr.h:23
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
struct _IO_STACK_LOCATION::@4024::@4049 QueryDeviceRelations
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
@ TargetDeviceRelation
Definition: iotypes.h:2156
enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by PartitionHandlePnp().

◆ PartitionHandlePnp()

NTSTATUS PartitionHandlePnp ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp 
)

Definition at line 507 of file partition.c.

510{
511 PPARTITION_EXTENSION partExt = DeviceObject->DeviceExtension;
514
515 PAGED_CODE();
516
517 switch (ioStack->MinorFunction)
518 {
520 {
522 break;
523 }
525 {
527 break;
528 }
534 {
536 break;
537 }
539 {
541 break;
542 }
544 {
546 break;
547 }
548 case IRP_MN_QUERY_ID:
549 {
551 break;
552 }
554 {
556 break;
557 }
558 default:
559 {
560 Irp->IoStatus.Information = 0;
562 }
563 }
564
565 Irp->IoStatus.Status = status;
567 return status;
568}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define TRUE
Definition: types.h:120
NTSTATUS PartitionHandleRemove(_In_ PPARTITION_EXTENSION PartExt, _In_ BOOLEAN FinalRemove)
Definition: partition.c:284
static NTSTATUS PartitionHandleQueryId(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
Definition: partition.c:408
static NTSTATUS PartitionHandleDeviceRelations(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
Definition: partition.c:369
static NTSTATUS PartitionHandleStartDevice(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
Definition: partition.c:106
static NTSTATUS PartitionHandleQueryCapabilities(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
Definition: partition.c:486
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_ID
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_QUERY_CAPABILITIES
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

Referenced by PartMgrPnp().

◆ PartitionHandleQueryCapabilities()

static NTSTATUS PartitionHandleQueryCapabilities ( _In_ PPARTITION_EXTENSION  PartExt,
_In_ PIRP  Irp 
)
static

Definition at line 486 of file partition.c.

489{
491 PDEVICE_CAPABILITIES devCaps = ioStack->Parameters.DeviceCapabilities.Capabilities;
492
493 PAGED_CODE();
494 ASSERT(devCaps);
495
496 devCaps->SilentInstall = TRUE;
497 devCaps->RawDeviceOK = TRUE;
498 devCaps->NoDisplayInUI = TRUE;
499 devCaps->Address = PartExt->OnDiskNumber;
500 devCaps->UniqueID = FALSE;
501
502 return STATUS_SUCCESS;
503}
struct _IO_STACK_LOCATION::@4024::@4051 DeviceCapabilities
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965

Referenced by PartitionHandlePnp().

◆ PartitionHandleQueryId()

static NTSTATUS PartitionHandleQueryId ( _In_ PPARTITION_EXTENSION  PartExt,
_In_ PIRP  Irp 
)
static

Definition at line 408 of file partition.c.

411{
413 BUS_QUERY_ID_TYPE idType = ioStack->Parameters.QueryId.IdType;
414 UNICODE_STRING idString;
416
417 PAGED_CODE();
418
419 switch (idType)
420 {
421 case BusQueryDeviceID:
422 status = RtlCreateUnicodeString(&idString, L"STORAGE\\Partition")
424 break;
426 {
427 static WCHAR volumeID[] = L"STORAGE\\Volume\0";
428
429 idString.Buffer = ExAllocatePoolWithTag(PagedPool, sizeof(volumeID), TAG_PARTMGR);
430 RtlCopyMemory(idString.Buffer, volumeID, sizeof(volumeID));
431
433 break;
434 }
436 {
437 WCHAR string[64];
438 PFDO_EXTENSION fdoExtension = PartExt->LowerDevice->DeviceExtension;
439
440 PartMgrAcquireLayoutLock(fdoExtension);
441
442 if (fdoExtension->DiskData.PartitionStyle == PARTITION_STYLE_MBR)
443 {
444 swprintf(string, L"S%08lx_O%I64x_L%I64x",
445 fdoExtension->DiskData.Mbr.Signature,
446 PartExt->StartingOffset,
447 PartExt->PartitionLength);
448 }
449 else
450 {
451 swprintf(string,
452 L"S%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02xS_O%I64x_L%I64x",
453 fdoExtension->DiskData.Gpt.DiskId.Data1,
454 fdoExtension->DiskData.Gpt.DiskId.Data2,
455 fdoExtension->DiskData.Gpt.DiskId.Data3,
456 fdoExtension->DiskData.Gpt.DiskId.Data4[0],
457 fdoExtension->DiskData.Gpt.DiskId.Data4[1],
458 fdoExtension->DiskData.Gpt.DiskId.Data4[2],
459 fdoExtension->DiskData.Gpt.DiskId.Data4[3],
460 fdoExtension->DiskData.Gpt.DiskId.Data4[4],
461 fdoExtension->DiskData.Gpt.DiskId.Data4[5],
462 fdoExtension->DiskData.Gpt.DiskId.Data4[6],
463 fdoExtension->DiskData.Gpt.DiskId.Data4[7],
464 PartExt->StartingOffset,
465 PartExt->PartitionLength);
466 }
467
468 PartMgrReleaseLayoutLock(fdoExtension);
469
470 status = RtlCreateUnicodeString(&idString, string)
472 break;
473 }
474 default:
476 break;
477 }
478
479 Irp->IoStatus.Information = NT_SUCCESS(status) ? (ULONG_PTR) idString.Buffer : 0;
480 return status;
481}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _IO_STACK_LOCATION::@4024::@4055 QueryId
enum _BUS_QUERY_ID_TYPE BUS_QUERY_ID_TYPE
@ BusQueryInstanceID
Definition: iotypes.h:2939
@ BusQueryDeviceID
Definition: iotypes.h:2936
@ BusQueryHardwareIDs
Definition: iotypes.h:2937

Referenced by PartitionHandlePnp().

◆ PartitionHandleRemove()

NTSTATUS PartitionHandleRemove ( _In_ PPARTITION_EXTENSION  PartExt,
_In_ BOOLEAN  FinalRemove 
)

Definition at line 284 of file partition.c.

287{
289
290 PAGED_CODE();
291
292 // remove the symbolic link
293 if (PartExt->SymlinkCreated)
294 {
295 WCHAR nameBuf[64];
296 UNICODE_STRING partitionSymlink;
297 PFDO_EXTENSION fdoExtension = PartExt->LowerDevice->DeviceExtension;
298
300 fdoExtension->DiskData.DeviceNumber, PartExt->DetectedNumber);
301
302 RtlInitUnicodeString(&partitionSymlink, nameBuf);
303
304 status = IoDeleteSymbolicLink(&partitionSymlink);
305
306 if (!NT_SUCCESS(status))
307 {
308 return status;
309 }
310 PartExt->SymlinkCreated = FALSE;
311
312 INFO("Symlink removed %wZ -> %wZ\n", &partitionSymlink, &PartExt->DeviceName);
313 }
314
315 // release device interfaces
316 if (PartExt->PartitionInterfaceName.Buffer)
317 {
318 status = IoSetDeviceInterfaceState(&PartExt->PartitionInterfaceName, FALSE);
319 if (!NT_SUCCESS(status))
320 {
321 return status;
322 }
323 RtlFreeUnicodeString(&PartExt->PartitionInterfaceName);
324 RtlInitUnicodeString(&PartExt->PartitionInterfaceName, NULL);
325 }
326
327 if (PartExt->VolumeInterfaceName.Buffer)
328 {
329 /* Notify MountMgr to delete all associated mount points.
330 * MountMgr does not automatically remove these in order to support
331 * drive letter persistence for online/offline volume transitions,
332 * or volumes arrival/removal on removable devices. */
334 if (!NT_SUCCESS(status))
335 {
336 ERR("VolumeDeleteMountPoints(%wZ) failed with status 0x%08lx\n",
337 &PartExt->DeviceName, status);
338 /* Failure isn't major, continue proceeding with volume removal */
339 }
340
341 /* Notify MountMgr of volume removal */
342 status = IoSetDeviceInterfaceState(&PartExt->VolumeInterfaceName, FALSE);
343 if (!NT_SUCCESS(status))
344 {
345 return status;
346 }
347 RtlFreeUnicodeString(&PartExt->VolumeInterfaceName);
348 RtlInitUnicodeString(&PartExt->VolumeInterfaceName, NULL);
349 }
350
351 if (FinalRemove)
352 {
353 ASSERT(PartExt->DeviceName.Buffer);
354 if (PartExt->DeviceName.Buffer)
355 {
356 INFO("Removed device %wZ\n", &PartExt->DeviceName);
357 RtlFreeUnicodeString(&PartExt->DeviceName);
358 }
359
360 IoDeleteDevice(PartExt->DeviceObject);
361 }
362
363 return STATUS_SUCCESS;
364}
static const WCHAR PartitionSymLinkFormat[]
Definition: partition.c:10
static NTSTATUS VolumeDeleteMountPoints(_In_ PPARTITION_EXTENSION PartExt)
Notifies MountMgr to delete all mount points associated with the given volume.
Definition: partition.c:193
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1793

Referenced by FdoHandleSurpriseRemoval(), PartitionHandlePnp(), and PartMgrUpdatePartitionDevices().

◆ PartitionHandleStartDevice()

static NTSTATUS PartitionHandleStartDevice ( _In_ PPARTITION_EXTENSION  PartExt,
_In_ PIRP  Irp 
)
static

Definition at line 106 of file partition.c.

109{
110 PAGED_CODE();
111
112 // first, create a symbolic link for our device
113 WCHAR nameBuf[64];
114 UNICODE_STRING partitionSymlink, interfaceName;
115 PFDO_EXTENSION fdoExtension = PartExt->LowerDevice->DeviceExtension;
116
117 // \\Device\\Harddisk%lu\\Partition%lu
119 fdoExtension->DiskData.DeviceNumber, PartExt->DetectedNumber);
120
121 if (!RtlCreateUnicodeString(&partitionSymlink, nameBuf))
122 {
124 }
125
126 NTSTATUS status = IoCreateSymbolicLink(&partitionSymlink, &PartExt->DeviceName);
127
128 if (!NT_SUCCESS(status))
129 {
130 return status;
131 }
132
133 PartExt->SymlinkCreated = TRUE;
134
135 INFO("Symlink created %wZ -> %wZ\n", &partitionSymlink, &PartExt->DeviceName);
136
137 // Our partition device will have two interfaces:
138 // GUID_DEVINTERFACE_PARTITION and GUID_DEVINTERFACE_VOLUME
139 // (aka. MOUNTDEV_MOUNTED_DEVICE_GUID).
140 // The latter one is used to notify MountMgr about the new volume.
141
142 status = IoRegisterDeviceInterface(PartExt->DeviceObject,
143 &GUID_DEVINTERFACE_PARTITION,
144 NULL,
145 &interfaceName);
146 if (!NT_SUCCESS(status))
147 {
148 return status;
149 }
150
151 INFO("Partition interface %wZ\n", &interfaceName);
152 PartExt->PartitionInterfaceName = interfaceName;
153 status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
154 if (!NT_SUCCESS(status))
155 {
156 RtlFreeUnicodeString(&interfaceName);
157 RtlInitUnicodeString(&PartExt->PartitionInterfaceName, NULL);
158 return status;
159 }
160
161 status = IoRegisterDeviceInterface(PartExt->DeviceObject,
162 &GUID_DEVINTERFACE_VOLUME,
163 NULL,
164 &interfaceName);
165 if (!NT_SUCCESS(status))
166 {
167 return status;
168 }
169
170 INFO("Volume interface %wZ\n", &interfaceName);
171 PartExt->VolumeInterfaceName = interfaceName;
172 status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
173 if (!NT_SUCCESS(status))
174 {
175 RtlFreeUnicodeString(&interfaceName);
176 RtlInitUnicodeString(&PartExt->VolumeInterfaceName, NULL);
177 return status;
178 }
179
180 return STATUS_SUCCESS;
181}
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:1437

Referenced by PartitionHandlePnp().

◆ VolumeDeleteMountPoints()

static NTSTATUS VolumeDeleteMountPoints ( _In_ PPARTITION_EXTENSION  PartExt)
static

Notifies MountMgr to delete all mount points associated with the given volume.

Note
This should belong to volmgr.sys and act on a PVOLUME_EXTENSION.

Definition at line 193 of file partition.c.

195{
197 UNICODE_STRING MountMgr;
198 ULONG InputSize, OutputSize;
199 LOGICAL Retry;
205
206 PAGED_CODE();
207
208 /* Get the device pointer to the MountMgr */
212 &FileObject,
213 &DeviceObject);
214 if (!NT_SUCCESS(Status))
215 return Status;
216
217 /* Setup the volume device name for deleting its mount points */
218 DeviceName = &PartExt->DeviceName;
219
220 /* Allocate the input buffer */
221 InputSize = sizeof(*InputBuffer) + DeviceName->Length;
223 if (!InputBuffer)
224 {
226 goto Quit;
227 }
228
229 /* Fill it in */
231 InputBuffer->DeviceNameOffset = sizeof(*InputBuffer);
232 InputBuffer->DeviceNameLength = DeviceName->Length;
233 RtlCopyMemory(&InputBuffer[1], DeviceName->Buffer, DeviceName->Length);
234
235 /*
236 * IOCTL_MOUNTMGR_DELETE_POINTS needs a large-enough scratch output buffer
237 * to work with. (It uses it to query the mount points, before deleting
238 * them.) Start with a guessed size and call the IOCTL. If the buffer is
239 * not big enough, use the value retrieved in MOUNTMGR_MOUNT_POINTS::Size
240 * to re-allocate a larger buffer and call the IOCTL once more.
241 */
242 OutputSize = max(PAGE_SIZE, sizeof(*OutputBuffer));
243 for (Retry = 0; Retry < 2; ++Retry)
244 {
246 if (!OutputBuffer)
247 {
249 break;
250 }
251
252 /* Call the MountMgr to delete the drive letter */
256 InputSize,
258 OutputSize,
259 FALSE);
260
261 /* Adjust the allocation size if it was too small */
263 {
264 OutputSize = OutputBuffer->Size;
266 continue;
267 }
268 /* Success or failure: stop the loop */
269 break;
270 }
271
272Quit:
273 if (OutputBuffer)
275 if (InputBuffer)
277 if (FileObject)
279 return Status;
280}
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:312
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:25
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define IOCTL_MOUNTMGR_DELETE_POINTS
Definition: imports.h:122
#define MOUNTMGR_DEVICE_NAME
Definition: imports.h:74
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
NTSTATUS IssueSyncIoControlRequest(_In_ UINT32 IoControlCode, _In_ PDEVICE_OBJECT DeviceObject, _In_ PVOID InputBuffer, _In_ ULONG InputBufferLength, _In_ PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _In_ BOOLEAN InternalDeviceIoControl)
Definition: utils.c:19
#define max(a, b)
Definition: svc.c:63
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by PartitionHandleRemove().

Variable Documentation

◆ PartitionSymLinkFormat

const WCHAR PartitionSymLinkFormat[] = L"\\Device\\Harddisk%lu\\Partition%lu"
static

Definition at line 10 of file partition.c.

Referenced by PartitionHandleRemove(), and PartitionHandleStartDevice().