driver service cannot be stopped

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,
RegistryPath,
&attributes,
&config,
WDF_NO_HANDLE
);

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

SERVICE_NAME: 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?

You can neither start nor stop PnP filters with the Service Control Manager. You need to use an INF and Device Manager (or devcon).

Peter
OSR
@OSRDrivers