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)
358 while (curEntry !=
NULL)
365 prevEntry = curEntry;
392 FdoExtension->EnumeratedPartitionsTotal = totalPartitions;
409 _Out_ PDRIVE_LAYOUT_INFORMATION_EX *DriveLayout)
419 PDRIVE_LAYOUT_INFORMATION_EX layoutEx =
NULL;
430 FdoExtension->DiskData.PartitionStyle = layoutEx->PartitionStyle;
433 FdoExtension->DiskData.Mbr.Signature = layoutEx->Mbr.Signature;
438 FdoExtension->DiskData.Gpt.DiskId = layoutEx->Gpt.DiskId;
443 *DriveLayout = layoutEx;
486 switch (geometryEx->
Partition.PartitionStyle)
530 .StartingOffset.QuadPart = 0,
531 .PartitionLength.QuadPart =
FdoExtension->DiskData.DiskSize,
533 .PartitionNumber = 0,
534 .BootIndicator =
FALSE,
535 .RewritePartition =
FALSE,
536 .RecognizedPartition =
FALSE,
541 Irp->IoStatus.Information =
sizeof(*partInfo);
566 .PartitionStyle =
FdoExtension->DiskData.PartitionStyle,
571 Irp->IoStatus.Information =
sizeof(*partInfoEx);
586 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
614 if (partitionList ==
NULL)
616 Irp->IoStatus.Information = 0;
623 Irp->IoStatus.Information =
size;
638 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
659 Irp->IoStatus.Information =
size;
689 if (layoutEx ==
NULL)
691 Irp->IoStatus.Information = 0;
699 if (
FdoExtension->IsSuperFloppy && (layoutEx->PartitionCount > 1))
753 Irp->IoStatus.Information = layoutSize;
764 PDRIVE_LAYOUT_INFORMATION_EX layoutEx, layoutUser =
Irp->AssociatedIrp.SystemBuffer;
774 size_t layoutSize =
FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[0]);
786 Irp->IoStatus.Information = 0;
798 (layoutEx->PartitionCount > 1)))
805 if (layoutEx->PartitionCount == 0)
807 CREATE_DISK createDisk = {0};
808 createDisk.PartitionStyle = layoutEx->PartitionStyle;
811 createDisk.Mbr.Signature = layoutEx->Mbr.Signature;
815 createDisk.Gpt.DiskId = layoutEx->Gpt.DiskId;
830 for (
UINT32 i = 0;
i < layoutEx->PartitionCount;
i++)
874 Irp->IoStatus.Information = layoutSize;
904 PCREATE_DISK createDisk =
Irp->AssociatedIrp.SystemBuffer;
928 CREATE_DISK createDisk = { .PartitionStyle = PARTITION_STYLE_RAW };
958 sizeof(deviceNumber),
971 &GUID_DEVINTERFACE_DISK,
976 ERR(
"Failed to register GUID_DEVINTERFACE_DISK, status %x\n",
status);
980 INFO(
"Disk interface %wZ\n", &interfaceName);
1025 PDRIVE_LAYOUT_INFORMATION_EX layoutEx =
NULL;
1054 Irp->IoStatus.Information = 0;
1056 return Irp->IoStatus.Status;
1063 PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
1078 if (!deviceRelations)
1082 Irp->IoStatus.Information = 0;
1084 return Irp->IoStatus.Status;
1087 deviceRelations->
Count = 0;
1090 while (curEntry !=
NULL)
1108 Irp->IoStatus.Information = (
ULONG_PTR)deviceRelations;
1155 curEntry = curEntry->Next)
1201 ERR(
"Failed to create FDO 0x%x\n",
status);
1244 INFO(
"IRP_MJ_DEVICE_CONTROL %p Irp %p IOCTL %x isFdo: %u\n",
1247 if (!fdoExtension->
IsFDO)
1316 INFO(
"IRP_MJ_PNP %p Irp %p %s isFDO: %u\n",
1319 if (!fdoExtension->
IsFDO)
1385 if (!partExt->
IsFDO)
1415 if (!partExt->
IsFDO)
1455 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 STATUS_DEVICE_REMOVED
#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)
#define FILE_DEVICE_MASS_STORAGE
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_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 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::@4065::@4069 Read
struct _IO_STACK_LOCATION::@4065::@4090 QueryDeviceRelations
struct _IO_STACK_LOCATION::@1605::@1606 DeviceIoControl
union _IO_STACK_LOCATION::@1605 Parameters
PDEVICE_OBJECT LowerDevice
struct _PARTITION_EXTENSION::@1357::@1360 Mbr
struct _PARTITION_EXTENSION::@1357::@1359 Gpt
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
_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