Hi Tony,
I am developing the mini-filter using the Microsoft provided IFS kit. I
have trapped the IRP_MJ_DIRECTORY_CONTROL Irp as per IFS requirement with
the following callback function:
FLT_PREOP_CALLBACK_STATUS PreDirControlOperation(IN OUT PFLT_CALLBACK_DATA
Data,
IN PCFLT_RELATED_OBJECTS
FltObjects,
OUT PVOID
*CompletionContext)
Following is my response to your questions:
-
Is the return indicating success?
Answer: I am not making any API call out here, as I get all the data as
parameter(PFLT_CALLBACK_DATA Data) to the callback function
(PreDirControlOperation). Also, my callback function returns a success.
-
Are you sure that you’re getting a FileBothDirectoryInformation
request?
Answer: Yes the request is FileBothDirectoryInformation.
-
Is the name coming back for your file?
Answer: The structure (of our interest) for the FLT_PARAMETERS for
IRP_MJ_DIRECTORY_CONTROL is as follows:
typedef union _FLT_PARAMETERS {
.
.
union {
struct {
ULONG Length;
PUNICODE_STRING FileName;
FILE_INFORMATION_CLASS FileInformationClass;
ULONG POINTER_ALIGNMENT FileIndex;
PVOID DirectoryBuffer;
PMDL MdlAddress;
} QueryDirectory;
.
.
}DirectoryControl;
} FLT_PARAMETERS, *PFLT_PARAMETERS;
The FileName in the QueryDirectory structure
(QueryDirectory.FileName) is returned correctly. However, when I try to get
the file name from the QueryDirectory.DirectoryBuffer (which is a PVOID and
a variable structure in my case of type FileBothDirectoryInformation) I
cannot retrieve it correctly. The code is similar to what I have given in my
previous posting.
- Yes I realize that. I understand that the structure we are referring
to (FILE_BOTH_DIR_INFORMATION) is of variable length and requires alignment
as well. In the following code I do not understand as to why the pointer
assignment (pudtDirectoryInformation = …) does not work correctly. I do not
know as to how the structure should be traversed.
PFILE_BOTH_DIR_INFORMATION pudtDirectoryInformation = NULL;
if(IRP_MN_QUERY_DIRECTORY == Data->Iopb->MinorFunction)
{
if(FileBothDirectoryInformation ==
Data->Iopb-Parameters.DirectoryControl.QueryDirectory.FileInformationClass)
{
pudtDirectoryInformation =
Data->Iopb->Parameters.DirectoryControl.QueryDirectory.DirectoryBuffer;
}
}
Thanks in advance,
Ruhina
****************************************************************************
**************************************************
Is the return indicating success? Are you sure that you’re getting a
FileBothDirectoryInformation request? Is the name coming back for your
file? You do realize that this call can return a set of entries (fixed
header + variable name + fixed header + variable name, etc.)
Regards,
Tony
From: ruhina [mailto:xxxxx@persistent.co.in]
Sent: Monday, March 27, 2006 10:15 AM
To: ‘Windows File Systems Devs Interest List’
Subject: RE: PFILE_BOTH_DIR_INFORMATION
Hi all,
Please let me know if I am doing anything wrong in the following
code.
PFILE_BOTH_DIR_INFORMATION pudtDirectoryInformation = NULL;
if(IRP_MN_QUERY_DIRECTORY == Data->Iopb->MinorFunction)
{
if(FileBothDirectoryInformation ==
Data->Iopb-Parameters.DirectoryControl.QueryDirectory.FileInformationCla
ss)
{
pudtDirectoryInformation =
Data->Iopb->Parameters.DirectoryControl.QueryDirectory.DirectoryBuffer;
}
}
The pudtDirectoryInformation is not populated correctly. For
example, pudtDirectoryInformation->EndOfFile.QuadPart is not returning
size of my file. Do I need to take care of the alignment of the
structure (Note that I am developing a mini filter and I have written
the above code in the IRP_MJ_DIRECTORY_CONTROL callback )? If yes, how
do I do it?
Thanks and regards,
Ruhina.
****************************************************************************
****************************************************************************
****************************************************************************
****************************************************************************
****************************************************************************
*******************************
You do realize your second if statement has an assignment, right? Might
I suggest that you use lint and/or prefast to check your code for bugs
like this?
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
****************************************************************************
****************************************************************************
****************************************************************************
****************************************************************************
****************************************
Hi all,
Please let me know if I am doing anything wrong in the following
code.
PFILE_BOTH_DIR_INFORMATION pudtDirectoryInformation = NULL;
if(IRP_MN_QUERY_DIRECTORY == Data->Iopb->MinorFunction)
{
if(FileBothDirectoryInformation ==
/*Eliminate the said bug,but this is not the source of
Data->Iopb-Parameters.DirectoryControl.QueryDirectory.FileInformationCla
the problem. pudtDirectoryInformation structure is
ss)
still not populating properly.*/
{
pudtDirectoryInformation =
Data->Iopb->Parameters.DirectoryControl.QueryDirectory.DirectoryBuffer;
}
}
The pudtDirectoryInformation is not populated correctly. For
example, pudtDirectoryInformation->EndOfFile.QuadPart is not returning
size of my file. Do I need to take care of the alignment of the
structure (Note that I am developing a mini filter and I have written
the above code in the IRP_MJ_DIRECTORY_CONTROL callback )? If yes, how
do I do it?
Thanks and regards,
Ruhina.