Problems with Real-Mode Keyboard Driver and International Code Page

ID: Q214408


The information in this article applies to:


SYMPTOMS

If an international code page is installed in conjunction with a real-mode keyboard driver (such as Keyboard.sys), console programs may not detect extended character keystrokes (such as the INSERT, DELETE, and HOME keys and so on).


CAUSE

When a real-mode keyboard driver is installed, the current character from the "MS-DOS" keyboard buffer is sent to the console program. With an international code page loaded, this value is xe0 instead of x0 when an extended key is pressed. The data returned through the console API is therefore slightly different than that in Microsoft Windows 95. Console programs that do not work directly with the console API may not recognize extended keystrokes.


RESOLUTION

A supported fix that corrects this problem is now available from Microsoft, but it has not been fully regression tested and should be applied only to systems experiencing this specific problem. If you are not severely affected by this specific problem, Microsoft recommends that you wait for the next that contains this fix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information on support costs, please go to the following address on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp

File name Date Time Size
Conagent.exe 12/14/98 11:03pm 14,696



NOTE: If this product was already installed on your computer when you purchased it from the Original Equipment Manufacturer (OEM) and you need this fix, please call the Pay Per Incident number listed on the above Web site. If you contact Microsoft to obtain this fix, and if it is determined that you only require the fix you requested, no fee will be charged. However, if you request additional technical support, and if your no-charge technical support period has expired, or if you are not eligible for standard no-charge technical support, you may be charged a non-refundable fee.

For more information about eligibility for no-charge technical support, see the following article in the Microsoft Knowledge Base:
Q154871 Determining If You Are Eligible for No-Charge Technical Support


STATUS

Microsoft has confirmed this to be a problem in Microsoft Windows 98.


MORE INFORMATION

Steps to Reproduce the Behavior

  1. Enter the following lines in the Autoexec.bat file (the example given is for German):

    
       mode con codepage prepare=((850) c:\windows\command\ega.cpi)
       mode con codepage select=850
       keyb gr,,c:\windows\command\keyboard.sys 


  2. Run a program in an MS-DOS window that uses the _getch() function. Note that the _getch() function is assumed to be from the standard Visual C libraries or any code library that uses GetConsoleInput() to service _getch(). Extended key codes are not returned properly.


The Win32 console API function "ReadConsoleInput()" returns the value xe0in the INPUT_RECORD 'KEY_EVENT_RECORD' structure AsciiChar field instead of the expected x0 value. Note that the ENHANCED_KEY bit is set in the 'dwControlKeyState' field. Some code libraries assume that the 'AsciiChar' field will always be zero when an extended keystroke occurs, and may not check the 'dwCOntrolKeyState' field bits, rendering them vulnerable to misinterpreting the returned keystroke.

   INPUT_RECORD.Event.KeyEvent.bKeyDown          x1
   INPUT_RECORD.Event.KeyEvent.wRepeatCount      x1
   INPUT_RECORD.Event.KeyEvent.wVirtualKeyCode   x2d
   INPUT_RECORD.Event.KeyEvent.wVirtualScanCode  x52
-->INPUT_RECORD.Event.KeyEvent.uChar.AsciiChar   x0  (CORRECT)
-->INPUT_RECORD.Event.KeyEvent.uChar.AsciiChar   xe0 (INCORRECT)
   INPUT_RECORD.Event.KeyEvent.dwControlKeyState x120 
Note that the Interrupt 16h (BIOS Keyboard Services) and the Interrupt 21h (System Calls) character input functions for reading keyboard input are unaffected. The C source code shown below is a minimal example that demonstrates the problem:

#include <stdio.h>
#include <conio.h>

void main ()
{
   int ch = 0;

   while ( 27 != ch )
   {
      ch = _getch();
      printf( "%i: %x\n", ch, ch );
   }
} 

Additional query words:


Keywords          : kbenv win98 
Version           : WINDOWS:
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: July 2, 1999