What difference between Custom Data and Custom Context in WDF

What difference between Custom Data and Custom Context in WDF object? For example WdfObjectGetTypedContext & WdfObjectGetCustomTypeData ?
What are best approaches to impl C++ inheritance style with WDF objects?

WDF handles are handles, not types. You can’t do inheritance with those.

Every WDF object can have a context structure. You will always want one with a WDFDEVICE, often with a WDFFILEOBJECT, and sometimes with a WDFQUEUE or WDFREQUEST, but any object can have one or more contexts.

WdfObjectGetCustomTypeData is only used if you create your own structures that you want KMDF to handle like its own objects. I have never used that, and it’s hard for me to think of a use case.

Typical WDF drivers call neither of these functions. WdgObjectGetTypedContext is called by your accessor function, that you declare with WDF_CONTEXT_DECLARE_TYPE_WITH_NAME. See the doc page.

The other, as Mr. Roberts describes, if for rolling your own WDF objects, about which see here.

Peer