FltSetInformationFile returns c0000033

Hi,
While renaming a file, i am getting error code c0000033
-STATUS_OBJECT_NAME_INVALID. (FltSetInformationFile returns)

source file name : D:\1.txt
Trying to Rename it as : D:\2.txt

Can anyone help me to resolve this problem?

Here is my sample code

void TestRename(PFLT_CALLBACK_DATA FltCallBackData)
{

NTSTATUS status;
OBJECT_ATTRIBUTES FileAttribute;
UNICODE_STRING FileName;
HANDLE FileHandle;
IO_STATUS_BLOCK IoStatusBlock;

//DbgBreakPoint();

RtlInitUnicodeString( &FileName , L"\??\D:\1.txt");
DbgPrint(“Test file name = %wZ\n”, &FileName );

InitializeObjectAttributes( &FileAttribute,
&FileName,
OBJ_CASE_INSENSITIVE | KERNEL_HANDLE,
NULL, NULL );

status = FltCreateFile( g_FileBackupFilterInfo.m_pFilter,
FltCallBackData->Iopb->TargetInstance,
&FileHandle, GENERIC_WRITE|DELETE,

&FileAttribute, &IoStatusBlock, NULL, 0,
0, FILE_OPEN, FILE_SYNCHRONOUS_IO_ALERT, NULL, 0, IO_IGNORE_SHARE_ACCESS_CHECK
);

if ( NT_SUCCESS( status ) )
{
DbgPrint(“File opened successfull \n”);
FILE_RENAME_INFORMATION * m_pFileRename;

size_t TotalSize = sizeof(FILE_RENAME_INFORMATION) + sizeof(L"2.txt");
size_t FileNameSize = sizeof(L"2.txt");

//DbgPrint(“Total Buffer Size = %d\n”, TotalSize );

m_pFileRename = (FILE_RENAME_INFORMATION *) ExAllocatePool(
PagedPool, TotalSize );

RtlZeroMemory( m_pFileRename, TotalSize );

m_pFileRename->ReplaceIfExists = TRUE;
m_pFileRename->RootDirectory = NULL;
m_pFileRename->FileNameLength = FileNameSize;

//DbgPrint(“File name length = %d\n”, m_pFileRename->FileNameLength);

wcscpy(&m_pFileRename->FileName[0],L"2.txt");

DbgPrint(“copied file name = %ws\n”, m_pFileRename->FileName );

PFILE_OBJECT tempFileObject = NULL;

status = ObReferenceObjectByHandle( FileHandle,
GENERIC_WRITE|DELETE,
*IoFileObjectType, KernelMode, (PVOID
*)&tempFileObject, NULL );

if (NT_SUCCESS( status ) )
{

DbgPrint(“Handle converted successfull\n”);

status = FltSetInformationFile(
FltCallBackData->Iopb->TargetInstance, tempFileObject,
m_pFileRename, TotalSize, FileRenameInformation );

if ( NT_SUCCESS( status ))
DbgPrint(“FltSetInformation succeeds\n”);
else
DbgPrint(“FltSetInformation couldn’t able succeed =
%08x\n”, status );

ObDereferenceObject( tempFileObject );
}
else
DbgPrint(“Object convertion failed = %08x\n”,status );
FltClose( FileHandle );

}
else
DbgPrint(“Faied to open the file = %08x\n”,status );

}

Regards,
Murali

Hi,

Sorry, my previous post format was poor to read. So, i am resending again.

While renaming a file, i am getting error code c0000033

-STATUS_OBJECT_NAME_INVALID. (FltSetInformationFile returns)

source file name : D:\1.txt

Trying to Rename it as : D:\2.txt

Can anyone help me to resolve this problem?

Here is my sample code

void TestRename(PFLT_CALLBACK_DATA FltCallBackData)

{

NTSTATUS status;

OBJECT_ATTRIBUTES FileAttribute;

UNICODE_STRING FileName;

HANDLE FileHandle;

IO_STATUS_BLOCK IoStatusBlock;

//DbgBreakPoint();

RtlInitUnicodeString( &FileName , L"\??\D:\1.txt");

DbgPrint(“Test file name = %wZ\n”, &FileName );

InitializeObjectAttributes( &FileAttribute,

&FileName,

OBJ_CASE_INSENSITIVE | KERNEL_HANDLE,

NULL, NULL );

status = FltCreateFile( g_FileBackupFilterInfo.m_pFilter,

FltCallBackData->Iopb->TargetInstance,

&FileHandle,

GENERIC_WRITE|DELETE,

&FileAttribute,

&IoStatusBlock,

NULL,

0,

0,

FILE_OPEN,

FILE_SYNCHRONOUS_IO_ALERT,

NULL,

0,

IO_IGNORE_SHARE_ACCESS_CHECK);

if ( NT_SUCCESS( status ) )

{

DbgPrint(“File opened successfull \n”);

FILE_RENAME_INFORMATION * m_pFileRename;

size_t TotalSize = sizeof(FILE_RENAME_INFORMATION) + sizeof(L"
2.txt");

size_t FileNameSize = sizeof(L"2.txt");

//DbgPrint(“Total Buffer Size = %d\n”, TotalSize );

m_pFileRename = (FILE_RENAME_INFORMATION *)
ExAllocatePool(PagedPool, TotalSize );

RtlZeroMemory( m_pFileRename, TotalSize );

m_pFileRename->ReplaceIfExists = TRUE;

m_pFileRename->RootDirectory = NULL;

m_pFileRename->FileNameLength = FileNameSize;

//DbgPrint(“File name length = %d\n”, m_pFileRename->FileNameLength);

wcscpy(&m_pFileRename->FileName[0],L"2.txt");

DbgPrint(“copied file name = %ws\n”, m_pFileRename->FileName );

PFILE_OBJECT tempFileObject = NULL;

status = ObReferenceObjectByHandle( FileHandle,

GENERIC_WRITE|DELETE,

*IoFileObjectType,

KernelMode, (PVOID*)&tempFileObject,

NULL );

if (NT_SUCCESS( status ) )

{

DbgPrint(“Handle converted successfull\n”);

status = FltSetInformationFile( FltCallBackData->Iopb->TargetInstance,

tempFileObject,

m_pFileRename,

TotalSize,

FileRenameInformation );

if ( NT_SUCCESS( status ))

DbgPrint(“FltSetInformation succeeds\n”);

else

DbgPrint(“FltSetInformation couldn’t able succeed =
%08x\n”, status );

ObDereferenceObject( tempFileObject );

}

else

DbgPrint(“Object convertion failed = %08x\n”,status
);

FltClose( FileHandle );

}

else

DbgPrint(“Faied to open the file = %08x\n”,status );

}

Regards

Murali

I got side tracked by the apparant space in the HTML version of

size_t FileNameSize = sizeof(L"2.txt");

But I see that that isn’t there in reality. However I you appear to be
adding a trailing null (unicode point 0) to your destination string “2.txt”.
Some filesystems might complain at that. I’d try

FileNameSize -= sizeof(WCHAR);

and see what happens…

Rod,

Thanks for your help. Yes it works fine with your fix.

Regards
Murali

On 6/5/06, Rod Widdowson wrote:
>
> I got side tracked by the apparant space in the HTML version of
>
> size_t FileNameSize = sizeof(L"2.txt");
>
> But I see that that isn’t there in reality. However I you appear to be
> adding a trailing null (unicode point 0) to your destination string "2.txt
> ".
> Some filesystems might complain at that. I’d try
>
> FileNameSize -= sizeof(WCHAR);
>
> and see what happens…
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>