Hi,
I have run into following rename implementation issue in my Filter Driver
(NTFS). Any help to solve this would be deeply appreciated. I keep gettting
STATUT_OBJECT_NAME_INVALID when IRP returns. Have read OSR article on Rename
but looks like I am still doing something wrong here.
Thanks.
Regards
Vikas
Goal: Rename “D:\Test\foo.txt” to “D:\Test\MyDir\foo2.txt”
Code Logic:
Allocate Buffer=sizeof (FILE_RENAME_INFORMATION) + (sizeof the wchar
“??\D:\Test\MyDir\foo2.txt” )
Copied the WCHAR string “??\D:\Test\MyDir\foo2.txt” at Buffer->FileName,
set all other fields appropriately.
Call ZwOpenFile get the handle of ??\D:\Test\foo.txt (call it MyFile)
Call ZwOpenFile get the handle of directory ??\D:\Test\MyDir (call it
TargetDir)
Call ObReferenceObjectByHandle to get the file objects for MyFile and
TargetDir, call it FileObject and DirObject Respectively.
Allocate IRP and do following:
DeviceExt = (PMY_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
NewIrp = IoAllocateIrp (DeviceExt->AttachedToDeviceObject->StackSize,
FALSE);
if(NewIrp == NULL)
{
KdPrint((“SetFileInformation: IoAllocateIrp failed\n”));
return STATUS_INSUFFICIENT_RESOURCES;
}
KdPrint((“SetFileInformation: SetFile <%Z>, FileObject <%Z> \n”,
&(DirFileObject->FileName), &(FileObject->FileName)));
KdPrint((“SetFileInformation: RenInfo->FileName <%S>…\n”,
((PFILE_RENAME_INFORMATION) Buffer)->FileName));
NewIrpSp = IoGetNextIrpStackLocation (NewIrp);
// Initialize the new Irp
NewIrp->AssociatedIrp.SystemBuffer = Buffer;
NewIrp->Flags = IRP_BUFFERED_IO;
NewIrp->RequestorMode = KernelMode;
NewIrp->Tail.Overlay.Thread = PsGetCurrentThread ();
// Initialize the new stack location
NewIrpSp->MajorFunction =IRP_MJ_SET_INFORMATION;
NewIrpSp->MinorFunction =0;
NewIrpSp->Flags = 0;
NewIrpSp->FileObject = FileObject;
NewIrpSp->DeviceObject = DeviceExt->AttachedToDeviceObject;
NewIrpSp->Parameters.SetFile.FileInformationClass =
FileRenameInformation;
NewIrpSp->Parameters.SetFile.Length = BuffLen;
NewIrpSp->Parameters.SetFile.ReplaceIfExists = TRUE;
NewIrpSp->Parameters.SetFile.FileObject = DirObject;
KeInitializeEvent (&WaitEvent, NotificationEvent, FALSE);
IoSetCompletionRoutine (NewIrp, SetFileInformationCompletion,
&WaitEvent,TRUE, TRUE, TRUE);
Status = IoCallDriver (DeviceExt->AttachedToDeviceObject, NewIrp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject (&WaitEvent, Executive, KernelMode, FALSE,
NULL);
}
Status = NewIrp->IoStatus.Status;
if (Status == STATUS_SUCCESS)
{
KdPrint ((“SetFileInformation: IoCallDriver Success\n”));
}
else
{
KdPrint ((“SetFileInformation: IoCallDriver failed (%X)\n”,
Status)); //Keeps printing STATUT_OBJECT_NAME_INVALID
}
IoFreeIrp (NewIrp);
return Status;
Gents,
Please disregard, Found some great stuff in the NTFSD archive and have
solution to this.
Regrads
Vikas
Agglut Technologies, Inc.
2140 Peralta Blvd #213-D
Fremont, CA 94536
510 793 4504 (o)
408 910 8570 (c)
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Vikas Ratna
Sent: Thursday, October 02, 2003 11:52 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] RENAME - C0000033
Hi,
I have run into following rename implementation issue in my Filter Driver
(NTFS). Any help to solve this would be deeply appreciated. I keep gettting
STATUT_OBJECT_NAME_INVALID when IRP returns. Have read OSR article on Rename
but looks like I am still doing something wrong here.
Thanks.
Regards
Vikas
Goal: Rename “D:\Test\foo.txt” to “D:\Test\MyDir\foo2.txt”
Code Logic:
Allocate Buffer=sizeof (FILE_RENAME_INFORMATION) + (sizeof the wchar
“??\D:\Test\MyDir\foo2.txt” )
Copied the WCHAR string “??\D:\Test\MyDir\foo2.txt” at Buffer->FileName,
set all other fields appropriately.
Call ZwOpenFile get the handle of ??\D:\Test\foo.txt (call it MyFile)
Call ZwOpenFile get the handle of directory ??\D:\Test\MyDir (call it
TargetDir)
Call ObReferenceObjectByHandle to get the file objects for MyFile and
TargetDir, call it FileObject and DirObject Respectively.
Allocate IRP and do following:
DeviceExt = (PMY_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
NewIrp = IoAllocateIrp (DeviceExt->AttachedToDeviceObject->StackSize,
FALSE);
if(NewIrp == NULL)
{
KdPrint((“SetFileInformation: IoAllocateIrp failed\n”));
return STATUS_INSUFFICIENT_RESOURCES;
}
KdPrint((“SetFileInformation: SetFile <%Z>, FileObject <%Z> \n”,
&(DirFileObject->FileName), &(FileObject->FileName)));
KdPrint((“SetFileInformation: RenInfo->FileName <%S>…\n”,
((PFILE_RENAME_INFORMATION) Buffer)->FileName));
NewIrpSp = IoGetNextIrpStackLocation (NewIrp);
// Initialize the new Irp
NewIrp->AssociatedIrp.SystemBuffer = Buffer;
NewIrp->Flags = IRP_BUFFERED_IO;
NewIrp->RequestorMode = KernelMode;
NewIrp->Tail.Overlay.Thread = PsGetCurrentThread ();
// Initialize the new stack location
NewIrpSp->MajorFunction =IRP_MJ_SET_INFORMATION;
NewIrpSp->MinorFunction =0;
NewIrpSp->Flags = 0;
NewIrpSp->FileObject = FileObject;
NewIrpSp->DeviceObject = DeviceExt->AttachedToDeviceObject;
NewIrpSp->Parameters.SetFile.FileInformationClass =
FileRenameInformation;
NewIrpSp->Parameters.SetFile.Length = BuffLen;
NewIrpSp->Parameters.SetFile.ReplaceIfExists = TRUE;
NewIrpSp->Parameters.SetFile.FileObject = DirObject;
KeInitializeEvent (&WaitEvent, NotificationEvent, FALSE);
IoSetCompletionRoutine (NewIrp, SetFileInformationCompletion,
&WaitEvent,TRUE, TRUE, TRUE);
Status = IoCallDriver (DeviceExt->AttachedToDeviceObject, NewIrp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject (&WaitEvent, Executive, KernelMode, FALSE,
NULL);
}
Status = NewIrp->IoStatus.Status;
if (Status == STATUS_SUCCESS)
{
KdPrint ((“SetFileInformation: IoCallDriver Success\n”));
}
else
{
KdPrint ((“SetFileInformation: IoCallDriver failed (%X)\n”,
Status)); //Keeps printing STATUT_OBJECT_NAME_INVALID
}
IoFreeIrp (NewIrp);
return Status;
You are currently subscribed to ntfsd as: xxxxx@agglut.com
To unsubscribe send a blank email to xxxxx@lists.osr.com