I’m converting a WDM driver to WDF (KMDF), but have run into a snag with my WdfDeviceCreate() calls. I currently one and only one active WdfDeviceCreate() call in all of my driver, under the EvtDeviceAdd() callback, but it fails every time with the status STATUS_INVALID_DEVICE_STATE (0xC0000184). I’m led by the WdfDeviceCreate() reference page to believe this is caused because “…the driver has already created a device object for the device”. I’m very puzzled. Frankly, I had this code fragment working until I modified my DEVICE_EXTENSION, but I don’t think that’s why it’s failing, as I swapped out the old for the new, and problem remains.
That said, I’m wondering what the framework might be keying off to return this status? I.e. are there other conditions which would yield this status?
Code snippet that is attached is very unremarkable for its generic nature,
hence my extreme puzzlement.
Thanks very much in advance for any help or suggestions.
Mike
NTSTATUS
EvtDeviceAdd(IN WDFDRIVER Driver, IN PWDFDEVICE_INIT DeviceInit)
…
…
WDF_OBJECT_ATTRIBUTES attrib;
NTSTATUS status;
WDFDEVICE device;
DEVICE_EXTENSION *p_fdo;
WDF_PNPPOWER_EVENT_CALLBACKS callbacks;
UNREFERENCED_PARAMETER(Driver);
PAGED_CODE ();
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&callbacks);
callbacks.EvtDevicePrepareHardware = EvtPrepareHardware;
callbacks.EvtDeviceReleaseHardware = EvtReleaseHardware;
callbacks.EvtDeviceD0Entry = EvtDeviceD0Entry;
callbacks.EvtDeviceD0Exit = EvtDeviceD0Exit;
WdfDeviceInitSetPnpPowerEventCallbacks( DeviceInit, &callbacks );
WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_UNKNOWN);
WdfDeviceInitSetExclusive(DeviceInit, FALSE);
WDF_OBJECT_ATTRIBUTES_INIT(&attrib);
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_EXTENSION);
status = WdfDeviceCreate(DeviceInit, &attrib, &device);
if (!NT_SUCCESS(status))
{
DbgPrint,(“WdfDeviceCreate failed with 0x%x\n”, status);
return status; //failure path…
}
…
…
// success path…
…
PS [Sorry if this posting is a duplicate. My first posting late on
6/15/2009 didn’t appear on two updates from NtDev].