IRP_MJ_CLEANUP not being called

i wrote a simple driver, that doesn’t not access hardware at all.
however, i do need to mark some irp as pending IoMarkPending, when i try
to close the handle using CloseFile, the Cleanup routine is not being
called (I already filled up the dispatch table) !! If i don’t mark the
irp as pending, then cleanup is being called. why is that ?? shouldn’t
clean up supposed to be called to cancel pending irp ?? any help or ideas
is appreciated, thank.

Do you have supplied in irp cancellation routine when you mark irp as
pending??
----- Original Message -----
From: “cksiow”
To: “NT Developers Interest List”
Sent: Friday, September 20, 2002 2:31 PM
Subject: [ntdev] IRP_MJ_CLEANUP not being called

> i wrote a simple driver, that doesn’t not access hardware at all.
> however, i do need to mark some irp as pending IoMarkPending, when i try
> to close the handle using CloseFile, the Cleanup routine is not being
> called (I already filled up the dispatch table) !! If i don’t mark the
> irp as pending, then cleanup is being called. why is that ?? shouldn’t
> clean up supposed to be called to cancel pending irp ?? any help or ideas
> is appreciated, thank.
>
> —
> You are currently subscribed to ntdev as: xxxxx@leadbyte.com
> To unsubscribe send a blank email to %%email.unsub%%
>

Clean up get called when you end your task, but the only IRP you get is the
one for cleanup. If clean is going to cancel a bunch of IRPs then it has to
know how to fetch those IRPs, usually in a linked list which you have saved
in your device extension. Any IRP you pend, you should also have a
canellation routine, which must not conflict with CleanUp.

Gary G. Little
Have Computer, will travel
909-551-2105
909-698-3191

“cksiow” wrote in message news:xxxxx@ntdev…
>
> i wrote a simple driver, that doesn’t not access hardware at all.
> however, i do need to mark some irp as pending IoMarkPending, when i try
> to close the handle using CloseFile, the Cleanup routine is not being
> called (I already filled up the dispatch table) !! If i don’t mark the
> irp as pending, then cleanup is being called. why is that ?? shouldn’t
> clean up supposed to be called to cancel pending irp ?? any help or ideas
> is appreciated, thank.
>
>

If I recall correctly, IRP_MJ_CLEANUP is called when the system wide
reference count of your device object turns to zero. So someone has to
reference your device object first and then dereference it (this include
handles) before your driver will gets the call.

:slight_smile:

Bi

-----Original Message-----
From: Gary G. Little [mailto:xxxxx@inland.net]
Sent: Friday, September 20, 2002 12:56 PM
To: NT Developers Interest List
Subject: [ntdev] Re: IRP_MJ_CLEANUP not being called

Clean up get called when you end your task, but the only IRP you get is the
one for cleanup. If clean is going to cancel a bunch of IRPs then it has to
know how to fetch those IRPs, usually in a linked list which you have saved
in your device extension. Any IRP you pend, you should also have a
canellation routine, which must not conflict with CleanUp.

Gary G. Little
Have Computer, will travel
909-551-2105
909-698-3191

“cksiow” wrote in message news:xxxxx@ntdev…
>
> i wrote a simple driver, that doesn’t not access hardware at all.
> however, i do need to mark some irp as pending IoMarkPending, when i try
> to close the handle using CloseFile, the Cleanup routine is not being
> called (I already filled up the dispatch table) !! If i don’t mark the
> irp as pending, then cleanup is being called. why is that ?? shouldn’t
> clean up supposed to be called to cancel pending irp ?? any help or ideas
> is appreciated, thank.
>
>


You are currently subscribed to ntdev as: xxxxx@appstream.com
To unsubscribe send a blank email to %%email.unsub%%

> Bi Chen wrote:

If I recall correctly, IRP_MJ_CLEANUP is called when the system wide
reference count of your device object turns to zero. So someone has to
reference your device object first and then dereference it (this
include handles) before your driver will gets the call.

Not so. IRP_MJ_CLEANUP occurs when someone closes the handle related to
a FILE_OBJECT, either by calling CloseHandle in user-mode or ZwClose in
kernel mode.

IRP_MJ_CLOSE occurs when the reference count on the FILE_OBJECT goes to
zero. This may take quite a while in the case of file with cached
sections.

If you think about it, it couldn’t possibly be right that receipt of
IRP_MJ_CLEANUP depends in any way on the reference count on a device
object. That would imply that someone could open an unbounded number of
handles and close them without the driver ever becoming aware of the
close events, whereupon IRP queues would grow without bound. In
addition, when the reference count on a device object goes to zero, the
I/O manager deletes the device object. Once that happens, it is simply
not possible to get IRPs for that device object.


Walter Oney, Consulting and Training
Check out new US seminar schedule at http://www.oneysoft.com