24 static UINT32 HarddiskVolumeNextId = 1;
31 swprintf(nameBuf,
L"\\Device\\HarddiskVolume%u", HarddiskVolumeNextId++);
45 ERR(
"Unable to create device object %wZ\n", &deviceName);
49 INFO(
"Created device object %p %wZ\n", partitionDevice, &deviceName);
54 partitionDevice->
StackSize = FDObject->StackSize;
59 partExt->
Mbr.PartitionType = PartitionEntry->Mbr.PartitionType;
60 partExt->
Mbr.BootIndicator = PartitionEntry->Mbr.BootIndicator;
61 partExt->
Mbr.HiddenSectors = PartitionEntry->Mbr.HiddenSectors;
65 partExt->
Gpt.PartitionType = PartitionEntry->Gpt.PartitionType;
66 partExt->
Gpt.PartitionId = PartitionEntry->Gpt.PartitionType;
67 partExt->
Gpt.Attributes = PartitionEntry->Gpt.Attributes;
81 partitionDevice->
Flags &= ~DO_DEVICE_INITIALIZING;
83 *PDO = partitionDevice;
104 fdoExtension->
DiskData.DeviceNumber, PartExt->DetectedNumber);
118 PartExt->SymlinkCreated =
TRUE;
120 TRACE(
"Symlink created %wZ -> %wZ\n", &PartExt->DeviceName, &partitionSymlink);
127 &GUID_DEVINTERFACE_PARTITION,
136 PartExt->PartitionInterfaceName = interfaceName;
139 INFO(
"Partition interface %wZ\n", &interfaceName);
149 &GUID_DEVINTERFACE_VOLUME,
158 PartExt->VolumeInterfaceName = interfaceName;
161 INFO(
"Volume interface %wZ\n", &interfaceName);
184 if (PartExt->SymlinkCreated)
191 fdoExtension->
DiskData.DeviceNumber, PartExt->DetectedNumber);
201 PartExt->SymlinkCreated =
FALSE;
203 INFO(
"Symlink removed %wZ -> %wZ\n", &PartExt->DeviceName, &partitionSymlink);
207 if (PartExt->PartitionInterfaceName.Buffer)
218 if (PartExt->VolumeInterfaceName.Buffer)
231 ASSERT(PartExt->DeviceName.Buffer);
232 if (PartExt->DeviceName.Buffer)
234 INFO(
"Removed device %wZ\n", &PartExt->DeviceName);
262 if (deviceRelations !=
NULL)
264 deviceRelations->
Count = 1;
265 deviceRelations->
Objects[0] = PartExt->DeviceObject;
278 Irp->IoStatus.Information = 0;
279 return Irp->IoStatus.Status;
305 static WCHAR volumeID[] =
L"STORAGE\\Volume\0";
322 swprintf(
string,
L"S%08lx_O%I64x_L%I64x",
323 fdoExtension->
DiskData.Mbr.Signature,
324 PartExt->StartingOffset,
325 PartExt->PartitionLength);
330 L"S%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02xS_O%I64x_L%I64x",
331 fdoExtension->
DiskData.Gpt.DiskId.Data1,
332 fdoExtension->
DiskData.Gpt.DiskId.Data2,
333 fdoExtension->
DiskData.Gpt.DiskId.Data3,
334 fdoExtension->
DiskData.Gpt.DiskId.Data4[0],
335 fdoExtension->
DiskData.Gpt.DiskId.Data4[1],
336 fdoExtension->
DiskData.Gpt.DiskId.Data4[2],
337 fdoExtension->
DiskData.Gpt.DiskId.Data4[3],
338 fdoExtension->
DiskData.Gpt.DiskId.Data4[4],
339 fdoExtension->
DiskData.Gpt.DiskId.Data4[5],
340 fdoExtension->
DiskData.Gpt.DiskId.Data4[6],
341 fdoExtension->
DiskData.Gpt.DiskId.Data4[7],
342 PartExt->StartingOffset,
343 PartExt->PartitionLength);
374 devCaps->SilentInstall =
TRUE;
375 devCaps->RawDeviceOK =
TRUE;
376 devCaps->NoDisplayInUI =
TRUE;
377 devCaps->Address = PartExt->OnDiskNumber;
378 devCaps->UniqueID =
FALSE;
438 Irp->IoStatus.Information = 0;
467 switch (ioStack->
Parameters.DeviceIoControl.IoControlCode)
494 .HiddenSectors = partExt->
Mbr.HiddenSectors,
496 .BootIndicator = partExt->
Mbr.BootIndicator,
497 .RecognizedPartition = partExt->
Mbr.RecognizedPartition,
498 .RewritePartition =
FALSE,
503 Irp->IoStatus.Information =
sizeof(*partInfo);
523 .PartitionStyle = fdoExtension->
DiskData.PartitionStyle,
524 .RewritePartition =
FALSE,
531 .HiddenSectors = partExt->
Mbr.HiddenSectors,
532 .BootIndicator = partExt->
Mbr.BootIndicator,
533 .RecognizedPartition = partExt->
Mbr.RecognizedPartition,
540 .PartitionId = partExt->
Gpt.PartitionId,
541 .Attributes = partExt->
Gpt.Attributes,
551 Irp->IoStatus.Information =
sizeof(*partInfoEx);
568 fdoExtension->
DiskData.BytesPerSector,
579 Irp->IoStatus.Information = 0;
584 PSET_PARTITION_INFORMATION_EX inputBuffer =
Irp->AssociatedIrp.SystemBuffer;
602 partExt->
Mbr.PartitionType = inputBuffer->Mbr.PartitionType;
606 partExt->
Gpt.PartitionType = inputBuffer->Gpt.PartitionType;
607 partExt->
Gpt.PartitionId = inputBuffer->Gpt.PartitionId;
608 partExt->
Gpt.Attributes = inputBuffer->Gpt.Attributes;
611 inputBuffer->Gpt.Name,
612 sizeof(partExt->
Gpt.Name));
618 Irp->IoStatus.Information = 0;
637 Irp->IoStatus.Information =
sizeof(*lengthInfo);
685 .DiskNumber = fdoExtension->
DiskData.DeviceNumber,
694 Irp->IoStatus.Information =
sizeof(*volExts);
721 Irp->IoStatus.Information =
sizeof(*gptAttrs);
740 Irp->IoStatus.Information =
sizeof(
USHORT);
748 Irp->IoStatus.Information =
sizeof(
USHORT) +
name->NameLength;
772 Irp->IoStatus.Information =
sizeof(
USHORT);
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
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 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 IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
struct _PARTITION_INFORMATION_EX PARTITION_INFORMATION_EX
#define IOCTL_DISK_GET_LENGTH_INFO
enum _PARTITION_STYLE PARTITION_STYLE
#define IOCTL_MOUNTDEV_QUERY_UNIQUE_ID
struct _PARTITION_INFORMATION_MBR PARTITION_INFORMATION_MBR
struct _PARTITION_INFORMATION_GPT PARTITION_INFORMATION_GPT
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_GET_GPT_ATTRIBUTES
struct _VOLUME_DISK_EXTENTS VOLUME_DISK_EXTENTS
#define IOCTL_VOLUME_ONLINE
#define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
#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 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_DEVICE_DOES_NOT_EXIST
FORCEINLINE VOID PartMgrReleaseLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
FORCEINLINE VOID PartMgrAcquireLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
FORCEINLINE BOOLEAN VerifyIrpInBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
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::@1297 DiskData
PDEVICE_OBJECT LowerDevice
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
struct _PARTITION_EXTENSION::@1302::@1304 Gpt
UNICODE_STRING VolumeInterfaceName
PDEVICE_OBJECT LowerDevice
struct _PARTITION_EXTENSION::@1302::@1305 Mbr
UNICODE_STRING DeviceName
PDEVICE_OBJECT DeviceObject
ULONG NumberOfDiskExtents
#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
_In_ PDEVICE_OBJECT DeviceObject
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
#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 ObReferenceObject