Permalink
Browse files

Make sure additional Layout IDs do not conflict; add some sort of Eng…

…lish article
  • Loading branch information...
1 parent a5cad00 commit 7396f4d50602d183c6157dd8d6f1355c7a2896bd @grompe committed May 28, 2016
Showing with 55 additions and 8 deletions.
  1. +28 −0 article_en.txt
  2. +16 −0 checklid.bat
  3. +11 −8 install.bat
View
@@ -0,0 +1,28 @@
+Windows keyboard layout, reverse engineered with fasm
+=====================================================
+
+I have reverse engineered the Windows keyboard layout format, found in files
+C:\Windows\System32\kbd*.dll.
+
+Initially I wanted to add easy typing of symbols like —, á, ∞ but then decided
+to get as much usability as I can from the layouts.
+
+The result? Layout that can switch between English and Russian keyboard with
+Caps Lock, globally across all applications, showing current language with
+Caps Lock LED, and with ability to type a whole bunch of additional symbols.
+
+As well as keyboard layout format described in flat assembler source.
+And for extra fun, a disassembler that turns a layout dll into source file.
+
+With this, you can freely customize and improve your Windows keyboard layouts!
+
+Published as public domain on https://github.com/grompe/kbdasm
+
+The keyboard layout source found in kbdusru_undead.asm has all structures of
+the layout format mapped, makes use of UTF-8, and is hopefully more-or-less
+understandable for customizing. Even if you're not bilingual you can benefit
+from being able to type Unicode symbols easily.
+
+The disassembler found in diskbd.bat is full of tricks to make fasm read a
+binary format and produce a text file. I had to write several macros to make
+it work.
View
@@ -0,0 +1,16 @@
+@echo off
+if "%1"=="" (
+ echo Usage: checklid.bat ^<layout_id^> - check if your new Layout ID is unique
+ exit /b 2
+)
+for /F "tokens=*" %%i in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layouts"') do (
+ for /F "tokens=4" %%j in ('reg query "%%i" /v "Layout Id" 2^>nul ^| find "Layout Id"') do (
+ if /I %%j==%1 (
+ echo Layout Id %1 already exists!
+ exit /b 1
+ )
+ )
+)
+exit /b 0
+
+
View
@@ -1,21 +1,26 @@
@echo off
if not "%cd%"\=="%~pd0" cd /d "%~pd0"
set target=%1
+
+:: Change the following four parameters when installing custom layouts
set shortname="US+"
set longname="United States-Custom"
set id=07430409
-set cat="English - US"
+set lid=00d1
+
if not "%target%"=="" goto:skipdefault
set target=kbdusru_undead.dll
set shortname="US+RU"
set longname="United States-International + Russian + Extra"
set id=07430419
-set cat="Russian"
+set lid=00d0
:skipdefault
if not exist %target% goto:notexist
if exist %windir%\system32\%target% goto:alreadyexist
call checkdll %target%
if errorlevel 1 goto:eof
+call checklid %lid%
+if errorlevel 1 goto:eof
net file >nul 2>&1
if not %errorlevel%==0 goto:notadmin
set /p answer="Do you want to install %target% in your system? [Y/N] "
@@ -35,12 +40,11 @@ if errorlevel 1 goto:cannotreg
reg add %key% /f /v "Layout Text" /t REG_SZ /d %shortname% >nul 2>&1
reg add %key% /f /v "Layout Display Name" /t REG_SZ /d %longname% >nul 2>&1
reg add %key% /f /v "Layout File" /t REG_SZ /d "%target%" >nul 2>&1
-reg add %key% /f /v "Layout Id" /t REG_SZ /d 00d0 >nul 2>&1
+reg add %key% /f /v "Layout Id" /t REG_SZ /d %lid% >nul 2>&1
if errorlevel 1 goto:cannotreg
if not x%nt5%==xyes reg_layout r 0x%id:~4,4%:0x%id%
if errorlevel 1 goto:cannotreg2
-echo The job is done. Now you should have additional layout under %cat%
-echo called %longname%
+echo The job is done. Now you should have additional layout called %longname%
goto:eof
:manualreg
echo REGEDIT4>>_install.reg
@@ -49,13 +53,12 @@ echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\%id%]
echo "Layout Text"=%shortname%>>_install.reg
echo "Layout Display Name"=%longname%>>_install.reg
echo "Layout File"="%target%">>_install.reg
-echo "Layout Id"="00d0">>_install.reg
+echo "Layout Id"="%lid%">>_install.reg
_install.reg
if errorlevel 1 goto:cannotreg
if not x%nt5%==xyes reg_layout r 0x%id:~4,4%:0x%id%
if errorlevel 1 goto:cannotreg2
-echo The job is done. Now you should have additional layout under %cat%
-echo called %longname%
+echo The job is done. Now you should have additional layout called %longname%
goto:eof
:notexist
echo There is no %target% here, compile it first!

0 comments on commit 7396f4d

Please sign in to comment.