Click here to Skip to main content
15,867,756 members
Articles / Programming Languages / C++
Article

RusKey: mapping the Russian keyboard layout into the Latin alphabets

Rate me:
Please Sign up or sign in to vote.
3.47/5 (9 votes)
15 Feb 2007CPOL3 min read 309.2K   549   19   34
An easy way to replace characters while typing in the keyboard.

Introduction

Using a very simple hook, you can change the meaning of what the user is typing and put anything else. The process is even easier if what you want is to replace the characters typed one by one.

This is a very simple program that uses this technique to make the Russian keyboard layout easy to learn. I made it for myself, but maybe it can be useful for anyone else. At least the hook technique, flexible enough, is worthy to learn.

Why map characters

An alphabet is one of the many ways to represent the words of a language in writing. A written word is a set of letters meaning the sounds we use to pronounce this word. Every different sound is a different phoneme.

Even though the Russian alphabet is so different from the Latin alphabet, they share many phonemes. This means that we can get some Cyrillic letters and replace them directly to some Latin letters. However, after the translation, the position of this letter normally is different from the Latin keyboard layout. So we have a Latin letter in a different place in the keyboard. If made a near translation between the both, the Latin letters will be disposed like this:

Latin phonemes inside the russian keyboard layout

Ii is a bit different from the well-known qwert asdfg, isn't?

When typing using this pseudo-keyboard layout, the Latin layout is replaced for the Russian layout in a Latin letters set. So a person can practice a Russian keyboard even using the Latin alphabet. Cool, isn't? I can code using the misplaced letters, because the final result is the same. I just need to train my fingers to beat the same letters in different places. This way, if I would need to use Cyrillic, I already know where every Russian letter is supposed to be in the Russian keyboard.

Obs: Almost all the Russian letters can be replaced using a Latin one, but there're some exceptions. So I chose to ignore the translation in this case and put another letter instead. It is not necessarily a good choice for the phoneme, but it is required in order to write using all the available Latin letters.

Background

It would be nice to know something about the Win32 API function SetWindowsHookEx() and how to use it for message hooks.

Using the code

The code itself is already a useful program (at least for me +). You can use it for typing training in another keyboard layout system. The only thing to change inside the code is the correspondence of the letters, located inside the arrays below:

C#
const TCHAR g_tzRussAlphabet[] = 
   _T("F<RLTAU{B:RKVYJGSHCNED}IOPf,rltau[b;rkvyjgshcned]iop");
const TCHAR g_tzPortAlphabet[] = 
  _T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");

The handling code is quite simple. It is about an original charset array search and consequent replace for its Latin brother (the same index inside another array):

switch( pMsg->message )
{
   case WM_CHAR:
   {
      LPTSTR ptzChar =
         _tcschr(g_tzRussAlphabet, (TCHAR) pMsg->wParam);

      if( ptzChar )
      {
         size_t offset = ptzChar - g_tzRussAlphabet;
         pMsg->wParam = (WPARAM) g_tzPortAlphabet[offset];
      }
   }
}

Points of Interest

While debugging a project that makes message hooks globally, the attention must be multiplied for three times or more. Any mistake you do inside the callback function can put the system down (like a MessageBox() called for any message, for example). However, once you're debugging a specific message for a specific process, generally the only process that will freeze will be the debuggee itself and the ones that depends directly on some frozen action.

History

15 Feb 2007 - updated the code to work with VS6 and using a makefile, allowing people to use several versions of Visual C++

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead Intelitrader
Brazil Brazil
Wanderley Caloni
Backend Specialist
Location: São Paulo, Brazil
Email: wanderley.caloni@gmail.com
Skills
C, C++, Assembly, Windows, x86, Reverse Engineering, Cryptography, Tech/Art Writing, Debugging, Git, SQL

Experience
Intelitrader, 2015 - current (Tech Lead)
Market Data System
DataHub System
Finantial Market Vendor Projects
BitForge, 2015 - current (Owner Developer)
Appliance ATM System Security
Information Security Product Maintenance
Minor projects and skills
Communication API with HID USB devices
Windows Phone and Android user interfaces programming
Boost.Asio Winsock bug
Hidapi issue with IO pending
UOL Diveo Broker, 2012 - 2015 (Backend Developer)
Financial Market Risk System (Stock Broker)
HUB Network API Development and Maintenance
Scua Information Security, 2008 - 2012 (Security Developer)
Information Security Product Maintenance
Disk Cryptography
Team Coordination
Minor projects and skills
Hardware inventory using WMI/SMBIOS
Software inventory using Windows Registry
PrintScreen protection using COM interfaces
Windows Event Log using device driver
User/Kernel communication using DeviceIoControl API
VNC like development
PsExec like development
Documents print control using regex (boost) and shell hook
User policies management using Windows Registry and API hooks
Database migration from CTree to SQL using OLE classes
Windows authentication using DCOM service, custom GINA and Credential Provider (Windows Vista)
Database synchronization using DCOM service
Linux maintenance bootable CD, bash scripts and cryptography tools
USB Cryptography (pen drives)
Crash dump analysis using Windbg
System account process execution using COM service
MBR (Master Boot Record) customization analysing BIOS features
Blowfish and SHA-1 development in 16 bits assembly (x86)
Audit driver using shared memory between user and kernel events
Open Communications Security, 2005 - 2008 (Security Specialist)
Reverse Engineering (Trojan Analysis)
API Hooking
Antidebugging Solution
Code Ofusc
Twitter LinkedIn

