Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reference Counting StartService/ControlService On Legacy Driver

2 views
Skip to first unread message

Le Chaud Lapin

unread,
Jul 16, 2008, 7:23:26 PM7/16/08
to
Hi All,

I have what I imagine is a common problem:

I have a legacy NDIS driver that is started/stopped dynamicaly by
StartService/ControlService. The problem is that user-mode EXE's, in
multiple user accounts, need to start, and perhaps stop, the service,
multiple times, simultaneously, during their normal courses of
execution.

Unfortunately, it seems that the policy of:

ControlService (hDriverService, SERVICE_CONTROL_STOP, &status);

...is to force a true stop of the service, always, irrespective of how
many StartService calls were invoked to start the driver.

I could do what I am doing now, which is simply let the driver stay
loaded until reboot, but I was wondering what is the proper way to
handle this situation.

TIA,

-Le Chaud Lapin-

Maxim S. Shatskih

unread,
Jul 17, 2008, 4:31:35 AM7/17/08
to
> I could do what I am doing now, which is simply let the driver stay
> loaded until reboot, but I was wondering what is the proper way to
> handle this situation.

Rewriting the driver as PnP is the proper way, then use SetupDiXxx instead of
SC API.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
ma...@storagecraft.com
http://www.storagecraft.com

Le Chaud Lapin

unread,
Jul 28, 2008, 12:50:21 AM7/28/08
to
On Jul 17, 3:31 am, "Maxim S. Shatskih" <ma...@storagecraft.com>
wrote:

> > I could do what I am doing now, which is simply let the driver stay
> > loaded until reboot, but I was wondering what is the proper way to
> > handle this situation.
>
> Rewriting the driver as PnP is the proper way, then use SetupDiXxx instead of
> SC API.

Hi Max,

How does that help?

For instance, what would be the equivalent function pairs for open/
close?

-Le Chaud Lapin-

Maxim S. Shatskih

unread,
Jul 28, 2008, 4:48:45 AM7/28/08
to
>Hi Max,
>How does that help?

Frankly speaking, Windows starting from w2k has only limited support for
non-PnP drivers _for real hardware_, so, it is a good idea to go PnP.

Le Chaud Lapin

unread,
Jul 28, 2008, 9:19:28 AM7/28/08
to
On Jul 28, 3:48 am, "Maxim S. Shatskih" <ma...@storagecraft.com>
wrote:

> >Hi Max,
> >How does that help?
>
> Frankly speaking, Windows starting from w2k has only limited support for
> non-PnP drivers _for real hardware_, so, it is a good idea to go PnP.

But this an NDISPROT-based protocol driver.

-Le Chaud Lapin-

Maxim S. Shatskih

unread,
Jul 28, 2008, 10:26:16 AM7/28/08
to
>But this an NDISPROT-based protocol driver.

Then why is it "legacy"? is it NDIS4? is there any ProtocolBind/UnbindAdapter
functions in it?

Le Chaud Lapin

unread,
Jul 28, 2008, 11:27:23 AM7/28/08
to
On Jul 28, 9:26 am, "Maxim S. Shatskih" <ma...@storagecraft.com>
wrote:

> >But this an NDISPROT-based protocol driver.
>
> Then why is it "legacy"? is it NDIS4? is there any ProtocolBind/UnbindAdapter
> functions in it?

5.1.

There is no AddDevice, and the the WDM flag is not being set in PE
header. [I think I learned this from you a while back].

It seems that this is a common problem, especially with applications
that disgorge a driver from their internal resource image table
dynamically at run-time. If multiple instances of such an application
is run, there will have to be some time of coordination among those
applications to make sure that the driver is not prematurely unloaded.
Seems like the coordination could not be done via the driver itself,
lest a race condition occurs (but with extremely small probability).

-Le Chaud Lapin-

0 new messages