mirror of
https://github.com/reactos/reactos.git
synced 2024-11-11 01:04:11 +00:00
bd8226afe7
This driver works as complement to disk.sys/classpnp.sys from Windows 10 Manages partition PDOs and exposes them as volumes to mountmgr.sys. The driver is almost complete, just some minor IOCTLs missing (will be added on demand)
73 lines
2.1 KiB
C
73 lines
2.1 KiB
C
#include "partmgr.h"
|
|
|
|
NTSTATUS
|
|
NTAPI
|
|
ForwardIrpAndForget(
|
|
_In_ PDEVICE_OBJECT DeviceObject,
|
|
_In_ PIRP Irp)
|
|
{
|
|
// this part of a structure is identical in both FDO and PDO
|
|
PDEVICE_OBJECT LowerDevice = ((PFDO_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
|
|
ASSERT(LowerDevice);
|
|
|
|
IoSkipCurrentIrpStackLocation(Irp);
|
|
return IoCallDriver(LowerDevice, Irp);
|
|
}
|
|
|
|
NTSTATUS
|
|
IssueSyncIoControlRequest(
|
|
_In_ UINT32 IoControlCode,
|
|
_In_ PDEVICE_OBJECT DeviceObject,
|
|
_In_ PVOID InputBuffer,
|
|
_In_ ULONG InputBufferLength,
|
|
_In_ PVOID OutputBuffer,
|
|
_In_ ULONG OutputBufferLength,
|
|
_In_ BOOLEAN InternalDeviceIoControl)
|
|
{
|
|
PIRP Irp;
|
|
IO_STATUS_BLOCK IoStatusBlock;
|
|
PKEVENT Event;
|
|
NTSTATUS Status;
|
|
PAGED_CODE();
|
|
|
|
/* Allocate a non-paged event */
|
|
Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(*Event), TAG_PARTMGR);
|
|
if (!Event)
|
|
{
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
}
|
|
|
|
/* Initialize it */
|
|
KeInitializeEvent(Event, NotificationEvent, FALSE);
|
|
|
|
/* Build the IRP */
|
|
Irp = IoBuildDeviceIoControlRequest(IoControlCode,
|
|
DeviceObject,
|
|
InputBuffer,
|
|
InputBufferLength,
|
|
OutputBuffer,
|
|
OutputBufferLength,
|
|
InternalDeviceIoControl,
|
|
Event,
|
|
&IoStatusBlock);
|
|
if (!Irp)
|
|
{
|
|
/* Fail, free the event */
|
|
ExFreePoolWithTag(Event, TAG_PARTMGR);
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
}
|
|
|
|
/* Call the driver and check if it's pending */
|
|
Status = IoCallDriver(DeviceObject, Irp);
|
|
if (Status == STATUS_PENDING)
|
|
{
|
|
/* Wait on the driver */
|
|
KeWaitForSingleObject(Event, Executive, KernelMode, FALSE, NULL);
|
|
Status = IoStatusBlock.Status;
|
|
}
|
|
|
|
/* Free the event and return the Status */
|
|
ExFreePoolWithTag(Event, TAG_PARTMGR);
|
|
return Status;
|
|
}
|