How can I add a device interface to a non-pnp driver?

First I’ll start by answering the obligatory “what are you really trying to do here?” question :slight_smile:

I just want to send IOCTLs to a driver from a UWP app. This has led me to the CustomDevice.FromIdAsync() method to open a driver. This open is based on a device interface GUID path, i.e. it won’t work with a symbolic link/control device type of driver. The core problem is, my device does not have a hardware component and is a simple nonpnp driver. The kmdf framework prevents device interfaces from being registered on these devices. To make sure I wasn’t doing something stupid I took the ioctl WDK sample and simply added a call to WdfDeviceCreateDeviceInterface, but it fails with STATUS_INVALID_DEVICE_REQUEST. The ioctl sample exposes a symlink name that the user app opens, and that’s great with win32, but seems to be a complete dead end with a UWP/store app.

So is there any way to do this? The only thing I can imagine is writing a bus driver to enumerate my hardware-less device, simply so that it fits into the pnp mold and thus can have a device interface exposed. But that seems like a huge amount of effort just to be able to send an ioctl.

-JT

Make your driver a PnP software only driver. Very simple in KMDF.

Add EvtDriverDeviceAdd and create your WDFDEVICE and Queues there. No need for EvtDevPrepareHwardware or EvtDeviceD0Entry.

Done.

Peter

You can’t create a device interface from a non pnp driver. This is a limitation of the OS, not WDF. You don’t need to write a bus driver (which would be root enumerated anyways), rather create a root enumerate software only pnp device and load your driver directly on it.

d

Thanks for the responses. I think I’m missing something very basic here. I took the “nothing_wdf” sample (http://www.osronline.com/article.cfm?article=390) and it installs fine. But it has just put a driver package in the driver store, no .sys has been copied and no registry entries have been created. How do I actually create the software device that would in turn cause the system to see our INF and subsequently load our driver to handle that device?

EDIT: using ‘devcon install nothing_wdf.inf Root\OsrNothing’ I was able to get the driver to install and load… I’ll just have to look at what devcon is doing internally to make this happen (unless I’m still heading down the wrong path and there is a better way). Ideally I’d be able to load/unload this driver at runtime, but I’m not sure if that is compatible with this type of install?

Creation of a root enumerated device is separate from importing and installing a driver package. Devcon install […] will create the root enumerated device. If you have an always running service paired with your driver SWDEVICE can be used to create a device node as well.

d

Bent from my phone


From: Jason_T.
Sent: Wednesday, January 16, 2019 1:49:27 PM
To: Doron Holan
Subject: Re: [NTDEV] How can I add a device interface to a non-pnp driver?

OSR https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.osr.com%2F&data=02|01|doron.holan%40microsoft.com|28209407970c4f26d4c308d67bfc7d4d|72f988bf86f141af91ab2d7cd011db47|1|0|636832721709362971&sdata=NU8jQoPzKlXXJ7IwcpLn6Ln%2FXxKEy3xWxiES6J3n%2FeY%3D&reserved=0
Jason_T. commented on How can I add a device interface to a non-pnp driver?

Thanks for the responses. I think I’m missing something very basic here. I took the “nothing_wdf” sample (https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.com%2Farticle.cfm%3Farticle%3D390&data=02|01|doron.holan%40microsoft.com|28209407970c4f26d4c308d67bfc7d4d|72f988bf86f141af91ab2d7cd011db47|1|0|636832721709362971&sdata=JlRikzylzwBvRSkaL0wOvXu6oPl%2F2%2BvfVsulvvD5Edo%3D&reserved=0) and it installs fine. But it has just put a driver package in the driver store, no .sys has been copied and no registry entries have been created. How do I actually create the software device that would in turn cause the system to see our INF and subsequently load our driver to handle that device?