Hi All,
I am trying to rename file in PostCleanup operation. For that I open the file handle and call FltSetInformationFile. But it fails with error code STATUS_ACCESS_DENIED.
InitializeObjectAttributes(
&ObjectAttribs,
(PUNICODE_STRING)pFilePath,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
0,
0
);
NTStatus = FltCreateFileEx(
s_filter->GetInstance(),
pVolume->GetInstance(),
&hFileHandle,
&pFileObject,
FILE_GENERIC_READ | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES,
&ObjectAttribs,
&IoStatus,
0,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FO_NO_INTERMEDIATE_BUFFERING,
0,
0,
0
);
if (!NT_SUCCESS(NTStatus))
{
__leave;
}
//
// Some Code
//
status = FltSetInformationFile(
pVolume->GetInstance(),
pFileObject,
renameInfo,
renameFileLength,
FileRenameInformation);
if (!NT_SUCCESS(status))
{
__leave;
}
Here I exclusively open the same file for which PostCleanup is called and then I try to rename it using FltSetInformationFile. Not sure why FltSetInformationFile should fail with error code STATUS_ACCESS_DENIED. If anyone have any pointers, please let me know.
Thanks & Regards,
Amit Kulkarni.