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

The RelatedFileObject pointer is not null if the file name is relative. So
RelatedFileObject->FileName points to the directory where the file is
located. You need check these things before call IoCallDriver.
After the call, RelatedFileObject becomes NULL in most cases.

Shangwu

“Vodicka, Michal” <michal.vodicka> wrote in message
news:xxxxx@ntfsd…
>
> > ----------
> > 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]
>
>
>
>
>
>
></michal.vodicka>

Michal,

Thank you for noticing this incorrect usage in SFilter. The
SfGetFileName routine is wrongly accessing the
“FileObject->RelatedFileObject->FileName” field. You should never
access the FileName field of the RelatedFileObject because it may
incorrect. If you need the name of the RelatedFileObject, query the
file system (as FileSpy does).

I have filed bugs to correct this routine in SFilter as well as fix the
inconsistent comment in SpyGetFullPathName.

Everyone, please do not use SpyGetFileName as an example of how to
retrieve a file name. Until SFilter is corrected look at how FileSpy
retrieves the name.

Neal Christiansen
Microsoft File System Filter Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Shangwu Qi [mailto:xxxxx@fcni.com]
Sent: Wednesday, February 05, 2003 7:10 AM
To: File Systems Developers

The RelatedFileObject pointer is not null if the file name is relative.
So
RelatedFileObject->FileName points to the directory where the file is
located. You need check these things before call IoCallDriver.
After the call, RelatedFileObject becomes NULL in most cases.

Shangwu

“Vodicka, Michal” <michal.vodicka> wrote in message
news:xxxxx@ntfsd…
>
> > ----------
> > 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@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</michal.vodicka>

Correction, I gave the wrong routine name below, it should read:

Everyone, please do not use “SfGetFileName” as an example of how to
retrieve a file name. Until SFilter is corrected look at how FileSpy
retrieves file names.

Neal Christiansen
Microsoft File System Filter Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Neal Christiansen
Sent: Wednesday, February 05, 2003 10:36 AM
To: ‘File Systems Developers’

Michal,

Thank you for noticing this incorrect usage in SFilter. The
SfGetFileName routine is wrongly accessing the
“FileObject->RelatedFileObject->FileName” field. You should never
access the FileName field of the RelatedFileObject because it may
incorrect. If you need the name of the RelatedFileObject, query the
file system (as FileSpy does).

I have filed bugs to correct this routine in SFilter as well as fix the
inconsistent comment in SpyGetFullPathName.

Everyone, please do not use SpyGetFileName as an example of how to
retrieve a file name. Until SFilter is corrected look at how FileSpy
retrieves the name.

Neal Christiansen
Microsoft File System Filter Group

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Shangwu Qi [mailto:xxxxx@fcni.com]
Sent: Wednesday, February 05, 2003 7:10 AM
To: File Systems Developers

The RelatedFileObject pointer is not null if the file name is relative.
So
RelatedFileObject->FileName points to the directory where the file is
located. You need check these things before call IoCallDriver.
After the call, RelatedFileObject becomes NULL in most cases.

Shangwu

“Vodicka, Michal” <michal.vodicka> wrote in message
news:xxxxx@ntfsd…
>
> > ----------
> > 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@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</michal.vodicka>