[PARTMGR] Register a disk interface for disk PDO

CORE-14187
This commit is contained in:
Victor Perevertkin 2020-12-06 19:47:15 +03:00
parent 883ae6d93b
commit 2d6c6fa38d
No known key found for this signature in database
GPG key ID: C750B7222E9C7830
2 changed files with 34 additions and 0 deletions

View file

@ -846,6 +846,32 @@ FdoHandleStartDevice(
}
FdoExtension->DiskData.DeviceNumber = deviceNumber.DeviceNumber;
// register the disk interface
// partmgr.sys from Windows 8.1 also registers a mysterious GUID_DEVINTERFACE_HIDDEN_DISK here
UNICODE_STRING interfaceName;
status = IoRegisterDeviceInterface(FdoExtension->PhysicalDiskDO,
&GUID_DEVINTERFACE_DISK,
NULL,
&interfaceName);
if(!NT_SUCCESS(status))
{
ERR("Failed to register GUID_DEVINTERFACE_DISK, status %x\n", status);
return status;
}
FdoExtension->DiskInterfaceName = interfaceName;
status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
INFO("Disk interface %wZ\n", &interfaceName);
if (!NT_SUCCESS(status))
{
RtlFreeUnicodeString(&interfaceName);
RtlInitUnicodeString(&FdoExtension->DiskInterfaceName, NULL);
}
return status;
}
@ -1002,6 +1028,13 @@ FdoHandleRemoveDevice(
ASSERT(partExt->DeviceRemoved);
}
if (FdoExtension->DiskInterfaceName.Buffer)
{
IoSetDeviceInterfaceState(&FdoExtension->DiskInterfaceName, FALSE);
RtlFreeUnicodeString(&FdoExtension->DiskInterfaceName);
RtlInitUnicodeString(&FdoExtension->DiskInterfaceName, NULL);
}
// Send the IRP down the stack
IoSkipCurrentIrpStackLocation(Irp);
Irp->IoStatus.Status = STATUS_SUCCESS;

View file

@ -44,6 +44,7 @@ typedef struct _FDO_EXTENSION
SINGLE_LIST_ENTRY PartitionList;
UINT32 EnumeratedPartitionsTotal;
UNICODE_STRING DiskInterfaceName;
struct {
UINT64 DiskSize;