calling the IoBuildAsynchronousFsdRequest?!?!

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.

Generally it is more productive if you include the appropriate crash
information rather than just some code segment. See the FAQ.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of A.Ilamparithi
Sent: Saturday, July 31, 2004 4:52 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] calling the IoBuildAsynchronousFsdRequest?!?!

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.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@hollistech.com To unsubscribe send a blank email to
xxxxx@lists.osr.com