;**************************************************************************************************
include w2k\ntstatus.inc
include w2k\ntddk.inc
include w2k\ntoskrnl.inc
includelib ntoskrnl.lib
include Strings.mac
ZwSetInformationFile
The ZwSetInformationFile routine changes various kinds of information about a file object.
NTSTATUS
ZwSetInformationFile(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass
);
Parameters
FileHandle
Handle to the file object. This handle is created by a successful call to ZwCreateFile or ZwOpenFile.
IoStatusBlock
Pointer to an IO_STATUS_BLOCK structure that receives the final completion status and information about the requested operation. The Information member receives the number of bytes set on the file.
FileInformation
Pointer to a buffer that contains the information to set for the file. The particular structure in this buffer is determined by the FileInformationClass parameter. Setting any member of the structure to zero tells ZwSetInformationFile to leave the current information about the file for that member unchanged.
Length
The size, in bytes, of the FileInformation buffer.
FileInformationClass
The type of information, supplied in the buffer pointed to by FileInformation, to set for the file. Device and intermediate drivers can specify any of the following values.FileInformationClass Value Meaning
FileBasicInformation Change the information that is supplied in a FILE_BASIC_INFORMATION structure. The caller must have opened the file with the FILE_WRITE_ATTRIBUTES flag set in the DesiredAccess parameter.
FileDispositionInformation Usually, sets the DeleteFile member of a FILE_DISPOSITION_INFORMATION to TRUE, so the file can be deleted when ZwClose is called to release the last open handle to the file object. The caller must have opened the file with the DELETE flag set in the DesiredAccess parameter.
FileEndOfFileInformation Change the current end-of-file information, supplied in a FILE_END_OF_FILE_INFORMATION structure. The operation can either truncate or extend the file. The caller must have opened the file with the FILE_WRITE_DATA flag set in the DesiredAccess parameter.
FileIoPriorityHintInformation Change the current default IRP priority hint for the file handle. The new value is supplied in a FILE_IO_PRIORITY_HINT_INFORMATION structure.
Note This structure must be 8-byte aligned.
FilePositionInformation Change the current file information, which is stored in a FILE_POSITION_INFORMATION structure.
FileShortNameInformation Change the current short file name, which is supplied in a FILE_NAME_INFORMATION structure. The file must be on an NTFS volume, and the caller must have opened the file with the DesiredAccess DELETE flag set in the DesiredAccess parameter.
FileValidDataLengthInformation Change the current valid data length for the file, which is supplied in a FILE_VALID_DATA_LENGTH_INFORMATION structure. The file must be on an NTFS volume, and the caller must have opened the file with the FILE_WRITE_DATA flag set in the DesiredAccess parameter. Nonadministrators and remote users must have the SeManageVolumePrivilege privilege.
Return Value
ZwSetInformationFile returns STATUS_SUCCESS or an appropriate error status.
Headers
Declared in ntddk.h. Include ntddk.h.
Comments
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.
If you set FileInformationClass to FileDispositionInformation, you can subsequently pass FileHandle to ZwClose but not to any other ZwXxxFile routine. Because FileDispositionInformation causes the file to be marked for deletion, it is a programming error to attempt any subsequent operation on the handle other than closing it.
If you set FileInformationClass to FilePositionInformation, and the preceding call to ZwCreateFile included the FILE_NO_INTERMEDIATE_BUFFERING flag in the CreateOptions parameter, certain restrictions on the CurrentByteOffset member of the FILE_POSITION_INFORMATION structure are enforced. For more information, see ZwCreateFile.
If you set FileInformationClass to FileEndOfFileInformation, and the EndOfFile member of FILE_END_OF_FILE_INFORMATION specifies an offset beyond the current end-of-file mark, ZwSetInformationFile extends the file and pads the extension with zeros.
For more information about working with files, see Using Files in a Driver.
Callers of ZwSetInformationFile must be running at IRQL = PASSIVE_LEVEL and with APCs enabled.
See Also
FILE_BASIC_INFORMATION, FILE_DISPOSITION_INFORMATION, FILE_END_OF_FILE_INFORMATION, FILE_NAME_INFORMATION, FILE_POSITION_INFORMATION, FILE_VALID_DATA_LENGTH_INFORMATION, ZwCreateFile, ZwQueryInformationFile