What is an opaque data structure?

The call to ZwCreateFile() requires a pointer to as structure
“POBJECT_ATTRIBUTES ObjectAttributes”

However, when I search for the structure definition in the DDK help file, I get circular references between ZwCreateFile() and InitializeObjectAttributes().

OBJECT_ATTRIBUTES
The OBJECT_ATTRIBUTES structure is an opaque structure that specifies the properties of an object handle. Use the InitializeObjectAttributes routine to set the members of this structure.

See Also
InitializeObjectAttributes

I had to grep through all the headers, before I could find what the structure looks like, but I still don’t know what opaque means, in reference to a structure

typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE
} OBJECT_ATTRIBUTES;
typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES;

I just did the search and here is the definition -

http://www.m-w.com/dictionary/opaque

It is anything but thickheaded :-).

It means, it could change anytime …

-pro

The call to ZwCreateFile() requires a pointer to as structure
“POBJECT_ATTRIBUTES ObjectAttributes”

However, when I search for the structure definition in the DDK help file,
I get circular references between ZwCreateFile() and
InitializeObjectAttributes().

OBJECT_ATTRIBUTES
The OBJECT_ATTRIBUTES structure is an opaque structure that specifies the
properties of an object handle. Use the InitializeObjectAttributes routine
to set the members of this structure.

See Also
InitializeObjectAttributes

I had to grep through all the headers, before I could find what the
structure looks like, but I still don’t know what opaque means, in
reference to a structure

typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
PVOID SecurityQualityOfService; // Points to type
SECURITY_QUALITY_OF_SERVICE
} OBJECT_ATTRIBUTES;
typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES;


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

An “Opaque” type in this context means that from the perspective of
developer who uses only the WDK header files (i. e. - does not have
access to Windows source code), the details of the type are at least
conceptually incomplete. Basically, this means that an incomplete type
is declared to satisfy the compiler, but the internals are not contained
in any header file. Generally, this means that a typedef declaring a
pointer to a type is declared as void *. The “conceptually” part is
necessary because some “opaque” types are, in fact, defined in the WDK
headers, but Microsoft wishes you to not use the internal definitions.
The complete definitions are contained in the private parts of the
Windows Source Code. As Pro indicated, these semantic construct is
generally used to prevent a developer from relying on the layout of a
type. A corollary of this is that this can be used to help prevent a
change in the declaration of a type to cause external developers from
having to recompile, but there are additional constraints that must be
met to ensure this.

mm

>> xxxxx@garlic.com 2007-05-07 22:32 >>>
I just did the search and here is the definition -

http://www.m-w.com/dictionary/opaque

It is anything but thickheaded :-).

It means, it could change anytime …

-pro

The call to ZwCreateFile() requires a pointer to as structure
“POBJECT_ATTRIBUTES ObjectAttributes”

However, when I search for the structure definition in the DDK help
file,
I get circular references between ZwCreateFile() and
InitializeObjectAttributes().

OBJECT_ATTRIBUTES
The OBJECT_ATTRIBUTES structure is an opaque structure that specifies
the
properties of an object handle. Use the InitializeObjectAttributes
routine
to set the members of this structure.

See Also
InitializeObjectAttributes

I had to grep through all the headers, before I could find what the
structure looks like, but I still don’t know what opaque means, in
reference to a structure

typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor; // Points to type
SECURITY_DESCRIPTOR
PVOID SecurityQualityOfService; // Points to type
SECURITY_QUALITY_OF_SERVICE
} OBJECT_ATTRIBUTES;
typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES;


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> I had to grep through all the headers, before I could find what the structure
looks

like, but I still don’t know what opaque means, in reference to a structure

“Opaque” means - the layout of the structure is not your business, even if it
is declared in the header.

You must only use functions and macros to access this structure, you must never
access the fields directly.

Usually, opaque structures are undocumented and not declared in the headers.
They are declared in the headers - like OBJECT_ATTRIBUTES - only to provide you
a way to declare them as variables/fields of larger structures in your code and
to make sizeof() meaningful.


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