Comments and Discussions

 
General My vote of 3 Pin
Sergey Alexandrovich Kryukov2-Oct-12 11:27
mva Sergey Alexandrovich Kryukov 2-Oct-12 11:27 
General Re: My vote of 3 Pin
Wanderley Caloni20-Apr-15 12:25
professional Wanderley Caloni 20-Apr-15 12:25 
General Re: My vote of 3 Pin
Sergey Alexandrovich Kryukov20-Apr-15 12:29
mva Sergey Alexandrovich Kryukov 20-Apr-15 12:29 
General RusKey Pin
geoyar15-Apr-07 6:24
professional geoyar 15-Apr-07 6:24 
General Re: RusKey Pin
Wanderley Caloni15-Apr-07 7:50
professional Wanderley Caloni 15-Apr-07 7:50 
General There are much better ways (Re: RusKey) Pin
Sergey Alexandrovich Kryukov2-Oct-12 11:16
mva Sergey Alexandrovich Kryukov 2-Oct-12 11:16 
General Check the Microsoft Keyboard Layout Creator Pin
Mihai Nita16-Feb-07 11:47
Mihai Nita 16-Feb-07 11:47 
General Re: Check the Microsoft Keyboard Layout Creator Pin
Wanderley Caloni21-Feb-07 23:50
professional Wanderley Caloni 21-Feb-07 23:50 
General Great! (Re: Check the Microsoft Keyboard Layout Creator) Pin
Sergey Alexandrovich Kryukov2-Oct-12 11:20
mva Sergey Alexandrovich Kryukov 2-Oct-12 11:20 
General Re: Great! (Re: Check the Microsoft Keyboard Layout Creator) Pin
Wanderley Caloni20-Apr-15 12:28
professional Wanderley Caloni 20-Apr-15 12:28 
General Re: Great! (Re: Check the Microsoft Keyboard Layout Creator) Pin
Sergey Alexandrovich Kryukov20-Apr-15 12:31
mva Sergey Alexandrovich Kryukov 20-Apr-15 12:31 
General Re: Great! (Re: Check the Microsoft Keyboard Layout Creator) Pin
Wanderley Caloni20-Apr-15 13:13
professional Wanderley Caloni 20-Apr-15 13:13 
General Re: Great! (Re: Check the Microsoft Keyboard Layout Creator) Pin
Sergey Alexandrovich Kryukov20-Apr-15 15:47
mva Sergey Alexandrovich Kryukov 20-Apr-15 15:47 
Question cannot run in another computer Pin
MartinLeung24-Oct-06 21:44
MartinLeung 24-Oct-06 21:44 
Answer Re: cannot run in another computer Pin
Wanderley Caloni26-Oct-06 3:17
professional Wanderley Caloni 26-Oct-06 3:17 
General Re: cannot run in another computer Pin
MartinLeung26-Oct-06 15:23
MartinLeung 26-Oct-06 15:23 
General Re: cannot run in another computer Pin
Wanderley Caloni27-Oct-06 2:21
professional Wanderley Caloni 27-Oct-06 2:21 
General Advise Pin
SMDtheone8-Feb-06 17:39
SMDtheone 8-Feb-06 17:39 
General Re: Advise Pin
Wanderley Caloni9-Feb-06 0:48
professional Wanderley Caloni 9-Feb-06 0:48 
General Great to disable cheating codes for kids Pin
Nick Gearls20-Oct-05 5:26
Nick Gearls 20-Oct-05 5:26 
General Re: Great to disable cheating codes for kids Pin
Wanderley Caloni20-Oct-05 5:31
professional Wanderley Caloni 20-Oct-05 5:31 
General Compatibility Pin
Nick Gearls20-Oct-05 1:56
Nick Gearls 20-Oct-05 1:56 
General Re: Compatibility Pin
Wanderley Caloni20-Oct-05 2:12
professional Wanderley Caloni 20-Oct-05 2:12 
News Russian keyboard. Pin
XoXoXo19-Oct-05 5:08
XoXoXo 19-Oct-05 5:08 
General Re: Russian keyboard. Pin
Wanderley Caloni19-Oct-05 5:51
professional Wanderley Caloni 19-Oct-05 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.