Why is IRP_MJ_CLOSE needed (when there is IRP_MJ_CLEANUP)?
- From: 0dbell@xxxxxxxxx
- Date: Mon, 18 Jun 2007 23:13:14 -0000
From the WDK documentation for IRP_MJ_CLEANUP:
"Receipt of the IRP_MJ_CLEANUP request indicates that the *handle*
reference count on a file object has reached zero."
From the WDK documentation for IRP_MJ_CLOSE:
"Receipt of the IRP_MJ_CLOSE request indicates that the reference
count on a file object has reached zero."
Is the difference abvoe between "handle reference count" and
"reference count" meaningful? If so, what does that mean?
OK, so I read on and the the WDK documentation for IRP_MJ_CLEANUP
says:
"Often it is sent when a user-mode application has called the
Microsoft Win32 CloseHandle function (or when a kernel-mode driver has
called ZwClose) on the last outstanding handle to a file object."
How confusing: a call to CloseHandle() does not translate into
IRP_MJ_CLOSE but rather into IRP_MJ_CLEANUP. Why is that?
The WDK documentation for IRP_MJ_CLOSE, on the other hand, reads:
"usually because a file system driver or other kernel-mode component
has called ObDereferenceObject on the file object."
OK, so I understand that while IRP_MJ_CLEANUP is guaranteed to be sent
in the context of the process that created the handle, IRP_MJ_CLOSE
can come in *any* context, including the system context after the
process has exited.
But... the WDK documentation for IRP_MJ_CLOSE, continues:
"This request normally follows a cleanup request. However, this does
not necessarily mean that the close request will be received
immediately after the cleanup request."
So, Is IRP_MJ_CLEANUP *always* followed by a IRP_MJ_CLOSE (even if not
"immediately")? What does "immediately" in the above context means?
My observation, using WinDbg on a driver that I develop, suggests that
the answer is "Yes" - IRP_MJ_CLEANUP is *always* followed by a
IRP_MJ_CLOSE. But this doesn't make sense: why two IRPs for the same
thing? What am I supposed to do in response to IRP_MJ_CLOSE if I
already handle IRP_MJ_CLEANUP?
What am I missing?
Thanks,
Don
.
- Follow-Ups:
- Re: Why is IRP_MJ_CLOSE needed (when there is IRP_MJ_CLEANUP)?
- From: Maxim S. Shatskih
- Re: Why is IRP_MJ_CLOSE needed (when there is IRP_MJ_CLEANUP)?
- From: Don Burn
- Re: Why is IRP_MJ_CLOSE needed (when there is IRP_MJ_CLEANUP)?
- Prev by Date: Re: Vista doesn't enumerate devices on second PCI bus
- Next by Date: Re: Why is IRP_MJ_CLOSE needed (when there is IRP_MJ_CLEANUP)?
- Previous by thread: Inter-driver communication in Windows
- Next by thread: Re: Why is IRP_MJ_CLOSE needed (when there is IRP_MJ_CLEANUP)?
- Index(es):
Relevant Pages
|