WdfDeviceCreateDeviceInterface

Hi

I am trying to create kernel-mode driver for virtual disk. The point is that I would like to be able to load and unload this driver from user-mode application (for let’s say creating and deleteing the disk from Windows Explorer using two buttons in Windows App). I was trying to create both WDM and KMDF version of this driver. Unfortunatelly with no success. Both of them are failing during the interface registration (the WDM one when I call IoRegisterDeviceInterface with MOUNTDEV_MOUNTED_DEVICE_GUID and KMDF one when I call WdfDeviceCreateDeviceInterface GUID_DEVINTERFACE_VOLUME). Acctually I was trying to use different GUID’s but non of them were ok. What shall I do inside the driver to be able to register an interface?? All attemts ended with STATUS_INVALID_DEVICE_REQUEST.

The other problem I have is that I was loading those drivers using the ORSDriverLoader and for the KMDF dirvers I was able to load onlu non pnp driver. The pnp one was causing the problem after the DeviceEntry exit (No harwdare found for that driver or service cannot start). Is it possible to load the pnp driver from normal application without using the inf file (using let’s say ServiceCreate, ServiceOpen and ServiceStart commands)??

Thanks for help in advance…

A pnp driver needs a devnode, you cannot use the osr tool or the SCM APIs to start the driver. IoRegisterDeviceInterface/ WdfDeviceCreateDeviceInterface require a pnp stack (a PDO really).

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@interia.pl
Sent: Thursday, April 02, 2009 1:44 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] WdfDeviceCreateDeviceInterface

Hi

I am trying to create kernel-mode driver for virtual disk. The point is that I would like to be able to load and unload this driver from user-mode application (for let’s say creating and deleteing the disk from Windows Explorer using two buttons in Windows App). I was trying to create both WDM and KMDF version of this driver. Unfortunatelly with no success. Both of them are failing during the interface registration (the WDM one when I call IoRegisterDeviceInterface with MOUNTDEV_MOUNTED_DEVICE_GUID and KMDF one when I call WdfDeviceCreateDeviceInterface GUID_DEVINTERFACE_VOLUME). Acctually I was trying to use different GUID’s but non of them were ok. What shall I do inside the driver to be able to register an interface?? All attemts ended with STATUS_INVALID_DEVICE_REQUEST.

The other problem I have is that I was loading those drivers using the ORSDriverLoader and for the KMDF dirvers I was able to load onlu non pnp driver. The pnp one was causing the problem after the DeviceEntry exit (No harwdare found for that driver or service cannot start). Is it possible to load the pnp driver from normal application without using the inf file (using let’s say ServiceCreate, ServiceOpen and ServiceStart commands)??

Thanks for help in advance…


NTDEV is sponsored by OSR

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

xxxxx@interia.pl wrote:

I am trying to create kernel-mode driver for virtual disk. The point is that I would like to be able to load and unload this driver from user-mode application (for let’s say creating and deleteing the disk from Windows Explorer using two buttons in Windows App). I was trying to create both WDM and KMDF version of this driver. Unfortunatelly with no success. Both of them are failing during the interface registration (the WDM one when I call IoRegisterDeviceInterface with MOUNTDEV_MOUNTED_DEVICE_GUID and KMDF one when I call WdfDeviceCreateDeviceInterface GUID_DEVINTERFACE_VOLUME). Acctually I was trying to use different GUID’s but non of them were ok. What shall I do inside the driver to be able to register an interface?? All attemts ended with STATUS_INVALID_DEVICE_REQUEST.

Device interfaces can only be used by PnP drivers.

The other problem I have is that I was loading those drivers using the ORSDriverLoader and for the KMDF dirvers I was able to load onlu non pnp driver. The pnp one was causing the problem after the DeviceEntry exit (No harwdare found for that driver or service cannot start). Is it possible to load the pnp driver from normal application without using the inf file (using let’s say ServiceCreate, ServiceOpen and ServiceStart commands)??

