ZwQueryQuotaInformationFile function (ntifs.h)

The ZwQueryQuotaInformationFile routine retrieves quota entries associated with the volume specified by the FileHandle parameter.

Syntax

NTSYSAPI NTSTATUS ZwQueryQuotaInformationFile(
  [in]           HANDLE           FileHandle,
  [out]          PIO_STATUS_BLOCK IoStatusBlock,
  [out]          PVOID            Buffer,
  [in]           ULONG            Length,
  [in]           BOOLEAN          ReturnSingleEntry,
  [in, optional] PVOID            SidList,
  [in]           ULONG            SidListLength,
  [in, optional] PSID             StartSid,
  [in]           BOOLEAN          RestartScan
);

Parameters

[in] FileHandle

A handle for the file object that represents the file or volume for which the quota information is requested.

[out] IoStatusBlock

The address of the caller's I/O status block.

[out] Buffer

A buffer to receive the quota information for the volume. The quota information is formatted as one or more FILE_QUOTA_INFORMATION structures. The NextEntryOffset field in the FILE_QUOTA_INFORMATION structure contains the offset, in bytes, of the next quota entry in the list. If there are no more entries after the current one, this member is zero.

[in] Length

The length in bytes of the buffer.

[in] ReturnSingleEntry

A Boolean value that indicates if only a single entry should be returned rather than filling the buffer with as many entries as possible.

[in, optional] SidList

An optional list of SIDs whose quota information is to be returned. Each entry in the list is a FILE_GET_QUOTA_INFORMATION structure. The NextEntryOffset field in the FILE_GET_QUOTA_INFORMATION structure contains the offset, in bytes, of the next quota entry in the list. If there are no more entries after the current one, this member is zero.

[in] SidListLength

The length in bytes of the SID list, if one was specified.

[in, optional] StartSid

An optional pointer to the SID of the entry at which to begin scanning the quota information. This parameter should be set if the returned information is to start with an entry other than the first SID. This parameter is ignored if a SidList parameter is specified.

[in] RestartScan

A Boolean value that indicates whether the scan of the quota information is to be restarted from the beginning. Set this parameter to TRUE if the scan of the quota information is to start at the first entry in the volume's quota information list. Set to FALSE if resuming the scan from a previous call to ZwQueryQuotaInformationFile. The caller must set this parameter to TRUE when calling ZwQueryQuotaInformationFile for the first time.

Return value

The ZwQueryQuotaInformationFile routine returns STATUS_SUCCESS if at least one FILE_QUOTA_INFORMATION structure is returned in the Buffer parameter or an appropriate NTSTATUS value such as one of the following:

Return code Description
STATUS_INSUFFICIENT_RESOURCES There were insufficient resources to complete the operation. This is an error code.
STATUS_INVALID_DEVICE_REQUEST Quotas are not enabled on the volume. This is an error code.
STATUS_INVALID_SID The StartSid parameter did not contain a valid SID. This is an error code.
STATUS_QUOTA_LIST_INCONSISTENT The SidList parameter did not contain a valid, properly formed list. This is an error code.

Remarks

The amount of information returned by ZwQueryQuotaInformationFile is based on the size of the quota information associated with the volume, the size of the buffer, and whether a specific set of entries has been requested.

A call to ZwQueryQuotaInformationFile will result in an IRP_MJ_SET_QUOTA request being sent to the device object that is associated with the file object whose handle is stored in the FileHandle parameter.

If the underlying file system does not support quota information (FAT and CDFS file systems, for example), ZwQueryQuotaInformationFile will fail returning STATUS_INVALID_DEVICE_REQUEST.

Note

If the call to the ZwQueryQuotaInformationFile function occurs in user mode, you should use the name "NtQueryQuotaInformationFile" instead of "ZwQueryQuotaInformationFile".

For calls from kernel-mode drivers, the NtXxx and ZwXxx versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the NtXxx and ZwXxx versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.

Requirements

Requirement Value
Minimum supported client Windows 7
Target Platform Universal
Header ntifs.h (include Ntifs.h, FltKernel.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL PASSIVE_LEVEL
DDI compliance rules HwStorPortProhibitedDDIs(storport), PowerIrpDDis(wdm)

See also

FILE_GET_QUOTA_INFORMATION

FILE_QUOTA_INFORMATION

IO_STATUS_BLOCK

IRP_MJ_QUERY_QUOTA

IRP_MJ_SET_QUOTA

IoCheckQuotaBufferValidity

Using Nt and Zw Versions of the Native System Services Routines

ZwSetQuotaInformationFile