21 _In_ CONST PDRIVE_LAYOUT_INFORMATION_EX LayoutEx)
47 Layout->
Signature = LayoutEx->Mbr.Signature;
50 for (
UINT32 i = 0;
i < LayoutEx->PartitionCount;
i++)
53 PartitionEx = &LayoutEx->PartitionEntry[
i];
71 PDRIVE_LAYOUT_INFORMATION_EX
75 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
81 size_t layoutSize =
FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[0]) +
92 layoutEx->PartitionCount = Layout->PartitionCount;
93 layoutEx->Mbr.Signature = Layout->Signature;
95 for (
UINT32 i = 0;
i < Layout->PartitionCount;
i++)
122 _Inout_ PDRIVE_LAYOUT_INFORMATION_EX NewLayout)
126 UINT32 totalPartitions = 0;
129 for (
UINT32 i = 0;
i < NewLayout->PartitionCount;
i++)
131 NewLayout->PartitionEntry[
i].PartitionNumber = 0;
137 while (curEntry !=
NULL)
145 for (
UINT32 i = 0;
i < NewLayout->PartitionCount;
i++)
147 partEntry = &NewLayout->PartitionEntry[
i];
202 curEntry = prevEntry;
212 prevEntry = curEntry;
213 curEntry = curEntry->
Next;
220 for (
UINT32 i = 0;
i < NewLayout->PartitionCount;
i++)
243 curEntry = curEntry->
Next)
277 while (curEntry !=
NULL)
284 prevEntry = curEntry;
311 FdoExtension->EnumeratedPartitionsTotal = totalPartitions;
320 _Out_ PDRIVE_LAYOUT_INFORMATION_EX *DriveLayout)
330 PDRIVE_LAYOUT_INFORMATION_EX layoutEx =
NULL;
346 *DriveLayout = layoutEx;
366 size_t outBufferLength = ioStack->
Parameters.DeviceIoControl.OutputBufferLength;
390 switch (geometryEx->
Partition.PartitionStyle)
434 .StartingOffset.QuadPart = 0,
435 .PartitionLength.QuadPart =
FdoExtension->DiskData.DiskSize,
437 .PartitionNumber = 0,
438 .BootIndicator =
FALSE,
439 .RewritePartition =
FALSE,
440 .RecognizedPartition =
FALSE,
445 Irp->IoStatus.Information =
sizeof(*partInfo);
470 .PartitionStyle =
FdoExtension->DiskData.PartitionStyle,
475 Irp->IoStatus.Information =
sizeof(*partInfoEx);
490 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
519 if (partitionList ==
NULL)
521 Irp->IoStatus.Information = 0;
528 Irp->IoStatus.Information =
size;
543 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
564 Irp->IoStatus.Information =
size;
594 if (layoutEx ==
NULL)
596 Irp->IoStatus.Information = 0;
648 Irp->IoStatus.Information = layoutSize;
659 PDRIVE_LAYOUT_INFORMATION_EX layoutEx, layoutUser =
Irp->AssociatedIrp.SystemBuffer;
669 size_t layoutSize =
FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[0]);
681 Irp->IoStatus.Information = 0;
690 if (layoutEx->PartitionCount == 0)
692 CREATE_DISK createDisk = {0};
693 createDisk.PartitionStyle = layoutEx->PartitionStyle;
696 createDisk.Mbr.Signature = layoutEx->Mbr.Signature;
700 createDisk.Gpt.DiskId = layoutEx->Gpt.DiskId;
715 for (
UINT32 i = 0;
i < layoutEx->PartitionCount;
i++)
757 Irp->IoStatus.Information = layoutSize;
787 PCREATE_DISK createDisk =
Irp->AssociatedIrp.SystemBuffer;
811 CREATE_DISK createDisk = { .PartitionStyle = PARTITION_STYLE_RAW };
841 sizeof(deviceNumber),
854 &GUID_DEVINTERFACE_DISK,
860 ERR(
"Failed to register GUID_DEVINTERFACE_DISK, status %x\n",
status);
867 INFO(
"Disk interface %wZ\n", &interfaceName);
907 PDRIVE_LAYOUT_INFORMATION_EX layoutEx =
NULL;
914 FdoExtension->DiskData.PartitionStyle = layoutEx->PartitionStyle;
917 FdoExtension->DiskData.Mbr.Signature = layoutEx->Mbr.Signature;
922 FdoExtension->DiskData.Gpt.DiskId = layoutEx->Gpt.DiskId;
949 Irp->IoStatus.Information = 0;
951 return Irp->IoStatus.Status;
958 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
973 if (!deviceRelations)
977 Irp->IoStatus.Information = 0;
979 return Irp->IoStatus.Status;
982 deviceRelations->
Count = 0;
985 while (curEntry !=
NULL)
1003 Irp->IoStatus.Information = (
ULONG_PTR)deviceRelations;
1022 curEntry = curEntry->Next)
1061 curEntry = curEntry->Next)
1101 ERR(
"Failed to create FDO 0x%x\n",
status);
1143 INFO(
"IRP_MJ_DEVICE_CONTROL %p Irp %p IOCTL %x isFdo: %u\n",
1146 if (!fdoExtension->
IsFDO)
1151 switch (ioStack->
Parameters.DeviceIoControl.IoControlCode)
1215 INFO(
"IRP_MJ_PNP %p Irp %p %s isFDO: %u\n",
1218 if (!fdoExtension->
IsFDO)
1284 if (!partExt->
IsFDO)
1314 if (!partExt->
IsFDO)
1354 if (!partExt->
IsFDO)
#define DO_DEVICE_INITIALIZING
#define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define STATUS_DEVICE_DOES_NOT_EXIST
#define IOCTL_DISK_SET_DRIVE_LAYOUT_EX
#define STATUS_DEVICE_REMOVED
#define IRP_MN_REMOVE_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
#define STATUS_INFO_LENGTH_MISMATCH
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_MN_QUERY_POWER
struct _PARTITION_EXTENSION::@1303::@1305 Gpt
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
PDEVICE_OBJECT Objects[1]
PDEVICE_OBJECT LowerDevice
static PDRIVE_LAYOUT_INFORMATION PartMgrConvertExtendedToLayout(_In_ CONST PDRIVE_LAYOUT_INFORMATION_EX LayoutEx)
static PDRIVE_LAYOUT_INFORMATION_EX PartMgrConvertLayoutToExtended(_In_ CONST PDRIVE_LAYOUT_INFORMATION Layout)
static NTSTATUS FdoHandleSurpriseRemoval(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
DRIVER_DISPATCH ForwardIrpAndForget
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
#define IOCTL_DISK_CREATE_DISK
static VOID PartMgrUpdatePartitionDevices(_In_ PFDO_EXTENSION FdoExtension, _Inout_ PDRIVE_LAYOUT_INFORMATION_EX NewLayout)
#define STATUS_INVALID_DEVICE_REQUEST
NTSTATUS NTAPI IoCreateDisk(IN PDEVICE_OBJECT DeviceObject, IN PCREATE_DISK Disk)
PDEVICE_OBJECT PhysicalDiskDO
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
static NTSTATUS NTAPI PartMgrReadWrite(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
#define IsContainerPartition(PartitionType)
NTSTATUS PartitionHandlePnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
PDEVICE_OBJECT PhysicalDeviceObject
DRIVER_DISPATCH PartMgrShutdownFlush
struct _PARTITION_INFORMATION PARTITION_INFORMATION
static NTSTATUS NTAPI PartMgrPnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
static NTSTATUS FdoIoctlDiskGetDriveLayoutEx(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
#define RtlMoveMemory(Destination, Source, Length)
#define STATUS_BUFFER_TOO_SMALL
NTSTATUS PartitionHandleDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
static NTSTATUS FdoIoctlDiskGetPartitionInfo(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS FdoHandleStartDevice(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
#define PARTITION_ENTRY_UNUSED
_In_ PDEVICE_OBJECT DeviceObject
NTSTATUS NTAPI DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
struct _PARTITION_INFORMATION_EX PARTITION_INFORMATION_EX
static NTSTATUS FdoIoctlDiskUpdateProperties(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
static NTSTATUS FdoHandleDeviceRelations(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
#define IRP_MN_QUERY_REMOVE_DEVICE
#define IOCTL_DISK_DELETE_DRIVE_LAYOUT
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
PDEVICE_OBJECT DeviceObject
#define IoCompleteRequest
#define IOCTL_STORAGE_GET_DEVICE_NUMBER
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
#define FILE_AUTOGENERATED_DEVICE_NAME
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
#define IRP_MN_QUERY_STOP_DEVICE
#define IOCTL_DISK_UPDATE_PROPERTIES
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 IRP_MN_SURPRISE_REMOVAL
FORCEINLINE BOOLEAN VerifyIrpOutBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
static NTSTATUS FdoHandleRemoveDevice(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS FdoIoctlDiskDeleteDriveLayout(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
#define IRP_MN_STOP_DEVICE
#define NT_SUCCESS(StatCode)
NTSTATUS PartitionCreateDevice(_In_ PDEVICE_OBJECT FDObject, _In_ PPARTITION_INFORMATION_EX PartitionEntry, _In_ UINT32 PdoNumber, _In_ PARTITION_STYLE PartitionStyle, _Out_ PDEVICE_OBJECT *PDO)
#define IRP_MN_START_DEVICE
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static NTSTATUS PartMgrRefreshDiskData(_In_ PFDO_EXTENSION FdoExtension)
static NTSTATUS FdoIoctlDiskSetDriveLayout(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
NTSTATUS NTAPI IoReadPartitionTableEx(IN PDEVICE_OBJECT DeviceObject, IN PDRIVE_LAYOUT_INFORMATION_EX *DriveLayout)
static NTSTATUS FdoIoctlDiskGetPartitionInfoEx(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
#define STATUS_UNSUCCESSFUL
#define ExAllocatePoolWithTag(hernya, size, tag)
struct _SINGLE_LIST_ENTRY * Next
#define IOCTL_DISK_GET_PARTITION_INFO
PDEVICE_OBJECT LowerDevice
static NTSTATUS NTAPI PartMgrAddDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT PhysicalDeviceObject)
NTSTATUS NTAPI IoWritePartitionTableEx(IN PDEVICE_OBJECT DeviceObject, IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout)
FORCEINLINE BOOLEAN VerifyIrpInBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
DRIVER_DISPATCH(nfs41_FsdDispatch)
MxDeviceObject deviceObject
struct _PARTITION_EXTENSION::@1303::@1306 Mbr
DRIVER_DISPATCH PartMgrPower
FORCEINLINE VOID PartMgrReleaseLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
#define IOCTL_DISK_GET_DRIVE_LAYOUT
FORCEINLINE PCHAR GetIRPMinorFunctionString(UCHAR MinorFunction)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
static NTSTATUS PartMgrGetDriveLayout(_In_ PFDO_EXTENSION FdoExtension, _Out_ PDRIVE_LAYOUT_INFORMATION_EX *DriveLayout)
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
#define KeInitializeEvent(pEvt, foo, foo2)
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
#define IOCTL_DISK_GET_DRIVE_LAYOUT_EX
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
VOID NTAPI PartMgrUnload(_In_ PDRIVER_OBJECT DriverObject)
PDEVICE_OBJECT DeviceObject
#define FIELD_OFFSET(t, f)
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IoSkipCurrentIrpStackLocation(Irp)
static NTSTATUS FdoIoctlDiskGetDriveLayout(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
NTSTATUS PartitionHandleRemove(_In_ PPARTITION_EXTENSION PartExt, _In_ BOOLEAN FinalRemove)
DISK_PARTITION_INFO Partition
#define ObReferenceObject
SINGLE_LIST_ENTRY ListEntry
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)
static NTSTATUS FdoIoctlDiskCreateDisk(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
#define RtlCopyMemory(Destination, Source, Length)
#define IOCTL_DISK_SET_DRIVE_LAYOUT
#define FILE_DEVICE_SECURE_OPEN
#define IRP_MN_CANCEL_STOP_DEVICE
GLuint GLuint GLsizei GLenum type
#define ExFreePoolWithTag(_P, _T)
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
static NTSTATUS FdoIoctlDiskGetDriveGeometryEx(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
#define FILE_DEVICE_BUS_EXTENDER
NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL)
FORCEINLINE VOID PartMgrAcquireLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
static SERVICE_STATUS status
#define IOCTL_DISK_GET_PARTITION_INFO_EX
static NTSTATUS FdoIoctlDiskSetDriveLayoutEx(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS NTAPI PartMgrDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
#define IRP_MJ_DEVICE_CONTROL