driverwdfumdf

UMDF: Access device registry key inside a EVT_WDF_TIMER callback function


I am having issues with a UMDF driver retrieving data stored in the device registry from a EVT_WDF_TIMER callback function. Such callback function only has WDFTIMER object as its sole parameter. To be able to access registry in UMDF, WdfDeviceOpenRegistryKey requires a pointer to the WDFDEVICE object. Prior to the callback function being called, my WDFTimer, which calls the callback function after the timer has elapsed, is created by WdfTimerCreate. I have provided the appropriate WDF_OBJECT_ATTRIBUTES as well, one of the attributes being a WDFOBJECT ParentObject where I assigned the WDFDEVICE object into.

Now, I was hoping I could retrieve the WDFDEVICE object I added in WDF_OBJECT_ATTRIBUTES, but it seems inaccessible from the WDFTIMER parameter. I am left wondering, is there any way I could retrieve a pointer to my WDFDEVICE from the EVT_WDF_TIMER callback function?


Solution

  • You can use WdfTimerGetParentObject to retrieve the WDFOBJECT.