When I try to stop the driver service by "sc stop", I got below error message.
C:\Temp>sc stop StorTrace
[SC] ControlService FAILED 1052:
The requested control is not valid for this service.
I have already specified the driver_unload function in the DriverEntry() as in below code. And I confirmed from the Dbg log that DriverUnload function is not get called when "sc stop" is issued. https://github.com/noguxun/StorTrace/blob/master/StorTrace/Driver.c
// config.DriverInitFlags = WdfDriverInitNonPnpDriver;
config.EvtDriverUnload = DriverUnload;
status = WdfDriverCreate(DriverObject,
The driver service is created by below, with
sc create StorTrace binPath= %SystemRoot%\System32\Drivers\StorTrace.sys type= kernel start= demand
Here is the service query information
C:\Temp>sc query StorTrace
TYPE : 1 KERNEL_DRIVER
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
Does anyone know what could be the reason the driver could not be stopped?