Problem in 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.

You can’t touch IRP after invoking IoCallDriver - IRP may already be deleted
by IoFreeIrp in your completion routine.

Alexei.

-----Original Message-----
From: A.Ilamparithi [mailto:xxxxx@msn.com]
Sent: Saturday, July 31, 2004 1:32 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Problem in 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 IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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

hi,
Thankz for your answer.We tried not to use the IRPs after
IoCallDriver. But result is the same.

Thanks in Advance,

Ilamparithi.

“Alexei Jelvis” wrote in message news:xxxxx@ntfsd…
You can’t touch IRP after invoking IoCallDriver - IRP may already be deleted
by IoFreeIrp in your completion routine.

Alexei.

-----Original Message-----
From: A.Ilamparithi [mailto:xxxxx@msn.com]
Sent: Saturday, July 31, 2004 1:32 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Problem in 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 IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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