Making my own serial driver's "port" appear in device manager as COMx

I have written a virtual serial driver which receives serial port
read/write requests from an existing application. This virtual driver
transforms the incoming buffer in the read/write despatch routine to
another form before actually transmitting it on the physical COM port.
Now my existing windows application has an edit box to configure the
COM port and takes and entry of the form “COMx” as a valid entry (where x
can vary between 1 to 9). This means that I cannot use my device name with
a form \.<mydev> for referring to the virtual serial port.
So I want to make my virtual serial port appear as another COM port in
the windows device listing ( say as COM3 assuming COM1 and COM2 are
already present). How do I do this? I tried making an entry in the
HKEY_LOCAL_MACHINE\Hardware\DeviceMap… for my own driver. Something like
\Device\VirPort COM9
It does not work. This entry gets deleted next time I boot the
system.
I am presently using Windows 2000 professional to test my driver. Please
help.

Hi

You’ll have to create a device object with the COMx and the create a
symbolic link to it (like \Device\VirPortx) and write it to the registry
HKEY_LOCAL_MACHINE\Hardware\DeviceMap… from your driver every time the
system boots.

Regards,
Rajiv.

I have written a virtual serial driver which receives serial port
read/write requests from an existing application. This virtual driver
transforms the incoming buffer in the read/write despatch routine to
another form before actually transmitting it on the physical COM port.
Now my existing windows application has an edit box to configure the
COM port and takes and entry of the form “COMx” as a valid entry (where x
can vary between 1 to 9). This means that I cannot use my device name with
a form \.<mydev> for referring to the virtual serial port.
> So I want to make my virtual serial port appear as another COM port in
> the windows device listing ( say as COM3 assuming COM1 and COM2 are
> already present). How do I do this? I tried making an entry in the
> HKEY_LOCAL_MACHINE\Hardware\DeviceMap… for my own driver. Something like
> \Device\VirPort COM9
> It does not work. This entry gets deleted next time I boot the
> system.
> I am presently using Windows 2000 professional to test my driver. Please
> help.

Hi Rajiv,
Thanks for the reply. But I tried making this entry manually using
regedit “after” the system booted but this did not work. Should it be done
internally by the driver during bootup to make it work?
Regards,
Ganesh

Did you create a symbolic link between \DosDevices\COMX and the name of your
deviceobject?

----- Original Message -----
From: “Ganesh Okade”
To: “NT Developers Interest List”
Sent: Thursday, July 04, 2002 1:00 PM
Subject: [ntdev] Re: Making my own serial driver’s “port” appear in device
manager as COMx

> Hi Rajiv,
> Thanks for the reply. But I tried making this entry manually using
> regedit “after” the system booted but this did not work. Should it be done
> internally by the driver during bootup to make it work?
> Regards,
> Ganesh
>
> —
> You are currently subscribed to ntdev as: xxxxx@connecttech.com
> To unsubscribe send a blank email to %%email.unsub%%

Hi Ganesh,

The entries in this registry key provides the available serial ports.
Marking an entry here won’t suffice. If you create an entry in the
registry like “\Device\VirPort” and “COM9”, you’ll have to create a device
object for “\Device\VirPort” and a symbolic link to it as
“\DosDevice\COM9”. Only after this you’ll be able to use the virtual port.
I think creating a entry manually or through the driver won’t make any
difference, but you got to have the device object and a symbolic link to
it. If you do it from your driver you’ll not have to do it manually.

Regards,
Rajiv.

Hello Rajiv,
I wrote an INF file for my device and installed my device using
Add/Remove hardware as a COM port. The driver is coming up as a COM port
now and it does not show any error in the device manager. The driver also
has been successfully loaded. But when I open a path on “COM3” (which is
the name given to my device by W2K) my driver’s despatch function is NOT
getting called. There was no entry in HKLM…\SERIALCOMM for my device
(though it still was being shown as a port) so I added an entry myself.
Still doesnot work.
I was wondering about the point you madein your last comment on
creating a symbolic name to my device as COMx. Is it a must to give the
symbolic name the same as that of the portname (COMx) which has been given
by W2K to my device? I have name it as “VirPort” instead.

Hi,

Firstly, tell me whether you are referring COM3 as the name provided to
your driver instance in the device manager or a symbolic link. The name
device manager provides and device objects are different things.

Secondly, have you created a device object associated with COM3 (something
like \Device\VirPort) and a symbolic link to it (like \DosDevice\COM3)?

Only if you have a device object and a symbolic link to it, you’ll be able
to open and your driver despatch will be called.

