24 static UINT32 HarddiskVolumeNextId = 1;
32 volumeNum = HarddiskVolumeNextId++;
33 swprintf(nameBuf,
L"\\Device\\HarddiskVolume%lu", volumeNum);
47 ERR(
"Unable to create device object %wZ\n", &deviceName);
51 INFO(
"Created device object %p %wZ\n", partitionDevice, &deviceName);
56 partitionDevice->
StackSize = FDObject->StackSize;
61 partExt->
Mbr.PartitionType = PartitionEntry->Mbr.PartitionType;
62 partExt->
Mbr.BootIndicator = PartitionEntry->Mbr.BootIndicator;
63 partExt->
Mbr.HiddenSectors = PartitionEntry->Mbr.HiddenSectors;
67 partExt->
Gpt.PartitionType = PartitionEntry->Gpt.PartitionType;
68 partExt->
Gpt.PartitionId = PartitionEntry->Gpt.PartitionId;
69 partExt->
Gpt.Attributes = PartitionEntry->Gpt.Attributes;
84 partitionDevice->
Flags &= ~DO_DEVICE_INITIALIZING;
86 *PDO = partitionDevice;
107 fdoExtension->
DiskData.DeviceNumber, PartExt->DetectedNumber);
121 PartExt->SymlinkCreated =
TRUE;
123 INFO(
"Symlink created %wZ -> %wZ\n", &partitionSymlink, &PartExt->DeviceName);
131 &GUID_DEVINTERFACE_PARTITION,
139 PartExt->PartitionInterfaceName = interfaceName;
142 INFO(
"Partition interface %wZ\n", &interfaceName);
152 &GUID_DEVINTERFACE_VOLUME,
160 PartExt->VolumeInterfaceName = interfaceName;
163 INFO(
"Volume interface %wZ\n", &interfaceName);
190 ULONG InputSize, OutputSize;
213 InputSize =
sizeof(*InputBuffer) +
DeviceName->Length;
223 InputBuffer->DeviceNameOffset =
sizeof(*InputBuffer);
285 if (PartExt->SymlinkCreated)
292 fdoExtension->
DiskData.DeviceNumber, PartExt->DetectedNumber);
302 PartExt->SymlinkCreated =
FALSE;
304 INFO(
"Symlink removed %wZ -> %wZ\n", &partitionSymlink, &PartExt->DeviceName);
308 if (PartExt->PartitionInterfaceName.Buffer)
319 if (PartExt->VolumeInterfaceName.Buffer)
328 ERR(
"VolumeDeleteMountPoints(%wZ) failed with status 0x%08lx\n",
329 &PartExt->DeviceName,
status);
345 ASSERT(PartExt->DeviceName.Buffer);
346 if (PartExt->DeviceName.Buffer)
348 INFO(
"Removed device %wZ\n", &PartExt->DeviceName);
376 if (deviceRelations !=
NULL)
378 deviceRelations->
Count = 1;
379 deviceRelations->
Objects[0] = PartExt->DeviceObject;
392 Irp->IoStatus.Information = 0;
393 return Irp->IoStatus.Status;
419 static WCHAR volumeID[] =
L"STORAGE\\Volume\0";
436 swprintf(
string,
L"S%08lx_O%I64x_L%I64x",
437 fdoExtension->
DiskData.Mbr.Signature,
438 PartExt->StartingOffset,
439 PartExt->PartitionLength);
444 L"S%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02xS_O%I64x_L%I64x",
445 fdoExtension->
DiskData.Gpt.DiskId.Data1,
446 fdoExtension->
DiskData.Gpt.DiskId.Data2,
447 fdoExtension->
DiskData.Gpt.DiskId.Data3,
448 fdoExtension->
DiskData.Gpt.DiskId.Data4[0],
449 fdoExtension->
DiskData.Gpt.DiskId.Data4[1],
450 fdoExtension->
DiskData.Gpt.DiskId.Data4[2],
451 fdoExtension->
DiskData.Gpt.DiskId.Data4[3],
452 fdoExtension->
DiskData.Gpt.DiskId.Data4[4],
453 fdoExtension->
DiskData.Gpt.DiskId.Data4[5],
454 fdoExtension->
DiskData.Gpt.DiskId.Data4[6],
455 fdoExtension->
DiskData.Gpt.DiskId.Data4[7],
456 PartExt->StartingOffset,
457 PartExt->PartitionLength);
488 devCaps->SilentInstall =
TRUE;
489 devCaps->RawDeviceOK =
TRUE;
490 devCaps->NoDisplayInUI =
TRUE;
491 devCaps->Address = PartExt->OnDiskNumber;
492 devCaps->UniqueID =
FALSE;
552 Irp->IoStatus.Information = 0;
608 .HiddenSectors = partExt->
Mbr.HiddenSectors,
610 .BootIndicator = partExt->
Mbr.BootIndicator,
611 .RecognizedPartition = partExt->
Mbr.RecognizedPartition,
612 .RewritePartition =
FALSE,
617 Irp->IoStatus.Information =
sizeof(*partInfo);
637 .PartitionStyle = fdoExtension->
DiskData.PartitionStyle,
638 .RewritePartition =
FALSE,
645 .HiddenSectors = partExt->
Mbr.HiddenSectors,
646 .BootIndicator = partExt->
Mbr.BootIndicator,
647 .RecognizedPartition = partExt->
Mbr.RecognizedPartition,
654 .PartitionId = partExt->
Gpt.PartitionId,
655 .Attributes = partExt->
Gpt.Attributes,
665 Irp->IoStatus.Information =
sizeof(*partInfoEx);
682 fdoExtension->
DiskData.BytesPerSector,
693 Irp->IoStatus.Information = 0;
698 PSET_PARTITION_INFORMATION_EX inputBuffer =
Irp->AssociatedIrp.SystemBuffer;
716 partExt->
Mbr.PartitionType = inputBuffer->Mbr.PartitionType;
720 partExt->
Gpt.PartitionType = inputBuffer->Gpt.PartitionType;
721 partExt->
Gpt.PartitionId = inputBuffer->Gpt.PartitionId;
722 partExt->
Gpt.Attributes = inputBuffer->Gpt.Attributes;
725 inputBuffer->Gpt.Name,
726 sizeof(partExt->
Gpt.Name));
732 Irp->IoStatus.Information = 0;
751 Irp->IoStatus.Information =
sizeof(*lengthInfo);
799 .DiskNumber = fdoExtension->
DiskData.DeviceNumber,
808 Irp->IoStatus.Information =
sizeof(*volExts);
830 Irp->IoStatus.Information =
sizeof(*volNum);
867 Irp->IoStatus.Information =
sizeof(*gptAttrs);
886 Irp->IoStatus.Information =
sizeof(
USHORT);
894 Irp->IoStatus.Information =
sizeof(
USHORT) +
name->NameLength;
929 if (!InterfaceName->Buffer || !InterfaceName->Length)
942 Irp->IoStatus.Information = headerSize;
962 basicVolId->
Mbr.Signature = fdoExtension->
DiskData.Mbr.Signature;
968 basicVolId->
Gpt.PartitionGuid = partExt->
Gpt.PartitionId;
973 InterfaceName->Buffer,
986#if (NTDDI_VERSION >= NTDDI_WS03)
995 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 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
#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_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_NOT_SUPPORTED
#define STATUS_NOT_IMPLEMENTED
#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
PDEVICE_OBJECT LowerDevice
UNICODE_STRING DiskInterfaceName
struct _FDO_EXTENSION::@1317 DiskData
struct _IO_STACK_LOCATION::@3976::@4003 DeviceCapabilities
union _IO_STACK_LOCATION::@1567 Parameters
struct _IO_STACK_LOCATION::@1567::@1568 DeviceIoControl
struct _IO_STACK_LOCATION::@3976::@4007 QueryId
struct _IO_STACK_LOCATION::@3976::@4001 QueryDeviceRelations
UNICODE_STRING VolumeInterfaceName
PDEVICE_OBJECT LowerDevice
struct _PARTITION_EXTENSION::@1322::@1325 Mbr
struct _PARTITION_EXTENSION::@1322::@1324 Gpt
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::@1315 Mbr
struct _BASIC_VOLUME_UNIQUE_ID::@1316 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