FILE_VALID_DATA_LENGTH_INFORMATION - NtDoc

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

/**
 * The FILE_VALID_DATA_LENGTH_INFORMATION structure is used to set the valid data length information for a file.
 * \sa https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddk/ns-ntddk-_file_valid_data_length_information
 */
typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION
{
    LARGE_INTEGER ValidDataLength;
} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;

#endif

View code on GitHub
// ntddk.h

typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
  LARGE_INTEGER ValidDataLength;
} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
View the official Windows Driver Kit DDI reference

NtDoc

This structure is documented in Windows Driver Kit.

Windows Driver Kit DDI reference (ns-ntddk-_file_valid_data_length_information)

_FILE_VALID_DATA_LENGTH_INFORMATION structure

Description

The FILE_VALID_DATA_LENGTH_INFORMATION structure is used as an argument to ZwSetInformationFile.

Members

ValidDataLength

Specifies the new valid data length for the file. This parameter must be a positive value that is greater than the current valid data length, but less than or equal to the current file size.

Remarks

The FILE_VALID_DATA_LENGTH_INFORMATION structure is used to set a new valid data length for a file on an NTFS volume. A file's valid data length is the length, in bytes, of the data that has been written to the file. This valid data extends from the beginning of the file to the last byte in the file that has not been zeroed or left uninitialized.

Setting this information requires FILE_WRITE_DATA access to the file. In addition, nonadministrators and remote users must have SeManageVolumePrivilege (SE_MANAGE_VOLUME_PRIVILEGE) for the volume on which the file resides.

File system filter drivers can find it useful to set a valid data length in the following scenarios:

The size of the FileInformation buffer passed to ZwSetInformationFile must be at least sizeof(FILE_VALID_DATA_LENGTH_INFORMATION).

This structure must be aligned on a LONGLONG (8-byte) boundary.

See also

ZwSetInformationFile