24 static UINT32 HarddiskVolumeNextId = 1;
30 volumeNum = HarddiskVolumeNextId++;
31 swprintf(nameBuf,
L"\\Device\\HarddiskVolume%lu", volumeNum);
55 ERR(
"Unable to create device object %wZ\n", &deviceName);
59 INFO(
"Created device object %p %wZ\n", partitionDevice, &deviceName);
71 partitionDevice->
StackSize = FDObject->StackSize;
76 partExt->
Mbr.PartitionType = PartitionEntry->Mbr.PartitionType;
77 partExt->
Mbr.BootIndicator = PartitionEntry->Mbr.BootIndicator;
78 partExt->
Mbr.HiddenSectors = PartitionEntry->Mbr.HiddenSectors;
82 partExt->
Gpt.PartitionType = PartitionEntry->Gpt.PartitionType;
83 partExt->
Gpt.PartitionId = PartitionEntry->Gpt.PartitionId;
84 partExt->
Gpt.Attributes = PartitionEntry->Gpt.Attributes;
97 partitionDevice->
Flags &= ~DO_DEVICE_INITIALIZING;
99 *PDO = partitionDevice;
119 fdoExtension->
DiskData.DeviceNumber, PartExt->DetectedNumber);
133 PartExt->SymlinkCreated =
TRUE;
135 INFO(
"Symlink created %wZ -> %wZ\n", &partitionSymlink, &PartExt->DeviceName);
143 &GUID_DEVINTERFACE_PARTITION,
151 INFO(
"Partition interface %wZ\n", &interfaceName);
152 PartExt->PartitionInterfaceName = interfaceName;
162 &GUID_DEVINTERFACE_VOLUME,
170 INFO(
"Volume interface %wZ\n", &interfaceName);
171 PartExt->VolumeInterfaceName = interfaceName;
198 ULONG InputSize, OutputSize;
221 InputSize =
sizeof(*InputBuffer) +
DeviceName->Length;
231 InputBuffer->DeviceNameOffset =
sizeof(*InputBuffer);
293 if (PartExt->SymlinkCreated)
300 fdoExtension->
DiskData.DeviceNumber, PartExt->DetectedNumber);
310 PartExt->SymlinkCreated =
FALSE;
312 INFO(
"Symlink removed %wZ -> %wZ\n", &partitionSymlink, &PartExt->DeviceName);
316 if (PartExt->PartitionInterfaceName.Buffer)
327 if (PartExt->VolumeInterfaceName.Buffer)
336 ERR(
"VolumeDeleteMountPoints(%wZ) failed with status 0x%08lx\n",
337 &PartExt->DeviceName,
status);
353 ASSERT(PartExt->DeviceName.Buffer);
354 if (PartExt->DeviceName.Buffer)
356 INFO(
"Removed device %wZ\n", &PartExt->DeviceName);
384 if (deviceRelations !=
NULL)
386 deviceRelations->
Count = 1;
387 deviceRelations->
Objects[0] = PartExt->DeviceObject;
400 Irp->IoStatus.Information = 0;
401 return Irp->IoStatus.Status;
427 static WCHAR volumeID[] =
L"STORAGE\\Volume\0";
444 swprintf(
string,
L"S%08lx_O%I64x_L%I64x",
445 fdoExtension->
DiskData.Mbr.Signature,
446 PartExt->StartingOffset,
447 PartExt->PartitionLength);
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);
496 devCaps->SilentInstall =
TRUE;
497 devCaps->RawDeviceOK =
TRUE;
498 devCaps->NoDisplayInUI =
TRUE;
499 devCaps->Address = PartExt->OnDiskNumber;
500 devCaps->UniqueID =
FALSE;
560 Irp->IoStatus.Information = 0;
616 .HiddenSectors = partExt->
Mbr.HiddenSectors,
618 .BootIndicator = partExt->
Mbr.BootIndicator,
619 .RecognizedPartition = partExt->
Mbr.RecognizedPartition,
620 .RewritePartition =
FALSE,
625 Irp->IoStatus.Information =
sizeof(*partInfo);
645 .PartitionStyle = fdoExtension->
DiskData.PartitionStyle,
646 .RewritePartition =
FALSE,
653 .HiddenSectors = partExt->
Mbr.HiddenSectors,
654 .BootIndicator = partExt->
Mbr.BootIndicator,
655 .RecognizedPartition = partExt->
Mbr.RecognizedPartition,
662 .PartitionId = partExt->
Gpt.PartitionId,
663 .Attributes = partExt->
Gpt.Attributes,
673 Irp->IoStatus.Information =
sizeof(*partInfoEx);
690 fdoExtension->
DiskData.BytesPerSector,
701 Irp->IoStatus.Information = 0;
706 PSET_PARTITION_INFORMATION_EX inputBuffer =
Irp->AssociatedIrp.SystemBuffer;
724 partExt->
Mbr.PartitionType = inputBuffer->Mbr.PartitionType;
728 partExt->
Gpt.PartitionType = inputBuffer->Gpt.PartitionType;
729 partExt->
Gpt.PartitionId = inputBuffer->Gpt.PartitionId;
730 partExt->
Gpt.Attributes = inputBuffer->Gpt.Attributes;
733 inputBuffer->Gpt.Name,
734 sizeof(partExt->
Gpt.Name));
740 Irp->IoStatus.Information = 0;
759 Irp->IoStatus.Information =
sizeof(*lengthInfo);
801 Irp->IoStatus.Information =
sizeof(*deviceNumber);
828 .DiskNumber = fdoExtension->
DiskData.DeviceNumber,
837 Irp->IoStatus.Information =
sizeof(*volExts);
859 Irp->IoStatus.Information =
sizeof(*volNum);
896 Irp->IoStatus.Information =
sizeof(*gptAttrs);
915 Irp->IoStatus.Information =
sizeof(
USHORT);
923 Irp->IoStatus.Information =
sizeof(
USHORT) +
name->NameLength;
958 if (!InterfaceName->Buffer || !InterfaceName->Length)
971 Irp->IoStatus.Information = headerSize;
991 basicVolId->
Mbr.Signature = fdoExtension->
DiskData.Mbr.Signature;
997 basicVolId->
Gpt.PartitionGuid = partExt->
Gpt.PartitionId;
1002 InterfaceName->Buffer,
1015#if (NTDDI_VERSION >= NTDDI_WS03)
1024 WARN(
"Ignored MountMgr notification: 0x%lX\n",
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
NTSTATUS FASTCALL IoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN ULONG PartitionNumber, IN ULONG PartitionType)
#define FILE_DEVICE_SECURE_OPEN
#define IOCTL_DISK_VERIFY
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_NOT_SUPPORTED
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
NTSTATUS PartitionHandleRemove(_In_ PPARTITION_EXTENSION PartExt, _In_ BOOLEAN FinalRemove)
NTSTATUS PartitionHandleDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
static NTSTATUS PartitionHandleQueryId(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
static NTSTATUS PartitionHandleDeviceRelations(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
static const WCHAR PartitionSymLinkFormat[]
static NTSTATUS PartitionHandleStartDevice(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
NTSTATUS PartitionHandlePnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
NTSTATUS PartitionCreateDevice(_In_ PDEVICE_OBJECT FDObject, _In_ PPARTITION_INFORMATION_EX PartitionEntry, _In_ UINT32 PdoNumber, _In_ PARTITION_STYLE PartitionStyle, _Out_ PDEVICE_OBJECT *PDO)
static NTSTATUS VolumeDeleteMountPoints(_In_ PPARTITION_EXTENSION PartExt)
Notifies MountMgr to delete all mount points associated with the given volume.
static NTSTATUS PartitionHandleQueryCapabilities(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define IOCTL_DISK_GET_PARTITION_INFO_EX
NTSTATUS NTAPI IoSetPartitionInformationEx(IN PDEVICE_OBJECT DeviceObject, IN ULONG PartitionNumber, IN PSET_PARTITION_INFORMATION_EX PartitionInfo)
GLuint GLuint GLsizei GLenum type
DRIVER_DISPATCH ForwardIrpAndForget
#define ExFreePoolWithTag(_P, _T)
#define IOCTL_MOUNTMGR_DELETE_POINTS
#define IOCTL_MOUNTDEV_LINK_CREATED
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
#define IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME
#define IOCTL_MOUNTDEV_QUERY_STABLE_GUID
struct _PARTITION_INFORMATION_EX PARTITION_INFORMATION_EX
#define IOCTL_DISK_GET_LENGTH_INFO
enum _PARTITION_STYLE PARTITION_STYLE
#define MOUNTDEVCONTROLTYPE
#define IOCTL_MOUNTDEV_QUERY_UNIQUE_ID
#define MOUNTMGR_DEVICE_NAME
#define IOCTL_MOUNTDEV_UNIQUE_ID_CHANGE_NOTIFY
struct _PARTITION_INFORMATION_MBR PARTITION_INFORMATION_MBR
#define IOCTL_MOUNTDEV_LINK_DELETED
struct _PARTITION_INFORMATION_GPT PARTITION_INFORMATION_GPT
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
#define CTL_CODE(DeviceType, Function, Method, Access)
#define FILE_READ_ATTRIBUTES
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define IOCTL_DISK_SET_PARTITION_INFO
#define IOCTL_DISK_SET_PARTITION_INFO_EX
struct _PARTITION_INFORMATION PARTITION_INFORMATION
#define IOCTL_DISK_GET_PARTITION_INFO
#define IOCTL_DISK_UPDATE_PROPERTIES
#define IOCTL_STORAGE_GET_DEVICE_NUMBER
#define IOCTL_STORAGE_MEDIA_REMOVAL
#define IOCTL_VOLUME_QUERY_VOLUME_NUMBER
#define IOCTL_VOLUME_GET_GPT_ATTRIBUTES
struct _VOLUME_DISK_EXTENTS VOLUME_DISK_EXTENTS
#define IOCTL_VOLUME_ONLINE
#define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
#define IOCTL_VOLUME_IS_PARTITION
#define IRP_MN_SURPRISE_REMOVAL
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)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
#define IoCompleteRequest
NTSTATUS NTAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName, IN PUNICODE_STRING DeviceName)
NTSTATUS NTAPI IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName)
#define STATUS_DEVICE_DOES_NOT_EXIST
union _BASIC_VOLUME_UNIQUE_ID * PBASIC_VOLUME_UNIQUE_ID
FORCEINLINE VOID PartMgrReleaseLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
FORCEINLINE VOID PartMgrAcquireLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
FORCEINLINE BOOLEAN VerifyIrpInBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
NTSTATUS IssueSyncIoControlRequest(_In_ UINT32 IoControlCode, _In_ PDEVICE_OBJECT DeviceObject, _In_ PVOID InputBuffer, _In_ ULONG InputBufferLength, _In_ PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _In_ BOOLEAN InternalDeviceIoControl)
#define DMIO_ID_SIGNATURE
FORCEINLINE BOOLEAN VerifyIrpOutBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
#define STATUS_BUFFER_TOO_SMALL
#define STATUS_BUFFER_OVERFLOW
PDEVICE_OBJECT Objects[1]
PDEVICE_OBJECT PhysicalDiskDO
struct _FDO_EXTENSION::@1366 DiskData
PDEVICE_OBJECT LowerDevice
UNICODE_STRING DiskInterfaceName
struct _IO_STACK_LOCATION::@4104::@4131 DeviceCapabilities
struct _IO_STACK_LOCATION::@4104::@4129 QueryDeviceRelations
union _IO_STACK_LOCATION::@1619 Parameters
struct _IO_STACK_LOCATION::@4104::@4135 QueryId
struct _IO_STACK_LOCATION::@1619::@1620 DeviceIoControl
struct _PARTITION_EXTENSION::@1371::@1373 Gpt
UNICODE_STRING VolumeInterfaceName
PDEVICE_OBJECT LowerDevice
struct _PARTITION_EXTENSION::@1371::@1374 Mbr
UNICODE_STRING DeviceName
PDEVICE_OBJECT DeviceObject
ULONG NumberOfDiskExtents
WCHAR VolumeManagerName[8]
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_INVALID_PARAMETER
#define STATUS_INFO_LENGTH_MISMATCH
#define STATUS_INSUFFICIENT_RESOURCES
struct _BASIC_VOLUME_UNIQUE_ID::@1364 Mbr
struct _BASIC_VOLUME_UNIQUE_ID::@1365 Gpt
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
#define IRP_MN_CANCEL_STOP_DEVICE
enum _BUS_QUERY_ID_TYPE BUS_QUERY_ID_TYPE
#define IRP_MN_START_DEVICE
#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
enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
#define IRP_MN_QUERY_REMOVE_DEVICE
#define ObDereferenceObject
#define ObReferenceObject