OpenVPN TAP Driver Installation

atanamir picture atanamir · Jan 19, 2010 · Viewed 7.3k times · Source

I'm trying to control multiple instances of OpenVPN's TAP driver in windows via tapinstall. It seems that because all of the devices have the same HWID -- 'tap0901' -- I'm unable to remove any single one with tapinstall -- all of them disappear when i issue

tapinstall.exe remove tap0901

Furthermore, when I do install another instance with

tapinstall.exe install OemWin2k.inf tap0901

all the other ones get reset (open connections using those existing tap installations are broken) because tapinstall tries to update the drivers on all the existing instances.

My solution thus far was to rename all instances of the hwid specified in the INF file to something else and to also rename the .cat and .sys files to this new name as well; however, this breaks the driver signing.

Does anyone know of any alternative ways to manage multiple OpenVPN TAP driver instances that allow me to:

  1. Remove any single instance of the driver without interfering with the operation of other instances
  2. Install new instances without interfering with the operation of the other instances

Win32 API calls are okay too; I'm trying to write a program to automate this.

Thanks for the help!

Answer

atanamir picture atanamir · Jan 20, 2010

If anyone is wondering, I found a way to do this, but it's pretty hacky. Inspired by the devcon source code.

  1. SetupDiCreateDeviceInfoList
  2. SetupDiCreateDeviceInfo
  3. SetupDiSetDeviceRegistryProperty
  4. SetupDiCallClassInstaller
  5. UpdateDriverForPlugAndPlayDevices
  6. SetupDiSetDeviceRegistryProperty - Rename the Hardware ID to something unique here.