NtQueryQuotaInformationFile function

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

Syntax

__kernel_entry NTSYSCALLAPI NTSTATUS NtQueryQuotaInformationFile(
  HANDLE           FileHandle,
  PIO_STATUS_BLOCK IoStatusBlock,
  PVOID            Buffer,
  ULONG            Length,
  BOOLEAN          ReturnSingleEntry,
  PVOID            SidList,
  ULONG            SidListLength,
  PSID             StartSid,
  BOOLEAN          RestartScan
);

Parameters

FileHandle

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

IoStatusBlock

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

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.

Length

The length in bytes of the buffer.

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.

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.

SidListLength

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

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.

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 NtQueryQuotaInformationFile. The caller must set this parameter to TRUE when calling NtQueryQuotaInformationFile for the first time.

Return Value

The NtQueryQuotaInformationFile 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 NtQueryQuotaInformationFile 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 NtQueryQuotaInformationFile will result in an IRP_MJ_QUERY_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), NtQueryQuotaInformationFile will fail returning STATUS_INVALID_DEVICE_REQUEST.

Note If the call to the NtQueryQuotaInformationFile 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

   
Windows version Available in Windows 7 and later versions of Windows operating systems.
Target Platform Universal
Header ntifs.h (include Ntifs.h, FltKernel.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL PASSIVE_LEVEL
DDI compliance rules PowerIrpDDis, HwStorPortProhibitedDDIs

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