WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE macro
[Applies to KMDF and UMDF]
The WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE macro initializes a driver's WDF_OBJECT_ATTRIBUTES structure and inserts an object's driver-defined context information into the structure.
Syntax
void WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(
_attributes,
_contexttype
);
Parameters
_attributes
A pointer to a WDF_OBJECT_ATTRIBUTES structure.
_contexttype
The structure type name of a driver-defined structure that describes the contents of an object's context space.
Return value
This macro does not return a value.
Remarks
Before calling WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE, you must call WDF_DECLARE_CONTEXT_TYPE or WDF_DECLARE_CONTEXT_TYPE_WITH_NAME globally (not within a function).
The WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE macro combines the WDF_OBJECT_ATTRIBUTES_INIT function and the WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE macro.
Examples
The following code example defines a WDM_NDIS_REQUEST context structure. Then, the example invokes the WDF_DECLARE_CONTEXT_TYPE_WITH_NAME macro to register the structure and specify that the context accessor method will be named RequestGetMyContext. Then, in a function, the example allocates a WDF_OBJECT_ATTRIBUTES structure, and then initializes the WDF_OBJECT_ATTRIBUTES structure.
typedef struct _WDM_NDIS_REQUEST
{
PMP_ADAPTER Adapter;
NDIS_OID Oid;
NDIS_REQUEST_TYPE RequestType;
PVOID InformationBuffer;
ULONG InformationBufferLength;
PULONG BytesReadOrWritten;
PULONG BytesNeeded;
} WDM_NDIS_REQUEST, *PWDM_NDIS_REQUEST;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(WDM_NDIS_REQUEST, RequestGetMyContext);
// above are in global space
...
WDF_OBJECT_ATTRIBUTES attributes;
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE( &attributes, WDM_NDIS_REQUEST );
Requirements
Target platform |
Universal |
Minimum KMDF version |
1.0 |
Minimum UMDF version |
2.0 |
Header |
Wdfobject.h (include Wdf.h) |