Trial Version Price Buy now Policies Subscribe

How does Windows 2000/XP detect serial mouse?


Quotation from the Windows 2000 DDK help:

SERENUM is a Plug and Play upper-level device filter driver that enumerates the following device types:

  • Plug and Play serial devices that comply with Plug and Play External COM Device Specification, Version 1.00, February 28, 1995
  • Pointer devices that comply with legacy mouse detection in Windows NT® 4.0 and earlier versions
  • SERENUM is used with Serial, the Windows 2000 system function driver for COM ports. The combined operation of Serial and SERENUM acts as a Plug and Play bus driver for a RS-232 port.

    The example shows how to use IrpTrace for:

  • Investigating algorithm used by SERENUM driver to detect device connected to COM port
  • Determining Plug and Play information returning by Microsoft Serial Mouse device
    • Equipment
      1. A computer running Windows 2000 or XP with one or more COM ports
      2. Microsoft Serial mouse attached to COM port (COM1)
      • Start IrpTrace.
      • Click button on the toolbar (or select Messages|Hook Setup command from the menu).
      • Switch to tab PnP. Expand "Ports COM & LPT" item and click on check box at the left of "Communications port (COM1)" item.
      • Click OK to close dialog.
      • Ensure that hooks are active (Messages|Activate Hooks button is pressed) and file logging is enabled (Messages|File Logging button is pressed)
      • Run Device Manager applet. Right click on "Communications port (COM1)" item and select "Scan for hardware changes" command
      • Switch to IrpTrace
      • Mouse click on last item in the tree. Invoke Edit|Find command.
      • Type "Query Device Relations (Bus)", set direction to "Up" and press Find button. Close Find dialog.
      • Expand selected item.

      Comparison time, process/tread ID of Create, Close and Set Power/Device Control/Read requests () shows that Set Power/Device Control/Read requests were sent after Create and before Close requests. It means that at receiving Query Device Relations request SERENUM

      • Opens lower device
      • Sends a sequence of Device Control and Read requests to detect device attached to COM port
      • Closes lower device

      Figure 1: Open request sent by SERENUM driver

      Figure 2: Close request sent by SERENUM driver

      Figure 3: Internal device control request

      Sequence of Device Control/Read requests can be separated on 5 groups:

      1. Configure port
        1. Serial Internal Basic Settings: disable FIFO, switch of using handshake flow control and timeouts
        2. Set DTR/Clear RTS: prevent response from COM device
        3. Set baud rate: 1200
        4. Set Line control: stop bits - 0, data bits - 7, parity - none
      2. Ask COM device to send PnP ID: Clear and then set DTR and RTS signals
      3. Read ID
      4. Restore port configuration

      IrpTrace shows that SERENUM sent five Read requests. Four of them were completed successfully (see figure 4) and one with status STATUS_TIMEOUT. So PnP ID of Microsoft Serial Mouse is:

      4D 43 3F 00 | MC?

      Figure 4: First byte of PnP ID

      Click here for additional information.