So I'm writing a PCIe device driver using the same PC for both the development and testing. The problem I'm having is that I cannot find any way to actually start the driver without having it automatically start up the next time my PC restarts. That's really important since if I crash the kernel/entire PC inside DriverEntry(), EVT_WDF_DEVICE_D0_ENTRY or EVT_WDF_DEVICE_PREPARE_HARDWARE, the PC will not start back up properly again as it tries to load the same buggy driver over and over and it's a complete pain to get out of this endless cycle.
What I'm trying to do is register my driver with StartType = 4 (SERVICE_DISABLED) in my INF file. That works fine and registers the driver without starting it as expected and shows up in the device manager fine with a caution sign on top of it (I'm simply installing it by right clicking and doing "Install" from file explorer on the INF file right next to my driver SYS file). The problem is I cannot figure out how to actually start the thing. "sc start" gives me error 1058 (ERROR_SERVICE_DISABLED), the service cannot be started, either because it is disabled or because it has no enabled devices associated with it. "devcon restart" at least said it succeeds, but it isn't actually started as I know my DriverEntry() is never called because I never get the output from a DbgPrintEx() statement in my DriverEntry() in the DebugView utility. "devcon enable" before doing "devcon start" doesn't help either. I even wrote a command line utility to start the driver using OpenSCManager(), OpenService() and StartService() to start it and StartService() also fails with error 1058 (ERROR_SERVICE_DISABLED) same as "sc start". I tried using the old OSR Loader utility which can start the driver (to the point of hitting DriverEntry()) but it cannot stop the driver once it's started so it's not of too much use.
Does anybody know a way to start a driver marked with SERVICE_DISABLED in it's INF file? Alternatively, is there another way to load and start a device driver in a way that it won't startup automatically the next time the PC is started?
It looks like you're new here. If you want to get involved, click one of these buttons!
|Upcoming OSR Seminars|
|Developing Minifilters||29 July 2019||OSR Seminar Space|
|Writing WDF Drivers||23 Sept 2019||OSR Seminar Space|
|Kernel Debugging||21 Oct 2019||OSR Seminar Space|
|Internals & Software Drivers||18 Nov 2019||Dulles, VA|