Windows UMDF drivers conflict - windows

I am working on a Windows UMDF project which is a virtual hid and is a modified version of Microsoft "vhidmini2" example.
This driver is a namedPipe server and one application (client) can connect to it. I need this driver for two applications so that I change the device information in Device section of .inx file along with the name of the Pipes and device string name macros in "common.h" and build it again. So that I have two drivers now and they are successfully installed and visible in Device manager.
Checking the Kernel logs I found out that uninstalling of the drivers has an effect on the other one. It looks like when one is uninstalled or installed the other one is reinstalled!!!
Another issue is that if one of the drivers is not connected to a client (through namedPipe) while the other one is, disabling the "Not Connected" one won't delete the created pipes. I must enable/disable that driver twice or disable the other driver also to delete the created pipes!
What can cause such a conflict? Is there a specific file or parameter that must be different in drivers?
I tried changing the provider's name or the ".cat" file name or the maindriver.c file name and did not help.

Related

Installing a driver for a specific device

I would like to install a custom driver for a specific device in my machine programmatically:
The driver comes as an .inf file (with some other files as well).
The device is one of two identical network adapters in my computer.
As far as I know the only way to achieve this goal is to use the Microsoft Setup API. From reading the documentation I would assume that I need to perform two steps:
Use "DiInstallDriver" to install my .inf-based driver into the driver store (see https://learn.microsoft.com/en-us/windows/win32/api/newdev/nf-newdev-diinstalldrivera).
Use "DiInstallDevice" to apply my driver to the device (see https://learn.microsoft.com/en-us/windows/win32/api/newdev/nf-newdev-diinstalldevice).
Would this be the correct/easiest way to do this?
If so, here's a follow up question: DiInstallDevice requires two parameters which I don't know how to acquire:
DeviceInfoData: this should point to the network adapter I want to modify. How do I get this?
DriverInfoData: this should probably point to the driver I installed in step 1? How do I get this?
PS: Doing all this manually is uper easy: Open device manager, right-click the network adapter, select 'Update driver', choose .imf file from disk -> done!
But in this case I need to do it programmatically.
PPS: DevCon is not an option. It only allows to exchange the driver based on an Hardware ID. And that ID is the same for both of my network adapters (since they are exactly identical). So it would change the driver both devices.
You don’t need to call two methods, DiInstallDriver not only preinstalls a driver in the driver store, but also installs the driver on devices present in the system that the driver supports.
You can refer to the following documents: Functions that Simplify Driver Installation
It seems that UpdateDriverForPlugAndPlayDevices is the simplest way.
For DiInstallDevice, this function should only be use if both of the following are true:
The application incorporates more than one device instance of the same type, that is, all the device instances have the same hardware IDs and compatible IDs.
The application requires that device-instance-specific drivers be installed on the device instances.
UpdateDriverForPlugAndPlayDevices or DiInstallDriver is the
simplest way for an installation application to install a new driver
that is the best match for devices in the system. ... The basic operation
of UpdateDriverForPlugAndPlayDevices is similar to the operation of
DiInstallDriver. However UpdateDriverForPlugAndPlayDevices
supports additional installation options.
You can specify the HardwareId of network adapter for the UpdateDriverForPlugAndPlayDevices. If you want to install your .inf driver no matter what a better driver already exists on your computer, you also need to specify InstallFlags as INSTALLFLAG_FORCE.(Caution: Forcing the installation of the driver can result in replacing a more compatible or newer driver with a less compatible or older driver.)

Change installed device driver

I am trying to change the installed driver for a device using SetupAPI. The driver is already present on the PC, just not currently selected.
More specifically, I am trying undo the installation of a third-party driver for a USB composite device, and install the default windows driver instead.
I already got it almost working like this: First, find the device using
SetupDiGetClassDevs
SetupDiEnumDeviceInfo
SetupDiGetDeviceInstanceId
to find the device.
Next, find the default USB composite device driver I want to install using
SetupDiBuildDriverInfoList
SetupDiEnumDriverInfo
SetupDiGetDriverInfoDetail
Once I found the driver, I call
SetupDiSetSelectedDriver
SetupDiInstallDevice
This actually does switch the driver back, as can be observed in device manager.
However, the third party driver put the device into its own group/category, and this change is not undone when using my approach.
Manually selecting the standard USB composite device driver in the device manager does restore the device category back to USB Controllers, which is why I think my driver installation process is incomplete. What might I be missing?
Turns out the working installation sequence is
SetupDiSetSelectedDevice
SetupDiSetSelectedDriver
InstallSelectedDriver // From newdev.dll, not in a public header

Is it possible to fully install a driver when the device is not present?

Is it possible to fully install (and not just pre-install) a device driver on a system before the physical device is plugged in? In particular, I'm looking at the D2XX drivers by FTDI. Their driver installation program effectively runs dpinst.exe, and if you watch the console output of that program it says this:
No matching device was found for 'c:\drivers\ftdiport.inf'. Driver will be installed when plugged in.
The trouble is that I'm also using their .NET library for accessing the device, and that library is funny. It pops up an alert in the constructor if the driver isn't installed. Of course the usual solution is to simply plug in the device and let the driver installation finish as normal, but sometimes this is neglected. The pitfalls with having an unavoidable popup box in a 3rd party library should be obvious.
So does anyone know of a way to automate the full installation, and not just the pre-installation? Are there any dangers to copying the driver to the system folder manually / in advance?
You seem to mention "fully install" by "staging" the driver not by "loading" the driver. You can refer to the source code of "devcon.exe" for dp_add command, which actually do staging the driver package. Staged driver package will be being searched by PnP Manager when the unknown device is detected.

Remove incorrect binding of composite device to custom driver

Our latest WHQL'ed custom driver has an incorrect entry for one of our upcoming product. The upcoming product is composite device and our WHQL'ed driver has an entry which matches the device ID for the composite device instead of the individual interfaces.
When the new device is connected to machines which have the WHQL'ed driver, the device gets binded to our driver and not to Windows Generic Parent Driver (usbccgp.sys). This prevents the interfaces in the device from being listed.
We could manually fix this by uninstalling the driver for the device and making it to bind to usbccgp.sys driver. In Vista and higher versions, we could delete the driver binaries at the time of uninstall. But there is no direct way to completely delete the driver binaries in XP. This makes it very difficult to cleanly uninstall the driver
Can this be fixed using an uninstaller? What is the best way to fix the affected machine in an automated way?
Download the Windows Driver Development Kit (Win DDK) and locate the devcon.exe executable for your architecture. Then, from an elevated command prompt:
devcon.exe find =usb
To list all of your current devices.
devcon.exe -r remove =usb *YOUR_HARDWARE_ID*
Will complete disassociate the device and driver from the target machine. If you have trouble getting the hardware id you can blow away all your USB drivers and let Windows auto-detect them after reboot.
devcon.exe -r remove =usb *
Extreme, yes. Effective, yes. We work with virtual comm ports all day and our test machines often experience your same issue. This technique has yet to fail.

Make driver load automatically when USB device is inserted

I'm using a Limited User account under Windows XP, and I'm having a bit of trouble getting my Adaptoid (the most coveted N64 controller -> USB adapter, because of it's support for sending raw N64 controller commands + the fact that it's been discontinued) to work smoothly: as installed, the included software requires Administrator privileges to load the driver.
Presumably, it is possible to arrange for the driver to be loaded automatically when the Adaptoid is inserted by adding some stuff to the INF file for the driver (wishna1.inf):
the question is, what stuff?
(It would also suit me just as well if the driver could be automatically loaded when anything attempted to open \Device\Wish_NA1, or even to have it automatically loaded at every boot, really, but doing it on insertion seems like the right way.)
Note: I do have access to an administrative account, it's just that I prefer not to have to use it day-to-day.
First of all, let's clarify that a USB device has a Plug & Play driver on Windows 2000 and higher, so services start modes are irrelevant. The driver will have an entry as a "service" in the registry, but its start mode is irrelevant here.
Let's split the problem into two parts:
Installing driver for the device: This requires administrative privileges. This happens when you insert a USB device into a port for the first time. Windows goes over your .INF files to find one that matches your hardware. If the driver is WHQL-certified, it'll load automatically. Otherwise, you'd see the dreaded Add New Hardware wizard. If you're running as admin, a few clicks on Next should be enough to install it. Otherwise, better have that Administrator password ready.
Loading the driver for the device: Once the device is installed, the driver will be loaded each time this device is inserted into this USB port without requiring any additional user intervention. Ever noticed how a USB printer, camera or disk drive load much faster the second time you plug it in? That's because that's just loading, without installing.
From looking at the .INF, it looks valid. Also, it's not WHQL-certified, so you'd have to install it manually.
I'm assuming when you insert the Adaptoid, you get an Add New Hardware wizard. If you point it manually to the installation directory, does the Adaptoid install and function? Does it appear in the Device Manager?
P.S. USB devices which have a serial number are an exception. They're installed once for all USB ports. Those devices are rather uncommon, though.

Resources