Question on driver installnation

Hi All,

Forgive me if this appears to be a na?ve question but I have failed to find myself a very satisfying explanation. Hopefully someone here could provide his ideas.

I have read and installed many sample drivers provided by some WDM tutorials. Nearly most of them are just for demonstration purposes without any connection with the real hardware. However, I noticed that they are installed just as normal device drivers with its AddDeive() called (observed in DbgView). And it shows that the Pdo for the device object is provided by PnpManager. And its device name are usually something like “ROOT#Unknown#0007#{…}”.

But when I tried to use SCM method to dynamically load the driver (without prior installation via .inf file), the AddDevice() will never be called. Without Pdo passing from outside, I couldn’t use IoRegisterInterface(). And I simply don’t know why it won’t call my AddDevice() function. Does it mean that I cannot use IoRegisterInterface() under this circumstance?

What else can I do if I really want to use IoRegisterInterface()?

Thanks in advance for any help generously provided.

Best regards,

Cody

To get your driver’s AddDevice routine called you need two things:

  1. Your driver has to have a service entry in SCM and has to be loaded

  2. There has to be a PDO which has your driver assigned to its device stack

Mucking around with SCM will only accomplish #1. You still need a PDO. There are a few ways to accomplish this:

  1. You can actually assign your driver to some appropriate piece of hardware. PNP normally does this as part of installing your driver from an INF. You can do it yourself using the SetupAPI functions to set the service property for the device then restarting it.

  2. You can create a device node manually using a tool like devcon.exe (in the DDK) and then you can assign it whatever hardware ID you like.

  3. You can call IoReportDetectedDevice from your driver to create a PDO and then attach to that. You still won’t get an AddDevice call, but you’ll have a PDO you can use for reporting interfaces.

What does your driver do that it needs to create an interface but doesn’t have any hardware?

-p

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Wu, Cody
Sent: Sunday, November 26, 2006 5:12 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question on driver installnation

Hi All,

Forgive me if this appears to be a na?ve question but I have failed to find myself a very satisfying explanation. Hopefully someone here could provide his ideas.

I have read and installed many sample drivers provided by some WDM tutorials. Nearly most of them are just for demonstration purposes without any connection with the real hardware. However, I noticed that they are installed just as normal device drivers with its AddDeive() called (observed in DbgView). And it shows that the Pdo for the device object is provided by PnpManager. And its device name are usually something like “ROOT#Unknown#0007#{…}”.

But when I tried to use SCM method to dynamically load the driver (without prior installation via .inf file), the AddDevice() will never be called. Without Pdo passing from outside, I couldn’t use IoRegisterInterface(). And I simply don’t know why it won’t call my AddDevice() function. Does it mean that I cannot use IoRegisterInterface() under this circumstance?

What else can I do if I really want to use IoRegisterInterface()?

Thanks in advance for any help generously provided.

Best regards,

Cody


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Hi Peter

Thanks very much for your explanation. :slight_smile:

Actually this is some question another guy asked me and I could not find a reasonable explanation because I myself have never given it a thought before. :frowning:

Pardon me if I still get some of the places unclear:

  1. You can actually assign your driver to some appropriate piece of hardware. PNP normally does this as part of installing your driver from an INF. You can >do it yourself using the SetupAPI functions to set the service property for the device then restarting it.

How can a inf file associate a driver with some piece of hardware if this driver itself is not connected with any hardware? I mean, the driver is put under Root/Unknown so no real hardware is there, right? Does it mean that the device manager couldn’t find the device but the inf file make him into believing that there is some hardware?

You can create a device node manually using a tool like devcon.exe (in the DDK) and then you can assign it whatever hardware ID you like.

Can you extend on this a little bit more or where can I find further information on this? Does it mean that the devcon produces some fake hardware which device manager just cannot tell it from real ones?

* What does your driver do that it needs to create an interface but doesn’t have any hardware?

Well, this is purely for experiment purposes. The guy want to use the driver to do some kernel-level operations from an application program and he doesn’t want to use CreateFile() or install the driver & let the driver create some symbolic link name. So he tried to see whether SCM & IoRegisterInterface() can fulfill his purpose. This surely enough sounds messy to me but I am just trying to get deeper understanding of the mechanisms behind the scene. :slight_smile:

Best regards,

Cody


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Monday, November 27, 2006 10:36 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Question on driver installnation

To get your driver’s AddDevice routine called you need two things:

  1. Your driver has to have a service entry in SCM and has to be loaded

  2. There has to be a PDO which has your driver assigned to its device stack

Mucking around with SCM will only accomplish #1. You still need a PDO. There are a few ways to accomplish this:

  1. You can actually assign your driver to some appropriate piece of hardware. PNP normally does this as part of installing your driver from an INF. You can do it yourself using the SetupAPI functions to set the service property for the device then restarting it.

  2. You can create a device node manually using a tool like devcon.exe (in the DDK) and then you can assign it whatever hardware ID you like.

  3. You can call IoReportDetectedDevice from your driver to create a PDO and then attach to that. You still won’t get an AddDevice call, but you’ll have a PDO you can use for reporting interfaces.

What does your driver do that it needs to create an interface but doesn’t have any hardware?

-p

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Wu, Cody
Sent: Sunday, November 26, 2006 5:12 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question on driver installnation

Hi All,

Forgive me if this appears to be a na?ve question but I have failed to find myself a very satisfying explanation. Hopefully someone here could provide his ideas.

I have read and installed many sample drivers provided by some WDM tutorials. Nearly most of them are just for demonstration purposes without any connection with the real hardware. However, I noticed that they are installed just as normal device drivers with its AddDeive() called (observed in DbgView). And it shows that the Pdo for the device object is provided by PnpManager. And its device name are usually something like “ROOT#Unknown#0007#{…}”.

But when I tried to use SCM method to dynamically load the driver (without prior installation via .inf file), the AddDevice() will never be called. Without Pdo passing from outside, I couldn’t use IoRegisterInterface(). And I simply don’t know why it won’t call my AddDevice() function. Does it mean that I cannot use IoRegisterInterface() under this circumstance?

What else can I do if I really want to use IoRegisterInterface()?

Thanks in advance for any help generously provided.

Best regards,

Cody


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer