Are you doing this in a pnp driver? Are you creating a pnp WDFDEVICE in addition to the control WDFDEVICE below?
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, July 28, 2015 7:28 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Not getting creates in KMDF
I have tried the following (error checking removed for clarity)
// BTW, what SDDL should be used here? Since I am not naming my device and don’t want it to be accessible directly, I first tried passing NULL but that bugchecks. I don’t want to limit or loosen whatever security RFCOMM is requesting…
deviceInit = WdfControlDeviceInitAllocate(MyDriver, &SDDL_DEVOBJ_KERNEL_ONLY);
ntStatus = WdfDeviceCreate(&deviceInit, WDF_NO_OBJECT_ATTRIBUTES, &MyControlDevice);
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQueueConfig, WdfIoQueueDispatchParallel);
// the docs indicate this will be set to WdfDefault which will only be WdfFalse in the case of a filter, which I am, however they also say I can’t call WdfFdoInitSetFilter on a control device so I figured I should manually override this. Correct?
ioQueueConfig.PowerManaged = WdfFalse;
ioQueueConfig.EvtIoDefault = MyFltrControlIoDefault;
ntStatus = WdfIoQueueCreate(MyControlDevice,
&ioQueueConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&queue);
RtlInitUnicodeString(&uniTargetName, L"\Device\BTHMS_RFCOMM");
ntStatus = WdfIoTargetCreate(MyControlDevice, WDF_NO_OBJECT_ATTRIBUTES, &MyControlIoTarget);
WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(&openParams, &uniTargetName, STANDARD_RIGHTS_ALL);
ntStatus = WdfIoTargetOpen(MyControlIoTarget, &openParams);
WdfControlFinishInitializing(MyControlDevice);
MyCtrlDevObj = WdfDeviceWdmGetDeviceObject(MyControlDevice);
ntStatus = IoAttachDevice(MyCtrlDevObj, &uniTargetName, &BTBTHMS_RFCOMMDevObj);
I kick off a timer routine and once the RFCOMM device is created this all succeeds… the problem is, the WDF control device seems to be going away shortly thereafter. A second after all of these steps succeed the WDF control device is no longer valid, nor is the WDM device object that was associated with it. But the RFCOMM device is still valid and still showing our now invalid device object as being attached so the system crashes as soon as RFCOMM gets its first request. Am I missing some step to “reference” the control device and keep it from being disposed?
Prior to the call to IoAttachDevice:
4: kd> !wdfkd.wdfdevice 0x0000057f`ef1c02a8 Treating handle as a KMDF handle!
Dumping WDFDEVICE 0x0000057fef1c02a8
WDM PDEVICE_OBJECTs: self fffffa8010e3fb40
Control WDFDEVICE
4: kd> !devobj 0xfffffa80`10e3fb40
Device object (fffffa8010e3fb40) is for:
000000e4 \Driver\MyFltr DriverObject fffffa8010473060 Current Irp 00000000 RefCount 0 Type 00000022 Flags 00000044 Dacl fffff9a100ceac51 DevExt fffffa8010e40000 DevObjExt fffffa8010e3fcb8 ExtensionFlags (0000000000) Characteristics (0x00000180) FILE_AUTOGENERATED_DEVICE_NAME, FILE_DEVICE_SECURE_OPEN Device queue is not busy.
IoAttachDevice returns success and the returned PDEVICE_OBJECT does point to RFCOMM as expected. But then I hit F5 and break in about 1 second later and now I get this:
4: kd> !wdfkd.wdfdevice 0x0000057fef1c02a8 Treating handle as a KMDF handle! Not a valid WDFDEVICE handle 4: kd\> !devobj 0xfffffa80
10e3fb40
fffffa8010e3fb40: is not a device object
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer