How to force the system load my driver?

Hi, I have a driver which is installed as a CDROM device lower filter like
imapi.sys. Now I meet a problem. After I disable the physical CDROM device
from the device manager and reboot the system, then the system will not load
my driver any more. I even couldn’t load it manually. Is there anyway that I
can force the system load my driver even when there is no real CDROM devices
in the system? Thanks.

You don’t mean “no REAL CDROM devices in the system”, right? You mean “no devices that are any kind of CDROM device”… I’m not sure if there’s something I’m missing with the word “real” in your post.

In any case, the short answer is “no” – You’re asking to be the lower filter of a given FDO. If that FDO isn’t instantiated, guess what? Neither are any filters that filter that FDO, either upper or lower.

That’s how things are supposed to work.

What is it that you are trying to accomplish by loading your filter? Instead of asking us why your pre-defined solution doesn’t work, try asking us how it might be best to solve your overall problem.

Peter
OSR

> After I disable the physical CDROM device from the device manager and reboot the system,

then the system will not load my driver any more.

Correct - this is how things are designed to work…

I even couldn’t load it manually.

Correct - you cannot load PnP drivers manually. If you load it with ZwLoadDriver() (i.e. something that SCM internally relies upon), the system will check whether your driver has created device objects in its DriverEntry(), and unload it if no device objects were created. Therefore, once PnP drivers create devices in AddDevice(), rather than in DriverEntry(), you cannot load them via SCM - they will get unloaded even before ZwLoadDriver() returns control…

Anton Bassov

> Correct - you cannot load PnP drivers manually.
For OP things are even worse: his (or hers) is a FILTER driver, IIRC.

When OP says “I want to load my filter” (to a nonexistent stack), I read it
as “I want my filter to auto-convert into a PnP driver”.

----- Original Message -----
From:
To: “Windows System Software Devs Interest List”
Sent: Tuesday, August 12, 2008 7:56 PM
Subject: RE:[ntdev] How to force the system load my driver?

>> After I disable the physical CDROM device from the device manager and
>> reboot the system,
>> then the system will not load my driver any more.
>
> Correct - this is how things are designed to work…
>
>> I even couldn’t load it manually.
>
> Correct - you cannot load PnP drivers manually. If you load it with
> ZwLoadDriver() (i.e. something that SCM internally relies upon), the
> system will check whether your driver has created device objects in its
> DriverEntry(), and unload it if no device objects were created.
> Therefore, once PnP drivers create devices in AddDevice(), rather than in
> DriverEntry(), you cannot load them via SCM - they will get unloaded even
> before ZwLoadDriver() returns control…
>
> Anton Bassov
>
> —
> 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

Actually my driver will create a communication device object in its
DriverEntry(). And that is the reason why I want to force the system load my
driver because some other modules (user mode and kernel mode) of our product
depend on this device. From you description do you mean that I can use
ZwLoadDriver() load my driver since my driver create device object in its
DriverEntry()?

Anyway I’ll give it a try. Thanks all you guys for the quick reponse.

On Tue, Aug 12, 2008 at 7:56 PM, wrote:

> > After I disable the physical CDROM device from the device manager and
> reboot the system,
> > then the system will not load my driver any more.
>
> Correct - this is how things are designed to work…
>
> > I even couldn’t load it manually.
>
> Correct - you cannot load PnP drivers manually. If you load it with
> ZwLoadDriver() (i.e. something that SCM internally relies upon), the system
> will check whether your driver has created device objects in its
> DriverEntry(), and unload it if no device objects were created. Therefore,
> once PnP drivers create devices in AddDevice(), rather than in
> DriverEntry(), you cannot load them via SCM - they will get unloaded even
> before ZwLoadDriver() returns control…
>
> Anton Bassov
>
> —
> 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
>

Quoting Michael Zhu :

> Hi, I have a driver which is installed as a CDROM device lower filter like
> imapi.sys. Now I meet a problem. After I disable the physical CDROM device
> from the device manager and reboot the system, then the system will not load
> my driver any more. I even couldn’t load it manually. Is there anyway that I
> can force the system load my driver even when there is no real CDROM devices
> in the system? Thanks.
>

You could install it also as a root enumerated device. You will need to alter your AddDevice routine and your
dispatch routines to distinguish between requests for cdrom and the root enumerated device.



-------------------------------------------------
Visit Pipex Business: The homepage for UK Small Businesses

Go to http://www.pipex.co.uk/business-services

Mr. Zhu,

You’re making us work awfully hard to try to figure out what you want to do. Just tell us what it is that you want to accomplish, and we can probably tell you how to best do it.

So far, it sounds like what you really want are TWO drivers: A root enumerated driver that establishes a control device object – this would be instantiated regardless of whether there are CDs in the system + a lower filter of the CDROM device that would only have it’s FDO instantiated for each CDROM device in the system. You’ll then need to establish a communication method between your root enumerated and your filter drivers. This is simple.

But, why make us guess so we can help you? Just tell us what it is you’re trying to do.

Peter
OSR

Hi Peter, sorry to make you confused by my description. The point is I don’t
want to implement 2 drivers. I hope I can use one driver to have all the
functionality. I’ll try to install my driver as a root enumerated driver and
have a test on it to see if this solution can solve my problem.

Again I am sorry to make you confused. Next time I’ll try to make my
question more clearly. And thank you very much for your response.

On Wed, Aug 13, 2008 at 10:29 AM, wrote:

>


>
> Mr. Zhu,
>
> You’re making us work awfully hard to try to figure out what you want to
> do. Just tell us what it is that you want to accomplish, and we can
> probably tell you how to best do it.
>
> So far, it sounds like what you really want are TWO drivers: A root
> enumerated driver that establishes a control device object – this would be
> instantiated regardless of whether there are CDs in the system + a lower
> filter of the CDROM device that would only have it’s FDO instantiated for
> each CDROM device in the system. You’ll then need to establish a
> communication method between your root enumerated and your filter drivers.
> This is simple.
>
> But, why make us guess so we can help you? Just tell us what it is you’re
> trying to do.
>
> Peter
> OSR
>
>
> —
> 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
>

NOTE: You STILL haven’t told us what you’re trying to achieve.

Hey, if you’re good with the answers you’ve gotten so far, great. Via con Dios.

Peter
OSR