Comparing opaque pointers

Can I assume that if I have two opaque pointers obtained via totally
different mechanisms (e.g. a PFLT_VOLUME from an earlier call to
FltGetVolumeFromName, and another PFLT_VOLUME from a callback’s
FLT_RELATED_OBJECTS), I can simply compare the pointers for equality. I.e.
can I be sure that there will not be two or more FLT_VOLUME structures for
the same notional volume for the lifetime of that volume? Or must I obtain
and compare its name to find out if the opaque pointers denote the same
volume?

And for future reference, is the mechanism the same for all opaque pointer
types - so that pointer comparison can always be used as an identity test?

Brian

Yes you can, since no 2 structures can be located at the same memory
addresses.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Brian Collins”
Newsgroups: ntfsd
To: “Windows File Systems Devs Interest List”
Sent: Thursday, April 15, 2004 10:00 PM
Subject: [ntfsd] Comparing opaque pointers

> Can I assume that if I have two opaque pointers obtained via totally
> different mechanisms (e.g. a PFLT_VOLUME from an earlier call to
> FltGetVolumeFromName, and another PFLT_VOLUME from a callback’s
> FLT_RELATED_OBJECTS), I can simply compare the pointers for equality. I.e.
> can I be sure that there will not be two or more FLT_VOLUME structures for
> the same notional volume for the lifetime of that volume? Or must I obtain
> and compare its name to find out if the opaque pointers denote the same
> volume?
>
> And for future reference, is the mechanism the same for all opaque pointer
> types - so that pointer comparison can always be used as an identity test?
>
> Brian
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

I know that no 2 structures can be located at the same memory address, but
the filter manager implementation (which by its design is deliberately
opaque) could choose to keep two logically identical structures which
“denote” the same object (volume, instance, whatever).

In contrast, the internals of FILE_OBJECT, DEVICE_OBJECT etc are fully
documented, and it is obvious from the documentation that each notional
“file” can be represented by one (and only one) FILE_OBJECT and therefore it
is always legal to compare the PFILE_OBJECT pointers.

With the filter manager’s opaque pointers, it would be very reasonable to
expect the same rules to apply. But there is actually nothing I can find in
the documentation that requires the filter manager to have been implemented
that way. I was just asking for confirmation that the pointer comparison was
a reasonable thing to do.

Brian

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntfsd…
> Yes you can, since no 2 structures can be located at the same memory
> addresses.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> ----- Original Message -----
> From: “Brian Collins”
> Newsgroups: ntfsd
> To: “Windows File Systems Devs Interest List”
> Sent: Thursday, April 15, 2004 10:00 PM
> Subject: [ntfsd] Comparing opaque pointers
>
>
> > Can I assume that if I have two opaque pointers obtained via totally
> > different mechanisms (e.g. a PFLT_VOLUME from an earlier call to
> > FltGetVolumeFromName, and another PFLT_VOLUME from a callback’s
> > FLT_RELATED_OBJECTS), I can simply compare the pointers for equality.
I.e.
> > can I be sure that there will not be two or more FLT_VOLUME structures
for
> > the same notional volume for the lifetime of that volume? Or must I
obtain
> > and compare its name to find out if the opaque pointers denote the same
> > volume?
> >
> > And for future reference, is the mechanism the same for all opaque
pointer
> > types - so that pointer comparison can always be used as an identity
test?
> >
> > Brian
> >
> >
> >
> > —
> > Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
> >
> > You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>

You can safely compare the opaque pointers.

The address for a FLT_VOLUME will not change over the lifetime of the
device stack it represents. Note that the device stack may have a
different lifetime than the device itself. For example, you could have
a hotplugable device which is pulled from the system (surprise removal
in PNP terms). The device stack will stick around until all the handle
are closed (of course, all future IO to these handles is going to fail).
If the device is reconnected to the machine, a new device stack will be
created, along with a new FLT_VOLUME structure (and new FLT_INSTANCE
structure for minifilter who wish to attach).

As long as your filter is loaded, your FLT_FILTER address will not
change. As long as your instance is attached to a volume, your
FLT_INSTANCE address will not change.

Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Brian Collins
Sent: Thursday, April 15, 2004 11:50 AM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Comparing opaque pointers

I know that no 2 structures can be located at the same memory address,
but the filter manager implementation (which by its design is
deliberately
opaque) could choose to keep two logically identical structures which
“denote” the same object (volume, instance, whatever).

In contrast, the internals of FILE_OBJECT, DEVICE_OBJECT etc are fully
documented, and it is obvious from the documentation that each notional
“file” can be represented by one (and only one) FILE_OBJECT and
therefore it is always legal to compare the PFILE_OBJECT pointers.

