4

I'm writing a driver stack for Windows (7/8) for a multiport serial card. The card has two ports so the driver stack comprises a bus driver that creates two PDOs, one for each port and then INVALIDATEs bus relations to initiate a PNP sequence resulting in the Port Drivers being loaded. The Port Drivers look for the PortName string in the registry when creating the Symbolic Links to allow application access. I guess the MS CoInstaller is assigning the names. The ports are given the usual COMn numbers, typically COM3 and COM4.

All seems to work well except that I cannot find a way to control which port is given which name - the ports have different Instance IDs (0x40 & 0x41) and different UINumbers (0 and 8). On some (maybe most) installs there's a mapping of 0x40=COM3 and 0x41=COM4 but on other installs the relationship is reversed.

Can anyone suggest what controls the port naming? I do not have my own coinstaller but could easily add a device-specific one if required.

Thanks

StanBell
  • 51
  • 2
  • I'm just guessing, but perhaps it would work if you only let the first PNP scan find one port, waited until that port driver has finished loading, then invalidated the bus relations again to find the second one? (But even if that works I very much hope someone else has a more elegant solution!) – Harry Johnston Oct 05 '15 at 23:49

1 Answers1

0

This is not a complete answer, but it does answer the question of some of how Windows chooses a new com port name:


According to this, the Windows registry contains a bitmap of the com port names in use:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter\ComDB

For example, a nearby Windows 7 system has

ComDB"=hex:fc,ff,ff,03,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00

The first byte (fc) indicates that COM1 and COM2 are available to be assigned and COM3 through COM8 are not available.

wallyk
  • 56,922
  • 16
  • 83
  • 148