Getting handle from File object

Hi,

Is it possible to get handle from file object?

Any information is helpful.

Thanks,
Kedar.

Use ObReferenceObjectByPointer, you will then create
handle that will be valid in the context of the caller’s
process. Or, if you specify OBJ_KERNEL_HANDLE,
you will create a handle that will be valid for all processes
in kernel mode.

L.

Does this send IRP_MJ_CREATE to device stack?

“Ladislav Zezula” wrote in message news:xxxxx@ntfsd…
> Use ObReferenceObjectByPointer, you will then create
> handle that will be valid in the context of the caller’s
> process. Or, if you specify OBJ_KERNEL_HANDLE,
> you will create a handle that will be valid for all processes
> in kernel mode.
>
> L.
>

It wasn’t clear from the OP’s question, but he may have been asking about
the handle created by a user process after an IRP_MJ_CREATE has completed
successfully. IOW, what is the handle the user process will see?

Ken

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Lyndon J Clarke
Sent: Friday, September 23, 2005 9:54 AM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Getting handle from File object

Does this send IRP_MJ_CREATE to device stack?

“Ladislav Zezula” wrote in message news:xxxxx@ntfsd…
> Use ObReferenceObjectByPointer, you will then create
> handle that will be valid in the context of the caller’s
> process. Or, if you specify OBJ_KERNEL_HANDLE,
> you will create a handle that will be valid for all processes
> in kernel mode.
>
> L.
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@comcast.net
To unsubscribe send a blank email to xxxxx@lists.osr.com

No.Why should it. It will just use up an extra entry in the handle table
(kernel or the process depending on the attributes) and that entry will
point to this object. In addition, it will increment the refcount.

On 9/23/05, Lyndon J Clarke wrote:
>
> Does this send IRP_MJ_CREATE to device stack?
>
> “Ladislav Zezula” wrote in message news:xxxxx@ntfsd…
> > Use ObReferenceObjectByPointer, you will then create
> > handle that will be valid in the context of the caller’s
> > process. Or, if you specify OBJ_KERNEL_HANDLE,
> > you will create a handle that will be valid for all processes
> > in kernel mode.
> >
> > L.
> >
>
>
>
> —
> 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
>

Actually, this will not create a handle. ObReferenceObjectByPointer just
increments the objects reference count. ObOpenObjectByPointer will create a
handle, but it will do a call to IRP_MJ_CREATE.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“Ladislav Zezula” wrote in message news:xxxxx@ntfsd…
> Use ObReferenceObjectByPointer, you will then create
> handle that will be valid in the context of the caller’s
> process. Or, if you specify OBJ_KERNEL_HANDLE,
> you will create a handle that will be valid for all processes
> in kernel mode.
>
> L.
>

sorry, I misread Ladislav’s original post. I thought he meant
ObOpenObjectByPointer.
But I am not sure, you will see an IRP_MJ_CREATE. If the object is already
created,
I am not sure why it will send another IRP_MJ_CREATE down. It should just
allocate a
handle and make sure it points to this object. In addition, it should
increment the refcount of
the object.

On 9/23/05, Don Burn wrote:
>
> Actually, this will not create a handle. ObReferenceObjectByPointer just
> increments the objects reference count. ObOpenObjectByPointer will create
> a
> handle, but it will do a call to IRP_MJ_CREATE.
>
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
>
>
> “Ladislav Zezula” wrote in message news:xxxxx@ntfsd…
> > Use ObReferenceObjectByPointer, you will then create
> > handle that will be valid in the context of the caller’s
> > process. Or, if you specify OBJ_KERNEL_HANDLE,
> > you will create a handle that will be valid for all processes
> > in kernel mode.
> >
> > L.
> >
>
>
>
> —
> 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
>

I thought so and my bad missed the typo is ladislav email :slight_smile: So kedar, be
careful where you use this one. Why dont your roll your own irp and send it
down to driver below?

“Don Burn” wrote in message news:xxxxx@ntfsd…
> Actually, this will not create a handle. ObReferenceObjectByPointer just
> increments the objects reference count. ObOpenObjectByPointer will create
> a handle, but it will do a call to IRP_MJ_CREATE.
>
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
>
>
> “Ladislav Zezula” wrote in message news:xxxxx@ntfsd…
>> Use ObReferenceObjectByPointer, you will then create
>> handle that will be valid in the context of the caller’s
>> process. Or, if you specify OBJ_KERNEL_HANDLE,
>> you will create a handle that will be valid for all processes
>> in kernel mode.
>>
>> L.
>>
>
>
>

> sorry, I misread Ladislav’s original post. I thought he meant ObOpenObjectByPointer.

But I am not sure, you will see an IRP_MJ_CREATE. If the object is already created,

Eh, sorry, I wrote it wrong. You’re right, I thought ObOpenObjectByPointer.
Things in my head are slowly changing to mess and I am getting crazy :frowning:

The question is (and should has been my first one), why exactly do you need
the handle in the filter driver (it is for a filter driver, isn’t it ?)
Do you plan to use any Zw function in the driver ?

L.

Well stuff dont always work the way you think it should you know, same with my car, and …
“faras namus” wrote in message news:xxxxx@ntfsd…
sorry, I misread Ladislav’s original post. I thought he meant ObOpenObjectByPointer.
But I am not sure, you will see an IRP_MJ_CREATE. If the object is already created,
I am not sure why it will send another IRP_MJ_CREATE down. It should just allocate a
handle and make sure it points to this object. In addition, it should increment the refcount of
the object.

On 9/23/05, Don Burn wrote:
Actually, this will not create a handle. ObReferenceObjectByPointer just
increments the objects reference count. ObOpenObjectByPointer will create a
handle, but it will do a call to IRP_MJ_CREATE.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“Ladislav Zezula” < xxxxx@volny.cz> wrote in message news:xxxxx@ntfsd…
> Use ObReferenceObjectByPointer, you will then create
> handle that will be valid in the context of the caller’s
> process. Or, if you specify OBJ_KERNEL_HANDLE,
> you will create a handle that will be valid for all processes
> in kernel mode.
>
> L.
>


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