With the filter manager’s opaque pointers, it would be very reasonable
to expect the same rules to apply. But there is actually nothing I can
find in the documentation that requires the filter manager to have been
implemented that way. I was just asking for confirmation that the
pointer comparison was a reasonable thing to do.

Brian

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntfsd…
> Yes you can, since no 2 structures can be located at the same
> memory addresses.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> ----- Original Message -----
> From: “Brian Collins”
> Newsgroups: ntfsd
> To: “Windows File Systems Devs Interest List”
> Sent: Thursday, April 15, 2004 10:00 PM
> Subject: [ntfsd] Comparing opaque pointers
>
>
> > Can I assume that if I have two opaque pointers obtained via totally

> > different mechanisms (e.g. a PFLT_VOLUME from an earlier call to
> > FltGetVolumeFromName, and another PFLT_VOLUME from a callback’s
> > FLT_RELATED_OBJECTS), I can simply compare the pointers for
equality.
I.e.
> > can I be sure that there will not be two or more FLT_VOLUME
> > structures
for
> > the same notional volume for the lifetime of that volume? Or must I
obtain
> > and compare its name to find out if the opaque pointers denote the
> > same volume?
> >
> > And for future reference, is the mechanism the same for all opaque
pointer
> > types - so that pointer comparison can always be used as an identity
test?
> >
> > Brian
> >
> >
> >
> > —
> > Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
> >
> > You are currently subscribed to ntfsd as: xxxxx@storagecraft.com To
> > unsubscribe send a blank email to xxxxx@lists.osr.com
>
>


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

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

Thanks Molly,

It might have been a bit pedantic asking this, but it probably *ought* to be
stated somewhere in future documentation.

Brian

“Molly Brown” wrote in message
news:xxxxx@ntfsd…
You can safely compare the opaque pointers.

The address for a FLT_VOLUME will not change over the lifetime of the
device stack it represents. Note that the device stack may have a
different lifetime than the device itself. For example, you could have
a hotplugable device which is pulled from the system (surprise removal
in PNP terms). The device stack will stick around until all the handle
are closed (of course, all future IO to these handles is going to fail).
If the device is reconnected to the machine, a new device stack will be
created, along with a new FLT_VOLUME structure (and new FLT_INSTANCE
structure for minifilter who wish to attach).

As long as your filter is loaded, your FLT_FILTER address will not
change. As long as your instance is attached to a volume, your
FLT_INSTANCE address will not change.

Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Brian Collins
Sent: Thursday, April 15, 2004 11:50 AM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Comparing opaque pointers

I know that no 2 structures can be located at the same memory address,
but the filter manager implementation (which by its design is
deliberately
opaque) could choose to keep two logically identical structures which
“denote” the same object (volume, instance, whatever).

In contrast, the internals of FILE_OBJECT, DEVICE_OBJECT etc are fully
documented, and it is obvious from the documentation that each notional
“file” can be represented by one (and only one) FILE_OBJECT and
therefore it is always legal to compare the PFILE_OBJECT pointers.

With the filter manager’s opaque pointers, it would be very reasonable
to expect the same rules to apply. But there is actually nothing I can
find in the documentation that requires the filter manager to have been
implemented that way. I was just asking for confirmation that the
pointer comparison was a reasonable thing to do.

Brian

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntfsd…
> Yes you can, since no 2 structures can be located at the same
> memory addresses.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> ----- Original Message -----
> From: “Brian Collins”
> Newsgroups: ntfsd
> To: “Windows File Systems Devs Interest List”
> Sent: Thursday, April 15, 2004 10:00 PM
> Subject: [ntfsd] Comparing opaque pointers
>
>
> > Can I assume that if I have two opaque pointers obtained via totally

> > different mechanisms (e.g. a PFLT_VOLUME from an earlier call to
> > FltGetVolumeFromName, and another PFLT_VOLUME from a callback’s
> > FLT_RELATED_OBJECTS), I can simply compare the pointers for
equality.
I.e.
> > can I be sure that there will not be two or more FLT_VOLUME
> > structures
for
> > the same notional volume for the lifetime of that volume? Or must I
obtain
> > and compare its name to find out if the opaque pointers denote the
> > same volume?
> >
> > And for future reference, is the mechanism the same for all opaque
pointer
> > types - so that pointer comparison can always be used as an identity
test?
> >
> > Brian
> >
> >
> >
> > —
> > Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
> >
> > You are currently subscribed to ntfsd as: xxxxx@storagecraft.com To
> > unsubscribe send a blank email to xxxxx@lists.osr.com
>
>


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

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