Note that IoSetCompletionRoutineEx can return !NT_SUCCESS and you must
check for failure and complete the original irp if you can’t set the
completion routine
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Arlie Davis
Sent: Friday, May 19, 2006 10:49 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Trouble sending SCSI IRP on Windows Vista
Use IoAllocateIrp to allocate an IRP, fill in the arguments for the
target driver, set a completion routine, and call the driver. Make sure
you specify the correct stack size, using the StackSize field of the
device object you intend to target.
PIRP Irp;
PIO_STACK_LOCATION Ios;
Irp = IoAllocateIrp(TargetDeviceObject->StackSize, FALSE);
if (Irp == NULL) { … }
// Set up call stack for next driver.
// This part completely depends on what kind of IRP you are submitting.
Ios = IoGetNextIrpStackLocation(Irp);
Ios->MajorFunction = IRP_MJ_DEVICE_CONTROL; // or whatever
Ios->MinorFunction = 0;
Ios->Parameters.DeviceIoControl.IoControlCode = …;
Ios->Parameters.DeviceIoControl.Xxx = etc.;
(fill in other parameter fields)
IoSetCompletionRoutine(Irp, MyIrpCompletionHandler);
Status = IoCallDriver(TargetDeviceObject, Irp);
Note: As the initiator of an IRP, you don’t set it pending. If anyone
sets it pending, it’s one of the drivers that processes the IRP, not the
initiator.
Also, you should not assume that the NTSTATUS value you get back from
IoCallDriver is the right value to return from your own IRP dispatch
routine.
You’ll also need to consider whether you need to use
IoSetCompletionRoutine or IoSetCompletionRoutineEx. The Ex version
handles a dangerous race condition for you (driver unload before I/O
completion routine returns to caller), but is not always necessary. In
this case, it probably *IS* necessary.
– arlie
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Fred
Sent: Friday, May 19, 2006 10:14 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Trouble sending SCSI IRP on Windows Vista
Can you recommend any sample code in the DDK to show how to set an irp
pending and issue an async irp?
“Peter Wieland” wrote in message
news:xxxxx@ntdev…
You can’t do synchronous I/O in an IRP_MJ_SCSI handler. Since it can be
invoked at dispatch level (and commonly is) you can only do asynch I/O.
-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Fred
Sent: Thursday, May 18, 2006 8:52 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Trouble sending SCSI IRP on Windows Vista
I have a lower filter driver on the HDD stack. I need to issue new
IRP_MJ_SCSI IRP’s downstream in my IRP_MJ_SCSI handler for each incoming
IRP request. My driver works well on W2k and XP but BSOD’s on Windows
Vista when I try to issue an IRP_MJ_SCSI via the
IoBuildSynchronousFsdRequest.
Is it legal to issue a new IRP via IoBuildSynchronousFsdRequest (from
the context of a IRP_MJ_SCSI handler) or do I have to use
IoBuildAsynchronousFsdRequest and mark the current IRP pending while I
issue my new IRP? I assume IoBuildSynchronousFsdRequest is okay (never
heard
otherwise) but a dev mentioned that I should use
IoBuildAsynchronousFsdRequest for Vista. I haven’t found any
documentation that supports his idea. Anybody konw one way or the
other?
Thanks.
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer