IoCreateFileSpecifyDeviceObjectHint by file or object id?

In my attempt to track the identity of all files in my MJ_CREATE handler, I
am storing the 64-bit and 128-bit file ids for each file in addition to the
names. When a new file id comes into my create handler that I’ve not seen
before, I need to open the file myself first to get various file info (I
know I can’t get the name at that point).

The OSR function OsrFilterForwardCreateIrp is working well for me when
opening by name, but now I need to do the equivalent by file id. Since
OsrFilterForwardCreateIrp uses IoCreateFileSpecifyDeviceObjectHint, it would
be nice if I could use IoCreateFileSpecifyDeviceObjectHint with file ids
instead of a file path.

Is this possible?

In create dispatch you have everything you need to
construct the name of the file that is to be opened.

You have to look at the name passed and the relative
file object to construct the full name.

Remember that you also get volume opens in create
dispatch.

— Mark Hahn wrote:

>
> In my attempt to track the identity of all files in
> my MJ_CREATE handler, I
> am storing the 64-bit and 128-bit file ids for each
> file in addition to the
> names. When a new file id comes into my create
> handler that I’ve not seen
> before, I need to open the file myself first to get
> various file info (I
> know I can’t get the name at that point).
>
> The OSR function OsrFilterForwardCreateIrp is
> working well for me when
> opening by name, but now I need to do the equivalent
> by file id. Since
> OsrFilterForwardCreateIrp uses
> IoCreateFileSpecifyDeviceObjectHint, it would
> be nice if I could use
> IoCreateFileSpecifyDeviceObjectHint with file ids
> instead of a file path.
>
> Is this possible?
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

Randy Cook wrote:

In create dispatch you have everything you need to
construct the name of the file that is to be opened.

You have to look at the name passed and the relative
file object to construct the full name.

Remember that you also get volume opens in create
dispatch.

But what about when FILE_OPEN_BY_FILE_ID is set in Create.Options? In that
case the filename field is actually the file id number. How can I construct
the name in that case?

According to the OSR IFS FAQ, Question 24: “The most substantial impact of
the use of file IDs for file system filter drivers is the inability to
extract a name for the file”.

Right now I am going to the trouble to create file contexts for file opens
that have no name and only the file id number. In order to make sure that
my file contexts are one-to-one with the actual files, and cover my butt for
the case of a file opened at one time with a file id and later with a path,
I have to look up the file id on every open-by-name to see if I already have
that context by file id.

If there was a way to get the name from the file id, I could make my context
lookup much simpler.

The same FAQ question says: “For CDFS, a filter can query the file system
for the name of the file … However, for NTFS there are certain cases when
it cannot return a path to the file (where the caller that opened the file
does not have traverse privileges, there is no mechanism for NTFS to
determine if it is allowed to return the path to the file)”.

Is it possible that I could get the name from NTFS by changing all creates
to have the traverse privilege and then managing user priveleges in my
filter? I don’t know anything about user privelages but that sounds hard.

This isn’t a show-stopper. I can work around this, but it is messy.

— Mark Hahn wrote:
>
>>
>> In my attempt to track the identity of all files in
>> my MJ_CREATE handler, I
>> am storing the 64-bit and 128-bit file ids for each
>> file in addition to the
>> names. When a new file id comes into my create
>> handler that I’ve not seen
>> before, I need to open the file myself first to get
>> various file info (I
>> know I can’t get the name at that point).
>>
>> The OSR function OsrFilterForwardCreateIrp is
>> working well for me when
>> opening by name, but now I need to do the equivalent
>> by file id. Since
>> OsrFilterForwardCreateIrp uses
>> IoCreateFileSpecifyDeviceObjectHint, it would
>> be nice if I could use
>> IoCreateFileSpecifyDeviceObjectHint with file ids
>> instead of a file path.
>>
>> Is this possible?
>>
>>
>>
>> —
>> Questions? First check the IFS FAQ at
>> https://www.osronline.com/article.cfm?id=17
>>
>> You are currently subscribed to ntfsd as:
>> xxxxx@yahoo.com
>> To unsubscribe send a blank email to
>> xxxxx@lists.osr.com
>>
>
>