ZwQueryInformationFile 函数

news/2024/7/4 10:29:28

 ZwQueryInformationFile 函数
The ZwQueryInformationFile routine returns various kinds of information about a given file object.

NTSTATUS
  ZwQueryInformationFile(
    IN HANDLE  FileHandle,
    OUT PIO_STATUS_BLOCK  IoStatusBlock,
    OUT PVOID  FileInformation,
    IN ULONG  Length,
    IN FILE_INFORMATION_CLASS  FileInformationClass
    );
Parameters
FileHandle
Handle to a file object. The handle is created by a successful call to ZwCreateFile or ZwOpenFile.
IoStatusBlock
Pointer to a variable that receives the final completion status and information about the operation.
FileInformation
Pointer to a caller-allocated buffer or variable that receives the desired information about the file. The contents of FileInformation are defined by the FileInformationClass parameter, described later.
Length
Specifies the size in bytes of FileInformation, which the caller should set according to the given FileInformationClass.
FileInformationClass
Specifies the type of information to be returned about the file, in the buffer specified by FileInformation. Device and intermediate drivers, can specify any of the following. FileInformationClass Value Meaning
FileAlignmentInformation Return a FILE_ALIGNMENT_INFORMATION structure. The caller can query this information as long as the file is open, without any particular requirements for DesiredAccess. This information is useful if the file was opened with the CreateOptions FILE_NO_INTERMEDIATE_BUFFERING flag set.
FileAttributeTagInformation Returns a FILE_ATTRIBUTE_TAG_INFORMATION structure. The caller must have opened the file with the DesiredAccess FILE_READ_ATTRIBUTES flag set.
FileBasicInformation Return a FILE_BASIC_INFORMATION structure. The caller must have opened the file with the DesiredAccess FILE_READ_ATTRIBUTES flag set.
FileNameInformation Return a FILE_NAME_INFORMATION structure. This might include the full file path or only a portion of the path.
See the comments below for details on the file name syntax.
FileNetworkOpenInformation Return a FILE_NETWORK_OPEN_INFORMATION structure. The caller must have opened the file with the DesiredAccess FILE_READ_ATTRIBUTES flag set.
FilePositionInformation Return a FILE_POSITION_INFORMATION structure. 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.
FileStandardInformation Return a FILE_STANDARD_INFORMATION structure. The caller can query this information as long as the file is open, without any particular requirements for DesiredAccess.


Return Value
ZwQueryInformationFile returns STATUS_SUCCESS or an appropriate error status. It also returns the number of bytes actually written to the given FileInformation buffer in the Information member of IoStatusBlock.

Headers
Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.

Comments
ZwQueryInformationFile returns information about the given file. Note that it returns zero in any member of a FILE_XXX_INFORMATION structure that is not supported by a particular device or file system.

When FileInformationClass equals FileNameInformation, the file name is returned in the FILE_NAME_INFORMATION structure. The precise syntax of the file name depends on a number of factors:

If the file was opened by submitting a full path and file name to ZwCreateFile, then ZwQueryInformationFile returns that full path and file name.

If the ObjectAttributes->RootDirectory handle was opened by name in a call to ZwCreateFile, and subsequently the file was opened by ZwCreateFile relative to this root directory handle, then the full path and file name are returned.

If the ObjectAttributes->RootDirectory handle was opened by file ID (using the FILE_OPEN_BY_FILE_ID flag) in a call to ZwCreateFile, and subsequently the file was opened by ZwCreateFile relative to this root directory handle, then only the relative path will be returned.

However, if the user has SeChangeNotifyPrivilege (described in Platform SDK documentation), the full path and file name will be returned in all cases.

If only the relative path is returned, the file name string will not begin with a backslash.

If the full path and file name are returned, the string will begin with a single backslash, regardless of its location. Thus the file C:/dir1/dir2/filename.ext will appear as /dir1/dir2/filename.ext, while the file //server/share/dir1/dir2/filename.ext will appear as /server/share/dir1/dir2/filename.ext.

Callers of ZwQueryInformationFile must be running at IRQL = PASSIVE_LEVEL.

See Also
FILE_ALIGNMENT_INFORMATION, FILE_ATTRIBUTE_TAG_INFORMATION, FILE_BASIC_INFORMATION, FILE_NAME_INFORMATION, FILE_NETWORK_OPEN_INFORMATION, FILE_POSITION_INFORMATION, FILE_STANDARD_INFORMATION, ZwCreateFile, ZwSetInformationFile

Built on Friday, April 11, 2003 

来源:http://www.osronline.com/DDKx/kmarch/k111_9pyq.htm


http://www.niftyadmin.cn/n/1995594.html

相关文章

Tapestry在静态页面和动态内容分工方面的研究

Tapestry在静态页面和动态内容分工方面的研究 Tapestry的一个最耀眼的功能是其绝好的模板设计思想,它能够将动态内容以极少的侵入性而展现到HTML页面上,我对其这一功能非常赞赏,如果 Tapestry能够像Spring那样把这一部分HTML模板解析功能独立…

java树形菜单制作

java树形菜单制作用到的技术代码实现用到的技术 SpringMVCSpringmybatiseasyui 代码实现 dto(适用于easyui的实体类) package com.grand.orgn.dto;import java.util.HashMap; import java.util.Map;/*** * author * 适用于easyUI树形结构的实体类* d…

文件-进程关联演示程序(出自CVC)

文件-进程关联演示程序(出自CVC)1、首先使用ZwQuerySystemInformation查询所有进程句柄,2、获取句柄所代表对象信息,查出目标文件。核心态程序相对简单,对于用户态程序,使用ZwQueryInformationFile同时与GetFileInformationByHand…

Tapestry中配置文件page的简化处理

Tapestry中配置文件page的简化处理 Tapestry每个页面基本上都需要一个.page的配置文件,因为需要对模板HTML的动态内容部分进行配置,这是为静态页面和动态内容更好的分工,确实需要这么做。但是,每个page文件的典型配置如下&#x…

关于由HANDLE获取文件名的问题

问题:关于由HANDLE获取文件名的问题 PFILE_NAME_INFORMATION pfni; pfni(PFILE_NAME_INFORMATION)ExAllocatePool(PagedPool, sizeof(FILE_NAME_INFORMATION) 255 * sizeof(WCHAR) ); memset(pfni,0,sizeof(FILE_NAME_INFORMATION) …

AngularJS controller调用factory

1、定义 factory.js 文件 var appFactorys angular.module(starter.factorys, []) appFactorys.factory(HouseFactory, function () {var houseList [{ id: 0, title: 急售北二环 小区配套齐全 精装修, price: 88.0, describe: 2室1厅 120平米, img: img/ben.png },{ id: 1, …

Tapestry中Sumbit/ImageSubmit的属性selected和tag

Tapestry中Sumbit/ImageSubmit的属性selected和tag 个人认为Submit/ImageSubmit标准组件的两个属性selected和tag的设置比较罗嗦,可能是性能和灵活性的一种权衡吧。其中,selected指定页面类的一个属性,tag设置该页面属性的值。selected和tag…

centos虚拟机无法上网

centos虚拟机无法上网解决办法解决办法 首先确保使用的是nat模式 修改vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICEeth0 HWADDR00:0C:29:8D:E6:73 TYPEEthernet UUIDa81ecb00-6b42-4ff4-8895-170ab7a2672a ONBOOTyes #开机启动 NM_CONTROLLEDyes BOOTPROTOstatic# 修…