>
- invalid 3rd ObreferenceObjectByHandle parameter (use *IoFileObjectType)
Not necessary for requestor mode = Kernel mode.
- you didn’t initialize all Irp/IrpSp parameters, or if yes, so incorrectly
(e.g.
Irp->UserEvent, Irp->Tail.Overlay.OriginalFileObject, …)
Irp->UserEvent and Irp->Tail.Overlay.OriginalFileObject belong to I/O
manager, should not modifiy these fields actually.
Look for the documented fields of the IRP in the msdn, this is my
recomandation, it will clear things out.
Look at this article (http://www.osronline.com/article.cfm?id=85 ) to see
more about rename operations.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Petr Kurtin
Sent: Monday, January 12, 2009 6:20 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Steps to send a IRP to FS
- use IoAllocateIrp function!
- use OBJ_KERNEL_HANDLE in InitializeObjectAttributes
- check error status codes (ExAllocatePool, IoAllocateIrp, ZwOpenFile, …)
- invalid 3rd ObreferenceObjectByHandle parameter (use *IoFileObjectType)
- you didn’t initialize all Irp/IrpSp parameters, or if yes, so incorrectly
(e.g. Irp->UserEvent, Irp->Tail.Overlay.OriginalFileObject, …)
according to filenames, your rename operation is called “fully qualified
renames”, and your values are:
irpSp->FileObject = pIrpFileObj /*Set it to soure file object*/;
pRenameInfo->RootDirectory = NULL;
irpSp->Parameters.SetFile.FileObject = NULL;
but the latest parameter cannot be NULL; read WDK and “Cracking Rename
Operations” article at OSR Online website
-pk
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: 12. ledna 2009 16:58
To: Windows File Systems Devs Interest List
Subject: RE:[ntfsd] Steps to send a IRP to FS
Actually I posted the code in my last post but that makes the post too long
to get some attention. So I thought a small post will be good and in that
attempt missed all information.
following is the code, I exclude all error checks to make it short, I am
getting device pointer using ObReferenceObjectByName APi.
IrpSize = IoSizeOfIrp( pDevicePre->StackSize+1 );
Irp = ExAllocatePool(NonPagedPool, IrpSize);
IoInitializeIrp(Irp, IrpSize, pDevicePre->StackSize+1);
RtlInitUnicodeString( &TargetStr,
L"\Device\HarddiskVolume1\aditya\abc.txt" );
InitializeObjectAttributes( &obj, &TargetStr, OBJ_CASE_INSENSITIVE, 0, 0 );
status = ZwOpenFile (&hFileHandle, STANDARD_RIGHTS_READ|DELETE, &obj,
&IoStatus,FILE_SHARE_READ,FILE_NON_DIRECTORY_FILE);
status = ObReferenceObjectByHandle( hFileHandle, GENERIC_READ|DELETE, NULL,
KernelMode, &pIrpFileObj, NULL );
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
Irp->RequestorMode = KernelMode;
Irp->UserIosb = &ioStatusBlock;
Irp->UserEvent = NULL;
Irp->Flags = IRP_SYNCHRONOUS_API;
irpSp = IoGetNextIrpStackLocation( Irp );
irpSp->MajorFunction = IRP_MJ_SET_INFORMATION;
irpSp->FileObject = pIrpFileObj /*Set it to soure file object*/;
pRenameInfo = ExAllocatePool( NonPagedPool, sizeof(FILE_RENAME_INFORMATION)
+wcslen( L"\Device\HarddiskVolume1\Aditya\abc.txt" )*sizeof(WCHAR) );
pRenameInfo->ReplaceIfExists = FALSE;
pRenameInfo->RootDirectory = NULL;
pRenameInfo->FileNameLength = wcslen(
L"\Device\HarddiskVolume1\Aditya\xyz.txt" )*sizeof(WCHAR);
wcscpy( pRenameInfo->FileName, L"\Device\HarddiskVolume1\Aditya\xyz.txt"
);
irpSp->Parameters.SetFile.Length = sizeof(FILE_RENAME_INFORMATION)+wcslen(
L"\Device\HarddiskVolume1\Aditya\abc.txt" )*sizeof(WCHAR);
irpSp->Parameters.SetFile.FileInformationClass = FileRenameInformation;
irpSp->Parameters.SetFile.FileObject = NULL;
irpSp->Parameters.SetFile.ReplaceIfExists =FALSE;
Irp->AssociatedIrp.SystemBuffer = pRenameInfo /*FileInformation*/;
IoSetCompletionRoutine( Irp, SpyQueryCompletion, &IoEvent,TRUE,TRUE, TRUE );
status = IoCallDriver( pDevicePre, Irp );//This return 0xC0000033L
Any pointers will help,
Thanks
Aditya
NTFSD is sponsored by OSR
For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
You are currently subscribed to ntfsd as: xxxxx@avast.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
NTFSD is sponsored by OSR
For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
You are currently subscribed to ntfsd as: xxxxx@gmail.com
To unsubscribe send a blank email to xxxxx@lists.osr.com