[PARTMGR] Minor code formatting.

This commit is contained in:
Hermès Bélusca-Maïto 2024-12-27 17:17:53 +01:00
parent 0929e96728
commit e1b835bdbf
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 11 additions and 22 deletions

View file

@ -27,7 +27,7 @@ PartitionCreateDevice(
UNICODE_STRING deviceName; UNICODE_STRING deviceName;
UINT32 volumeNum; UINT32 volumeNum;
// create the device object // Create the partition/volume device object
volumeNum = HarddiskVolumeNextId++; volumeNum = HarddiskVolumeNextId++;
swprintf(nameBuf, L"\\Device\\HarddiskVolume%lu", volumeNum); swprintf(nameBuf, L"\\Device\\HarddiskVolume%lu", volumeNum);
@ -41,7 +41,6 @@ PartitionCreateDevice(
FILE_DEVICE_SECURE_OPEN, FILE_DEVICE_SECURE_OPEN,
FALSE, FALSE,
&partitionDevice); &partitionDevice);
if (!NT_SUCCESS(status)) if (!NT_SUCCESS(status))
{ {
ERR("Unable to create device object %wZ\n", &deviceName); ERR("Unable to create device object %wZ\n", &deviceName);
@ -81,10 +80,10 @@ PartitionCreateDevice(
partExt->DeviceObject = partitionDevice; partExt->DeviceObject = partitionDevice;
partExt->LowerDevice = FDObject; partExt->LowerDevice = FDObject;
// The device is initialized
partitionDevice->Flags &= ~DO_DEVICE_INITIALIZING; partitionDevice->Flags &= ~DO_DEVICE_INITIALIZING;
*PDO = partitionDevice; *PDO = partitionDevice;
return status; return status;
} }
@ -136,11 +135,9 @@ PartitionHandleStartDevice(
return status; return status;
} }
INFO("Partition interface %wZ\n", &interfaceName);
PartExt->PartitionInterfaceName = interfaceName; PartExt->PartitionInterfaceName = interfaceName;
status = IoSetDeviceInterfaceState(&interfaceName, TRUE); status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
INFO("Partition interface %wZ\n", &interfaceName);
if (!NT_SUCCESS(status)) if (!NT_SUCCESS(status))
{ {
RtlFreeUnicodeString(&interfaceName); RtlFreeUnicodeString(&interfaceName);
@ -157,11 +154,9 @@ PartitionHandleStartDevice(
return status; return status;
} }
INFO("Volume interface %wZ\n", &interfaceName);
PartExt->VolumeInterfaceName = interfaceName; PartExt->VolumeInterfaceName = interfaceName;
status = IoSetDeviceInterfaceState(&interfaceName, TRUE); status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
INFO("Volume interface %wZ\n", &interfaceName);
if (!NT_SUCCESS(status)) if (!NT_SUCCESS(status))
{ {
RtlFreeUnicodeString(&interfaceName); RtlFreeUnicodeString(&interfaceName);

View file

@ -340,7 +340,6 @@ PartMgrUpdatePartitionDevices(
pdoNumber, pdoNumber,
NewLayout->PartitionStyle, NewLayout->PartitionStyle,
&partitionDevice); &partitionDevice);
if (!NT_SUCCESS(status)) if (!NT_SUCCESS(status))
{ {
partEntry->PartitionNumber = 0; partEntry->PartitionNumber = 0;
@ -948,8 +947,8 @@ FdoHandleStartDevice(
_In_ PFDO_EXTENSION FdoExtension, _In_ PFDO_EXTENSION FdoExtension,
_In_ PIRP Irp) _In_ PIRP Irp)
{ {
// obtain the disk device number // Obtain the disk device number.
// this is not expected to change thus not in PartMgrRefreshDiskData // It is not expected to change, thus not in PartMgrRefreshDiskData().
STORAGE_DEVICE_NUMBER deviceNumber; STORAGE_DEVICE_NUMBER deviceNumber;
NTSTATUS status = IssueSyncIoControlRequest(IOCTL_STORAGE_GET_DEVICE_NUMBER, NTSTATUS status = IssueSyncIoControlRequest(IOCTL_STORAGE_GET_DEVICE_NUMBER,
FdoExtension->LowerDevice, FdoExtension->LowerDevice,
@ -965,25 +964,22 @@ FdoHandleStartDevice(
FdoExtension->DiskData.DeviceNumber = deviceNumber.DeviceNumber; FdoExtension->DiskData.DeviceNumber = deviceNumber.DeviceNumber;
// register the disk interface // Register the disk interface.
// partmgr.sys from Windows 8.1 also registers a mysterious GUID_DEVINTERFACE_HIDDEN_DISK here // partmgr.sys from Windows 8.1 also registers a mysterious GUID_DEVINTERFACE_HIDDEN_DISK here.
UNICODE_STRING interfaceName; UNICODE_STRING interfaceName;
status = IoRegisterDeviceInterface(FdoExtension->PhysicalDiskDO, status = IoRegisterDeviceInterface(FdoExtension->PhysicalDiskDO,
&GUID_DEVINTERFACE_DISK, &GUID_DEVINTERFACE_DISK,
NULL, NULL,
&interfaceName); &interfaceName);
if(!NT_SUCCESS(status)) if(!NT_SUCCESS(status))
{ {
ERR("Failed to register GUID_DEVINTERFACE_DISK, status %x\n", status); ERR("Failed to register GUID_DEVINTERFACE_DISK, status %x\n", status);
return status; return status;
} }
INFO("Disk interface %wZ\n", &interfaceName);
FdoExtension->DiskInterfaceName = interfaceName; FdoExtension->DiskInterfaceName = interfaceName;
status = IoSetDeviceInterfaceState(&interfaceName, TRUE); status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
INFO("Disk interface %wZ\n", &interfaceName);
if (!NT_SUCCESS(status)) if (!NT_SUCCESS(status))
{ {
RtlFreeUnicodeString(&interfaceName); RtlFreeUnicodeString(&interfaceName);
@ -1188,12 +1184,11 @@ PartMgrAddDevice(
NTSTATUS status = IoCreateDevice(DriverObject, NTSTATUS status = IoCreateDevice(DriverObject,
sizeof(FDO_EXTENSION), sizeof(FDO_EXTENSION),
0, NULL,
FILE_DEVICE_BUS_EXTENDER, FILE_DEVICE_BUS_EXTENDER,
FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN, FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
FALSE, FALSE,
&deviceObject); &deviceObject);
if (!NT_SUCCESS(status)) if (!NT_SUCCESS(status))
{ {
ERR("Failed to create FDO 0x%x\n", status); ERR("Failed to create FDO 0x%x\n", status);
@ -1218,9 +1213,8 @@ PartMgrAddDevice(
} }
deviceObject->Flags |= DO_DIRECT_IO | DO_POWER_PAGABLE; deviceObject->Flags |= DO_DIRECT_IO | DO_POWER_PAGABLE;
// device is initialized // The device is initialized
deviceObject->Flags &= ~DO_DEVICE_INITIALIZING; deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }