installing driver "FROM" a Service during startup

M

mlc

Calling OpenSCManager() to install a driver from a service that is
automatially starting during system start appears to "block" after the SCM
has determined that the Service has hung. Why is this? What can I do to
install a driver at service * system start time.

DETAILS:

I have a service that is automatically started on system startup. During
service start it installs and creates a driver. This works fine starting and
stopping the driver using the MCC Service manager. However, it "blocks"
during system startup but does load successfully -- placing a number of
eventlog entries in the Service I see:

Service starting (time x)
Service ready to call OpenSCManager() to load driver (time x+1 second)
SCM reporting Service "Hung" (time x+10 seconds)
Service finishes call to OpenSCManager() and successfully loads driver
(time x + 11seconds to 1 minute!!!)
Service started

When starting under MCC Service manager it starts in a second or two. Under
system start the Service components all start very quickly, except the call
to OpenSCManager does not complete until the SCM loading the Service
declares the Service Hung. What gives?
 
M

mlc

Actually, what is happening here is the OpenSCManager() is not blocking, but
the call to CreateService() that creates the driver service.
So, why is CreateService blocking? Would SCM locking cause this?
 
P

Peter Wieland [MSFT]

it's very likely that this is the problem.

why wouldn't your driver be installed along with your service?

-p
 
M

Maxim S. Shatskih

Actually, what is happening here is the OpenSCManager() is not blocking, but
the call to CreateService() that creates the driver service.
So, why is CreateService blocking? Would SCM locking cause this?

Some deadlock inside SCM. Probably it is not possible to call OpenSCManager
from the service's init path.

I would suggest installing the driver once forever during the installation in
Manual start mode, and then starting it from the service (not from the init
paths).
 
S

soumik

From MSDN help for StartService:


"A service cannot call StartService during initialization. The reason
is that the SCM locks the service control database during
initialization, so a call to StartService will block. Once the service
reports to the SCM that it has successfully started, it can call
StartService."

HTH.
Soumik.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top