Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > Help on IoGetDeviceObjectPointer and ObDeferenceObject

Reply
Thread Tools Display Modes

Help on IoGetDeviceObjectPointer and ObDeferenceObject

 
 
Nikhil
Guest
Posts: n/a

 
      03-13-2006
Hi,

I am using IoGetDeviceObjectPointer() API to get handle to a named device
object. In that call I am passing device object and file object as local
variables (stack variables). Once IoGetDeviceObjectPointer() returns
success, I am acquiring spin lock and copying those device object and file
object to a permanent storage. My question is do I need to call
ObDereferenceObject() for a stack variable which I passed in
IoGetDeviceObjectPointer() API? I am calling ObDereferenceObject(FileObject)
later on when I the close device stack.

The code is something like this.

Status = IoGetDeviceObject(xxx, xxx, &TempFO, &TempDO).

if (NT_SUCCESS(Status) {

Acquire spin lock;

PermFO = TempFO;
PermDO = TempDO;

Release spin lock;
}

CloseStack() {
ObDereferenceObject(PermFO);
}

My question is do I need to ObDereferenceObject(TempFO) somewhere in the
code?????

Thanks.

 
Reply With Quote
 
 
 
 
Don Burn
Guest
Posts: n/a

 
      03-13-2006
No, making a copy of a pointer is not going to increment the objects
reference count. So only when you do an explict call that changes the
reference count do you need to worry.

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




"Nikhil" <> wrote in message
news:AE9D47D4-62E9-4902-B3E1-...
> Hi,
>
> I am using IoGetDeviceObjectPointer() API to get handle to a named device
> object. In that call I am passing device object and file object as local
> variables (stack variables). Once IoGetDeviceObjectPointer() returns
> success, I am acquiring spin lock and copying those device object and file
> object to a permanent storage. My question is do I need to call
> ObDereferenceObject() for a stack variable which I passed in
> IoGetDeviceObjectPointer() API? I am calling
> ObDereferenceObject(FileObject)
> later on when I the close device stack.
>
> The code is something like this.
>
> Status = IoGetDeviceObject(xxx, xxx, &TempFO, &TempDO).
>
> if (NT_SUCCESS(Status) {
>
> Acquire spin lock;
>
> PermFO = TempFO;
> PermDO = TempDO;
>
> Release spin lock;
> }
>
> CloseStack() {
> ObDereferenceObject(PermFO);
> }
>
> My question is do I need to ObDereferenceObject(TempFO) somewhere in the
> code?????
>
> Thanks.
>



 
Reply With Quote
 
Nikhil
Guest
Posts: n/a

 
      03-13-2006
Thank you for a quick response.

"Don Burn" wrote:

> No, making a copy of a pointer is not going to increment the objects
> reference count. So only when you do an explict call that changes the
> reference count do you need to worry.
>
> --
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
>
>
>
> "Nikhil" <> wrote in message
> news:AE9D47D4-62E9-4902-B3E1-...
> > Hi,
> >
> > I am using IoGetDeviceObjectPointer() API to get handle to a named device
> > object. In that call I am passing device object and file object as local
> > variables (stack variables). Once IoGetDeviceObjectPointer() returns
> > success, I am acquiring spin lock and copying those device object and file
> > object to a permanent storage. My question is do I need to call
> > ObDereferenceObject() for a stack variable which I passed in
> > IoGetDeviceObjectPointer() API? I am calling
> > ObDereferenceObject(FileObject)
> > later on when I the close device stack.
> >
> > The code is something like this.
> >
> > Status = IoGetDeviceObject(xxx, xxx, &TempFO, &TempDO).
> >
> > if (NT_SUCCESS(Status) {
> >
> > Acquire spin lock;
> >
> > PermFO = TempFO;
> > PermDO = TempDO;
> >
> > Release spin lock;
> > }
> >
> > CloseStack() {
> > ObDereferenceObject(PermFO);
> > }
> >
> > My question is do I need to ObDereferenceObject(TempFO) somewhere in the
> > code?????
> >
> > Thanks.
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
STATUS_INVALID_DEVICE_REQUEST from IoGetDeviceObjectPointer Hua-Ying Ling Windows Vista Drivers 9 03-04-2006 09:09 PM
IoGetDeviceObjectPointer & IRP_MJ_CREATE Andrew Windows Vista Drivers 2 06-03-2005 06:36 PM
About IoGetDeviceObjectPointer and KB835732 About IoGetDeviceObjectPointer and KB835 Windows Vista Drivers 2 05-18-2005 03:03 AM
IoGetDeviceObjectPointer fails -- sometimes Vitus Jensen Windows Vista Drivers 6 02-04-2005 01:31 PM
one question about IoGetDeviceObjectPointer John Windows Vista Drivers 0 01-11-2004 07:01 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59