NtSetQuotaInformationFile - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTIOAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetQuotaInformationFile(
    _In_ HANDLE FileHandle,
    _Out_ PIO_STATUS_BLOCK IoStatusBlock,
    _In_reads_bytes_(Length) PVOID Buffer,
    _In_ ULONG Length
    );

#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwSetQuotaInformationFile(
    _In_ HANDLE FileHandle,
    _Out_ PIO_STATUS_BLOCK IoStatusBlock,
    _In_reads_bytes_(Length) PVOID Buffer,
    _In_ ULONG Length
    );

#endif

View code on GitHub
// ntifs.h

__kernel_entry NTSYSCALLAPI NTSTATUS NtSetQuotaInformationFile(
  [in]  HANDLE           FileHandle,
  [out] PIO_STATUS_BLOCK IoStatusBlock,
  [in]  PVOID            Buffer,
  [in]  ULONG            Length
);

View the official Windows Driver Kit DDI reference
// ntifs.h

NTSYSAPI NTSTATUS ZwSetQuotaInformationFile(
  [in]  HANDLE           FileHandle,
  [out] PIO_STATUS_BLOCK IoStatusBlock,
  [in]  PVOID            Buffer,
  [in]  ULONG            Length
);

View the official Windows Driver Kit DDI reference

NtDoc

This function is documented in Windows Driver Kit here and here.

Windows Driver Kit DDI reference (nf-ntifs-ntsetquotainformationfile)

NtSetQuotaInformationFile function

Description

The NtSetQuotaInformationFile routine changes quota entries for the volume associated with the FileHandle parameter. All of the quota entries in the specified buffer are applied to the volume.

Parameters

FileHandle [in]

A handle for the file object that represents the file or volume for which the quota information is to be modified.

IoStatusBlock [out]

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

Buffer [in]

A buffer containing the new quota entries that should be applied to the volume. The quota information must be 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 [in]

The length in bytes of the buffer.

Return value

The NtSetQuotaInformationFile routine returns STATUS_SUCCESS 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_MEDIA_WRITE_PROTECTED The volume is read only. This is an error code.

Remarks

The NtSetQuotaInformationFile routine applies all of the quota entries in the specified Buffer parameter to the volume.

The IoCheckQuotaBufferValidity function can check whether the specified quota buffer passed as the Buffer parameter is valid.

A call to NtSetQuotaInformationFile 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), NtSetQuotaInformationFile will fail returning STATUS_INVALID_DEVICE_REQUEST.

[!NOTE] If the call to the NtSetQuotaInformationFile function occurs in kernel mode, you should use the name "ZwSetQuotaInformationFile" instead of "NtSetQuotaInformationFile".

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.

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

NtQueryQuotaInformationFile


Windows Driver Kit DDI reference (nf-ntifs-zwsetquotainformationfile)

ZwSetQuotaInformationFile function

Description

The ZwSetQuotaInformationFile routine changes quota entries for the volume associated with the FileHandle parameter. All of the quota entries in the specified buffer are applied to the volume.

Parameters

FileHandle [in]

A handle for the file object that represents the file or volume for which the quota information is to be modified.

IoStatusBlock [out]

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

Buffer [in]

A buffer containing the new quota entries that should be applied to the volume. The quota information must be 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 [in]

The length in bytes of the buffer.

Return value

The ZwSetQuotaInformationFile routine returns STATUS_SUCCESS 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_MEDIA_WRITE_PROTECTED The volume is read only. This is an error code.

Remarks

The ZwSetQuotaInformationFile routine applies all of the quota entries in the specified Buffer parameter to the volume.

The IoCheckQuotaBufferValidity function can check whether the specified quota buffer passed as the Buffer parameter is valid.

A call to ZwSetQuotaInformationFile 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), ZwSetQuotaInformationFile will fail returning STATUS_INVALID_DEVICE_REQUEST.

[!NOTE] If the call to the ZwSetQuotaInformationFile function occurs in user mode, you should use the name "NtSetQuotaInformationFile" instead of "ZwSetQuotaInformationFile".

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.

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

ZwQueryQuotaInformationFile