Hi,
I am trying to use the IoBuildAsynchronousFsdRequest funtion inside my
IRP_MJ_READ dispatcher function. When i call the IoCallDriver , i am getting
BSOD. Can anybody help me out ? i have attached the source code here with.
{
StartingOffset.HighPart = StartingOffset.LowPart = 0;
m_WriteBuffer = ExAllocatePool( NonPagedPool, BUFFER_SIZE );
// Build asynchronous Irp request
localIrp = IoBuildAsynchronousFsdRequest(
IRP_MJ_READ,
deviceExtension->FileSystemDeviceObject,
m_WriteBuffer,
512,
&StartingOffset,
&ioStatusBlock);
if (!localIrp)
{
return STATUS_UNSUCCESSFUL;
}
// Set completion routine to validate finishing request.
KeInitializeEvent(&event,NotificationEvent,FALSE);
localIrp->UserEvent = &event;
localIrp->Tail.Overlay.OriginalFileObject = current->FileObject;
localIrp->RequestorMode = KernelMode;
IoSetCompletionRoutine(
localIrp,
MyComplete,
0,
TRUE,
TRUE,
TRUE);
status = IoCallDriver(deviceExtension->FileSystemDeviceObject, localIrp);
// Set Irp stack frame to the next loweer one.
localIrp->CurrentLocation–;
localIrp->Tail.Overlay.CurrentStackLocation
= IoGetNextIrpStackLocation(localIrp);
if (status == STATUS_PENDING)
{
KeWaitForSingleObject(&event,
Executive,
KernelMode,
FALSE,
NULL);
}
}
TSTATUS
MyComplete(
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context
)
{
//
*Irp->UserIosb = Irp->IoStatus;
if( !NT_SUCCESS(Irp->IoStatus.Status) ) {
DbgPrint(" ERROR ON IRP: %x\n", Irp->IoStatus.Status );
}
//
// Set the user event - wakes up the mainline code doing this.
//
KeSetEvent(Irp->UserEvent, 0, FALSE);
//
// Free the IRP now that we are done with it.
DbgPrint(“IMP : Inside Completion routine \n”);
//
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
}
Thankx in Advance,
Ilamparithi.