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.FileInformationClass)
{
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.

Fat sources are helpful in this case:

Seach for “FatQueryDirectory” and “FatMapUserBuffer”. There you will see how
to access the buffer.


“ruhina” schrieb im Newsbeitrag
news:xxxxx@ntfsd…
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.FileInformationClass)
{
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

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 18-21, 2006.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of ruhina
Sent: Friday, March 24, 2006 3:45 AM
To: ntfsd redirect
Subject: [ntfsd] 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.


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Guess we need to turn-on the auto-code-correctness-checks feature of NTFSD :slight_smile:

Peter
OSR

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.

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

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 18-21, 2006.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of ruhina
Sent: Sunday, March 26, 2006 11:45 PM
To: ntfsd redirect
Subject: RE:[ntfsd] 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.


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

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:

  1. 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.

  2. Are you sure that you’re getting a FileBothDirectoryInformation
    request?
    Answer: Yes the request is FileBothDirectoryInformation.

  3. 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.

  1. 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.

Of course the buffer is not populated in the pre-operation. The buffer is populated by the file system, and the request has not gone to the file system yet.

  • Dan.
    ----- Original Message -----
    From: ruhina
    To: Windows File Systems Devs Interest List
    Sent: Sunday, March 26, 2006 11:48 PM
    Subject: RE:[ntfsd] PFILE_BOTH_DIR_INFORMATION

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: 1. 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. 2. Are you sure that you're getting a FileBothDirectoryInformation request? Answer: Yes the request is FileBothDirectoryInformation. 3. 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. 4. 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 aFileBothDirectoryInformation request? Is the name coming back for yourfile? You do realize that this call can return a set of entries (fixedheader + 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 followingcode. 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. Forexample, pudtDirectoryInformation->EndOfFile.QuadPart is not returningsize of my file. Do I need to take care of the alignment of thestructure (Note that I am developing a mini filter and I have writtenthe above code in the IRP_MJ_DIRECTORY_CONTROL callback )? If yes, howdo I do it? Thanks and regards,Ruhina. ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

You do realize your second if statement has an assignment, right? MightI suggest that you use lint and/or prefast to check your code for bugslike 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 followingcode. 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. Forexample, pudtDirectoryInformation->EndOfFile.QuadPart is not returningsize of my file. Do I need to take care of the alignment of thestructure (Note that I am developing a mini filter and I have writtenthe above code in the IRP_MJ_DIRECTORY_CONTROL callback )? If yes, howdo I do it? Thanks and regards, Ruhina.


Questions? First check the IFS FAQ at The NT Insider:Windows NT Virtual Memory (Part I)

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ''
To unsubscribe send a blank email to xxxxx@lists.osr.com

Good pick-up Dan. Since I’d asked “was the operation successful” and
the follow-up ignored that question and said “I’m not making any API
call” I decided I couldn’t add any further value (a bit like asking
“what color is the sky” and the answer back being “I didn’t ask for
water” - definitely no continuity and it is tough to even figure out
where to go from there.)

Regards,

Tony

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 18-21, 2006.