Hi All,
I have a user-space application that launches and interacts with the control driver, once the operation is complete triggers a unload request using service-control APIs.
Stopping of driver service is done in the following way:
ControlService((SC_HANDLE)hService, SERVICE_CONTROL_STOP,&serviceStatus);
DeleteService((SC_HANDLE)hService);
CloseServiceHandle((SC_HANDLE)hService);
CloseServiceHandle((SC_HANDLE)hSCManager);
There are no errors seen in the above sequence of operations. But I do not see EvtDriverUnload() callback of the control driver is called as well.
Upon the next run of the user-space application, the CreateService() call fails with the error as ERROR_SERVICE_MARKED_FOR_DELETE (which means the service was marked for deletion but the operation is not complete yet?)
How can one perform clean unload of the control driver at the first attempt? Am I missing anything that is leading to this behavior?
Thanks!