none
Need to prevent installation of a second bus RRS feed

  • Question

  • I am in the process of improving a given virtual bus.

    This is a virtual USB bus written in WDM

    I'd like to prevent the user from installing more than one bus at a time.

    In my AddDevice I have added a mechanism to detect the existence of such bus:

    	// Test that there isn't another such bus
    	status = IoGetDeviceInterfaces(&GUID_DEVINTERFACE_SCPVBUS, NULL, DEVICE_INTERFACE_INCLUDE_NONACTIVE, &pSymbolicNameList);
    	if  (0 != *pSymbolicNameList)
    	{
    		Bus_KdPrint(("Add Device (bus): Already exists\n"));
    		status = STATUS_NO_SUCH_DEVICE;
    		return status;
    	}
    

    The detection is good.

    The first bus instance installs correctly. However, after the second attempt, both the existing bus and the new bus exhibit a failure message when examined with Device Manager:

    This device is not working properly because Windows cannot load the drivers required for this device. (Code 31)

    A device which does not exist was specified.


    Saturday, April 2, 2016 12:23 PM

Answers

  • you might be returning failure in the first stack. your better bet is to fail start device, not add

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by shaul_ei Monday, April 4, 2016 5:30 AM
    Sunday, April 3, 2016 4:58 AM

All replies

  • Don't return STATUS_NO_SUCH DEVICE?

    Sunday, April 3, 2016 12:30 AM
  • you might be returning failure in the first stack. your better bet is to fail start device, not add

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by shaul_ei Monday, April 4, 2016 5:30 AM
    Sunday, April 3, 2016 4:58 AM
  • The solution was, as Doron suggested, to detect the interface 

    IoGetDeviceInterfaces(&GUID_DEVINTERFACE_SCPVBUS, NULL, 0, &pSymbolicNameList);

    when the Bus FDO Starts
    I did return STATUS_NO_SUCH_DEVICE to make the Device Manager mark the 2nd bus as "not Started".

    Monday, April 4, 2016 5:35 AM