I guess you are not just looking at displaying COMx in the device manager.
Are you? If not, and you want applications to access the port, you’ll have
to create a device object for it and provide a symbolic link to it.

Regards,
Rajiv.

Just look at the SerialDoExternalNaming procedure in the std serial source.
DDKDir\src\kernel\serial

You should see all you need there.

…Chris

----- Original Message -----
From: “Chris Dore”
To: “NT Developers Interest List”
Sent: Thursday, July 04, 2002 1:09 PM
Subject: [ntdev] Re: Making my own serial driver’s “port” appear in device
manager as COMx

> Did you create a symbolic link between \DosDevices\COMX and the name of
your
> deviceobject?
>
> ----- Original Message -----
> From: “Ganesh Okade”
> To: “NT Developers Interest List”
> Sent: Thursday, July 04, 2002 1:00 PM
> Subject: [ntdev] Re: Making my own serial driver’s “port” appear in device
> manager as COMx
>
>
> > Hi Rajiv,
> > Thanks for the reply. But I tried making this entry manually using
> > regedit “after” the system booted but this did not work. Should it be
done
> > internally by the driver during bootup to make it work?
> > Regards,
> > Ganesh
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@connecttech.com
> > To unsubscribe send a blank email to %%email.unsub%%
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@connecttech.com
> To unsubscribe send a blank email to %%email.unsub%%

Hello Raviv/Chris,
I got it working! Thanks. I am posting another question on how to
implement IOCTL_SERIAL_WAIT_MASK in my own driver. Please let me know the
answer if you know.

Regards,
Ganesh

I would like to add one more thing: how you get a COM port name that is
unique in the system and does not conflict with other com port names.

  1. The device class in your INF should be “Ports”, ie

[version]
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}

  1. you need to add an INF AddReg entry which tells the ports class
    installer that you are installing a COM port vs a LPT port
    (unfortunately they are both in the same device class).

In your dev install section, add the following entries:

[InstallSection]
AddReg=InstallSection.AddReg

[InstallSection.AddReg]
HKR,PortSubClass,1,01

Once this is done, the ports class installer will give you a new unique
com port name when your device is installed. You can find it in the
device node’s device parameters key, as the following

“PortName” : REG_SZ :

For instance, for COM1 it would be

“PortName” : REG_SZ : “COM1”

serial.sys (in the DDK) demonstrates how to read this value and create
the symbolic link (as others have said already)

d

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Chris Dore [mailto:xxxxx@connecttech.com]
Sent: Friday, July 05, 2002 6:29 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Making my own serial driver’s “port” appear in
device manager as COMx

Just look at the SerialDoExternalNaming procedure in the std serial
source.
DDKDir\src\kernel\serial

You should see all you need there.

…Chris

----- Original Message -----
From: “Chris Dore”
To: “NT Developers Interest List”
Sent: Thursday, July 04, 2002 1:09 PM
Subject: [ntdev] Re: Making my own serial driver’s “port” appear in
device
manager as COMx

> Did you create a symbolic link between \DosDevices\COMX and the name
of
your
> deviceobject?
>
> ----- Original Message -----
> From: “Ganesh Okade”
> To: “NT Developers Interest List”
> Sent: Thursday, July 04, 2002 1:00 PM
> Subject: [ntdev] Re: Making my own serial driver’s “port” appear in
device
> manager as COMx
>
>
> > Hi Rajiv,
> > Thanks for the reply. But I tried making this entry manually
using
> > regedit “after” the system booted but this did not work. Should it
be
done
> > internally by the driver during bootup to make it work?
> > Regards,
> > Ganesh
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@connecttech.com
> > To unsubscribe send a blank email to %%email.unsub%%
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@connecttech.com
> To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to %%email.unsub%%

Hi,
Does the above discussion apply to Windows NT as well? If not how does
it differ in NT?
Regards,
Ganesh

In NT take a sample Serial Port Inf and use it - you may have to vary it
some since you do not have any hardware - the important thing is the
DeviceClass you use and you can make up your own hardware id.

Next the fun part you will have to write a very simple driver to suceed
DriverEntry - AddDevice and the plug-n-play. Check out the toaster sample
for just the FDO.

Yes in NT the serial ports or all “standard” kernel drivers can be virtual
meaning the Hardware ID is any string you wish!

Hi,
Thanks for the reply. I specifically wanted to know where I have to
look for the friendly name (COMx) assigned to my driver in NT. In Win 2K I
can see the value in “Portname” string under “device parameters” of my
device’s node in the registry. In NT I do not find anything of that kind
in the registry.
Regards,
Ganesh