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];
71PDRIVE_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)
281 while (curEntry !=
NULL)
288 prevEntry = curEntry;
315 FdoExtension->EnumeratedPartitionsTotal = totalPartitions;
324 _Out_ PDRIVE_LAYOUT_INFORMATION_EX *DriveLayout)
334 PDRIVE_LAYOUT_INFORMATION_EX layoutEx =
NULL;
350 *DriveLayout = layoutEx;
370 size_t outBufferLength = ioStack->
Parameters.DeviceIoControl.OutputBufferLength;
394 switch (geometryEx->
Partition.PartitionStyle)
438 .StartingOffset.QuadPart = 0,
439 .PartitionLength.QuadPart =
FdoExtension->DiskData.DiskSize,
441 .PartitionNumber = 0,
442 .BootIndicator =
FALSE,
443 .RewritePartition =
FALSE,
444 .RecognizedPartition =
FALSE,
449 Irp->IoStatus.Information =
sizeof(*partInfo);
474 .PartitionStyle =
FdoExtension->DiskData.PartitionStyle,
479 Irp->IoStatus.Information =
sizeof(*partInfoEx);
494 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
523 if (partitionList ==
NULL)
525 Irp->IoStatus.Information = 0;
532 Irp->IoStatus.Information =
size;
547 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
568 Irp->IoStatus.Information =
size;
598 if (layoutEx ==
NULL)
600 Irp->IoStatus.Information = 0;
652 Irp->IoStatus.Information = layoutSize;
663 PDRIVE_LAYOUT_INFORMATION_EX layoutEx, layoutUser =
Irp->AssociatedIrp.SystemBuffer;
673 size_t layoutSize =
FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[0]);
685 Irp->IoStatus.Information = 0;
694 if (layoutEx->PartitionCount == 0)
696 CREATE_DISK createDisk = {0};
697 createDisk.PartitionStyle = layoutEx->PartitionStyle;
700 createDisk.Mbr.Signature = layoutEx->Mbr.Signature;
704 createDisk.Gpt.DiskId = layoutEx->Gpt.DiskId;
719 for (
UINT32 i = 0;
i < layoutEx->PartitionCount;
i++)
761 Irp->IoStatus.Information = layoutSize;
791 PCREATE_DISK createDisk =
Irp->AssociatedIrp.SystemBuffer;
815 CREATE_DISK createDisk = { .PartitionStyle = PARTITION_STYLE_RAW };
845 sizeof(deviceNumber),
858 &GUID_DEVINTERFACE_DISK,
864 ERR(
"Failed to register GUID_DEVINTERFACE_DISK, status %x\n",
status);
871 INFO(
"Disk interface %wZ\n", &interfaceName);
911 PDRIVE_LAYOUT_INFORMATION_EX layoutEx =
NULL;
918 FdoExtension->DiskData.PartitionStyle = layoutEx->PartitionStyle;
921 FdoExtension->DiskData.Mbr.Signature = layoutEx->Mbr.Signature;
926 FdoExtension->DiskData.Gpt.DiskId = layoutEx->Gpt.DiskId;
953 Irp->IoStatus.Information = 0;
955 return Irp->IoStatus.Status;
962 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
977 if (!deviceRelations)
981 Irp->IoStatus.Information = 0;
983 return Irp->IoStatus.Status;
986 deviceRelations->
Count = 0;
989 while (curEntry !=
NULL)
1007 Irp->IoStatus.Information = (
ULONG_PTR)deviceRelations;
1054 curEntry = curEntry->Next)
1094 ERR(
"Failed to create FDO 0x%x\n",
status);
1136 INFO(
"IRP_MJ_DEVICE_CONTROL %p Irp %p IOCTL %x isFdo: %u\n",
1139 if (!fdoExtension->
IsFDO)
1144 switch (ioStack->
Parameters.DeviceIoControl.IoControlCode)
1208 INFO(
"IRP_MJ_PNP %p Irp %p %s isFDO: %u\n",
1211 if (!fdoExtension->
IsFDO)
1277 if (!partExt->
IsFDO)
1307 if (!partExt->
IsFDO)
1347 if (!partExt->
IsFDO)
#define PARTITION_ENTRY_UNUSED
PDEVICE_OBJECT PhysicalDeviceObject
#define FILE_DEVICE_SECURE_OPEN
#define NT_SUCCESS(StatCode)
FORCEINLINE PCHAR GetIRPMinorFunctionString(UCHAR MinorFunction)
DRIVER_INITIALIZE DriverEntry
NTSTATUS PartitionHandleRemove(_In_ PPARTITION_EXTENSION PartExt, _In_ BOOLEAN FinalRemove)
NTSTATUS PartitionHandleDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _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)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeInitializeEvent(pEvt, foo, foo2)
#define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
#define IOCTL_DISK_GET_PARTITION_INFO_EX
#define IOCTL_DISK_GET_DRIVE_LAYOUT_EX
NTSTATUS NTAPI IoCreateDisk(IN PDEVICE_OBJECT DeviceObject, IN PCREATE_DISK Disk)
NTSTATUS NTAPI IoWritePartitionTableEx(IN PDEVICE_OBJECT DeviceObject, IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout)
NTSTATUS NTAPI IoReadPartitionTableEx(IN PDEVICE_OBJECT DeviceObject, IN PDRIVE_LAYOUT_INFORMATION_EX *DriveLayout)
MxDeviceObject deviceObject
GLuint GLuint GLsizei GLenum type
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
DRIVER_DISPATCH ForwardIrpAndForget
#define ExFreePoolWithTag(_P, _T)
struct _PARTITION_INFORMATION_EX PARTITION_INFORMATION_EX
#define FILE_AUTOGENERATED_DEVICE_NAME
DRIVER_DISPATCH(nfs41_FsdDispatch)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define FILE_REMOVABLE_MEDIA
#define IOCTL_DISK_SET_DRIVE_LAYOUT
#define IsContainerPartition(PartitionType)
#define IOCTL_DISK_GET_DRIVE_LAYOUT
#define IOCTL_DISK_CREATE_DISK
struct _PARTITION_INFORMATION PARTITION_INFORMATION
#define IOCTL_DISK_SET_DRIVE_LAYOUT_EX
#define IOCTL_DISK_GET_PARTITION_INFO
#define IOCTL_DISK_DELETE_DRIVE_LAYOUT
#define IOCTL_DISK_UPDATE_PROPERTIES
#define IOCTL_STORAGE_GET_DEVICE_NUMBER
#define IRP_MN_SURPRISE_REMOVAL
#define IoSkipCurrentIrpStackLocation(Irp)
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
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 IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
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
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
#define STATUS_DEVICE_REMOVED
#define STATUS_DEVICE_DOES_NOT_EXIST
static PDRIVE_LAYOUT_INFORMATION PartMgrConvertExtendedToLayout(_In_ CONST PDRIVE_LAYOUT_INFORMATION_EX LayoutEx)
static NTSTATUS FdoIoctlDiskCreateDisk(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static PDRIVE_LAYOUT_INFORMATION_EX PartMgrConvertLayoutToExtended(_In_ CONST PDRIVE_LAYOUT_INFORMATION Layout)
static NTSTATUS NTAPI PartMgrAddDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT PhysicalDeviceObject)
static NTSTATUS FdoIoctlDiskSetDriveLayout(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS FdoHandleRemoveDevice(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS FdoHandleDeviceRelations(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
VOID NTAPI PartMgrUnload(_In_ PDRIVER_OBJECT DriverObject)
static NTSTATUS NTAPI PartMgrReadWrite(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
static NTSTATUS PartMgrGetDriveLayout(_In_ PFDO_EXTENSION FdoExtension, _Out_ PDRIVE_LAYOUT_INFORMATION_EX *DriveLayout)
static NTSTATUS FdoIoctlDiskDeleteDriveLayout(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static VOID PartMgrUpdatePartitionDevices(_In_ PFDO_EXTENSION FdoExtension, _Inout_ PDRIVE_LAYOUT_INFORMATION_EX NewLayout)
static NTSTATUS FdoIoctlDiskGetPartitionInfoEx(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS NTAPI PartMgrPnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
static NTSTATUS FdoIoctlDiskUpdateProperties(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
DRIVER_DISPATCH PartMgrPower
static NTSTATUS FdoIoctlDiskGetPartitionInfo(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS FdoIoctlDiskGetDriveLayoutEx(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS FdoHandleSurpriseRemoval(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
DRIVER_DISPATCH PartMgrShutdownFlush
static NTSTATUS FdoHandleStartDevice(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS FdoIoctlDiskGetDriveGeometryEx(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS PartMgrRefreshDiskData(_In_ PFDO_EXTENSION FdoExtension)
static NTSTATUS FdoIoctlDiskSetDriveLayoutEx(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS FdoIoctlDiskGetDriveLayout(_In_ PFDO_EXTENSION FdoExtension, _In_ PIRP Irp)
static NTSTATUS NTAPI PartMgrDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
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)
FORCEINLINE BOOLEAN VerifyIrpOutBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL)
#define FILE_DEVICE_BUS_EXTENDER
#define IRP_MJ_DEVICE_CONTROL
#define STATUS_BUFFER_TOO_SMALL
PDEVICE_OBJECT Objects[1]
DISK_PARTITION_INFO Partition
PDEVICE_OBJECT PhysicalDiskDO
PDEVICE_OBJECT DeviceObject
PDEVICE_OBJECT LowerDevice
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
struct _PARTITION_EXTENSION::@1302::@1304 Gpt
PDEVICE_OBJECT LowerDevice
struct _PARTITION_EXTENSION::@1302::@1305 Mbr
SINGLE_LIST_ENTRY ListEntry
PDEVICE_OBJECT DeviceObject
struct _SINGLE_LIST_ENTRY * Next
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_UNSUCCESSFUL
#define STATUS_INFO_LENGTH_MISMATCH
#define STATUS_INSUFFICIENT_RESOURCES
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_START_DEVICE
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
#define IRP_MN_QUERY_POWER
#define IRP_MN_QUERY_REMOVE_DEVICE
#define ObReferenceObject