TL;DR: How do I get device context structure inside IRP_MJ_DEVICE_CONTROL callback function for an NDIS Miniport driver.
I am writing an NDIS Miniport drivers based on "netvmini" in the Windows Driver Samples.
I am allocating a context structure to a WDFDevice I get from WdfDeviceMiniportCreate() call. I get FunctionalDeviceObject, NextDeviceObject, and PhysicalDeviceObject to pass into WdfDeviceMiniportCreate() from NdisMGetDeviceProperty() call.
I have found WdfWdmDeviceGetWdfDeviceHandle() function that I can call from the IRP_MJ_DEVICE_CONTROL callback function to get the WDFDevice and then get device context from WDFDevice. But according to https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfdevice/nf-wdfdevice-wdfwdmdevicegetwdfdevicehandle, I can't use this function: "the structure cannot represent any of the WDM device objects that the driver specified in a previous call to WdfDeviceMiniportCreate."
Other option I have is to use fDeviceObject->DeviceExtension member. But I don't get a chance to set up this DeviceExtension since I get fDeviceObject from NdisMGetDeviceProperty() call.
How else can I get device context in IRP_MJ_DEVICE_CONTROL callback function?