Please Help! Writing a virtual serial driver in XP/2000?

Hello geniuses of driver development,

I’ve just now subscribed to this list because I’ve looked everywhere on the
web but I’m still hopelessly lost on where to start building a virtual
serial port driver for WinXP/2000! I’ve been reading the DDK documentation
on msdn.microsoft.com/library for days and I’ve got the WinXP DDK downloaded
and have looked at the serial and serenum source code but I’m totally lost
because there’s so *much* information. To be specific, I want to create a
driver (I’m not sure if it should be a bus driver, filter driver,
minidriver, with or without serial.sys and serenum.sys, etc) that forwards
characters from one COM port to another. For example, I want the driver to
create two COM ports, say COM5 and COM6, and if you connect a Hyper-Terminal
window to COM5 and another window to COM6 then characters typed in one
window will show up in the other. Seems pretty simple, doesn’t it? In my
searching I found a product available that does exactly what I’m trying to
accomplish (http://www.mks.zp.ua/vspdxp.php) but it doesn’t come with source
code and I’ve never written a driver before and I’d really like to know how
to accomplish such a task. This should be simple shouldn’t it? I’m good at
C and C++ and Win32 SDK development but I’ve never done anything with driver
or kernel-mode development before. Can someone please point me in the right
direction for the following questions? I’m sure even simple answers would
greatly shed some light on the maze of DDK information!

To write a driver that creates two ‘virtual’ COM ports (say COM5 and COM6,
or any other combination of two COMx port names) and forwards all characters
sent to COM5 to COM6 and visa-versa (via Hyperterminal or any other Win32
app that uses COMx ports; i.e. no physical devices are involved at all),

  1. Do I need to write a bus driver, function driver, filter driver,
    mini-driver, etc? I would like to leverage as much existing support as
    possible, but I don’t know if mini-drivers are available for serial/serenum.

  2. Does Serial.sys and Serenum.sys play a part in this, or do I need
    to write everything from scratch? I can pre-define the COMx port names if I
    have to.

  3. Do I need to consider WDM? There’s a lot of WDM information out
    there but I know serial ports are pretty old so I don’t know if I should be
    thinking of writing a ‘legacy’ driver or not.

  4. Do I need to consider Plug-and-Play? I don’t want to have to
    reboot to add or remove the ‘virtual’ COM ports.

  5. Do I need to handle all of the RS-232 IO requests such as flow
    control and signaling in order to simply pass the characters from one COM
    port to the other? I would like to simply use a named pipe to pass bytes
    back and forth and ignore any flow control or baud rate issues all together.

Thank you all for any response I may receive. As I said, the product (VSPD
http: ) does exactly what I’m trying to do, so I
don’t have an immediate business need for any of this, but I’m very curious
and intrigued about the mysterious world of driver development and this
seems like it should be a very simple driver to create. Help!

-Kael

xxxxx@kael.cc</http:>

First of all, sending your message in HTML means that it’s hard to quote
it in reply.

Basically, writing a virtual serial port driver is *not* simple. A
serial port driver for 2K/XP needs to handle about 40 IOCTL operations
plus IRP_MJ_READ and IRP_MJ_WRITE, any of which might arrive at any IRQL
<= DISPATCH_LEVEL. You need to group IRPs into about three classes, each
of which requires its own queue. To communicate with an application on
the other side of the virtual port, you need to run at PASSIVE_LEVEL,
and that means some sort of mechanism to get from DISPATCH_LEVEL on one
side to PASSIVE_LEVEL on the other.

If VSPD really does what you want, $99 is amazingly cheap. In my
experience, however, most products that claim to provide virtual serial
port emulation fall very far short of full compliance with the Win32 API
spec. So you’d better have the option to return a product in this class
if it doesn’t really do what you expect.


Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Now teaming with John Hyde for USB Device Engineering Seminars
Check out our schedule at http://www.oneysoft.com