Hi everyone.
we are writing a virtual com port driver, which is almost completed and
working fine. the com port numbers to this virtual port drivers are
allocated by ports class installer.
now we want to assign this comport number to user desired one. we have user
application which will write the user desired comports number into registry
before driver got installed. when we are installing the driver we need to
assign same com port numbers to driver.
To Implement this i am reading the com port numbers from the registry and
saving into my driver sources in DriverEntry Routine.
In AddDevice Routine, after creating device object i am opening registry
key and doing the following things.
status = IoOpenDeviceRegistryKey(pdx->PhysicalDeviceObject,
PLUGPLAY_REGKEY_DEVICE, KEY_ALL_ACCESS, &hkey);
RtlInitUnicodeString(&tempPort, L"COM66");//user desired com port number
temporally hardcoded.
//setting the new “PortName”
status = ZwSetValueKey(hKey, &keyname, 0, REG_SZ, pData, DataLength);
//keyname=“PortName” pData=“COM66” only providing required data
//getting the New “PortName”
status = ZwQueryValueKey(hKey_, &valname, KeyValuePartialInformation, vpip,
size, &size);
//valname=“PortName”
here i got vpip->date=“COM66” so i am thinking that what ever i assinged is
getting reflected.Created the symbolic link(\Dosdevices\COM66) and wrote
vpip->data to SerialMap registry key using
status = RtlWriteRegistryValue(RTL_REGISTRY_DEVICEMAP,
SERIAL_DEVICE_MAP,
pdx->uniNameString.Buffer,
REG_SZ,
portname.Buffer,
portname.Length + sizeof(WCHAR));
After installing the driver i am able to communicate with COM66, but where
as in device manager the com port number is showing as different number
means other number. is there any way to change the name in device manager
from with in the driver sources itself.
here my Questions are, can we implement this logic to assign user desired
comports. if Yes why it is not reflecting in device manager. please suggest
me proper way to achieve this.
as i know we can implement co-installer also to achieve this. which one is
preferred way to solve this problem.
please forgive me if did any wrong thinking in implementing this type of
logic, as i am very less experienced in windows drivers and for this
lengthy Question also.