Hello,
I have a question about the IoBuildSynchronousFsdRequest() method.
I am developing a storage filter driver, from my IRP_MJ_WRITE dispatch routine I have to update a file by building an IRP with IoBuildSynchronousFsdRequest() call. I do that only when IRQL value is PASSIVE_LEVEL, otherwise I put IRP’s data (size, offset) to my private queue and process them later. Everything works fine on regular, non-system volumes. If I install the driver on a system volume, the boot is delayed for 5-8 minutes. The code of the method is:
NTSTATUS ForwardIrpDirectly(PDEVICE_OBJECT xi_device_object,
ULONG xi_mj_function,
BYTE* xio_buffer,
ULONG xi_buffer_size,
LARGE_INTEGER* xi_offset,
IO_STATUS_BLOCK* xo_iosb)
{
NTSTATUS result = STATUS_SUCCESS;
TraceRoutine(DEBUG_LEVEL_TRACE, (“ForwardIrpDirectly: init, IRQL [%ld].”, KeGetCurrentIrql()));
ASSERT_IRQL(PASSIVE_LEVEL);
NT_ASSERT(xi_device_object != NULL && xo_iosb != NULL);
if(xi_device_object != NULL && xo_iosb != NULL)
{
IRP* irp;
KEVENT event;
if(xi_mj_function == IRP_MJ_READ || xi_mj_function == IRP_MJ_WRITE)
{
NT_ASSERT(xio_buffer != NULL && xi_buffer_size > 0 && xi_offset != NULL);
}
KeInitializeEvent(&event, NotificationEvent, FALSE);
irp = IoBuildSynchronousFsdRequest(xi_mj_function,
xi_device_object,
xio_buffer,
xi_buffer_size,
xi_offset,
&event,
xo_iosb);
if(irp == NULL)
{
result = STATUS_INSUFFICIENT_RESOURCES;
}
if(NT_SUCCESS(result))
{
(*irp).Flags |= IRP_NOCACHE;
result = IoCallDriver(xi_device_object, irp);
if(result == STATUS_PENDING)
{
KeEnterCriticalRegion();
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
KeLeaveCriticalRegion();
result = (*xo_iosb).Status;
}
}
else
{
// log error
TraceRoutine(DEBUG_LEVEL_LOGGING, (“ERROR: [%X], %s (%ld)”, result, FILE, LINE));
}
}
else
{
// log error
result = STATUS_INVALID_PARAMETER;
TraceRoutine(DEBUG_LEVEL_LOGGING, (“ERROR: [%X], %s (%ld)”, result, FILE, LINE));
}
TraceRoutine(DEBUG_LEVEL_TRACE, (“ForwardIrpDirectly: final [%X].”, result));
return result;
}
At some point, I commented out everything except that call to IoBuildSynchronousFsdRequest() and the system still delayed to boot. Is anything special about this method? How a system drive (C:) is different from a regular one from that method point of view? I tried with and without the page file (just a thought).
Thank you in advance,
Arthur