I am really new to KMDF and while I am looking into USBSamp samples from WDK6000 I came upon a quetion about the powerful macro : WDF_DECLARE_CONTEXT_TYPE_WITH_NAME
There are 4 declarations in the <private.h>
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(
FILE_CONTEXT, GetFileContext)
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(
DEVICE_CONTEXT, GetDeviceContext)
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(REQUEST_CONTEXT , GetRequestContext)
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(WORKITEM_CONTEXT, GetWorkItemContext)
Whenever you need one of the context we just call the casting function of the macro like below.
pDeviceContext = GetDeviceContext(Device);
fileContext = GetFileContext(WdfRequestGetFileObject(Request));
Then what kind of argument can go in the casting function to call GetDeviceContext(??) or GetFileContext(??) ?
In this example they used WDFDEVICE for GetDeviceContext() and WDFFILEOBJECT for GetFileContext()
Thank you.</private.h>