hi eyeone,
I have a problem.In my driver, I have my own irp created for some
kind of io operations, but in some cases, I want to cancel the pending
Irp.Since I know that cancel a Irp is very complex, so I ask the
question.
Can I do the following codeline?
Irp = CreateMyIrp();//assume some CancelRoutine have been set
status = IoCallDriver(Dev, Irp);
if(status == STATUS_PENDING) {
ret = KeWaitForSingleObject();
if(ret == STATUS_TIMEOUT) {
IoCancelIrp(Irp);
}
}
if that above codeling can work, How should I realize the
CancelRoutine. If that doesn’t work, What should I do?
Thank you for you relplay.
You are confused here, Dev in the IoCallDriver statement should be another
drivers device, if so you should not touch the IRP again since you do not
own it. Once you call IoCallDriver you should not touch the IRP until it
has been completed and is back to you.
If you are calling IoCallDriver with your own device, you have another set
of problems.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply
“??” wrote in message news:xxxxx@ntdev…
> hi eyeone,
>
> I have a problem.In my driver, I have my own irp created for some
> kind of io operations, but in some cases, I want to cancel the pending
> Irp.Since I know that cancel a Irp is very complex, so I ask the
> question.
>
> Can I do the following codeline?
>
> Irp = CreateMyIrp();//assume some CancelRoutine have been set
> status = IoCallDriver(Dev, Irp);
> if(status == STATUS_PENDING) {
> ret = KeWaitForSingleObject();
> if(ret == STATUS_TIMEOUT) {
> IoCancelIrp(Irp);
> }
> }
>
> if that above codeling can work, How should I realize the
> CancelRoutine. If that doesn’t work, What should I do?
>
> Thank you for you relplay.
>
֣Ȼ wrote:
I have a problem.In my driver, I have my own irp created for some
kind of io operations, but in some cases, I want to cancel the pending
Irp.Since I know that cancel a Irp is very complex, so I ask the
question.
Can I do the following codeline?
Irp = CreateMyIrp();//assume some CancelRoutine have been set
status = IoCallDriver(Dev, Irp);
if(status == STATUS_PENDING) {
ret = KeWaitForSingleObject();
if(ret == STATUS_TIMEOUT) {
IoCancelIrp(Irp);
}
}
if that above codeling can work, How should I realize the
CancelRoutine. If that doesn’t work, What should I do?
Yes, you can do that, but the driver that holds the IRP is not obligated
to respond to it. IoCancelIrp is only a suggestion. Also, you should
check the return value of IoCancelIrp to see if the IRP is non-cancelable.
Your cancel routine should do whatever you need to do when the request
is cancelled. You probably need to free the IRP.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
You cannot call IoCancelIrp after your completion routine was called with
this IRP. Usually, this is done by storing the IRP pointer somewhere in the
device extension atomically, and atomically storing NULL in the same location
in the completion routine.
I believe the DDK samples have some code, just grep them for “IoCancelIrp”.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “??”
To: “Windows System Software Devs Interest List”
Sent: Monday, July 03, 2006 3:18 PM
Subject: [ntdev] how to cancel my own irp
> hi eyeone,
>
> I have a problem.In my driver, I have my own irp created for some
> kind of io operations, but in some cases, I want to cancel the pending
> Irp.Since I know that cancel a Irp is very complex, so I ask the
> question.
>
> Can I do the following codeline?
>
> Irp = CreateMyIrp();//assume some CancelRoutine have been set
> status = IoCallDriver(Dev, Irp);
> if(status == STATUS_PENDING) {
> ret = KeWaitForSingleObject();
> if(ret == STATUS_TIMEOUT) {
> IoCancelIrp(Irp);
> }
> }
>
> if that above codeling can work, How should I realize the
> CancelRoutine. If that doesn’t work, What should I do?
>
> Thank you for you relplay.
>
> —
> 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
It’s possible to cancel an IRP either you create or you receive from the
caller but you have to do it very carefully. You can not touch the IRP
after you have passed to other driver by IoCallDriver safely unless you
have a completion and the completion routine is coded in the way to
prevent the IRP being deallocated when you try to touch it later - i.e
you want to cancel it. In your completion routine, you need to use
carefully if the completion is result of a cancellation or normal
completion. When you try to invoke iocancelirp, you need to detect
whether or not the completion routine has been called (if yes, for what
reason).
Walter describes the process pretty well in his WDM 2nd edition book.
Calvin Guan
NetXtreme Vista/LH Server Miniport
Broadcom Corporation
Connecting Everything(r)
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of ??
Sent: Monday, July 03, 2006 4:18 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] how to cancel my own irp
hi eyeone,
I have a problem.In my driver, I have my own irp created for some
kind of io operations, but in some cases, I want to cancel the pending
Irp.Since I know that cancel a Irp is very complex, so I ask the
question.
Can I do the following codeline?
Irp = CreateMyIrp();//assume some CancelRoutine have been set
status = IoCallDriver(Dev, Irp);
if(status == STATUS_PENDING) {
ret = KeWaitForSingleObject();
if(ret == STATUS_TIMEOUT) {
IoCancelIrp(Irp);
}
}
if that above codeling can work, How should I realize the
CancelRoutine. If that doesn’t work, What should I do?
Thank you for you relplay.
— 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