xxxxx@gmail.com wrote:

The call to ZwCreateFile() requires a pointer to as structure
“POBJECT_ATTRIBUTES ObjectAttributes”

However, when I search for the structure definition in the DDK help
file, I get circular references between ZwCreateFile() and
InitializeObjectAttributes().

OBJECT_ATTRIBUTES The OBJECT_ATTRIBUTES structure is an opaque
structure that specifies the properties of an object handle. Use the
InitializeObjectAttributes routine to set the members of this
structure.

See Also InitializeObjectAttributes

Actually, the documentation for InitializeObjectAttributes points
directly to ntdef.h (at least it used to). In older versions of the DDK
(I checked the 1996 NT 4.0 DDK), OBJECT_ATTRIBUTES was not considered
opaque, with all the fields actually described in the documentation for
ZwCreateFile(). Some DDK samples also used the fields directly and
InitializeObjectAttributes() is a trivial inline macro anyway.

So until I saw this discussion thread I never thought of
OBJECT_ATTRIBUTES as an opaque data structure at all, just as a common
parameter bundle similar to the related user mode structure
SECURITY_ATTRIBUTES.

I had to grep through all the headers, before I could find what the
structure looks like, but I still don’t know what opaque means, in
reference to a structure

typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE
} OBJECT_ATTRIBUTES;
typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES;


Jakob Bøhm, M.Sc.Eng. * xxxxx@danware.dk * direct tel:+45-45-90-25-33
Danware Data A/S * Bregnerodvej 127 * DK-3460 Birkerod * DENMARK
http://www.netop.com * tel:+45-45-90-25-25 * fax tel:+45-45-90-25-26
Information in this mail is hasty, not binding and may not be right

> “Opaque” means - the layout of the structure is not your business, even if it

is declared in the header.

Actually, most of the WDK structures are opaque, including even so widely-used ones as DEVICE_OBJECT and DRIVER_OBJECT…

Anton Bassov

xxxxx@hotmail.com wrote:

> “Opaque” means - the layout of the structure is not your business, even if it
> is declared in the header.
>

Actually, most of the WDK structures are opaque, including even so widely-used ones as DEVICE_OBJECT and DRIVER_OBJECT…

No, this is just not true. There are many fields in both of these
structures that a driver is required to use for normal day-to-day
operation. Some of them even have to be changed. For example,
virtually every function in a WDM driver uses DEVICE_OBJECT.DriverExtension.

There are many DDK types that ARE opaque, but those two aren’t among them.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Well, they are partially opaque then ;). You are allowed to touch some
fields (DEVICE_OBJECT::DeviceExtension), but not others
(DRIVER_OBJECT::NextDevice). You just have to show discipline and read
the docs and not use the undocumented fields. Fortunately verification
tools like PFD and SDV can tell warn you that you are touching fields
that are private/opaque.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Thursday, May 10, 2007 11:03 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] What is an opaque data structure?

xxxxx@hotmail.com wrote:

> “Opaque” means - the layout of the structure is not your business,
even if it
> is declared in the header.
>

Actually, most of the WDK structures are opaque, including even so
widely-used ones as DEVICE_OBJECT and DRIVER_OBJECT…

No, this is just not true. There are many fields in both of these
structures that a driver is required to use for normal day-to-day
operation. Some of them even have to be changed. For example,
virtually every function in a WDM driver uses
DEVICE_OBJECT.DriverExtension.

There are many DDK types that ARE opaque, but those two aren’t among
them.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Tim,

> Actually, most of the WDK structures are opaque, including even so
> widely-used ones as DEVICE_OBJECT and DRIVER_OBJECT…

No, this is just not true. There are many fields in both of these
structures that a driver is required to use for normal day-to-day operation.

If you look at declarations in ntddk.h and compare them with documentation, you will see that
these structures are *mostly*undocumented - the number of fields that we are officially allowed to access is quite limited. This is why I said that these structures are opaque (in fact, I should have said
“mostly opaque”, rather than just “opaque” - I see your point)

Anton Bassov