Driver is installed via DiInstallDevice and then DriverEntry fails. How to catch it?

My KMDF driver is installed via the following sequence from a user-mode app:

SetupCopyOEMInfW(path_to_inf_file, SPOST_PATH, );
SetupDiCallClassInstaller(DIF_REGISTERDEVICE, );

//Install the driver in the driver store
DiInstallDevice(,,);

From what I understand DiInstallDevice just copies my driver to the driver store and then (shortly thereafter) the PnP starts it. So the result returned by DiInstallDevice is just concerning the fact of whether the driver was installed in the driver store or not.

In case the driver fails to initialize (start), its DriverEntry may return a failure status code.

Is there a way to know from the user-mode app that called DiInstallDevice that the driver failed to start? Other than just polling for it with the SetupDi* functions.

The DiInstallDevice call covers both the driver store import and the installation on the device (including device start/restart). I can’t recall off hand if the DriverEntry failure will bubble out (don’t think so), but you should be able to check the status of the device immediately after DiInstallDevice returns.

DiInstallDevice returns success even if DriverEntry returns a failure NTSTATUS.