1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * PURPOSE:         Test for NtUserToUnicodeEx
5  * PROGRAMMERS:
6  */
7 
8 #include <win32nt.h>
9 
10 START_TEST(NtUserToUnicodeEx)
11 {
12 	BYTE KeyState[256] = {0};
13 	WCHAR Buffer[10];
14 	HKL hkl = LoadKeyboardLayoutW(L"00000409", KLF_NOTELLSHELL);
15 
16 	TEST(NtUserToUnicodeEx(27, 1, KeyState, Buffer, 10, 0, 0) == 1);
17 
18 	/* Test with no key pressed */
19 	ZeroMemory(KeyState, 256);
20 	TEST(NtUserToUnicodeEx(27, 1, KeyState, Buffer, 10, 0, hkl) == 1);
21 	TEST(Buffer[0] == 27);
22 	TEST(NtUserToUnicodeEx(49, 2, KeyState, Buffer, 10, 0, hkl) == 1);
23 	TEST(Buffer[0] == '1');
24 	TEST(NtUserToUnicodeEx(50, 3, KeyState, Buffer, 10, 0, hkl) == 1);
25 	TEST(Buffer[0] == '2');
26 	TEST(NtUserToUnicodeEx(51, 4, KeyState, Buffer, 10, 0, hkl) == 1);
27 	TEST(Buffer[0] == '3');
28 	TEST(NtUserToUnicodeEx(52, 5, KeyState, Buffer, 10, 0, hkl) == 1);
29 	TEST(Buffer[0] == '4');
30 	TEST(NtUserToUnicodeEx(53, 6, KeyState, Buffer, 10, 0, hkl) == 1);
31 	TEST(Buffer[0] == '5');
32 	TEST(NtUserToUnicodeEx(54, 7, KeyState, Buffer, 10, 0, hkl) == 1);
33 	TEST(Buffer[0] == '6');
34 	TEST(NtUserToUnicodeEx(55, 8, KeyState, Buffer, 10, 0, hkl) == 1);
35 	TEST(Buffer[0] == '7');
36 	TEST(NtUserToUnicodeEx(56, 9, KeyState, Buffer, 10, 0, hkl) == 1);
37 	TEST(Buffer[0] == '8');
38 	TEST(NtUserToUnicodeEx(57, 10, KeyState, Buffer, 10, 0, hkl) == 1);
39 	TEST(Buffer[0] == '9');
40 	TEST(NtUserToUnicodeEx(48, 11, KeyState, Buffer, 10, 0, hkl) == 1);
41 	TEST(Buffer[0] == '0');
42 	TEST(NtUserToUnicodeEx(189, 12, KeyState, Buffer, 10, 0, hkl) == 1);
43 	TEST(Buffer[0] == '-');
44 	TEST(NtUserToUnicodeEx(187, 13, KeyState, Buffer, 10, 0, hkl) == 1);
45 	TEST(Buffer[0] == '=');
46 	TEST(NtUserToUnicodeEx(8, 14, KeyState, Buffer, 10, 0, hkl) == 1);
47 	TEST(Buffer[0] == 8);
48 	TEST(NtUserToUnicodeEx(9, 15, KeyState, Buffer, 10, 0, hkl) == 1);
49 	TEST(Buffer[0] == 9);
50 	TEST(NtUserToUnicodeEx(81, 16, KeyState, Buffer, 10, 0, hkl) == 1);
51 	TEST(Buffer[0] == 'q');
52 	TEST(NtUserToUnicodeEx(87, 17, KeyState, Buffer, 10, 0, hkl) == 1);
53 	TEST(Buffer[0] == 'w');
54 	TEST(NtUserToUnicodeEx(69, 18, KeyState, Buffer, 10, 0, hkl) == 1);
55 	TEST(Buffer[0] == 'e');
56 	TEST(NtUserToUnicodeEx(82, 19, KeyState, Buffer, 10, 0, hkl) == 1);
57 	TEST(Buffer[0] == 'r');
58 	TEST(NtUserToUnicodeEx(84, 20, KeyState, Buffer, 10, 0, hkl) == 1);
59 	TEST(Buffer[0] == 't');
60 	TEST(NtUserToUnicodeEx(89, 21, KeyState, Buffer, 10, 0, hkl) == 1);
61 	TEST(Buffer[0] == 'y');
62 	TEST(NtUserToUnicodeEx(85, 22, KeyState, Buffer, 10, 0, hkl) == 1);
63 	TEST(Buffer[0] == 'u');
64 	TEST(NtUserToUnicodeEx(73, 23, KeyState, Buffer, 10, 0, hkl) == 1);
65 	TEST(Buffer[0] == 'i');
66 	TEST(NtUserToUnicodeEx(79, 24, KeyState, Buffer, 10, 0, hkl) == 1);
67 	TEST(Buffer[0] == 'o');
68 	TEST(NtUserToUnicodeEx(80, 25, KeyState, Buffer, 10, 0, hkl) == 1);
69 	TEST(Buffer[0] == 'p');
70 	TEST(NtUserToUnicodeEx(219, 26, KeyState, Buffer, 10, 0, hkl) == 1);
71 	TEST(Buffer[0] == '[');
72 	TEST(NtUserToUnicodeEx(221, 27, KeyState, Buffer, 10, 0, hkl) == 1);
73 	TEST(Buffer[0] == ']');
74 	TEST(NtUserToUnicodeEx(13, 28, KeyState, Buffer, 10, 0, hkl) == 1);
75 	TEST(Buffer[0] == 13);
76 	TEST(NtUserToUnicodeEx(65, 30, KeyState, Buffer, 10, 0, hkl) == 1);
77 	TEST(Buffer[0] == 'a');
78 	TEST(NtUserToUnicodeEx(83, 31, KeyState, Buffer, 10, 0, hkl) == 1);
79 	TEST(Buffer[0] == 's');
80 	TEST(NtUserToUnicodeEx(68, 32, KeyState, Buffer, 10, 0, hkl) == 1);
81 	TEST(Buffer[0] == 'd');
82 	TEST(NtUserToUnicodeEx(70, 33, KeyState, Buffer, 10, 0, hkl) == 1);
83 	TEST(Buffer[0] == 'f');
84 	TEST(NtUserToUnicodeEx(71, 34, KeyState, Buffer, 10, 0, hkl) == 1);
85 	TEST(Buffer[0] == 'g');
86 	TEST(NtUserToUnicodeEx(72, 35, KeyState, Buffer, 10, 0, hkl) == 1);
87 	TEST(Buffer[0] == 'h');
88 	TEST(NtUserToUnicodeEx(74, 36, KeyState, Buffer, 10, 0, hkl) == 1);
89 	TEST(Buffer[0] == 'j');
90 	TEST(NtUserToUnicodeEx(75, 37, KeyState, Buffer, 10, 0, hkl) == 1);
91 	TEST(Buffer[0] == 'k');
92 	TEST(NtUserToUnicodeEx(76, 38, KeyState, Buffer, 10, 0, hkl) == 1);
93 	TEST(Buffer[0] == 'l');
94 	TEST(NtUserToUnicodeEx(186, 39, KeyState, Buffer, 10, 0, hkl) == 1);
95 	TEST(Buffer[0] == ';');
96 	TEST(NtUserToUnicodeEx(222, 40, KeyState, Buffer, 10, 0, hkl) == 1);
97 	TEST(Buffer[0] == '\'');
98 	TEST(NtUserToUnicodeEx(192, 41, KeyState, Buffer, 10, 0, hkl) == 1);
99 	TEST(Buffer[0] == '`');
100 	TEST(NtUserToUnicodeEx(220, 43, KeyState, Buffer, 10, 0, hkl) == 1);
101 	TEST(Buffer[0] == '\\');
102 	TEST(NtUserToUnicodeEx(90, 44, KeyState, Buffer, 10, 0, hkl) == 1);
103 	TEST(Buffer[0] == 'z');
104 	TEST(NtUserToUnicodeEx(88, 45, KeyState, Buffer, 10, 0, hkl) == 1);
105 	TEST(Buffer[0] == 'x');
106 	TEST(NtUserToUnicodeEx(67, 46, KeyState, Buffer, 10, 0, hkl) == 1);
107 	TEST(Buffer[0] == 'c');
108 	TEST(NtUserToUnicodeEx(86, 47, KeyState, Buffer, 10, 0, hkl) == 1);
109 	TEST(Buffer[0] == 'v');
110 	TEST(NtUserToUnicodeEx(66, 48, KeyState, Buffer, 10, 0, hkl) == 1);
111 	TEST(Buffer[0] == 'b');
112 	TEST(NtUserToUnicodeEx(78, 49, KeyState, Buffer, 10, 0, hkl) == 1);
113 	TEST(Buffer[0] == 'n');
114 	TEST(NtUserToUnicodeEx(77, 50, KeyState, Buffer, 10, 0, hkl) == 1);
115 	TEST(Buffer[0] == 'm');
116 	TEST(NtUserToUnicodeEx(188, 51, KeyState, Buffer, 10, 0, hkl) == 1);
117 	TEST(Buffer[0] == ',');
118 	TEST(NtUserToUnicodeEx(190, 52, KeyState, Buffer, 10, 0, hkl) == 1);
119 	TEST(Buffer[0] == '.');
120 	TEST(NtUserToUnicodeEx(191, 53, KeyState, Buffer, 10, 0, hkl) == 1);
121 	TEST(Buffer[0] == '/');
122 	TEST(NtUserToUnicodeEx(106, 55, KeyState, Buffer, 10, 0, hkl) == 1);
123 	TEST(Buffer[0] == '*');
124 	TEST(NtUserToUnicodeEx(32, 57, KeyState, Buffer, 10, 0, hkl) == 1);
125 	TEST(Buffer[0] == ' ');
126 	TEST(NtUserToUnicodeEx(109, 74, KeyState, Buffer, 10, 0, hkl) == 1);
127 	TEST(Buffer[0] == '-');
128 	TEST(NtUserToUnicodeEx(107, 78, KeyState, Buffer, 10, 0, hkl) == 1);
129 	TEST(Buffer[0] == '+');
130 	TEST(NtUserToUnicodeEx(226, 86, KeyState, Buffer, 10, 0, hkl) == 1);
131 	TEST(Buffer[0] == '\\');
132 	TEST(NtUserToUnicodeEx(9, 124, KeyState, Buffer, 10, 0, hkl) == 1);
133 	TEST(Buffer[0] == 9);
134 
135 	/* Test with shift key pressed */
136 	ZeroMemory(KeyState, 256);
137 	KeyState[VK_SHIFT] = 0xff;
138 	TEST(NtUserToUnicodeEx(27, 1, KeyState, Buffer, 10, 0, hkl) == 1);
139 	TEST(Buffer[0] == 27);
140 	TEST(NtUserToUnicodeEx(49, 2, KeyState, Buffer, 10, 0, hkl) == 1);
141 	TEST(Buffer[0] == '!');
142 	TEST(NtUserToUnicodeEx(50, 3, KeyState, Buffer, 10, 0, hkl) == 1);
143 	TEST(Buffer[0] == '@');
144 	TEST(NtUserToUnicodeEx(51, 4, KeyState, Buffer, 10, 0, hkl) == 1);
145 	TEST(Buffer[0] == '#');
146 	TEST(NtUserToUnicodeEx(52, 5, KeyState, Buffer, 10, 0, hkl) == 1);
147 	TEST(Buffer[0] == '$');
148 	TEST(NtUserToUnicodeEx(53, 6, KeyState, Buffer, 10, 0, hkl) == 1);
149 	TEST(Buffer[0] == '%');
150 	TEST(NtUserToUnicodeEx(54, 7, KeyState, Buffer, 10, 0, hkl) == 1);
151 	TEST(Buffer[0] == '^');
152 	TEST(NtUserToUnicodeEx(55, 8, KeyState, Buffer, 10, 0, hkl) == 1);
153 	TEST(Buffer[0] == '&');
154 	TEST(NtUserToUnicodeEx(56, 9, KeyState, Buffer, 10, 0, hkl) == 1);
155 	TEST(Buffer[0] == '*');
156 	TEST(NtUserToUnicodeEx(57, 10, KeyState, Buffer, 10, 0, hkl) == 1);
157 	TEST(Buffer[0] == '(');
158 	TEST(NtUserToUnicodeEx(48, 11, KeyState, Buffer, 10, 0, hkl) == 1);
159 	TEST(Buffer[0] == ')');
160 	TEST(NtUserToUnicodeEx(189, 12, KeyState, Buffer, 10, 0, hkl) == 1);
161 	TEST(Buffer[0] == '_');
162 	TEST(NtUserToUnicodeEx(187, 13, KeyState, Buffer, 10, 0, hkl) == 1);
163 	TEST(Buffer[0] == '+');
164 	TEST(NtUserToUnicodeEx(8, 14, KeyState, Buffer, 10, 0, hkl) == 1);
165 	TEST(Buffer[0] == 8);
166 	TEST(NtUserToUnicodeEx(9, 15, KeyState, Buffer, 10, 0, hkl) == 1);
167 	TEST(Buffer[0] == 9);
168 	TEST(NtUserToUnicodeEx(81, 16, KeyState, Buffer, 10, 0, hkl) == 1);
169 	TEST(Buffer[0] == 'Q');
170 	TEST(NtUserToUnicodeEx(87, 17, KeyState, Buffer, 10, 0, hkl) == 1);
171 	TEST(Buffer[0] == 'W');
172 	TEST(NtUserToUnicodeEx(69, 18, KeyState, Buffer, 10, 0, hkl) == 1);
173 	TEST(Buffer[0] == 'E');
174 	TEST(NtUserToUnicodeEx(82, 19, KeyState, Buffer, 10, 0, hkl) == 1);
175 	TEST(Buffer[0] == 'R');
176 	TEST(NtUserToUnicodeEx(84, 20, KeyState, Buffer, 10, 0, hkl) == 1);
177 	TEST(Buffer[0] == 'T');
178 	TEST(NtUserToUnicodeEx(89, 21, KeyState, Buffer, 10, 0, hkl) == 1);
179 	TEST(Buffer[0] == 'Y');
180 	TEST(NtUserToUnicodeEx(85, 22, KeyState, Buffer, 10, 0, hkl) == 1);
181 	TEST(Buffer[0] == 'U');
182 	TEST(NtUserToUnicodeEx(73, 23, KeyState, Buffer, 10, 0, hkl) == 1);
183 	TEST(Buffer[0] == 'I');
184 	TEST(NtUserToUnicodeEx(79, 24, KeyState, Buffer, 10, 0, hkl) == 1);
185 	TEST(Buffer[0] == 'O');
186 	TEST(NtUserToUnicodeEx(80, 25, KeyState, Buffer, 10, 0, hkl) == 1);
187 	TEST(Buffer[0] == 'P');
188 	TEST(NtUserToUnicodeEx(219, 26, KeyState, Buffer, 10, 0, hkl) == 1);
189 	TEST(Buffer[0] == '{');
190 	TEST(NtUserToUnicodeEx(221, 27, KeyState, Buffer, 10, 0, hkl) == 1);
191 	TEST(Buffer[0] == '}');
192 	TEST(NtUserToUnicodeEx(13, 28, KeyState, Buffer, 10, 0, hkl) == 1);
193 	TEST(Buffer[0] == 13);
194 	TEST(NtUserToUnicodeEx(65, 30, KeyState, Buffer, 10, 0, hkl) == 1);
195 	TEST(Buffer[0] == 'A');
196 	TEST(NtUserToUnicodeEx(83, 31, KeyState, Buffer, 10, 0, hkl) == 1);
197 	TEST(Buffer[0] == 'S');
198 	TEST(NtUserToUnicodeEx(68, 32, KeyState, Buffer, 10, 0, hkl) == 1);
199 	TEST(Buffer[0] == 'D');
200 	TEST(NtUserToUnicodeEx(70, 33, KeyState, Buffer, 10, 0, hkl) == 1);
201 	TEST(Buffer[0] == 'F');
202 	TEST(NtUserToUnicodeEx(71, 34, KeyState, Buffer, 10, 0, hkl) == 1);
203 	TEST(Buffer[0] == 'G');
204 	TEST(NtUserToUnicodeEx(72, 35, KeyState, Buffer, 10, 0, hkl) == 1);
205 	TEST(Buffer[0] == 'H');
206 	TEST(NtUserToUnicodeEx(74, 36, KeyState, Buffer, 10, 0, hkl) == 1);
207 	TEST(Buffer[0] == 'J');
208 	TEST(NtUserToUnicodeEx(75, 37, KeyState, Buffer, 10, 0, hkl) == 1);
209 	TEST(Buffer[0] == 'K');
210 	TEST(NtUserToUnicodeEx(76, 38, KeyState, Buffer, 10, 0, hkl) == 1);
211 	TEST(Buffer[0] == 'L');
212 	TEST(NtUserToUnicodeEx(186, 39, KeyState, Buffer, 10, 0, hkl) == 1);
213 	TEST(Buffer[0] == ':');
214 	TEST(NtUserToUnicodeEx(222, 40, KeyState, Buffer, 10, 0, hkl) == 1);
215 	TEST(Buffer[0] == '"');
216 	TEST(NtUserToUnicodeEx(192, 41, KeyState, Buffer, 10, 0, hkl) == 1);
217 	TEST(Buffer[0] == '~');
218 	TEST(NtUserToUnicodeEx(220, 43, KeyState, Buffer, 10, 0, hkl) == 1);
219 	TEST(Buffer[0] == '|');
220 	TEST(NtUserToUnicodeEx(90, 44, KeyState, Buffer, 10, 0, hkl) == 1);
221 	TEST(Buffer[0] == 'Z');
222 	TEST(NtUserToUnicodeEx(88, 45, KeyState, Buffer, 10, 0, hkl) == 1);
223 	TEST(Buffer[0] == 'X');
224 	TEST(NtUserToUnicodeEx(67, 46, KeyState, Buffer, 10, 0, hkl) == 1);
225 	TEST(Buffer[0] == 'C');
226 	TEST(NtUserToUnicodeEx(86, 47, KeyState, Buffer, 10, 0, hkl) == 1);
227 	TEST(Buffer[0] == 'V');
228 	TEST(NtUserToUnicodeEx(66, 48, KeyState, Buffer, 10, 0, hkl) == 1);
229 	TEST(Buffer[0] == 'B');
230 	TEST(NtUserToUnicodeEx(78, 49, KeyState, Buffer, 10, 0, hkl) == 1);
231 	TEST(Buffer[0] == 'N');
232 	TEST(NtUserToUnicodeEx(77, 50, KeyState, Buffer, 10, 0, hkl) == 1);
233 	TEST(Buffer[0] == 'M');
234 	TEST(NtUserToUnicodeEx(188, 51, KeyState, Buffer, 10, 0, hkl) == 1);
235 	TEST(Buffer[0] == '<');
236 	TEST(NtUserToUnicodeEx(190, 52, KeyState, Buffer, 10, 0, hkl) == 1);
237 	TEST(Buffer[0] == '>');
238 	TEST(NtUserToUnicodeEx(191, 53, KeyState, Buffer, 10, 0, hkl) == 1);
239 	TEST(Buffer[0] == '?');
240 	TEST(NtUserToUnicodeEx(106, 55, KeyState, Buffer, 10, 0, hkl) == 1);
241 	TEST(Buffer[0] == '*');
242 	TEST(NtUserToUnicodeEx(32, 57, KeyState, Buffer, 10, 0, hkl) == 1);
243 	TEST(Buffer[0] == ' ');
244 	TEST(NtUserToUnicodeEx(109, 74, KeyState, Buffer, 10, 0, hkl) == 1);
245 	TEST(Buffer[0] == '-');
246 	TEST(NtUserToUnicodeEx(107, 78, KeyState, Buffer, 10, 0, hkl) == 1);
247 	TEST(Buffer[0] == '+');
248 	TEST(NtUserToUnicodeEx(226, 86, KeyState, Buffer, 10, 0, hkl) == 1);
249 	TEST(Buffer[0] == '|');
250 	TEST(NtUserToUnicodeEx(9, 124, KeyState, Buffer, 10, 0, hkl) == 1);
251 	TEST(Buffer[0] == 9);
252 
253 	/* Test with ctrl key pressed */
254 	ZeroMemory(KeyState, 256);
255 	KeyState[VK_CONTROL] = 0xff;
256 //	TEST(NtUserToUnicodeEx(27, 1, KeyState, Buffer, 10, 0, hkl) == 1);
257 //	TEST(Buffer[0] == 27);
258 //	TEST(NtUserToUnicodeEx(8, 14, KeyState, Buffer, 10, 0, hkl) == 1);
259 //	TEST(Buffer[0] == 127);
260 	TEST(NtUserToUnicodeEx(81, 16, KeyState, Buffer, 10, 0, hkl) == 1);
261 	TEST(Buffer[0] == 17);
262 	TEST(NtUserToUnicodeEx(87, 17, KeyState, Buffer, 10, 0, hkl) == 1);
263 	TEST(Buffer[0] == 23);
264 	TEST(NtUserToUnicodeEx(69, 18, KeyState, Buffer, 10, 0, hkl) == 1);
265 	TEST(Buffer[0] == 5);
266 	TEST(NtUserToUnicodeEx(82, 19, KeyState, Buffer, 10, 0, hkl) == 1);
267 	TEST(Buffer[0] == 18);
268 	TEST(NtUserToUnicodeEx(84, 20, KeyState, Buffer, 10, 0, hkl) == 1);
269 	TEST(Buffer[0] == 20);
270 	TEST(NtUserToUnicodeEx(89, 21, KeyState, Buffer, 10, 0, hkl) == 1);
271 	TEST(Buffer[0] == 25);
272 	TEST(NtUserToUnicodeEx(85, 22, KeyState, Buffer, 10, 0, hkl) == 1);
273 	TEST(Buffer[0] == 21);
274 	TEST(NtUserToUnicodeEx(73, 23, KeyState, Buffer, 10, 0, hkl) == 1);
275 	TEST(Buffer[0] == 9);
276 	TEST(NtUserToUnicodeEx(79, 24, KeyState, Buffer, 10, 0, hkl) == 1);
277 	TEST(Buffer[0] == 15);
278 	TEST(NtUserToUnicodeEx(80, 25, KeyState, Buffer, 10, 0, hkl) == 1);
279 	TEST(Buffer[0] == 16);
280 	TEST(NtUserToUnicodeEx(219, 26, KeyState, Buffer, 10, 0, hkl) == 1);
281 	TEST(Buffer[0] == 27);
282 	TEST(NtUserToUnicodeEx(221, 27, KeyState, Buffer, 10, 0, hkl) == 1);
283 	TEST(Buffer[0] == 29);
284 	TEST(NtUserToUnicodeEx(13, 28, KeyState, Buffer, 10, 0, hkl) == 1);
285 	TEST(Buffer[0] == 10);
286 	TEST(NtUserToUnicodeEx(65, 30, KeyState, Buffer, 10, 0, hkl) == 1);
287 	TEST(Buffer[0] == 1);
288 	TEST(NtUserToUnicodeEx(83, 31, KeyState, Buffer, 10, 0, hkl) == 1);
289 	TEST(Buffer[0] == 19);
290 	TEST(NtUserToUnicodeEx(68, 32, KeyState, Buffer, 10, 0, hkl) == 1);
291 	TEST(Buffer[0] == 4);
292 	TEST(NtUserToUnicodeEx(70, 33, KeyState, Buffer, 10, 0, hkl) == 1);
293 	TEST(Buffer[0] == 6);
294 	TEST(NtUserToUnicodeEx(71, 34, KeyState, Buffer, 10, 0, hkl) == 1);
295 	TEST(Buffer[0] == 7);
296 	TEST(NtUserToUnicodeEx(72, 35, KeyState, Buffer, 10, 0, hkl) == 1);
297 	TEST(Buffer[0] == 8);
298 	TEST(NtUserToUnicodeEx(74, 36, KeyState, Buffer, 10, 0, hkl) == 1);
299 	TEST(Buffer[0] == 10);
300 	TEST(NtUserToUnicodeEx(75, 37, KeyState, Buffer, 10, 0, hkl) == 1);
301 	TEST(Buffer[0] == 11);
302 	TEST(NtUserToUnicodeEx(76, 38, KeyState, Buffer, 10, 0, hkl) == 1);
303 	TEST(Buffer[0] == 12);
304 	TEST(NtUserToUnicodeEx(220, 43, KeyState, Buffer, 10, 0, hkl) == 1);
305 	TEST(Buffer[0] == 28);
306 	TEST(NtUserToUnicodeEx(90, 44, KeyState, Buffer, 10, 0, hkl) == 1);
307 	TEST(Buffer[0] == 26);
308 	TEST(NtUserToUnicodeEx(88, 45, KeyState, Buffer, 10, 0, hkl) == 1);
309 	TEST(Buffer[0] == 24);
310 	TEST(NtUserToUnicodeEx(67, 46, KeyState, Buffer, 10, 0, hkl) == 1);
311 	TEST(Buffer[0] == 3);
312 	TEST(NtUserToUnicodeEx(86, 47, KeyState, Buffer, 10, 0, hkl) == 1);
313 	TEST(Buffer[0] == 22);
314 	TEST(NtUserToUnicodeEx(66, 48, KeyState, Buffer, 10, 0, hkl) == 1);
315 	TEST(Buffer[0] == 2);
316 	TEST(NtUserToUnicodeEx(78, 49, KeyState, Buffer, 10, 0, hkl) == 1);
317 	TEST(Buffer[0] == 14);
318 	TEST(NtUserToUnicodeEx(77, 50, KeyState, Buffer, 10, 0, hkl) == 1);
319 	TEST(Buffer[0] == 13);
320 //	TEST(NtUserToUnicodeEx(32, 57, KeyState, Buffer, 10, 0, hkl) == 1);
321 //	TEST(Buffer[0] == 32);
322 	TEST(NtUserToUnicodeEx(226, 86, KeyState, Buffer, 10, 0, hkl) == 1);
323 	TEST(Buffer[0] == 28);
324 
325 	/* Test with VK_CAPITAL key pressed */
326 	ZeroMemory(KeyState, 256);
327 	KeyState[VK_CAPITAL] = 0xff;
328 	TEST(NtUserToUnicodeEx(27, 1, KeyState, Buffer, 10, 0, hkl) == 1);
329 	TEST(Buffer[0] == 27);
330 	TEST(NtUserToUnicodeEx(49, 2, KeyState, Buffer, 10, 0, hkl) == 1);
331 	TEST(Buffer[0] == '1');
332 	TEST(NtUserToUnicodeEx(50, 3, KeyState, Buffer, 10, 0, hkl) == 1);
333 	TEST(Buffer[0] == '2');
334 	TEST(NtUserToUnicodeEx(51, 4, KeyState, Buffer, 10, 0, hkl) == 1);
335 	TEST(Buffer[0] == '3');
336 	TEST(NtUserToUnicodeEx(52, 5, KeyState, Buffer, 10, 0, hkl) == 1);
337 	TEST(Buffer[0] == '4');
338 	TEST(NtUserToUnicodeEx(53, 6, KeyState, Buffer, 10, 0, hkl) == 1);
339 	TEST(Buffer[0] == '5');
340 	TEST(NtUserToUnicodeEx(54, 7, KeyState, Buffer, 10, 0, hkl) == 1);
341 	TEST(Buffer[0] == '6');
342 	TEST(NtUserToUnicodeEx(55, 8, KeyState, Buffer, 10, 0, hkl) == 1);
343 	TEST(Buffer[0] == '7');
344 	TEST(NtUserToUnicodeEx(56, 9, KeyState, Buffer, 10, 0, hkl) == 1);
345 	TEST(Buffer[0] == '8');
346 	TEST(NtUserToUnicodeEx(57, 10, KeyState, Buffer, 10, 0, hkl) == 1);
347 	TEST(Buffer[0] == '9');
348 	TEST(NtUserToUnicodeEx(48, 11, KeyState, Buffer, 10, 0, hkl) == 1);
349 	TEST(Buffer[0] == '0');
350 	TEST(NtUserToUnicodeEx(189, 12, KeyState, Buffer, 10, 0, hkl) == 1);
351 	TEST(Buffer[0] == '-');
352 	TEST(NtUserToUnicodeEx(187, 13, KeyState, Buffer, 10, 0, hkl) == 1);
353 	TEST(Buffer[0] == '=');
354 	TEST(NtUserToUnicodeEx(8, 14, KeyState, Buffer, 10, 0, hkl) == 1);
355 	TEST(Buffer[0] == 8);
356 	TEST(NtUserToUnicodeEx(9, 15, KeyState, Buffer, 10, 0, hkl) == 1);
357 	TEST(Buffer[0] == 9);
358 	TEST(NtUserToUnicodeEx(81, 16, KeyState, Buffer, 10, 0, hkl) == 1);
359 	TEST(Buffer[0] == 'Q');
360 	TEST(NtUserToUnicodeEx(87, 17, KeyState, Buffer, 10, 0, hkl) == 1);
361 	TEST(Buffer[0] == 'W');
362 	TEST(NtUserToUnicodeEx(69, 18, KeyState, Buffer, 10, 0, hkl) == 1);
363 	TEST(Buffer[0] == 'E');
364 	TEST(NtUserToUnicodeEx(82, 19, KeyState, Buffer, 10, 0, hkl) == 1);
365 	TEST(Buffer[0] == 'R');
366 	TEST(NtUserToUnicodeEx(84, 20, KeyState, Buffer, 10, 0, hkl) == 1);
367 	TEST(Buffer[0] == 'T');
368 	TEST(NtUserToUnicodeEx(89, 21, KeyState, Buffer, 10, 0, hkl) == 1);
369 	TEST(Buffer[0] == 'Y');
370 	TEST(NtUserToUnicodeEx(85, 22, KeyState, Buffer, 10, 0, hkl) == 1);
371 	TEST(Buffer[0] == 'U');
372 	TEST(NtUserToUnicodeEx(73, 23, KeyState, Buffer, 10, 0, hkl) == 1);
373 	TEST(Buffer[0] == 'I');
374 	TEST(NtUserToUnicodeEx(79, 24, KeyState, Buffer, 10, 0, hkl) == 1);
375 	TEST(Buffer[0] == 'O');
376 	TEST(NtUserToUnicodeEx(80, 25, KeyState, Buffer, 10, 0, hkl) == 1);
377 	TEST(Buffer[0] == 'P');
378 	TEST(NtUserToUnicodeEx(219, 26, KeyState, Buffer, 10, 0, hkl) == 1);
379 	TEST(Buffer[0] == '[');
380 	TEST(NtUserToUnicodeEx(221, 27, KeyState, Buffer, 10, 0, hkl) == 1);
381 	TEST(Buffer[0] == ']');
382 	TEST(NtUserToUnicodeEx(13, 28, KeyState, Buffer, 10, 0, hkl) == 1);
383 	TEST(Buffer[0] == 13);
384 	TEST(NtUserToUnicodeEx(65, 30, KeyState, Buffer, 10, 0, hkl) == 1);
385 	TEST(Buffer[0] == 'A');
386 	TEST(NtUserToUnicodeEx(83, 31, KeyState, Buffer, 10, 0, hkl) == 1);
387 	TEST(Buffer[0] == 'S');
388 	TEST(NtUserToUnicodeEx(68, 32, KeyState, Buffer, 10, 0, hkl) == 1);
389 	TEST(Buffer[0] == 'D');
390 	TEST(NtUserToUnicodeEx(70, 33, KeyState, Buffer, 10, 0, hkl) == 1);
391 	TEST(Buffer[0] == 'F');
392 	TEST(NtUserToUnicodeEx(71, 34, KeyState, Buffer, 10, 0, hkl) == 1);
393 	TEST(Buffer[0] == 'G');
394 	TEST(NtUserToUnicodeEx(72, 35, KeyState, Buffer, 10, 0, hkl) == 1);
395 	TEST(Buffer[0] == 'H');
396 	TEST(NtUserToUnicodeEx(74, 36, KeyState, Buffer, 10, 0, hkl) == 1);
397 	TEST(Buffer[0] == 'J');
398 	TEST(NtUserToUnicodeEx(75, 37, KeyState, Buffer, 10, 0, hkl) == 1);
399 	TEST(Buffer[0] == 'K');
400 	TEST(NtUserToUnicodeEx(76, 38, KeyState, Buffer, 10, 0, hkl) == 1);
401 	TEST(Buffer[0] == 'L');
402 	TEST(NtUserToUnicodeEx(186, 39, KeyState, Buffer, 10, 0, hkl) == 1);
403 	TEST(Buffer[0] == ';');
404 	TEST(NtUserToUnicodeEx(222, 40, KeyState, Buffer, 10, 0, hkl) == 1);
405 	TEST(Buffer[0] == '\'');
406 	TEST(NtUserToUnicodeEx(192, 41, KeyState, Buffer, 10, 0, hkl) == 1);
407 	TEST(Buffer[0] == '`');
408 	TEST(NtUserToUnicodeEx(220, 43, KeyState, Buffer, 10, 0, hkl) == 1);
409 	TEST(Buffer[0] == '\\');
410 	TEST(NtUserToUnicodeEx(90, 44, KeyState, Buffer, 10, 0, hkl) == 1);
411 	TEST(Buffer[0] == 'Z');
412 	TEST(NtUserToUnicodeEx(88, 45, KeyState, Buffer, 10, 0, hkl) == 1);
413 	TEST(Buffer[0] == 'X');
414 	TEST(NtUserToUnicodeEx(67, 46, KeyState, Buffer, 10, 0, hkl) == 1);
415 	TEST(Buffer[0] == 'C');
416 	TEST(NtUserToUnicodeEx(86, 47, KeyState, Buffer, 10, 0, hkl) == 1);
417 	TEST(Buffer[0] == 'V');
418 	TEST(NtUserToUnicodeEx(66, 48, KeyState, Buffer, 10, 0, hkl) == 1);
419 	TEST(Buffer[0] == 'B');
420 	TEST(NtUserToUnicodeEx(78, 49, KeyState, Buffer, 10, 0, hkl) == 1);
421 	TEST(Buffer[0] == 'N');
422 	TEST(NtUserToUnicodeEx(77, 50, KeyState, Buffer, 10, 0, hkl) == 1);
423 	TEST(Buffer[0] == 'M');
424 	TEST(NtUserToUnicodeEx(188, 51, KeyState, Buffer, 10, 0, hkl) == 1);
425 	TEST(Buffer[0] == ',');
426 	TEST(NtUserToUnicodeEx(190, 52, KeyState, Buffer, 10, 0, hkl) == 1);
427 	TEST(Buffer[0] == '.');
428 	TEST(NtUserToUnicodeEx(191, 53, KeyState, Buffer, 10, 0, hkl) == 1);
429 	TEST(Buffer[0] == '/');
430 	TEST(NtUserToUnicodeEx(106, 55, KeyState, Buffer, 10, 0, hkl) == 1);
431 	TEST(Buffer[0] == '*');
432 	TEST(NtUserToUnicodeEx(32, 57, KeyState, Buffer, 10, 0, hkl) == 1);
433 	TEST(Buffer[0] == ' ');
434 	TEST(NtUserToUnicodeEx(109, 74, KeyState, Buffer, 10, 0, hkl) == 1);
435 	TEST(Buffer[0] == '-');
436 	TEST(NtUserToUnicodeEx(107, 78, KeyState, Buffer, 10, 0, hkl) == 1);
437 	TEST(Buffer[0] == '+');
438 	TEST(NtUserToUnicodeEx(226, 86, KeyState, Buffer, 10, 0, hkl) == 1);
439 	TEST(Buffer[0] == '\\');
440 	TEST(NtUserToUnicodeEx(9, 124, KeyState, Buffer, 10, 0, hkl) == 1);
441 	TEST(Buffer[0] == 9);
442 }
443 
444