Hello,
I have encoded this code, but the call for ObOpenObjectByPointer
() returns status_unsuccessfull and I cannot tell why. Have you
any idea? Note, there are two file objects - one user’s
referenced by handle and mine (MyFileObject) without any handles
opened - so I need to REcreate handle for MyFileObject when its
older one has been closed immediatelly after its creation.
This routine is part of FsctlMoveFile() - so the InputBuffer-
FileHandle statement is here.
Status = ObReferenceObjectByHandle( InputBuffer->FileHandle,
0,
*IoFileObjectType,
KernelMode, //Irp-
RequestorMode, for sure…
&FileObject,
&HandleInformation );
//
// Get MyFileObject from FileObject…
//
//
// The key point here is, that MyFileObject have closed all
handles long before
// and (MyFileObject->Flags & FO_HANDLE_CREATED) == 0
//
Status = ObOpenObjectByPointer( MyFileObject,
HandleInformation.HandleAttributes,
NULL,
HandleInformation.GrantedAccess,
*IoFileObjectType,
KernelMode,
&MyFileHandle );
Thanks Ondra Sevecek.
ZDARMA a RYCHL? zas?l?n? SMS z www.posliSMS.cz
>> // Get MyFileObject from FileObject…
How should I understand this ?
Anyway, ObOpenObjectByPointer() is a undocumented routine , full of quirks,
and which cannot be safely used for
recreating handles for IO purpose to file objects which alredy has been
processed by a IRP_MJ_CLEANUP. File system are just not prepared to handle
this situation.
Dan
“Ondøej©eveèek” wrote in message
news:xxxxx@ntfsd…
Hello,
I have encoded this code, but the call for ObOpenObjectByPointer
() returns status_unsuccessfull and I cannot tell why. Have you
any idea? Note, there are two file objects - one user’s
referenced by handle and mine (MyFileObject) without any handles
opened - so I need to REcreate handle for MyFileObject when its
older one has been closed immediatelly after its creation.
This routine is part of FsctlMoveFile() - so the InputBuffer-
>FileHandle statement is here.
Status = ObReferenceObjectByHandle( InputBuffer->FileHandle,
0,
*IoFileObjectType,
KernelMode, //Irp-
>RequestorMode, for sure…
&FileObject,
&HandleInformation );
//
// Get MyFileObject from FileObject…
//
//
// The key point here is, that MyFileObject have closed all
handles long before
// and (MyFileObject->Flags & FO_HANDLE_CREATED) == 0
//
Status = ObOpenObjectByPointer( MyFileObject,
HandleInformation.HandleAttributes,
NULL,
HandleInformation.GrantedAccess,
*IoFileObjectType,
KernelMode,
&MyFileHandle );
Thanks Ondra Sevecek.
--------------------
ZDARMA a RYCHLÉ zasílání SMS z www.posliSMS.cz
xxxxx@centrum.cz writes:
I have encoded this code, but the call for ObOpenObjectByPointer
() returns status_unsuccessfull and I cannot tell why. Have you
any idea? Note, there are two file objects - one user’s
referenced by handle and mine (MyFileObject) without any handles
opened - so I need to REcreate handle for MyFileObject when its
older one has been closed immediatelly after its creation.
I asked the same question in March. You simply need to keep an open handle
if you want to be able to use it again. Nagar isn’t very clear about
this… Perhaps you want to save a kernel handle instead of the pointer. I
seem to get a usable handle by
InitializeObjectAttributes(&objattr, &fname_u,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL, NULL);
status = ZwOpenFile(…)
/Tomas (thanks Max)