Strange call to ObDereferenceObject

Hello All!

Looking through the code I found the following code:


status = IoGetDeviceObjectPointer(
&lowerDeviceName,
FILE_ALL_ACCESS,
&lowerFileObject,
&lowerDeviceObject
);
status = ObReferenceObjectByPointer (
lowerDeviceObject,
FILE_ALL_ACCESS,
NULL,
KernelMode
);
ObDereferenceObject (lowerFileObject);


Do we really need to dereference loverFileObject? My concern is that it
wasn’t referenced before.

Slava


Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

IoGetDeviceObjectPointer increments the reference on the lowerFileObject.

Rather than keep both the lowerDeviceObject and the lowerFileObject
pointers, the code segment increments the reference count on the
lowerDeviceObject and then can safely dereference the lowerFileObject and
ignore it. The pointer to the lowerDeviceObject will remain valid until it
is dereferenced. The code is correct.

-----Original Message-----
From: Slava Abramov [mailto:xxxxx@yahoo.com]
Sent: Wednesday, December 05, 2001 10:43 AM
To: NT Developers Interest List
Subject: [ntdev] Strange call to ObDereferenceObject

Hello All!

Looking through the code I found the following code:


status = IoGetDeviceObjectPointer(
&lowerDeviceName,
FILE_ALL_ACCESS,
&lowerFileObject,
&lowerDeviceObject
);
status = ObReferenceObjectByPointer (
lowerDeviceObject,
FILE_ALL_ACCESS,
NULL,
KernelMode
);
ObDereferenceObject (lowerFileObject);


Do we really need to dereference loverFileObject? My concern is that it
wasn’t referenced before.

Slava


Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping. http://shopping.yahoo.com


You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You mix the Ob’s refcount on the device object and DeviceObject->ReferenceCount.
The second is the count of file objects living on the device object, but not the first.
For instance, NT4’s unload path pays NO attention to the Ob’s refcounts on the device objects.

Max

----- Original Message -----
From: “Roddy, Mark”
To: “NT Developers Interest List”
Sent: Wednesday, December 05, 2001 6:53 PM
Subject: [ntdev] RE: Strange call to ObDereferenceObject

> IoGetDeviceObjectPointer increments the reference on the lowerFileObject.
>
> Rather than keep both the lowerDeviceObject and the lowerFileObject
> pointers, the code segment increments the reference count on the
> lowerDeviceObject and then can safely dereference the lowerFileObject and
> ignore it. The pointer to the lowerDeviceObject will remain valid until it
> is dereferenced. The code is correct.
>
> -----Original Message-----
> From: Slava Abramov [mailto:xxxxx@yahoo.com]
> Sent: Wednesday, December 05, 2001 10:43 AM
> To: NT Developers Interest List
> Subject: [ntdev] Strange call to ObDereferenceObject
>
>
> Hello All!
>
> Looking through the code I found the following code:
>
> —
> status = IoGetDeviceObjectPointer(
> &lowerDeviceName,
> FILE_ALL_ACCESS,
> &lowerFileObject,
> &lowerDeviceObject
> );
> status = ObReferenceObjectByPointer (
> lowerDeviceObject,
> FILE_ALL_ACCESS,
> NULL,
> KernelMode
> );
> ObDereferenceObject (lowerFileObject);
>
> —
>
> Do we really need to dereference loverFileObject? My concern is that it
> wasn’t referenced before.
>
>
> Slava
>
> __________________________________________________
> Do You Yahoo!?
> Buy the perfect holiday gifts at Yahoo! Shopping. http://shopping.yahoo.com
>
> —
> You are currently subscribed to ntdev as: xxxxx@stratus.com To
> unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com