FltGetFileNameInformation fails on open by file id operation

Hi,

Hi, I’m developing a fs minifilter and I just got a strange failure on FltGetFileNameInformation. However the symptom of failure is very simple whenever file open by file id operation comes to PreCreate, FltGetFileNameInformation always fails with error code STATUS_INVALID_PARAMETER.

How do I properly obtain FileName Information for the FileObject in this situation? Is it even possible? Or is there some work around method for this?

thank you in advance.

In this case open by file id, get file name information in post create.

Good Luck!

wrote in message news:xxxxx@ntfsd…
> Hi,
>
> Hi, I’m developing a fs minifilter and I just got a strange failure on
> FltGetFileNameInformation. However the symptom of failure is very simple
> whenever file open by file id operation comes to PreCreate,
> FltGetFileNameInformation always fails with error code
> STATUS_INVALID_PARAMETER.
>
> How do I properly obtain FileName Information for the FileObject in this
> situation? Is it even possible? Or is there some work around method for
> this?
>
> thank you in advance.
>

Hi, Lyndon

Thank you for reply.

If I have to get a name from PostCreate then it will be a big problem for me. Cuz I need to reparse name of FileObject at that point. File Id is unique so there must be a way to identify the file and its name. Is there such method that can get file name from file id?
However, I checked DDK reparse sample (‘simrep’) for the solution but I can’t find any related work in the source. Im just confused… If you got a any suggestion It will be great help.

Thank you in advance.

> File Id is unique so there must be a way to identify the file and its

name. Is there such method that can get file name from? file
id?

See question 24 from the IFS FAQ:

Q24 How are file IDs and Object IDs used in the file systems? In my filter driver, how do I deal with them?

http://www.osronline.com/article.cfm?article=17

Regards,
Razvan

If you really need to get the name in pre-create then you could issue your own create to open the file by ID and query for the name with that handle, then close that handle and continue processing the original create request. Not the greatest for performance but I do not think open by ID is used very often.

Sorry for jumping in so late in this thread, but as far as I know FltGetFileNameInformation works for opens by ID both in preCreate and after that. I guess there must be something else going on. Could you post some code ?

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

Thank you all for reply.

Rick, I will try what you have suggested.

Alex, I’m not doing anything special, what my driver do is redirect all file operation to hidden virtual disk and I got problem when I try to get a file name from FILE_OPEN_BY_FILE_ID operation in PreCreate.
anyway, My code that retrieve file name looks like this.

nStatus = FltGetFileNameInformation( Data, FLT_FILE_NAME_NORMALIZED|FLT_FILE_NAME_QUERY_ALWAYS_ALLOW_CACHE_LOOKUP,
ppTargetFileInformation );

if( STATUS_SUCCESS != nStatus )
{
//
// Error, try to open with FLT_FILE_NAME_OPENED Flag
//

nStatus = FltGetFileNameInformation( Data, FLT_FILE_NAME_OPENED|FLT_FILE_NAME_QUERY_ALWAYS_ALLOW_CACHE_LOOKUP, ppTargetFileInformation );

if( STATUS_SUCCESS != nStatus )
{
AhnDbgPrint( ASTD_MESSAGE_LV,
(“[VeffhGetParsedFileNameInformation] Failed to FltGetFileNameInformation (Err:%d)\n”,
nStatus ) );

ASSERT(FALSE);
}

}

if( STATUS_SUCCESS == nStatus )
{
// Parse File Name
nStatus = FltParseFileNameInformation( *ppTargetFileInformation );

if( STATUS_SUCCESS != nStatus )
{

AhnDbgPrint( ASTD_MESSAGE_LV,
(“[VeffhGetParsedFileNameInformation] Failed to FltParseFileNameInformation (Err:%d)\n”,
nStatus ) );

ASSERT(FALSE);
}
}

this code stay on very first of My PreCreate CallBack routine. everything i do comes after getting file name cuz I need file name to validate what to do next.
I just check ‘simrep’ sample source code in DDK and I think the sample has same problem that I have. cuz FltGetFileNameInformation fails everytime for file ID operation.