IRP_MJ_SET_INFORMATION
什么时候发送
IO管理器和其他操作系统组件,其他内核模式驱动程序发送 IRP_MJ_SET_INFORMATION 请求。例如当用户模式下的应用程序调用一个像SetEndOfFile 的微软Win32函数,或者是内核模式下的组件调用ZwSetInformationFile时会发送这个请求。
操作:文件系统驱动程序
文件系统驱动程序应当提取和解码文件对象以确定这个文件对象是否代表的是打开一个用户文件或目录。如果是,那么文件系统驱动程序应当正确处理这个请求并且完成这个IRP。
以下类型的信息(属性)可以在文件和目录上设置:
FileBasicInformation
FileDispositionInformation
FileLinkInformation (允许在目录层次中创建环形结构的文件系统???(for file systems that allow cycles to be created in the directory hierarchy))
FilePositionInformation
FileRenameInformation
以下类型的information 仅能在文件上设置:
FileAllocationInformation
FileEndOfFileInformation
FileLinkInformation (for file systems, such as NTFS, that do not allow cycles to be created in the directory hierarchy)
FileValidDataLengthInformation
操作:文件系统过滤驱动程序
文件过滤驱动必须传递这个IRP到驱动栈中的下一层驱动程序。
参数
文件系统或者文件过滤驱动程序以给定的IRP为参数调用 IoGetCurrentIrpStackLocation 获得一个此驱动程序拥有的stack location ,在下面的代码示例中是”IrpSp”。 (给定的IRP 是”Irp”) ,在处理这个IPR请求的过程中,驱动程序可以使用在IPR和IRP stack location 中设置的以下成员:
DeviceObject
指向目标设备对象的指针。
Irp->AssociatedIrp.SystemBuffer
指向一个缓冲区,它包含了将要设置的文件或者目录信息。这个信息被存放在以下结构体之一中:
FILE_VALID_DATA_LENGTH_INFORMATION
Irp->IoStatus
指向一个IO_STATUS_BLOCK结构体,它用于存放关于此请求的信息和此请求的最后完成状态。更多信息,见 ZwSetInformationFile中有关IoStatusBlock参数的详细描述。
IrpSp->FileObject
指向与DeviceObject关联的文件对象。IrpSp->FileObject参数包含了一个RelatedFileObject域,它同样也是一个FILE_OBECT类型,FILE_OBJECT的RelatedFileObject域,在IRP_MJ_SET_INFORMATION的处理过程中无效,不应当使用它。
IrpSp->MajorFunction
此参数被指定为IRP_MJ_SET_INFORMATION.
IrpSp->Parameters.SetFile.AdvanceOnly
end-of-file操作的一个标志。当FileInformationClass == FileEndOfFileInformation时,它决定了EndOfFile成员FILE_END_OF_FILE_INFORMATION 结构如何使用。 如果为TRUE, 仅当它增加当前有效数据长度时EndOfFile中设置一个新的有效数据长度。如果为FALSE,EndOfFile设置一个新的文件大小。
IrpSp->Parameters.SetFile.ClusterCount
保留给系统使用。
IrpSp->Parameters.SetFile.DeleteHandle
保留给系统使用。
IrpSp->Parameters.SetFile.FileInformationClass
指定为文件设置的信息类型,以下之一:
值 | 意义 |
FileAllocationInformation | |
FileBasicInformation | |
FileDispositionInformation | |
FileEndOfFileInformation | |
FileLinkInformation | |
FilePositionInformation | |
FileRenameInformation | |
FileValidDataLengthInformation |
IrpSp->Parameters.SetFile.FileObject
此参数用于重命名或者文件链接操作。 如果Irp->AssociatedIrp.SystemBuffer->FileName包含了一个完全限定的文件名,或者如果Irp->AssociatedIrp.SystemBuffer->RootDirectory不是一个NULL,此成员是一个文件对象,它指向了此操作目标文件的上一级目录(this member is a file object pointer for the parent directory of the file that is the target of the operation)。 否则为NULL.
IrpSp->Parameters.SetFile.Length
以字节为单位,它是Irp->AssociatedIrp.SystemBuffer的长度。
IrpSp->Parameters.SetFile.ReplaceIfExists
指定如果同名文件已经存在时重命名操作的方式,设置为TRUE用给定的文件替换原文件,如FALSE 则重命名操作应当返回失败。
Remarks
The AdvanceOnly member is set to TRUE by the cache manager to notify the file system to advance the current valid data length on the disk to the new valid data length in EndOfFile. If AdvanceOnly is FALSE, a new file size, in the EndOfFile member, is being set which can be larger or smaller than the current file size.
See also
FILE_VALID_DATA_LENGTH_INFORMATION