minifilter重命名

场景:

minifilter重命名文件
C/C++ code

The FILE_RENAME_INFORMATION structure is used to rename a file. 

typedef struct _FILE_RENAME_INFORMATION {
    BOOLEAN ReplaceIfExists;
    HANDLE RootDirectory;
    ULONG FileNameLength;
    WCHAR FileName[1];
} FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;


Members
ReplaceIfExists 
Set to TRUE to specify that if a file with the given name already exists, it should be replaced with the given file. Set to FALSE if the rename operation should fail if a file with the given name already exists. 
RootDirectory 
If the file is not being moved to a different directory, or if the FileName member contains the full pathname, this member is NULL. Otherwise, it is a handle for the root directory under which the file will reside after it is renamed. 
FileNameLength 
Length, in bytes, of the new name for the file. 
FileName 
The first character of a wide-character string containing the new name for the file. This is followed in memory by the remainder of the string. If the RootDirectory member is NULL, and the file is being moved to a different directory, this member specifies the full pathname to be assigned to the file. Otherwise, it specifies only the file name or a relative pathname. 

Comments
The file name string in the FileName member must be specified in one of the following forms. 

A simple file name. (The RootDirectory member is NULL.) In this case, the file is simply renamed within the same directory. That is, the rename operation changes the name of the file but not its location. 
A fully qualified file name. (The RootDirectory member is NULL.) In this case, the rename operation changes the name and location of the file. 
A relative file name. In this case, the RootDirectory member contains a handle to the target directory for the rename operation. The file name itself must be a simple file name. 



上面是WDK帮助还有这个http://www.osronline.com/custom.cfm?name=articlePrint.cfm&id=85
说的和我自己的结论的有点出入。
我试验了两种情况,
一种是直接改名,一种是移动文件的所在目录
两种情况RootDirectory都是NULL
FileName都是fully qualified file name,形如\??\C:\1\2.txt

我是在PostSetInfo里得到FILE_RENAME_INFORMATION的

PFILE_RENAME_INFORMATION fri = (PFILE_RENAME_INFORMATION) Cbd->Iopb->Parameters.SetFileInformation.InfoBuffer;

------解决方案--------------------
RootDirectory
If the file is not being moved to a different directory, or if the FileName member contains the full pathname, this member is NULL. Otherwise, it is a handle for the root directory under which the file will reside after it is renamed.