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++)
166 WARN(
"Super-Floppy disk %lu signature %08x != 1!\n",
175 WARN(
"Super-Floppy disk %lu does not return default settings!\n"
176 " RecognizedPartition = %s, expected TRUE\n"
177 " PartitionType = 0x%02x, expected 0x04 (PARTITION_FAT_16)\n"
178 " BootIndicator = %s, expected FALSE\n",
188 WARN(
"PartitionLength = %I64u is different from DiskSize = %I64u\n",
200 _Inout_ PDRIVE_LAYOUT_INFORMATION_EX NewLayout)
204 UINT32 totalPartitions = 0;
207 for (
UINT32 i = 0;
i < NewLayout->PartitionCount;
i++)
209 NewLayout->PartitionEntry[
i].PartitionNumber = 0;
215 while (curEntry !=
NULL)
223 for (
UINT32 i = 0;
i < NewLayout->PartitionCount;
i++)
225 partEntry = &NewLayout->PartitionEntry[
i];
280 curEntry = prevEntry;
290 prevEntry = curEntry;
291 curEntry = curEntry->
Next;
298 for (
UINT32 i = 0;
i < NewLayout->PartitionCount;
i++)
321 curEntry = curEntry->
Next)
359 while (curEntry !=
NULL)
366 prevEntry = curEntry;
393 FdoExtension->EnumeratedPartitionsTotal = totalPartitions;
410 _Out_ PDRIVE_LAYOUT_INFORMATION_EX *DriveLayout)
420 PDRIVE_LAYOUT_INFORMATION_EX layoutEx =
NULL;
431 FdoExtension->DiskData.PartitionStyle = layoutEx->PartitionStyle;
434 FdoExtension->DiskData.Mbr.Signature = layoutEx->Mbr.Signature;
439 FdoExtension->DiskData.Gpt.DiskId = layoutEx->Gpt.DiskId;
444 *DriveLayout = layoutEx;
487 switch (geometryEx->
Partition.PartitionStyle)
531 .StartingOffset.QuadPart = 0,
532 .PartitionLength.QuadPart =
FdoExtension->DiskData.DiskSize,
534 .PartitionNumber = 0,
535 .BootIndicator =
FALSE,
536 .RewritePartition =
FALSE,
537 .RecognizedPartition =
FALSE,
542 Irp->IoStatus.Information =
sizeof(*partInfo);
567 .PartitionStyle =
FdoExtension->DiskData.PartitionStyle,
572 Irp->IoStatus.Information =
sizeof(*partInfoEx);
587 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
615 if (partitionList ==
NULL)
617 Irp->IoStatus.Information = 0;
624 Irp->IoStatus.Information =
size;
639 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
660 Irp->IoStatus.Information =
size;
690 if (layoutEx ==
NULL)
692 Irp->IoStatus.Information = 0;
700 if (
FdoExtension->IsSuperFloppy && (layoutEx->PartitionCount > 1))
754 Irp->IoStatus.Information = layoutSize;
765 PDRIVE_LAYOUT_INFORMATION_EX layoutEx, layoutUser =
Irp->AssociatedIrp.SystemBuffer;
775 size_t layoutSize =
FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[0]);
787 Irp->IoStatus.Information = 0;
799 (layoutEx->PartitionCount > 1)))
806 if (layoutEx->PartitionCount == 0)
808 CREATE_DISK createDisk = {0};
809 createDisk.PartitionStyle = layoutEx->PartitionStyle;
812 createDisk.Mbr.Signature = layoutEx->Mbr.Signature;
816 createDisk.Gpt.DiskId = layoutEx->Gpt.DiskId;
831 for (
UINT32 i = 0;
i < layoutEx->PartitionCount;
i++)
875 Irp->IoStatus.Information = layoutSize;
905 PCREATE_DISK createDisk =
Irp->AssociatedIrp.SystemBuffer;
929 CREATE_DISK createDisk = { .PartitionStyle = PARTITION_STYLE_RAW };
959 sizeof(deviceNumber),
972 &GUID_DEVINTERFACE_DISK,
978 ERR(
"Failed to register GUID_DEVINTERFACE_DISK, status %x\n",
status);
985 INFO(
"Disk interface %wZ\n", &interfaceName);
1029 PDRIVE_LAYOUT_INFORMATION_EX layoutEx =
NULL;
1058 Irp->IoStatus.Information = 0;
1060 return Irp->IoStatus.Status;
1067 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
1082 if (!deviceRelations)
1086 Irp->IoStatus.Information = 0;
1088 return Irp->IoStatus.Status;
1091 deviceRelations->
Count = 0;
1094 while (curEntry !=
NULL)
1112 Irp->IoStatus.Information = (
ULONG_PTR)deviceRelations;
1159 curEntry = curEntry->Next)
1199 ERR(
"Failed to create FDO 0x%x\n",
status);
1241 INFO(
"IRP_MJ_DEVICE_CONTROL %p Irp %p IOCTL %x isFdo: %u\n",
1244 if (!fdoExtension->
IsFDO)
1313 INFO(
"IRP_MJ_PNP %p Irp %p %s isFDO: %u\n",
1316 if (!fdoExtension->
IsFDO)
1382 if (!partExt->
IsFDO)
1412 if (!partExt->
IsFDO)
1452 if (!partExt->
IsFDO)
#define ExAllocatePoolUninitialized
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#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)
Retrieves the disk partition layout from the given disk FDO.
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)
static BOOLEAN PartMgrIsDiskSuperFloppy(_In_ PFDO_EXTENSION FdoExtension)
Detects whether a disk is a "super-floppy", i.e. an unpartitioned disk with only a valid VBR,...
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)
Refreshes all the cached disk FDO data. The geometry of the disk and its partition layout cache is up...
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 _IO_STACK_LOCATION::@3974::@3978 Read
struct _IO_STACK_LOCATION::@1575::@1576 DeviceIoControl
struct _IO_STACK_LOCATION::@3974::@3999 QueryDeviceRelations
union _IO_STACK_LOCATION::@1575 Parameters
struct _PARTITION_EXTENSION::@1330::@1333 Mbr
PDEVICE_OBJECT LowerDevice
SINGLE_LIST_ENTRY ListEntry
struct _PARTITION_EXTENSION::@1330::@1332 Gpt
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
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
#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