mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 19:21:38 +00:00
[DISK] Forcibly declare our partitions to the MountMgr
Because our disk.sys doesn't do anything related to PnP (compared to disk_new.sys), forcibly declare our partitions to the MountMgr so that it can references them and assign them a DOS drive letter on demand later on.
This commit is contained in:
parent
410c606999
commit
b68104dd87
1 changed files with 131 additions and 0 deletions
|
@ -1067,6 +1067,129 @@ CreateDiskDeviceObjectsExit:
|
|||
|
||||
} // end CreateDiskDeviceObjects()
|
||||
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ReportToMountMgr(
|
||||
IN PDEVICE_OBJECT DiskDeviceObject
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This routine reports the creation of a disk device object to the
|
||||
MountMgr to fake PnP.
|
||||
|
||||
Arguments:
|
||||
|
||||
DiskDeviceObject - Pointer to the created disk device.
|
||||
|
||||
Return Value:
|
||||
|
||||
VOID
|
||||
|
||||
--*/
|
||||
{
|
||||
NTSTATUS status;
|
||||
UNICODE_STRING mountMgrDevice;
|
||||
PDEVICE_OBJECT deviceObject;
|
||||
PFILE_OBJECT fileObject;
|
||||
PMOUNTMGR_TARGET_NAME mountTarget;
|
||||
ULONG diskLen;
|
||||
PDEVICE_EXTENSION deviceExtension;
|
||||
PIRP irp;
|
||||
KEVENT event;
|
||||
IO_STATUS_BLOCK ioStatus;
|
||||
|
||||
//
|
||||
// First, get MountMgr DeviceObject.
|
||||
//
|
||||
|
||||
RtlInitUnicodeString(&mountMgrDevice, MOUNTMGR_DEVICE_NAME);
|
||||
status = IoGetDeviceObjectPointer(&mountMgrDevice, FILE_READ_ATTRIBUTES,
|
||||
&fileObject, &deviceObject);
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
|
||||
DebugPrint((1,
|
||||
"ReportToMountMgr: Can't get MountMgr pointers %lx\n",
|
||||
status));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
deviceExtension = DiskDeviceObject->DeviceExtension;
|
||||
diskLen = deviceExtension->DeviceName.Length;
|
||||
|
||||
//
|
||||
// Allocate input buffer to report our partition device.
|
||||
//
|
||||
|
||||
mountTarget = ExAllocatePool(NonPagedPool,
|
||||
sizeof(MOUNTMGR_TARGET_NAME) + diskLen);
|
||||
|
||||
if (!mountTarget) {
|
||||
|
||||
DebugPrint((1,
|
||||
"ReportToMountMgr: Allocation of mountTarget failed\n"));
|
||||
|
||||
ObDereferenceObject(fileObject);
|
||||
return;
|
||||
}
|
||||
|
||||
mountTarget->DeviceNameLength = diskLen;
|
||||
RtlCopyMemory(mountTarget->DeviceName, deviceExtension->DeviceName.Buffer, diskLen);
|
||||
|
||||
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
||||
|
||||
//
|
||||
// Build the IRP used to communicate with the MountMgr.
|
||||
//
|
||||
|
||||
irp = IoBuildDeviceIoControlRequest(IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION,
|
||||
deviceObject,
|
||||
mountTarget,
|
||||
sizeof(MOUNTMGR_TARGET_NAME) + diskLen,
|
||||
NULL,
|
||||
0,
|
||||
FALSE,
|
||||
&event,
|
||||
&ioStatus);
|
||||
|
||||
if (!irp) {
|
||||
|
||||
DebugPrint((1,
|
||||
"ReportToMountMgr: Allocation of irp failed\n"));
|
||||
|
||||
ExFreePool(mountTarget);
|
||||
ObDereferenceObject(fileObject);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Call the MountMgr.
|
||||
//
|
||||
|
||||
status = IoCallDriver(deviceObject, irp);
|
||||
|
||||
if (status == STATUS_PENDING) {
|
||||
KeWaitForSingleObject(&event, Suspended, KernelMode, FALSE, NULL);
|
||||
status = ioStatus.Status;
|
||||
}
|
||||
|
||||
//
|
||||
// We're done.
|
||||
//
|
||||
|
||||
DPRINT1("Reported to the MountMgr: %lx\n", status);
|
||||
|
||||
ExFreePool(mountTarget);
|
||||
ObDereferenceObject(fileObject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
|
@ -1460,6 +1583,14 @@ CreatePartitionDeviceObjects(
|
|||
deviceExtension->DeviceObject = deviceObject;
|
||||
deviceExtension->DeviceFlags |= physicalDeviceExtension->DeviceFlags;
|
||||
|
||||
//
|
||||
// Now we're done, report to the MountMgr.
|
||||
// This is a HACK required to have the driver
|
||||
// handle the associated DosDevices.
|
||||
//
|
||||
|
||||
ReportToMountMgr(deviceObject);
|
||||
|
||||
} // end for (partitionNumber) ...
|
||||
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue