NTSTATUS
ZwSetInformationFile(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass
);
ZwSetInformationFile changes various kinds of information about a given file object.
FileInformationClass Value |
Meaning |
FileBasicInformation |
Change FILE_BASIC_INFORMATION about the file. The caller must have opened the file with the DesiredAccess FILE_WRITE_ATTRIBUTES flag set. |
FileDispositionInformation |
Usually, sets DeleteFile in FILE_DISPOSITION_INFORMATION to TRUE, so the file can be deleted when ZwClose is called to release the last open handle for the file object. The caller must have opened the file with the DesiredAccess DELETE flag set. |
FilePositionInformation |
Change the current FILE_POSITION_INFORMATION for the file. The caller must have opened the file with the DesiredAccess FILE_READ_DATA or FILE_WRITE_DATA flag set and with either of the CreateOptions FILE_SYNCHRONOUS_IO_ALERT or FILE_SYNCHRONOUS_IO_NONALERT. |
FileEndOfFileInformation |
Change the current FILE_END_OF_FILE_INFORMATION for the file: either truncate or extend the amount of valid data in the file by moving the current end-of-file position. The caller must have opened the file with the DesiredAccess FILE_WRITE_DATA flag set. |
ZwSetInformationFile returns STATUS_SUCCESS or an appropriate error status. It also returns the number of bytes set on the file in the Information member of IoStatusBlock.
ZwSetInformationFile changes information about a file. It ignores any member of a FILE_XXX_INFORMATION structure that is not supported by a particular device or file system. For example, the FAT file system does not support file-creation times, so ZwSetInformationFile ignores the CreationTime member of the FILE_BASIC_INFORMATION structure when it is called to change basic file information for files on a FAT partition.
A caller that sets FileInformationClass to FileDispositionInformation can pass the FileHandle subsequently to ZwClose but to no other Zw..File routine. On return from ZwSetInformationFile, the file has been marked for deletion. It is a programming error to attempt any subsequent operation on the open file except closing it.
If the the caller sets FileInformationClass to FilePositionInformation and the preceding call to ZwCreateFile set the CreateOptions flag FILE_NO_INTERMEDIATE_BUFFERING, certain restrictions on the input FILE_POSITION_INFORMATION CurrentByteOffset are enforced. See ZwCreateFile for specifics.
If the caller sets FileInformationClass to FileEndOfFileInformation and the input FILE_END_OF_FILE_INFORMATION EndOfFile value specifies an offset beyond the current end-of-file mark, ZwSetInformationFile extends the file and writes pad bytes of zeroes between the old and new end-of-file marks.
Callers of ZwSetInformationFile must be running at IRQL PASSIVE_LEVEL.
FILE_BASIC_INFORMATION, FILE_DISPOSITION_INFORMATION, FILE_END_OF_FILE_INFORMATION, FILE_POSITION_INFORMATION, ZwCreateFile, ZwQueryInformationFile