I recently (mostly) completed my first driver, which essentially allows the creation of an virtual serial port, which can then be used by an application to expose it to other programs which can connect to it like to any other serial port.
I now wanted to write an command line application that can be used to create and remove these ports, and so far that works fine too.
The problem is, that right now, in the driver, I set the ports name to be what ever windows provides in the registry entry:
HKLM\SYSTEM\CurrentControlSet\Enum\ROOT\PORTS\*port dev id*\Device Parameters\PortName
which I access using WdfDeviceOpenRegistryKey and WdfRegistryQueryUnicodeString.
Its how it was done in the official windows example driver.
But to make it easier to use and add a more clear distinction between normal and virtual ports, I want the ability to optionally specify a custom name on the command line.
My first idea was to simply use SetupDiOpenDevRegKey to change the value in “PortName” to my custom name and hope that windows does not override it if it is already set.
But it turns out, the “Device Parameters” key is only created after the call to UpdateDriverForPlugAndPlayDevicesA which also runs the configuration in the driver.
My question is, is there a way to supply any additional configuration information to the driver before calling UpdateDriverForPlugAndPlayDevicesA ?
I tought about trying to create the Device Parameters key manually, but that is a bit more complicated than it seems, and also seems not like it is intended.
Also, is there a faster way to “install my driver” for the newly created device, than using UpdateDriverForPlugAndPlayDevicesA ?
I noticed that not only takes that function really long, it also takes very long per device.
If I want to create like 5 virtual ports, it takes like half a minute to complete.
Maybe an another method would also solve my configuration issue, I am not sure.