SERIAL

SUMMARY

This serial (16550-based RS-232) driver is a WDF version of inbox serial driver present under %DDKROOT%\src\serial\serial directory of the Windows DDK. This sample is functionally equivalent to the WDM version of the sample with two exceptions. 1) This sample doesn’t support Multi-function serial devices. 2) It doesn’t support legacy serial ports – ports that are not detected by the BIOS and as a result not enumerated by the OS.

The code works on Microsoft® Windows® 2000 and later platforms.

The driver also supports Power Management; when the port is not opened, it is powered down and powered up on open. It supports wake-on-ring for platforms that support that function. The driver works on both x86 and 64 bit platforms.

BUILDING THE SAMPLE

To build the sample, run the build -ceZ command in the DDK build environment.  Once built, the sample produces one binary: Serial.sys. The necessary Inf file is msports.inf and is located in the %WINDIR%\inf directory.

INSTALLING THE SAMPLE

For testing purposes, you can replace the inbox serial.sys present in %windir%\system32\drivers with this sample. Steps:

1.    Disable Windows File Protection by following the information given below.

2.    Bring up the Device Manager and disable all the com ports so that system can unload the serial.sys driver. Make sure no applications are talking to the serial device before you disable the ports.

3.    Copy the sample serial.sys to windows drivers directory (%windir%\system32\drivers). If the windows file protection is not disabled, the system will replace the sample driver with the original inbox driver.

4.    Enable the ports to load the new driver. Make sure in the debugger that your sample driver is loaded by running  “!lmi serial.sys”. This will dump information about the loaded image.

5.    Run hypertrm.exe or some other test application to open port and read/write.

Disabling Windows File Protection

You may disable WFP by setting the value SFCDisable (REG_DWORD) in HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ Winlogon. By default, SFCDisable is set to 0, which means WFP is active. Setting SFCDisable to 1 will disable WFP. Setting SFCDisable to 2 will disable WFP for the next system restart only (without a prompt to re-enable).

Important: You must have a kernel debugger attached to the system via null modem cable (for example:I386kd.exe or Windbg.exe) to use SFCDisable = 1 or SFCDisable = 2.

After WFP is disabled using the SFCDisable = 1 setting, the following message will appear after logon:

Warning! Windows File Protection is not active on this system. Would you like to enable Windows File Protection now? This will enable Windows File Protection until the next system restart. <Yes> <No>.

Clicking Yes will reactivate WFP until the next system restart. This message will appear at every successful logon until SFCDisable is set to 0.

NOTE: The above message will only be presented to Administrators.

RESOURCES

For the serial enumeration spec, read http://www.microsoft.com/technet/prodtechnol/winntas/deploy/nt5serie.mspx#XS

CODE TOUR

File Manifest

File                   Description
 
Serial.htm             The documentation for this sample (this file).
Sources                The generic file for building this code sample.
Error.c                Error operations
Immediate.c            Handles the sending of immediate data
Initunlo.c             Performs driver initialization and unload
Ioctl.c                IOCTL requests
Isr.c                  Interrupt service routine functionality
Modmflow.c             Flow control functionality.
Openclos.c             CreateFile / Close functionality
Purge.c                Purge operations
Read.c                 Read operations
Serial.rc              Resource data
Utils.c                Generic helper functionality
Waitmask.c             Wait/Mask functionality
Write.c                Write operations
Pnp.c                  Plug-N-Play support
Registry.c             Misc. registry access functions
Wmi.c                  WMI support
Power.c                Power support
Serlog.mc              Log messages
 

Top of page

 

 

 
 

© 1999 Microsoft Corporation