Getting WDFDEVICE from WDFOBJECT

Hi All,

In my KMDF function driver, I need to create a bunch of WDFOBJECTS (they have some parent and child hierarchy)and then during their cleanup callback, need to delete those by firing a command to hardware. I am initiating the cleanup from “EvtPreInterruptDisable” by deleting the TOP WDF object, so that entire chain on cleanup callbacks get called. My problem is that in every cleanup
I get a WDFOBJECT which I am cleaning up.

Is there a way I can get my DeviceExtension or my FDO (so that I can get my DeviceExtension)?
I can always save my device extension in the context of the object that I create then get it from there, but just wondering if there is a better way to do it.

Thanks
Aj

You need to store the wdfdevice in each objects context