2.2.33 SMB2 QUERY_DIRECTORY Request

The SMB2 QUERY_DIRECTORY Request packet is sent by the client to obtain a directory enumeration on a directory open. This request consists of an SMB2 header, as specified in section 2.2.1, followed by this request structure:


0


1


2


3


4


5


6


7


8


9

1
0


1


2


3


4


5


6


7


8


9

2
0


1


2


3


4


5


6


7


8


9

3
0


1

StructureSize

FileInformationClass

Flags

FileIndex

FileId

...

...

...

FileNameOffset

FileNameLength

OutputBufferLength

Buffer (variable)

...

StructureSize (2 bytes): The client MUST set this field to 33, indicating the size of the request structure, not including the header. The client MUST set this field to this value regardless of how long Buffer[] actually is in the request being sent.

FileInformationClass (1 byte): The file information class describing the format that data MUST be returned in. Possible values are as specified in [MS-FSCC] section 2.4. This field MUST contain one of the following values:

Value

Meaning

FileDirectoryInformation

0x01

Basic information of a file or directory. Basic information is defined as the file's name, time stamp, size and attributes. File attributes are as specified in [MS-FSCC] section 2.6.

FileFullDirectoryInformation

0x02

Full information of a file or directory. Full information is defined as all the basic information plus extended attribute size.

FileIdFullDirectoryInformation

0x26

Full information, plus 64-bit file ID of a file or directory, as specified in [MS-FSCC] section 2.1.9.

FileBothDirectoryInformation

0x03

Basic information plus extended attribute size and short name of a file or directory.

FileIdBothDirectoryInformation

0x25

FileBothDirectoryInformation plus 64-bit file ID of a file or directory.

FileNamesInformation

0x0C

Detailed information of the names of files and directories in a directory.

FileIdExtdDirectoryInformation

0x3C

Extended information of a file or directory, including reparse point tag, if any.<72>

FileId64ExtdDirectoryInformation

0x4E

Extended information of a file or directory, including a 64-bit file ID and a reparse point tag, if any.<73>

FileId64ExtdBothDirectoryInformation

0x4F

FileBothDirectoryInformation plus 64-bit file ID and a reparse point tag, if any.<74>

FileIdAllExtdDirectoryInformation

0x50

FileId64ExtdDirectoryInformation plus a 128-bit file ID.<75>

FileIdAllExtdBothDirectoryInformation

0x51

FileId64ExtdBothDirectoryInformation plus a 128-bit file ID.<76>

FileInformationClass_Reserved

0x64

This value MUST be reserved and MUST be ignored on receipt.

Flags (1 byte): Flags indicating how the query directory operation MUST be processed. This field MUST be a logical OR of the following values, or zero if none are selected:

Value

Meaning

SMB2_RESTART_SCANS

0x01

The server is requested to restart the enumeration from the beginning as specified in section 3.3.5.18.

SMB2_RETURN_SINGLE_ENTRY

0x02

The server is requested to only return the first entry of the search results.

SMB2_INDEX_SPECIFIED

0x04

The server is requested to return entries beginning at the byte number specified by FileIndex.

SMB2_REOPEN

0x10

The server is requested to restart the enumeration from the beginning, and the search pattern is to be changed to the provided value.

FileIndex (4 bytes): The byte offset within the directory, indicating the position at which to resume the enumeration. If SMB2_INDEX_SPECIFIED is set in Flags, this value MUST be supplied and is based on the FileIndex value received in a previous enumeration response. Otherwise, it MUST be set to zero and the server MUST ignore it.

FileId (16 bytes): An SMB2_FILEID identifier of the directory on which to perform the enumeration. This is returned from an SMB2 Create Request to open a directory on the server.

FileNameOffset (2 bytes): The offset, in bytes, from the beginning of the SMB2 header to the search pattern to be used for the enumeration. This field MUST be 0 if no search pattern is provided.

FileNameLength (2 bytes): The length, in bytes, of the search pattern. This field MUST be 0 if no search pattern is provided.

OutputBufferLength (4 bytes): The maximum number of bytes the server is allowed to return in the SMB2 QUERY_DIRECTORY Response.

Buffer (variable): A variable-length buffer containing the Unicode search pattern for the request, as described by the FileNameOffset and FileNameLength fields. The format, including wildcards and other conventions for this pattern, is specified in [MS-CIFS] section 2.2.1.1.3.<77>