RE: How can I get the current dirctory in a file syst em filter driver?

No, it is not guaranteed.

If you need the full name, call the FSD below you to get the file name
of the related file object. You can then append the filename of the
current file object to the name returned from the FSD and you will have
the full canonical name of the file. I have done it in several drivers
and it is an extremely reliable method.

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Vodicka, Michal
Sent: Tuesday, February 04, 2003 9:26 PM
To: File Systems Developers
Subject: [ntfsd] RE: How can I get the current dirctory in a file syst
em filter driver?


From:
xxxxx@windows.microsoft.com[SMTP:xxxxx@windows.microsoft.com]
Reply To: xxxxx@lists.osr.com
Sent: Tuesday, February 04, 2003 1:58 AM
To: xxxxx@lists.osr.com
Subject: [ntfsd] RE: How can I get the current dirctory in a file
system filter driver?

It is only valid to look at the FileName and RelatedFileObject fields
of
a FILE_OBJECT structure during pre-create. These fields are not
necessarily valid at any other time.

Is RelatedFileObject->FileName always valid in pre-create path?

I’m just investigating IFS (XP SP1) examples to find how to get
canonical
name in pre-create path and have to say I’m a bit confused. SFilter
accesses
RelatedFileObject->FileName directly (post-create when open fails)
whereas
FileSpy queries for FileNameInfo. There is a comment (fspylib.c / 1272)
which explains it is because RelatedFileObject may be also relative.
Well,
so why don’t use relative name directly if it isn’t?

The comment is also misleading because tells about using
ObQueryNameString()
and is followed by call of SpyQueryFileSystemForFileName() which
contains
following comment “ObQueryNameString CANNOT be used here…”

Can somebody explain when is RelatedFileObject created and give an
example
of real situation when it can be relative to the other one?

Thanks.

Best regards,

Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]


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

As it was said many times on this list, PFILE_OBJECT->FileName field is
guaranteed to be valid only in IRP_MJ_CREATE dispatch routine. It may not be
valid even on IRP_MJ_CREATE completion. But related file object is already
created, possibly a long time before, so nothing can guarantee, that
PFILE_OBJECT->RelatedFileObject->FileName is still valid. Method shown in
FileSpy example in XP IFSKit (i.e., rolling
IRP_MJ_QUERY_INFORMATION/FileNameInformation request) is the best way.
ObQueryNameString may not be used as far as it will send
IRP_MJ_QUERY_INFORMATION request to the topmost driver in the stack. This
will definitely cause reentrancy. Assuming, that rolling
IRP_MJ_QUERY_INFORMATION request is very easy and described in FileSpy
sources, there is no better way.

----- Original Message -----
From: “Vodicka, Michal” <michal.vodicka>
To: “File Systems Developers”
Sent: Wednesday, February 05, 2003 7:25 AM
Subject: [ntfsd] RE: How can I get the current dirctory in a file syst em
filter driver?

> > ----------
> > From:
> > xxxxx@windows.microsoft.com[SMTP:xxxxx@windows.microsoft.com]
> > Reply To: xxxxx@lists.osr.com
> > Sent: Tuesday, February 04, 2003 1:58 AM
> > To: xxxxx@lists.osr.com
> > Subject: [ntfsd] RE: How can I get the current dirctory in a file
> > system filter driver?
> >
> > It is only valid to look at the FileName and RelatedFileObject fields of
> > a FILE_OBJECT structure during pre-create. These fields are not
> > necessarily valid at any other time.
> >
> Is RelatedFileObject->FileName always valid in pre-create path?
>
> I’m just investigating IFS (XP SP1) examples to find how to get canonical
> name in pre-create path and have to say I’m a bit confused. SFilter
accesses
> RelatedFileObject->FileName directly (post-create when open fails) whereas
> FileSpy queries for FileNameInfo. There is a comment (fspylib.c / 1272)
> which explains it is because RelatedFileObject may be also relative. Well,
> so why don’t use relative name directly if it isn’t?
>
> The comment is also misleading because tells about using
ObQueryNameString()
> and is followed by call of SpyQueryFileSystemForFileName() which contains
> following comment “ObQueryNameString CANNOT be used here…”
>
> Can somebody explain when is RelatedFileObject created and give an example
> of real situation when it can be relative to the other one?
>
> Thanks.
>
> Best regards,
>
> Michal Vodicka
> STMicroelectronics Design and Application s.r.o.
> [michal.vodicka@st.com, http:://www.st.com]
>
>
>
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@vba.com.by
> To unsubscribe send a blank email to xxxxx@lists.osr.com
></michal.vodicka>