Hello, I reread my message on the same subject that I posted yesterday and I
think
it was a little unclear. Here it is again in the hope that someone can help
me.
I have a kernel driver that creates a few devices visible from ring3
applications
and I want it to be able to prevent the user from stopping it under certain
conditions,
namely while one of its device is in the open state.
After I call ControlService with the CONTROL_SERVICE_STOP while one of the
devices is open, I noticed that, upon return, there is no error reported,
the status
of the service is “closing” and the driver unload routine is not called
until the
device is later closed by its user.
Although this is almost what I am looking for, the problem is that once
ControlService is called and has queued the CLOSE control command to the
service there seems to be no way to abort it (afaik), and the result
is that the system will keep it queued for an indefinite time, eventually
stopping the service but without synchronous control from the issuer of
the STOP command point of view.
The solution of this problem is probably to disable the STOP command while
the
driver has one of its devices in the open state so that when the STOP is
issued,
ControlService will return an appropriate error indicating that one of the
devices
is not idle. In a ring3 service, that task could be done by calling
SetServiceStatus
to disable SERVICE_ACCEPT_STOP from the controls that can be accepted so
that ControlService will fail, but the question is : how it can be done from
within a
kernel mode driver?
Thanks in advance and sorry for the duplicate message,
Marco