No. By definition, non-PnP drivers use the service manger, and PnP
drivers do not. Just that simple.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

So I have to use pnp driver to be able to implement interfaces. And that means I cannot use Service Manager to load the driver. So what is the option to dynamicly load and unload the pnp driver from user mode application ??

xxxxx@interia.pl wrote:

So I have to use pnp driver to be able to implement interfaces. And that means I cannot use Service Manager to load the driver. So what is the option to dynamicly load and unload the pnp driver from user mode application ??

If you are dynamically loading and unloading the driver, why do you need
interfaces? Just use a symbolic link. Interfaces are beneficial when
you don’t know how many there will be, or when several different drivers
offer the same service. Neither is the case for you. You have a single
purpose driver, loaded once, offering fixed services. Nothing wrong
with a named object and a symbolic link in that case.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Yes I thought that also. However in one of the articles on MSDN I could read that I need to implement one of those interfaces to be ablo to cooparte with mount manager. And that beast is needed to make the disk visible inside the Windows Explorer.
So right now I don’t know weather it is true or not.

Creating a symbolic link is a not a problem. What is more in command line console the drive letter that is linked to my driver is normally visible. However Windows Explorer doesn’t show this at all…

So any ideas how to deal with that??

If you need a device interface and you need to dynamically create/destroy a device stack, look at the devcon sources in the wdk. It will show you how to create a root enumerated stack which can then enable the interface

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@interia.pl
Sent: Friday, April 03, 2009 12:02 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfDeviceCreateDeviceInterface

Yes I thought that also. However in one of the articles on MSDN I could read that I need to implement one of those interfaces to be ablo to cooparte with mount manager. And that beast is needed to make the disk visible inside the Windows Explorer.
So right now I don’t know weather it is true or not.

Creating a symbolic link is a not a problem. What is more in command line console the drive letter that is linked to my driver is normally visible. However Windows Explorer doesn’t show this at all…

So any ideas how to deal with that??


NTDEV is sponsored by OSR

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

Seach list archives. The problem with visibility in exploder was
discussed numerous times and solution is known for a long time (I guess
I posted it when XP were new or beta). Basically, you need to send a
broadcast in user mode informing exploder about new drive arrival.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@interia.pl
Sent: Friday, April 03, 2009 9:02 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfDeviceCreateDeviceInterface

Yes I thought that also. However in one of the articles on
MSDN I could read that I need to implement one of those
interfaces to be ablo to cooparte with mount manager. And
that beast is needed to make the disk visible inside the
Windows Explorer.
So right now I don’t know weather it is true or not.

Creating a symbolic link is a not a problem. What is more in
command line console the drive letter that is linked to my
driver is normally visible. However Windows Explorer doesn’t
show this at all…

So any ideas how to deal with that??


NTDEV is sponsored by OSR

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

>Manager to load the driver. So what is the option to dynamicly load and unload the pnp driver from

user mode application ??

Enable or disable its device node with SetupDiCallClassInstaller


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Thanks for information that you given me so far.
However one more think is not fully clear for me:

> Basically, you need to send a broadcast in user mode informing exploder about new drive arrival

Do you mean

  1. Create symbolic link from the driver
  2. Call DefineDosDevice from the user mode app
    ??

> -----Original Message-----

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@interia.pl
Sent: Saturday, April 04, 2009 9:36 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfDeviceCreateDeviceInterface

Do you mean

  1. Create symbolic link from the driver
  2. Call DefineDosDevice from the user mode app

No, I mean to create symbolic link in the driver and then call a
broadcast in user mode to inform exploder about new drive arrival. Don’t
ask me about exact code; just search archives.

Anyway, you can try the second possibility. When driver creates new
device on demand, it can return its name to the app which requested it
and app can call DefineDosDevice() on its own. It should send the
broadcast internally. The problem is it’ll probably create drive letter
for current logon session only. Similarly as “net use x:” does. I’m not
quite sure, though and it may not be a problem at all for you.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]