PIRP
IoBuildSynchronousFsdRequest(
IN ULONG MajorFunction,
IN PDEVICE_OBJECT DeviceObject,
IN OUT PVOID Buffer, /* optional */
IN ULONG Length, /* optional */
IN PLARGE_INTEGER StartingOffset, /* optional */
IN PKEVENT Event,
OUT PIO_STATUS_BLOCK IoStatusBlock
);
IoBuildSynchronousFsdRequest allocates and builds IRP to be sent synchronously to lower driver(s).
IoBuildSynchronousFsdRequest returns a pointer to the IRP or NULL if an IRP cannot be allocated.
Intermediate or highest-level drivers can call IoBuildSynchronousFsdRequest to set up IRPs for requests sent to lower-level drivers, only if the caller is running in a nonarbitrary thread context and at IRQL PASSIVE_LEVEL.
IoBuildSynchronousFsdRequest allocates and sets up an IRP that can be sent to a device driver to perform a synchronous read, write, flush, or shutdown operation. The IRP contains only enough information to get the operation started.
The caller can determine when the I/O has completed by calling KeWaitForSingleObject with the Event. Performing this wait operation causes the current thread to wait. Therefore, this operation can be requested during the initialization of an intermediate driver or from an FSD in the context of a thread requesting a synchronous I/O operation. A driver cannot wait for a nonzero interval on the Event at raised IRQL in an arbitrary thread context.
Because the caller can wait on a given Event, the caller need not set an IoCompletion routine in the caller-allocated IRP before calling IoCallDriver. When the caller completes the IRP, the I/O Manager releases it.
IO_STACK_LOCATION, IoAllocateIrp, IoBuildAsynchronousFsdRequest, IoCompleteRequest, IRP, KeInitializeEvent, KeWaitForSingleObject