[REGEDIT_WINETEST] Sync with Wine 3.0. CORE-14225
[reactos.git] / modules / rostests / winetests / regedit / regedit.c
1 /*
2 * Copyright 2010 Andrew Eikum for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #include <windows.h>
20 #include <stdio.h>
21 #include "wine/test.h"
22
23 #define lok ok_(__FILE__,line)
24
25 #define run_regedit_exe(c) run_regedit_exe_(__LINE__,c)
26 static BOOL run_regedit_exe_(unsigned line, const char *cmd)
27 {
28 STARTUPINFOA si = {sizeof(STARTUPINFOA)};
29 PROCESS_INFORMATION pi;
30 DWORD ret;
31 char cmdline[256];
32
33 si.dwFlags = STARTF_USESTDHANDLES;
34 si.hStdInput = INVALID_HANDLE_VALUE;
35 si.hStdOutput = INVALID_HANDLE_VALUE;
36 si.hStdError = INVALID_HANDLE_VALUE;
37
38 strcpy(cmdline, cmd);
39 if (!CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
40 return FALSE;
41
42 ret = WaitForSingleObject(pi.hProcess, 10000);
43 if (ret == WAIT_TIMEOUT)
44 TerminateProcess(pi.hProcess, 1);
45
46 CloseHandle(pi.hThread);
47 CloseHandle(pi.hProcess);
48 return (ret != WAIT_TIMEOUT);
49 }
50
51 static BOOL write_file(const void *str, DWORD size)
52 {
53 HANDLE file;
54 BOOL ret;
55 DWORD written;
56
57 file = CreateFileA("test.reg", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
58 FILE_ATTRIBUTE_NORMAL, NULL);
59 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
60 if (file == INVALID_HANDLE_VALUE)
61 return FALSE;
62
63 ret = WriteFile(file, str, size, &written, NULL);
64 ok(ret, "WriteFile failed: %u\n", GetLastError());
65 CloseHandle(file);
66
67 return ret;
68 }
69
70 #define exec_import_str(c) import_reg(__LINE__,c,FALSE)
71 #define exec_import_wstr(c) import_reg(__LINE__,c,TRUE)
72
73 static BOOL import_reg(unsigned line, const char *contents, BOOL unicode)
74 {
75 int lenA;
76 BOOL ret;
77
78 lenA = strlen(contents);
79
80 if (unicode)
81 {
82 int len = MultiByteToWideChar(CP_UTF8, 0, contents, lenA, NULL, 0);
83 int size = len * sizeof(WCHAR);
84 WCHAR *wstr = HeapAlloc(GetProcessHeap(), 0, size);
85 if (!wstr) return FALSE;
86 MultiByteToWideChar(CP_UTF8, 0, contents, lenA, wstr, len);
87
88 ret = write_file(wstr, size);
89 HeapFree(GetProcessHeap(), 0, wstr);
90 }
91 else
92 ret = write_file(contents, lenA);
93
94 if (!ret) return FALSE;
95
96 run_regedit_exe("regedit.exe /s test.reg");
97
98 ret = DeleteFileA("test.reg");
99 lok(ret, "DeleteFile failed: %u\n", GetLastError());
100
101 return ret;
102 }
103
104 #define TODO_REG_TYPE (0x0001u)
105 #define TODO_REG_SIZE (0x0002u)
106 #define TODO_REG_DATA (0x0004u)
107 #define TODO_REG_COMPARE (0x0008u)
108
109 /* verify_reg() adapted from programs/reg/tests/reg.c */
110 #define verify_reg(k,v,t,d,s,todo) verify_reg_(__LINE__,k,v,t,d,s,todo)
111 static void verify_reg_(unsigned line, HKEY hkey, const char *value,
112 DWORD exp_type, const void *exp_data, DWORD exp_size, DWORD todo)
113 {
114 DWORD type, size;
115 BYTE data[256];
116 LONG err;
117
118 size = sizeof(data);
119 memset(data, 0xdd, size);
120 err = RegQueryValueExA(hkey, value, NULL, &type, data, &size);
121 lok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
122 if (err != ERROR_SUCCESS)
123 return;
124
125 todo_wine_if (todo & TODO_REG_TYPE)
126 lok(type == exp_type, "got wrong type %d, expected %d\n", type, exp_type);
127 todo_wine_if (todo & TODO_REG_SIZE)
128 lok(size == exp_size, "got wrong size %d, expected %d\n", size, exp_size);
129 if (exp_data)
130 {
131 todo_wine_if (todo & TODO_REG_DATA)
132 lok(memcmp(data, exp_data, size) == 0, "got wrong data\n");
133 }
134 }
135
136 #define verify_reg_nonexist(k,n) r_verify_reg_nonexist(__LINE__,k,n)
137 static void r_verify_reg_nonexist(unsigned line, HKEY key, const char *value_name)
138 {
139 LONG lr;
140
141 lr = RegQueryValueExA(key, value_name, NULL, NULL, NULL, NULL);
142 lok(lr == ERROR_FILE_NOT_FOUND, "registry value '%s' shouldn't exist; got %d, expected 2\n",
143 (value_name && *value_name) ? value_name : "(Default)", lr);
144 }
145
146 #define open_key(b,p,s,k) open_key_(__LINE__,b,p,s,k)
147 static void open_key_(unsigned line, const HKEY base, const char *path, const DWORD sam, HKEY *hkey)
148 {
149 LONG lr;
150
151 lr = RegOpenKeyExA(base, path, 0, KEY_READ|sam, hkey);
152 lok(lr == ERROR_SUCCESS, "RegOpenKeyExA failed: %d\n", lr);
153 }
154
155 #define verify_key(k,s) verify_key_(__LINE__,k,s)
156 static void verify_key_(unsigned line, HKEY key_base, const char *subkey)
157 {
158 HKEY hkey;
159 LONG lr;
160
161 lr = RegOpenKeyExA(key_base, subkey, 0, KEY_READ, &hkey);
162 lok(lr == ERROR_SUCCESS, "RegOpenKeyExA failed: got %d\n", lr);
163
164 if (hkey)
165 RegCloseKey(hkey);
166 }
167
168 #define verify_key_nonexist(k,s) verify_key_nonexist_(__LINE__,k,s)
169 static void verify_key_nonexist_(unsigned line, HKEY key_base, const char *subkey)
170 {
171 HKEY hkey;
172 LONG lr;
173
174 lr = RegOpenKeyExA(key_base, subkey, 0, KEY_READ, &hkey);
175 lok(lr == ERROR_FILE_NOT_FOUND, "registry key '%s' shouldn't exist; got %d, expected 2\n",
176 subkey, lr);
177
178 if (hkey)
179 RegCloseKey(hkey);
180 }
181
182 #define add_key(k,p,s) add_key_(__LINE__,k,p,s)
183 static void add_key_(unsigned line, const HKEY hkey, const char *path, HKEY *subkey)
184 {
185 LONG lr;
186
187 lr = RegCreateKeyExA(hkey, path, 0, NULL, REG_OPTION_NON_VOLATILE,
188 KEY_READ|KEY_WRITE, NULL, subkey, NULL);
189 lok(lr == ERROR_SUCCESS, "RegCreateKeyExA failed: %d\n", lr);
190 }
191
192 #define delete_key(k,p) delete_key_(__LINE__,k,p)
193 static void delete_key_(unsigned line, const HKEY hkey, const char *path)
194 {
195 if (path && *path)
196 {
197 LONG lr;
198
199 lr = RegDeleteKeyA(hkey, path);
200 lok(lr == ERROR_SUCCESS, "RegDeleteKeyA failed: %d\n", lr);
201 }
202 }
203
204 static LONG delete_tree(const HKEY key, const char *subkey)
205 {
206 HKEY hkey;
207 LONG ret;
208 char *subkey_name = NULL;
209 DWORD max_subkey_len, subkey_len;
210 static const char empty[1];
211
212 ret = RegOpenKeyExA(key, subkey, 0, KEY_READ, &hkey);
213 if (ret) return ret;
214
215 ret = RegQueryInfoKeyA(hkey, NULL, NULL, NULL, NULL, &max_subkey_len,
216 NULL, NULL, NULL, NULL, NULL, NULL);
217 if (ret) goto cleanup;
218
219 max_subkey_len++;
220
221 subkey_name = HeapAlloc(GetProcessHeap(), 0, max_subkey_len);
222 if (!subkey_name)
223 {
224 ret = ERROR_NOT_ENOUGH_MEMORY;
225 goto cleanup;
226 }
227
228 for (;;)
229 {
230 subkey_len = max_subkey_len;
231 ret = RegEnumKeyExA(hkey, 0, subkey_name, &subkey_len, NULL, NULL, NULL, NULL);
232 if (ret == ERROR_NO_MORE_ITEMS) break;
233 if (ret) goto cleanup;
234 ret = delete_tree(hkey, subkey_name);
235 if (ret) goto cleanup;
236 }
237
238 ret = RegDeleteKeyA(hkey, empty);
239
240 cleanup:
241 HeapFree(GetProcessHeap(), 0, subkey_name);
242 RegCloseKey(hkey);
243 return ret;
244 }
245
246 #define add_value(k,n,t,d,s) add_value_(__LINE__,k,n,t,d,s)
247 static void add_value_(unsigned line, HKEY hkey, const char *name, DWORD type,
248 const void *data, size_t size)
249 {
250 LONG lr;
251
252 lr = RegSetValueExA(hkey, name, 0, type, (const BYTE *)data, size);
253 lok(lr == ERROR_SUCCESS, "RegSetValueExA failed: %d\n", lr);
254 }
255
256 #define delete_value(k,n) delete_value_(__LINE__,k,n)
257 static void delete_value_(unsigned line, const HKEY hkey, const char *name)
258 {
259 LONG lr;
260
261 lr = RegDeleteValueA(hkey, name);
262 lok(lr == ERROR_SUCCESS, "RegDeleteValueA failed: %d\n", lr);
263 }
264
265 #define KEY_BASE "Software\\Wine\\regedit_test"
266
267 static void test_basic_import(void)
268 {
269 HKEY hkey, subkey;
270 DWORD dword = 0x17, type, size;
271 char exp_binary[] = {0xAA,0xBB,0xCC,0x11};
272 LONG lr;
273 char buffer[256];
274 BYTE hex[8];
275
276 lr = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
277 ok(lr == ERROR_SUCCESS || lr == ERROR_FILE_NOT_FOUND,
278 "RegDeleteKeyA failed: %d\n", lr);
279
280 exec_import_str("REGEDIT4\n\n"
281 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
282 "\"TestValue\"=\"AValue\"\n");
283 open_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
284 verify_reg(hkey, "TestValue", REG_SZ, "AValue", 7, 0);
285
286 exec_import_str("REGEDIT4\r\n\r\n"
287 "[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n"
288 "\"TestValue2\"=\"BValue\"\r\n");
289 verify_reg(hkey, "TestValue2", REG_SZ, "BValue", 7, 0);
290
291 exec_import_str("Windows Registry Editor Version 5.00\n\n"
292 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
293 "\"TestValue3\"=\"Value\"\n");
294 verify_reg(hkey, "TestValue3", REG_SZ, "Value", 6, 0);
295
296 exec_import_str("REGEDIT4\r\r"
297 "[HKEY_CURRENT_USER\\" KEY_BASE "]\r"
298 "\"TestValue4\"=\"DValue\"\r");
299 verify_reg(hkey, "TestValue4", REG_SZ, "DValue", 7, 0);
300
301 exec_import_str("Windows Registry Editor Version 5.00\r\r"
302 "[HKEY_CURRENT_USER\\" KEY_BASE "]\r"
303 "\"TestValue5\"=\"Value\"\r");
304 verify_reg(hkey, "TestValue5", REG_SZ, "Value", 6, 0);
305
306 exec_import_str("REGEDIT4\n\n"
307 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
308 "\"TestDword\"=dword:00000017\n");
309 verify_reg(hkey, "TestDword", REG_DWORD, &dword, sizeof(dword), 0);
310
311 exec_import_str("REGEDIT4\n\n"
312 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
313 "\"TestBinary\"=hex:aa,bb,cc,11\n");
314 verify_reg(hkey, "TestBinary", REG_BINARY, exp_binary, sizeof(exp_binary), 0);
315
316 exec_import_str("REGEDIT4\n\n"
317 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
318 "\"With=Equals\"=\"asdf\"\n");
319 verify_reg(hkey, "With=Equals", REG_SZ, "asdf", 5, 0);
320
321 exec_import_str("REGEDIT4\n\n"
322 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
323 "\"Empty string\"=\"\"\n"
324 "\"\"=\"Default registry value\"\n\n");
325 verify_reg(hkey, "Empty string", REG_SZ, "", 1, 0);
326 verify_reg(hkey, NULL, REG_SZ, "Default registry value", 23, 0);
327
328 exec_import_str("REGEDIT4\n\n"
329 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
330 "\"Line1\"=\"Value1\"\n\n"
331 "\"Line2\"=\"Value2\"\n\n\n"
332 "\"Line3\"=\"Value3\"\n\n\n\n"
333 "\"Line4\"=\"Value4\"\n\n");
334 verify_reg(hkey, "Line1", REG_SZ, "Value1", 7, 0);
335 verify_reg(hkey, "Line2", REG_SZ, "Value2", 7, 0);
336 verify_reg(hkey, "Line3", REG_SZ, "Value3", 7, 0);
337 verify_reg(hkey, "Line4", REG_SZ, "Value4", 7, 0);
338
339 exec_import_str("REGEDIT4\n\n"
340 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
341 "\"Wine1\"=dword:00000782\n\n"
342 "\"Wine2\"=\"Test Value\"\n"
343 "\"Wine3\"=hex(7):4c,69,6e,65,20,\\\n"
344 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
345 "#comment\n"
346 "@=\"Test\"\n"
347 ";comment\n\n"
348 "\"Wine4\"=dword:12345678\n\n");
349 dword = 0x782;
350 verify_reg(hkey, "Wine1", REG_DWORD, &dword, sizeof(dword), 0);
351 verify_reg(hkey, "Wine2", REG_SZ, "Test Value", 11, 0);
352 verify_reg(hkey, "Wine3", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
353 verify_reg(hkey, "", REG_SZ, "Test", 5, 0);
354 dword = 0x12345678;
355 verify_reg(hkey, "Wine4", REG_DWORD, &dword, sizeof(dword), 0);
356
357 exec_import_str("REGEDIT4\n\n"
358 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
359 "\"Wine5\"=\"No newline\"");
360 verify_reg(hkey, "Wine5", REG_SZ, "No newline", 11, 0);
361
362 exec_import_str("REGEDIT4\n\n"
363 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
364 "\"Wine6\"=dword:00000050\n\n"
365 "\"Wine7\"=\"No newline\"");
366 dword = 0x50;
367 verify_reg(hkey, "Wine6", REG_DWORD, &dword, sizeof(dword), 0);
368 verify_reg(hkey, "Wine7", REG_SZ, "No newline", 11, 0);
369
370 exec_import_str("REGEDIT4\n\n"
371 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
372 "\"Wine8a\"=dword:1\n"
373 "\"Wine8b\"=dword:4444\n\n");
374 dword = 0x1;
375 verify_reg(hkey, "Wine8a", REG_DWORD, &dword, sizeof(dword), 0);
376 dword = 0x4444;
377 verify_reg(hkey, "Wine8b", REG_DWORD, &dword, sizeof(dword), 0);
378
379 exec_import_str("REGEDIT4\n\n"
380 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
381 "\"Wine9a\"=hex(2):4c,69,6e,65,00\n"
382 "\"Wine9b\"=\"Value 1\"\n"
383 "\"Wine9c\"=hex(2):4c,69,6e,65\\\n"
384 "\"Wine9d\"=\"Value 2\"\n"
385 "\"Wine9e\"=hex(2):4c,69,6e,65,\\\n"
386 "\"Wine9f\"=\"Value 3\"\n"
387 "\"Wine9g\"=\"Value 4\"\n\n");
388 verify_reg(hkey, "Wine9a", REG_EXPAND_SZ, "Line", 5, 0);
389 verify_reg(hkey, "Wine9b", REG_SZ, "Value 1", 8, 0);
390 verify_reg_nonexist(hkey, "Wine9c");
391 verify_reg(hkey, "Wine9d", REG_SZ, "Value 2", 8, 0);
392 verify_reg_nonexist(hkey, "Wine9e");
393 verify_reg_nonexist(hkey, "Wine9f");
394 verify_reg(hkey, "Wine9g", REG_SZ, "Value 4", 8, 0);
395
396 exec_import_str("REGEDIT4\n\n"
397 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
398 "\"double\\\"quote\"=\"valid \\\"or\\\" not\"\n"
399 "\"single'quote\"=dword:00000008\n\n");
400 verify_reg(hkey, "double\"quote", REG_SZ, "valid \"or\" not", 15, 0);
401 dword = 0x00000008;
402 verify_reg(hkey, "single'quote", REG_DWORD, &dword, sizeof(dword), 0);
403
404 /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
405 exec_import_str("REGEDIT4\n\n"
406 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
407 "\"Wine10a\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n"
408 "\"Wine10b\"=hex(0):56,00,61,00,6c,00,\\\n"
409 " 75,00,65,00,00,00\n"
410 "\"Wine10c\"=hex(0):56,00,61,00,\\;comment\n"
411 " 6c,00,75,00,\\\n"
412 " 65,00,00,00\n"
413 "\"Wine10d\"=hex(0):56,00,61,00,\\;comment\n"
414 " 6c,00,75,00,\n"
415 " 65,00,00,00\n"
416 "\"Wine10e\"=hex(0):56,00,61,00,\\;comment\n"
417 " 6c,00,75,00,;comment\n"
418 " 65,00,00,00\n");
419 verify_reg(hkey, "Wine10a", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
420 verify_reg(hkey, "Wine10b", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
421 verify_reg(hkey, "Wine10c", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
422 verify_reg(hkey, "Wine10d", REG_NONE, "V\0a\0l\0u", 8, 0);
423 verify_reg(hkey, "Wine10e", REG_NONE, "V\0a\0l\0u", 8, 0);
424
425 exec_import_str("REGEDIT4\n\n"
426 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
427 "\"Wine11a\"=hex(2):25,50,41,54,48,25,00\n"
428 "\"Wine11b\"=hex(2):25,50,41,\\\n"
429 " 54,48,25,00\n"
430 "\"Wine11c\"=hex(2):25,50,41,\\;comment\n"
431 " 54,48,\\\n"
432 " 25,00\n"
433 "\"Wine11d\"=hex(2):25,50,41,\\;comment\n"
434 " 54,48,\n"
435 " 25,00\n"
436 "\"Wine11e\"=hex(2):25,50,41,\\;comment\n"
437 " 54,48,;comment\n"
438 " 25,00\n");
439 verify_reg(hkey, "Wine11a", REG_EXPAND_SZ, "%PATH%", 7, 0);
440 verify_reg(hkey, "Wine11b", REG_EXPAND_SZ, "%PATH%", 7, 0);
441 verify_reg(hkey, "Wine11c", REG_EXPAND_SZ, "%PATH%", 7, 0);
442 /* Wine11d */
443 size = sizeof(buffer);
444 lr = RegQueryValueExA(hkey, "Wine11d", NULL, &type, (BYTE *)&buffer, &size);
445 ok(lr == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", lr);
446 ok(type == REG_EXPAND_SZ, "got wrong type %u, expected %u\n", type, REG_EXPAND_SZ);
447 ok(size == 6 || broken(size == 5) /* Win2k */, "got wrong size %u, expected 6\n", size);
448 ok(memcmp(buffer, "%PATH", size) == 0, "got wrong data\n");
449 /* Wine11e */
450 size = sizeof(buffer);
451 memset(buffer, '-', size);
452 lr = RegQueryValueExA(hkey, "Wine11e", NULL, &type, (BYTE *)&buffer, &size);
453 ok(lr == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", lr);
454 ok(type == REG_EXPAND_SZ, "got wrong type %u, expected %u\n", type, REG_EXPAND_SZ);
455 ok(size == 6 || broken(size == 5) /* Win2k */, "got wrong size %u, expected 6\n", size);
456 ok(memcmp(buffer, "%PATH", size) == 0, "got wrong data\n");
457
458 exec_import_str("REGEDIT4\n\n"
459 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
460 "\"Wine12a\"=hex:11,22,33,44,55,66,77,88\n"
461 "\"Wine12b\"=hex:11,22,33,44,\\\n"
462 " 55,66,77,88\n"
463 "\"Wine12c\"=hex:11,22,33,44,\\;comment\n"
464 " 55,66,\\\n"
465 " 77,88\n"
466 "\"Wine12d\"=hex:11,22,33,44,\\;comment\n"
467 " 55,66,\n"
468 " 77,88\n"
469 "\"Wine12e\"=hex:11,22,33,44,\\;comment\n"
470 " 55,66,;comment\n"
471 " 77,88\n");
472 hex[0] = 0x11; hex[1] = 0x22; hex[2] = 0x33; hex[3] = 0x44;
473 hex[4] = 0x55; hex[5] = 0x66; hex[6] = 0x77; hex[7] = 0x88;
474 verify_reg(hkey, "Wine12a", REG_BINARY, hex, sizeof(hex), 0);
475 verify_reg(hkey, "Wine12b", REG_BINARY, hex, sizeof(hex), 0);
476 verify_reg(hkey, "Wine12c", REG_BINARY, hex, sizeof(hex), 0);
477 verify_reg(hkey, "Wine12d", REG_BINARY, hex, 6, 0);
478 verify_reg(hkey, "Wine12e", REG_BINARY, hex, 6, 0);
479
480 /* Test import with subkeys */
481 exec_import_str("REGEDIT4\n\n"
482 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey\"1]\n"
483 "\"Wine\\\\31\"=\"Test value\"\n\n");
484 open_key(hkey, "Subkey\"1", 0, &subkey);
485 verify_reg(subkey, "Wine\\31", REG_SZ, "Test value", 11, 0);
486 lr = RegCloseKey(subkey);
487 ok(lr == ERROR_SUCCESS, "got %d, expected 0\n", lr);
488 delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey\"1");
489
490 exec_import_str("REGEDIT4\n\n"
491 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey/2]\n"
492 "\"123/\\\"4;'5\"=\"Random value name\"\n\n");
493 open_key(hkey, "Subkey/2", 0, &subkey);
494 verify_reg(subkey, "123/\"4;'5", REG_SZ, "Random value name", 18, 0);
495 lr = RegCloseKey(subkey);
496 ok(lr == ERROR_SUCCESS, "got %d, expected 0\n", lr);
497 delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey/2");
498
499 /* Test the accepted range of the hex-based data types */
500 exec_import_str("REGEDIT4\n\n"
501 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
502 "\"Wine13a\"=hex(0):56,61,6c,75,65,00\n"
503 "\"Wine13b\"=hex(10):56,61,6c,75,65,00\n"
504 "\"Wine13c\"=hex(100):56,61,6c,75,65,00\n"
505 "\"Wine13d\"=hex(1000):56,61,6c,75,65,00\n"
506 "\"Wine13e\"=hex(7fff):56,61,6c,75,65,00\n"
507 "\"Wine13f\"=hex(ffff):56,61,6c,75,65,00\n"
508 "\"Wine13g\"=hex(7fffffff):56,61,6c,75,65,00\n"
509 "\"Wine13h\"=hex(ffffffff):56,61,6c,75,65,00\n"
510 "\"Wine13i\"=hex(100000000):56,61,6c,75,65,00\n"
511 "\"Wine13j\"=hex(0x2):56,61,6c,75,65,00\n"
512 "\"Wine13k\"=hex(0X2):56,61,6c,75,65,00\n"
513 "\"Wine13l\"=hex(x2):56,61,6c,75,65,00\n\n");
514 verify_reg(hkey, "Wine13a", REG_NONE, "Value", 6, 0);
515 verify_reg(hkey, "Wine13b", 0x10, "Value", 6, 0);
516 verify_reg(hkey, "Wine13c", 0x100, "Value", 6, 0);
517 verify_reg(hkey, "Wine13d", 0x1000, "Value", 6, 0);
518 verify_reg(hkey, "Wine13e", 0x7fff, "Value", 6, 0);
519 verify_reg(hkey, "Wine13f", 0xffff, "Value", 6, 0);
520 verify_reg(hkey, "Wine13g", 0x7fffffff, "Value", 6, 0);
521 verify_reg(hkey, "Wine13h", 0xffffffff, "Value", 6, 0);
522 verify_reg_nonexist(hkey, "Wine13i");
523 verify_reg_nonexist(hkey, "Wine13j");
524 verify_reg_nonexist(hkey, "Wine13k");
525 verify_reg_nonexist(hkey, "Wine13l");
526
527 exec_import_str("REGEDIT4\n\n"
528 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
529 "\"Wine14a\"=hex(7):4c,69,6e,65,20, \\\n"
530 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
531 "\"Wine14b\"=hex(7):4c,69,6e,65,20,\t\\\n"
532 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
533 verify_reg(hkey, "Wine14a", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
534 verify_reg(hkey, "Wine14b", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
535
536 exec_import_str("REGEDIT4\n\n"
537 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
538 "\"Wine15\"=hex(2):25,50,41,54,48,25,00,\n\n");
539 verify_reg(hkey, "Wine15", REG_EXPAND_SZ, "%PATH%", 7, 0);
540
541 exec_import_str("REGEDIT4\n\n"
542 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
543 "\"Wine16\"=hex(2):\\\n"
544 " 25,48,4f,4d,45,25,00\n\n");
545 verify_reg(hkey, "Wine16", REG_EXPAND_SZ, "%HOME%", 7, 0);
546
547 exec_import_str("REGEDIT4\n\n"
548 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
549 "\"Wine17a\"=hex(0):56,61,6c,75,65,\\");
550 verify_reg(hkey, "Wine17a", REG_NONE, "Value", 5, 0);
551
552 exec_import_str("REGEDIT4\n\n"
553 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
554 "\"Wine17b\"=hex(2):25,50,41,54,48,25,\\");
555 verify_reg(hkey, "Wine17b", REG_EXPAND_SZ, "%PATH%", 7, 0);
556
557 exec_import_str("REGEDIT4\n\n"
558 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
559 "\"Wine17c\"=hex:11,22,33,44,55,\\");
560 verify_reg(hkey, "Wine17c", REG_BINARY, hex, 5, 0);
561
562 exec_import_str("REGEDIT4\n\n"
563 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
564 "\"Wine17d\"=hex(7):4c,69,6e,65,\\");
565 verify_reg(hkey, "Wine17d", REG_MULTI_SZ, "Line", 5, 0);
566
567 exec_import_str("REGEDIT4\n\n"
568 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
569 "\"Wine17e\"=hex(100):56,61,6c,75,65,\\");
570 verify_reg(hkey, "Wine17e", 0x100, "Value", 5, 0);
571
572 exec_import_str("REGEDIT4\n\n"
573 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
574 "\"Wine18a\"=hex(7):4c,69,6e,65,00,00\n"
575 "\"Wine18b\"=hex(7):4c,69,6e,65,20,\\\n"
576 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
577 "\"Wine18c\"=hex(7):4c,69,6e,65,20,\\;comment\n"
578 " 63,6f,6e,63,61,74,\\\n"
579 " 65,6e,61,74,69,6f,6e,00,00\n"
580 "\"Wine18d\"=hex(7):4c,69,6e,65,20,\\;comment\n"
581 " 63,6f,6e,63,61,74,\n"
582 " 65,6e,61,74,69,6f,6e,00,00\n"
583 "\"Wine18e\"=hex(7):4c,69,6e,65,20,\\\n"
584 " 63,6f,6e,63,61,74,;comment\n"
585 " 65,6e,61,74,69,6f,6e,00,00\n\n");
586 verify_reg(hkey, "Wine18a", REG_MULTI_SZ, "Line\0", 6, 0);
587 verify_reg(hkey, "Wine18b", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
588 verify_reg(hkey, "Wine18c", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
589 /* Wine18d */
590 size = sizeof(buffer);
591 memset(buffer, '-', size);
592 lr = RegQueryValueExA(hkey, "Wine18d", NULL, &type, (BYTE *)&buffer, &size);
593 ok(lr == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", lr);
594 ok(type == REG_MULTI_SZ, "got wrong type %u, expected %u\n", type, REG_MULTI_SZ);
595 ok(size == 12 || broken(size == 11) /* Win2k */, "got wrong size %u, expected 12\n", size);
596 ok(memcmp(buffer, "Line concat", size) == 0, "got wrong data\n");
597 /* Wine18e */
598 size = sizeof(buffer);
599 memset(buffer, '-', size);
600 lr = RegQueryValueExA(hkey, "Wine18e", NULL, &type, (BYTE *)&buffer, &size);
601 ok(lr == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", lr);
602 ok(type == REG_MULTI_SZ, "got wrong type %u, expected %u\n", type, REG_MULTI_SZ);
603 ok(size == 12 || broken(size == 11) /* Win2k */, "got wrong size %u, expected 12\n", size);
604 ok(memcmp(buffer, "Line concat", size) == 0, "got wrong data\n");
605
606 exec_import_str("REGEDIT4\n\n"
607 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
608 "\"Wine19a\"=hex(100):25,50,41,54,48,25,00\n"
609 "\"Wine19b\"=hex(100):25,50,41,\\\n"
610 " 54,48,25,00\n"
611 "\"Wine19c\"=hex(100):25,50,41,\\;comment\n"
612 " 54,48,\\\n"
613 " 25,00\n"
614 "\"Wine19d\"=hex(100):25,50,41,\\;comment\n"
615 " 54,48,\n"
616 " 25,00\n"
617 "\"Wine19e\"=hex(100):25,50,41,\\;comment\n"
618 " 54,48,;comment\n"
619 " 25,00\n");
620 verify_reg(hkey, "Wine19a", 0x100, "%PATH%", 7, 0);
621 verify_reg(hkey, "Wine19b", 0x100, "%PATH%", 7, 0);
622 verify_reg(hkey, "Wine19c", 0x100, "%PATH%", 7, 0);
623 verify_reg(hkey, "Wine19d", 0x100, "%PATH", 5, 0);
624 verify_reg(hkey, "Wine19e", 0x100, "%PATH", 5, 0);
625
626 /* Test null-termination of REG_EXPAND_SZ and REG_MULTI_SZ data*/
627 exec_import_str("REGEDIT4\n\n"
628 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
629 "\"Wine20a\"=hex(7):4c,69,6e,65\n"
630 "\"Wine20b\"=hex(7):4c,69,6e,65,\n"
631 "\"Wine20c\"=hex(7):4c,69,6e,65,00\n"
632 "\"Wine20d\"=hex(7):4c,69,6e,65,00,\n"
633 "\"Wine20e\"=hex(7):4c,69,6e,65,00,00\n"
634 "\"Wine20f\"=hex(7):4c,69,6e,65,00,00,\n\n");
635 verify_reg(hkey, "Wine20a", REG_MULTI_SZ, "Line", 5, 0);
636 verify_reg(hkey, "Wine20b", REG_MULTI_SZ, "Line", 5, 0);
637 verify_reg(hkey, "Wine20c", REG_MULTI_SZ, "Line", 5, 0);
638 verify_reg(hkey, "Wine20d", REG_MULTI_SZ, "Line", 5, 0);
639 verify_reg(hkey, "Wine20e", REG_MULTI_SZ, "Line\0", 6, 0);
640 verify_reg(hkey, "Wine20f", REG_MULTI_SZ, "Line\0", 6, 0);
641
642 exec_import_str("REGEDIT4\n\n"
643 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
644 "\"Wine21a\"=hex(2):25,50,41,54,48,25\n"
645 "\"Wine21b\"=hex(2):25,50,41,54,48,25,\n"
646 "\"Wine21c\"=hex(2):25,50,41,54,48,25,00\n"
647 "\"Wine21d\"=hex(2):25,50,41,54,48,25,00,\n\n");
648 verify_reg(hkey, "Wine21a", REG_EXPAND_SZ, "%PATH%", 7, 0);
649 verify_reg(hkey, "Wine21b", REG_EXPAND_SZ, "%PATH%", 7, 0);
650 verify_reg(hkey, "Wine21c", REG_EXPAND_SZ, "%PATH%", 7, 0);
651 verify_reg(hkey, "Wine21d", REG_EXPAND_SZ, "%PATH%", 7, 0);
652
653 exec_import_str("REGEDIT4\n\n"
654 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
655 "\"Wine22a\"=hex(1):\n"
656 "\"Wine22b\"=hex(2):\n"
657 "\"Wine22c\"=hex(3):\n"
658 "\"Wine22d\"=hex(4):\n"
659 "\"Wine22e\"=hex(7):\n"
660 "\"Wine22f\"=hex(100):\n"
661 "\"Wine22g\"=hex(abcd):\n"
662 "\"Wine22h\"=hex:\n"
663 "\"Wine22i\"=hex(0):\n\n");
664 verify_reg(hkey, "Wine22a", REG_SZ, NULL, 0, 0);
665 verify_reg(hkey, "Wine22b", REG_EXPAND_SZ, NULL, 0, 0);
666 verify_reg(hkey, "Wine22c", REG_BINARY, NULL, 0, 0);
667 verify_reg(hkey, "Wine22d", REG_DWORD, NULL, 0, 0);
668 verify_reg(hkey, "Wine22e", REG_MULTI_SZ, NULL, 0, 0);
669 verify_reg(hkey, "Wine22f", 0x100, NULL, 0, 0);
670 verify_reg(hkey, "Wine22g", 0xabcd, NULL, 0, 0);
671 verify_reg(hkey, "Wine22h", REG_BINARY, NULL, 0, 0);
672 verify_reg(hkey, "Wine22i", REG_NONE, NULL, 0, 0);
673
674 RegCloseKey(hkey);
675
676 delete_key(HKEY_CURRENT_USER, KEY_BASE);
677 }
678
679 static void test_basic_import_unicode(void)
680 {
681 HKEY hkey, subkey;
682 DWORD dword = 0x17, type, size;
683 char exp_binary[] = {0xAA,0xBB,0xCC,0x11};
684 LONG lr;
685 char buffer[256];
686 BYTE hex[8];
687
688 lr = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
689 ok(lr == ERROR_SUCCESS || lr == ERROR_FILE_NOT_FOUND, "RegDeleteKeyA failed: %d\n", lr);
690
691 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
692 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
693 "\"TestValue\"=\"AValue\"\n");
694 open_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
695 verify_reg(hkey, "TestValue", REG_SZ, "AValue", 7, 0);
696
697 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
698 "[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n"
699 "\"TestValue2\"=\"BValue\"\r\n");
700 verify_reg(hkey, "TestValue2", REG_SZ, "BValue", 7, 0);
701
702 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
703 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
704 "\"TestValue3\"=\"Value\"\n");
705 verify_reg(hkey, "TestValue3", REG_SZ, "Value", 6, 0);
706
707 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\r\r"
708 "[HKEY_CURRENT_USER\\" KEY_BASE "]\r"
709 "\"TestValue4\"=\"DValue\"\r");
710 verify_reg(hkey, "TestValue4", REG_SZ, "DValue", 7, 0);
711
712 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\r\r"
713 "[HKEY_CURRENT_USER\\" KEY_BASE "]\r"
714 "\"TestValue5\"=\"Value\"\r");
715 verify_reg(hkey, "TestValue5", REG_SZ, "Value", 6, 0);
716
717 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
718 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
719 "\"TestDword\"=dword:00000017\n");
720 verify_reg(hkey, "TestDword", REG_DWORD, &dword, sizeof(dword), 0);
721
722 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
723 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
724 "\"TestBinary\"=hex:aa,bb,cc,11\n");
725 verify_reg(hkey, "TestBinary", REG_BINARY, exp_binary, sizeof(exp_binary), 0);
726
727 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
728 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
729 "\"With=Equals\"=\"asdf\"\n");
730 verify_reg(hkey, "With=Equals", REG_SZ, "asdf", 5, 0);
731
732 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
733 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
734 "\"Empty string\"=\"\"\n"
735 "\"\"=\"Default registry value\"\n\n");
736 verify_reg(hkey, "Empty string", REG_SZ, "", 1, 0);
737 verify_reg(hkey, NULL, REG_SZ, "Default registry value", 23, 0);
738
739 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
740 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
741 "\"Line1\"=\"Value1\"\n\n"
742 "\"Line2\"=\"Value2\"\n\n\n"
743 "\"Line3\"=\"Value3\"\n\n\n\n"
744 "\"Line4\"=\"Value4\"\n\n");
745 verify_reg(hkey, "Line1", REG_SZ, "Value1", 7, 0);
746 verify_reg(hkey, "Line2", REG_SZ, "Value2", 7, 0);
747 verify_reg(hkey, "Line3", REG_SZ, "Value3", 7, 0);
748 verify_reg(hkey, "Line4", REG_SZ, "Value4", 7, 0);
749
750 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
751 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
752 "\"Wine1\"=dword:00000782\n\n"
753 "\"Wine2\"=\"Test Value\"\n"
754 "\"Wine3\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
755 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
756 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
757 "#comment\n"
758 "@=\"Test\"\n"
759 ";comment\n\n"
760 "\"Wine4\"=dword:12345678\n\n");
761 dword = 0x782;
762 verify_reg(hkey, "Wine1", REG_DWORD, &dword, sizeof(dword), 0);
763 verify_reg(hkey, "Wine2", REG_SZ, "Test Value", 11, 0);
764 verify_reg(hkey, "Wine3", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
765 verify_reg(hkey, "", REG_SZ, "Test", 5, 0);
766 dword = 0x12345678;
767 verify_reg(hkey, "Wine4", REG_DWORD, &dword, sizeof(dword), 0);
768
769 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
770 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
771 "\"Wine5\"=\"No newline\"");
772 verify_reg(hkey, "Wine5", REG_SZ, "No newline", 11, 0);
773
774 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
775 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
776 "\"Wine6\"=dword:00000050\n\n"
777 "\"Wine7\"=\"No newline\"");
778 dword = 0x50;
779 verify_reg(hkey, "Wine6", REG_DWORD, &dword, sizeof(dword), 0);
780 verify_reg(hkey, "Wine7", REG_SZ, "No newline", 11, 0);
781
782 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
783 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
784 "\"Wine8a\"=dword:1\n"
785 "\"Wine8b\"=dword:4444\n\n");
786 dword = 0x1;
787 verify_reg(hkey, "Wine8a", REG_DWORD, &dword, sizeof(dword), 0);
788 dword = 0x4444;
789 verify_reg(hkey, "Wine8b", REG_DWORD, &dword, sizeof(dword), 0);
790
791 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
792 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
793 "\"Wine9a\"=hex(2):4c,00,69,00,6e,00,65,00,00,00\n"
794 "\"Wine9b\"=\"Value 1\"\n"
795 "\"Wine9c\"=hex(2):4c,00,69,00,6e,00,65,00\\\n"
796 "\"Wine9d\"=\"Value 2\"\n"
797 "\"Wine9e\"=hex(2):4c,00,69,00,6e,00,65,00,\\\n"
798 "\"Wine9f\"=\"Value 3\"\n"
799 "\"Wine9g\"=\"Value 4\"\n\n");
800 verify_reg(hkey, "Wine9a", REG_EXPAND_SZ, "Line", 5, 0);
801 verify_reg(hkey, "Wine9b", REG_SZ, "Value 1", 8, 0);
802 verify_reg_nonexist(hkey, "Wine9c");
803 verify_reg(hkey, "Wine9d", REG_SZ, "Value 2", 8, 0);
804 verify_reg_nonexist(hkey, "Wine9e");
805 verify_reg_nonexist(hkey, "Wine9f");
806 verify_reg(hkey, "Wine9g", REG_SZ, "Value 4", 8, 0);
807
808 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
809 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
810 "\"double\\\"quote\"=\"valid \\\"or\\\" not\"\n"
811 "\"single'quote\"=dword:00000008\n\n");
812 verify_reg(hkey, "double\"quote", REG_SZ, "valid \"or\" not", 15, 0);
813 dword = 0x00000008;
814 verify_reg(hkey, "single'quote", REG_DWORD, &dword, sizeof(dword), 0);
815
816 /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
817 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
818 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
819 "\"Wine10a\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n"
820 "\"Wine10b\"=hex(0):56,00,61,00,6c,00,\\\n"
821 " 75,00,65,00,00,00\n"
822 "\"Wine10c\"=hex(0):56,00,61,00,\\;comment\n"
823 " 6c,00,75,00,\\\n"
824 " 65,00,00,00\n"
825 "\"Wine10d\"=hex(0):56,00,61,00,\\;comment\n"
826 " 6c,00,75,00,\n"
827 " 65,00,00,00\n"
828 "\"Wine10e\"=hex(0):56,00,61,00,\\;comment\n"
829 " 6c,00,75,00,;comment\n"
830 " 65,00,00,00\n");
831 verify_reg(hkey, "Wine10a", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
832 verify_reg(hkey, "Wine10b", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
833 verify_reg(hkey, "Wine10c", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
834 verify_reg(hkey, "Wine10d", REG_NONE, "V\0a\0l\0u", 8, 0);
835 verify_reg(hkey, "Wine10e", REG_NONE, "V\0a\0l\0u", 8, 0);
836
837 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
838 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
839 "\"Wine11a\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
840 "\"Wine11b\"=hex(2):25,00,50,00,41,00,\\\n"
841 " 54,00,48,00,25,00,00,00\n"
842 "\"Wine11c\"=hex(2):25,00,50,00,41,00,\\;comment\n"
843 " 54,00,48,00,\\\n"
844 " 25,00,00,00\n"
845 "\"Wine11d\"=hex(2):25,00,50,00,41,00,\\;comment\n"
846 " 54,00,48,00,\n"
847 " 25,00,00,00\n"
848 "\"Wine11e\"=hex(2):25,00,50,00,41,00,\\;comment\n"
849 " 54,00,48,00,;comment\n"
850 " 25,00,00,00\n");
851 verify_reg(hkey, "Wine11a", REG_EXPAND_SZ, "%PATH%", 7, 0);
852 verify_reg(hkey, "Wine11b", REG_EXPAND_SZ, "%PATH%", 7, 0);
853 verify_reg(hkey, "Wine11c", REG_EXPAND_SZ, "%PATH%", 7, 0);
854 /* Wine11d */
855 size = sizeof(buffer);
856 lr = RegQueryValueExA(hkey, "Wine11d", NULL, &type, (BYTE *)&buffer, &size);
857 ok(lr == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", lr);
858 ok(type == REG_EXPAND_SZ, "got wrong type %u, expected %u\n", type, REG_EXPAND_SZ);
859 ok(size == 6 || broken(size == 5) /* Win2k */, "got wrong size %u, expected 6\n", size);
860 ok(memcmp(buffer, "%PATH", size) == 0, "got wrong data\n");
861 /* Wine11e */
862 size = sizeof(buffer);
863 memset(buffer, '-', size);
864 lr = RegQueryValueExA(hkey, "Wine11e", NULL, &type, (BYTE *)&buffer, &size);
865 ok(lr == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", lr);
866 ok(type == REG_EXPAND_SZ, "got wrong type %u, expected %u\n", type, REG_EXPAND_SZ);
867 ok(size == 6 || broken(size == 5) /* Win2k */, "got wrong size %u, expected 6\n", size);
868 ok(memcmp(buffer, "%PATH", size) == 0, "got wrong data\n");
869
870 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
871 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
872 "\"Wine12a\"=hex:11,22,33,44,55,66,77,88\n"
873 "\"Wine12b\"=hex:11,22,33,44,\\\n"
874 " 55,66,77,88\n"
875 "\"Wine12c\"=hex:11,22,33,44,\\;comment\n"
876 " 55,66,\\\n"
877 " 77,88\n"
878 "\"Wine12d\"=hex:11,22,33,44,\\;comment\n"
879 " 55,66,\n"
880 " 77,88\n"
881 "\"Wine12e\"=hex:11,22,33,44,\\;comment\n"
882 " 55,66,;comment\n"
883 " 77,88\n");
884 hex[0] = 0x11; hex[1] = 0x22; hex[2] = 0x33; hex[3] = 0x44;
885 hex[4] = 0x55; hex[5] = 0x66; hex[6] = 0x77; hex[7] = 0x88;
886 verify_reg(hkey, "Wine12a", REG_BINARY, hex, sizeof(hex), 0);
887 verify_reg(hkey, "Wine12b", REG_BINARY, hex, sizeof(hex), 0);
888 verify_reg(hkey, "Wine12c", REG_BINARY, hex, sizeof(hex), 0);
889 verify_reg(hkey, "Wine12d", REG_BINARY, hex, 6, 0);
890 verify_reg(hkey, "Wine12e", REG_BINARY, hex, 6, 0);
891
892 /* Test import with subkeys */
893 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
894 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey\"1]\n"
895 "\"Wine\\\\31\"=\"Test value\"\n\n");
896 open_key(hkey, "Subkey\"1", 0, &subkey);
897 verify_reg(subkey, "Wine\\31", REG_SZ, "Test value", 11, 0);
898 lr = RegCloseKey(subkey);
899 ok(lr == ERROR_SUCCESS, "got %d, expected 0\n", lr);
900 delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey\"1");
901
902 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
903 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey/2]\n"
904 "\"123/\\\"4;'5\"=\"Random value name\"\n\n");
905 open_key(hkey, "Subkey/2", 0, &subkey);
906 verify_reg(subkey, "123/\"4;'5", REG_SZ, "Random value name", 18, 0);
907 lr = RegCloseKey(subkey);
908 ok(lr == ERROR_SUCCESS, "got %d, expected 0\n", lr);
909 delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey/2");
910
911 /* Test the accepted range of the hex-based data types */
912 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
913 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
914 "\"Wine13a\"=hex(0):56,61,6c,75,65,00\n"
915 "\"Wine13b\"=hex(10):56,61,6c,75,65,00\n"
916 "\"Wine13c\"=hex(100):56,61,6c,75,65,00\n"
917 "\"Wine13d\"=hex(1000):56,61,6c,75,65,00\n"
918 "\"Wine13e\"=hex(7fff):56,61,6c,75,65,00\n"
919 "\"Wine13f\"=hex(ffff):56,61,6c,75,65,00\n"
920 "\"Wine13g\"=hex(7fffffff):56,61,6c,75,65,00\n"
921 "\"Wine13h\"=hex(ffffffff):56,61,6c,75,65,00\n"
922 "\"Wine13i\"=hex(100000000):56,61,6c,75,65,00\n"
923 "\"Wine13j\"=hex(0x2):56,61,6c,75,65,00\n"
924 "\"Wine13k\"=hex(0X2):56,61,6c,75,65,00\n"
925 "\"Wine13l\"=hex(x2):56,61,6c,75,65,00\n\n");
926 verify_reg(hkey, "Wine13a", REG_NONE, "Value", 6, 0);
927 verify_reg(hkey, "Wine13b", 0x10, "Value", 6, 0);
928 verify_reg(hkey, "Wine13c", 0x100, "Value", 6, 0);
929 verify_reg(hkey, "Wine13d", 0x1000, "Value", 6, 0);
930 verify_reg(hkey, "Wine13e", 0x7fff, "Value", 6, 0);
931 verify_reg(hkey, "Wine13f", 0xffff, "Value", 6, 0);
932 verify_reg(hkey, "Wine13g", 0x7fffffff, "Value", 6, 0);
933 verify_reg(hkey, "Wine13h", 0xffffffff, "Value", 6, 0);
934 verify_reg_nonexist(hkey, "Wine13i");
935 verify_reg_nonexist(hkey, "Wine13j");
936 verify_reg_nonexist(hkey, "Wine13k");
937 verify_reg_nonexist(hkey, "Wine13l");
938
939 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
940 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
941 "\"Wine14a\"=hex(7):4c,00,69,00,6e,00,65,00,20,00, \\\n"
942 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
943 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
944 "\"Wine14b\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\t\\\n"
945 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
946 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
947 verify_reg(hkey, "Wine14a", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
948 verify_reg(hkey, "Wine14b", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
949
950 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
951 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
952 "\"Wine15\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00,\n\n");
953 verify_reg(hkey, "Wine15", REG_EXPAND_SZ, "%PATH%", 7, 0);
954
955 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
956 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
957 "\"Wine16\"=hex(2):\\\n"
958 " 25,00,48,00,4f,00,4d,00,45,00,25,00,00,00\n\n");
959 verify_reg(hkey, "Wine16", REG_EXPAND_SZ, "%HOME%", 7, 0);
960
961 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
962 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
963 "\"Wine17a\"=hex(0):56,61,6c,75,65,\\");
964 verify_reg(hkey, "Wine17a", REG_NONE, "Value", 5, 0);
965
966 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
967 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
968 "\"Wine17b\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,\\");
969 verify_reg(hkey, "Wine17b", REG_EXPAND_SZ, "%PATH%", 7, 0);
970
971 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
972 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
973 "\"Wine17c\"=hex:11,22,33,44,55,\\");
974 verify_reg(hkey, "Wine17c", REG_BINARY, hex, 5, 0);
975
976 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
977 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
978 "\"Wine17d\"=hex(7):4c,00,69,00,6e,00,65,00,\\");
979 verify_reg(hkey, "Wine17d", REG_MULTI_SZ, "Line", 5, 0);
980
981 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
982 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
983 "\"Wine17e\"=hex(100):56,61,6c,75,65,\\");
984 verify_reg(hkey, "Wine17e", 0x100, "Value", 5, 0);
985
986 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
987 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
988 "\"Wine18a\"=hex(7):4c,00,69,00,6e,00,65,00,00,00,00,00\n"
989 "\"Wine18b\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
990 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
991 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
992 "\"Wine18c\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\;comment\n"
993 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
994 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
995 "\"Wine18d\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\;comment\n"
996 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\n"
997 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
998 "\"Wine18e\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
999 " 63,00,6f,00,6e,00,63,00,61,00,74,00,;comment\n"
1000 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
1001 verify_reg(hkey, "Wine18a", REG_MULTI_SZ, "Line\0", 6, 0);
1002 verify_reg(hkey, "Wine18b", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1003 verify_reg(hkey, "Wine18c", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1004 /* Wine18d */
1005 size = sizeof(buffer);
1006 memset(buffer, '-', size);
1007 lr = RegQueryValueExA(hkey, "Wine18d", NULL, &type, (BYTE *)&buffer, &size);
1008 ok(lr == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", lr);
1009 ok(type == REG_MULTI_SZ, "got wrong type %u, expected %u\n", type, REG_MULTI_SZ);
1010 ok(size == 12 || broken(size == 11) /* Win2k */, "got wrong size %u, expected 12\n", size);
1011 ok(memcmp(buffer, "Line concat", size) == 0, "got wrong data\n");
1012 /* Wine18e */
1013 size = sizeof(buffer);
1014 memset(buffer, '-', size);
1015 lr = RegQueryValueExA(hkey, "Wine18e", NULL, &type, (BYTE *)&buffer, &size);
1016 ok(lr == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", lr);
1017 ok(type == REG_MULTI_SZ, "got wrong type %u, expected %u\n", type, REG_MULTI_SZ);
1018 ok(size == 12 || broken(size == 11) /* Win2k */, "got wrong size %u, expected 12\n", size);
1019 ok(memcmp(buffer, "Line concat", size) == 0, "got wrong data\n");
1020
1021 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1022 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1023 "\"Wine19a\"=hex(100):25,50,41,54,48,25,00\n"
1024 "\"Wine19b\"=hex(100):25,50,41,\\\n"
1025 " 54,48,25,00\n"
1026 "\"Wine19c\"=hex(100):25,50,41,\\;comment\n"
1027 " 54,48,\\\n"
1028 " 25,00\n"
1029 "\"Wine19d\"=hex(100):25,50,41,\\;comment\n"
1030 " 54,48,\n"
1031 " 25,00\n"
1032 "\"Wine19e\"=hex(100):25,50,41,\\;comment\n"
1033 " 54,48,;comment\n"
1034 " 25,00\n");
1035 verify_reg(hkey, "Wine19a", 0x100, "%PATH%", 7, 0);
1036 verify_reg(hkey, "Wine19b", 0x100, "%PATH%", 7, 0);
1037 verify_reg(hkey, "Wine19c", 0x100, "%PATH%", 7, 0);
1038 verify_reg(hkey, "Wine19d", 0x100, "%PATH", 5, 0);
1039 verify_reg(hkey, "Wine19e", 0x100, "%PATH", 5, 0);
1040
1041 /* Test null-termination of REG_EXPAND_SZ and REG_MULTI_SZ data*/
1042 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1043 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1044 "\"Wine20a\"=hex(7):4c,00,69,00,6e,00,65,00\n"
1045 "\"Wine20b\"=hex(7):4c,00,69,00,6e,00,65,00,\n"
1046 "\"Wine20c\"=hex(7):4c,00,69,00,6e,00,65,00,00,00\n"
1047 "\"Wine20d\"=hex(7):4c,00,69,00,6e,00,65,00,00,00,\n"
1048 "\"Wine20e\"=hex(7):4c,00,69,00,6e,00,65,00,00,00,00,00\n"
1049 "\"Wine20f\"=hex(7):4c,00,69,00,6e,00,65,00,00,00,00,00,\n\n");
1050 verify_reg(hkey, "Wine20a", REG_MULTI_SZ, "Line", 5, 0);
1051 verify_reg(hkey, "Wine20b", REG_MULTI_SZ, "Line", 5, 0);
1052 verify_reg(hkey, "Wine20c", REG_MULTI_SZ, "Line", 5, 0);
1053 verify_reg(hkey, "Wine20d", REG_MULTI_SZ, "Line", 5, 0);
1054 verify_reg(hkey, "Wine20e", REG_MULTI_SZ, "Line\0", 6, 0);
1055 verify_reg(hkey, "Wine20f", REG_MULTI_SZ, "Line\0", 6, 0);
1056
1057 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1058 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1059 "\"Wine21a\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00\n"
1060 "\"Wine21b\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,\n"
1061 "\"Wine21c\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
1062 "\"Wine21d\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00,\n\n");
1063 verify_reg(hkey, "Wine21a", REG_EXPAND_SZ, "%PATH%", 7, 0);
1064 verify_reg(hkey, "Wine21b", REG_EXPAND_SZ, "%PATH%", 7, 0);
1065 verify_reg(hkey, "Wine21c", REG_EXPAND_SZ, "%PATH%", 7, 0);
1066 verify_reg(hkey, "Wine21d", REG_EXPAND_SZ, "%PATH%", 7, 0);
1067
1068 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1069 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1070 "\"Wine22a\"=hex(1):\n"
1071 "\"Wine22b\"=hex(2):\n"
1072 "\"Wine22c\"=hex(3):\n"
1073 "\"Wine22d\"=hex(4):\n"
1074 "\"Wine22e\"=hex(7):\n"
1075 "\"Wine22f\"=hex(100):\n"
1076 "\"Wine22g\"=hex(abcd):\n"
1077 "\"Wine22h\"=hex:\n"
1078 "\"Wine22i\"=hex(0):\n\n");
1079 verify_reg(hkey, "Wine22a", REG_SZ, NULL, 0, 0);
1080 verify_reg(hkey, "Wine22b", REG_EXPAND_SZ, NULL, 0, 0);
1081 verify_reg(hkey, "Wine22c", REG_BINARY, NULL, 0, 0);
1082 verify_reg(hkey, "Wine22d", REG_DWORD, NULL, 0, 0);
1083 verify_reg(hkey, "Wine22e", REG_MULTI_SZ, NULL, 0, 0);
1084 verify_reg(hkey, "Wine22f", 0x100, NULL, 0, 0);
1085 verify_reg(hkey, "Wine22g", 0xabcd, NULL, 0, 0);
1086 verify_reg(hkey, "Wine22h", REG_BINARY, NULL, 0, 0);
1087 verify_reg(hkey, "Wine22i", REG_NONE, NULL, 0, 0);
1088
1089 RegCloseKey(hkey);
1090
1091 delete_key(HKEY_CURRENT_USER, KEY_BASE);
1092 }
1093
1094 static void test_basic_import_31(void)
1095 {
1096 HKEY hkey;
1097 LONG lr;
1098
1099 lr = RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
1100 ok(lr == ERROR_SUCCESS || lr == ERROR_FILE_NOT_FOUND,
1101 "RegDeleteKeyA failed: %d\n", lr);
1102
1103 /* Check if regedit.exe is running with elevated privileges */
1104 lr = RegCreateKeyExA(HKEY_CLASSES_ROOT, KEY_BASE, 0, NULL, REG_OPTION_NON_VOLATILE,
1105 KEY_READ, NULL, &hkey, NULL);
1106 if (lr == ERROR_ACCESS_DENIED)
1107 {
1108 win_skip("regedit.exe is not running with elevated privileges; "
1109 "skipping Windows 3.1 import tests\n");
1110 return;
1111 }
1112
1113 /* Test simple value */
1114 exec_import_str("REGEDIT\r\n"
1115 "HKEY_CLASSES_ROOT\\" KEY_BASE " = Value0\r\n");
1116 verify_reg(hkey, "", REG_SZ, "Value0", 7, 0);
1117
1118 /* Test proper handling of spaces and equals signs */
1119 exec_import_str("REGEDIT\r\n"
1120 "HKEY_CLASSES_ROOT\\" KEY_BASE " =Value1\r\n");
1121 verify_reg(hkey, "", REG_SZ, "Value1", 7, 0);
1122
1123 exec_import_str("REGEDIT\r\n"
1124 "HKEY_CLASSES_ROOT\\" KEY_BASE " = Value2\r\n");
1125 verify_reg(hkey, "", REG_SZ, " Value2", 8, 0);
1126
1127 exec_import_str("REGEDIT\r\n"
1128 "HKEY_CLASSES_ROOT\\" KEY_BASE " = Value3 \r\n");
1129 verify_reg(hkey, "", REG_SZ, "Value3 ", 8, 0);
1130
1131 exec_import_str("REGEDIT\r\n"
1132 "HKEY_CLASSES_ROOT\\" KEY_BASE " Value4\r\n");
1133 verify_reg(hkey, "", REG_SZ, "Value4", 7, 0);
1134
1135 exec_import_str("REGEDIT\r\n"
1136 "HKEY_CLASSES_ROOT\\" KEY_BASE " Value5\r\n");
1137 verify_reg(hkey, "", REG_SZ, "Value5", 7, 0);
1138
1139 exec_import_str("REGEDIT\r\n"
1140 "HKEY_CLASSES_ROOT\\" KEY_BASE "\r\n");
1141 verify_reg(hkey, "", REG_SZ, "", 1, 0);
1142
1143 exec_import_str("REGEDIT\r\n"
1144 "HKEY_CLASSES_ROOT\\" KEY_BASE " \r\n");
1145 verify_reg(hkey, "", REG_SZ, "", 1, 0);
1146
1147 exec_import_str("REGEDIT\r\n"
1148 "HKEY_CLASSES_ROOT\\" KEY_BASE " = No newline");
1149 verify_reg(hkey, "", REG_SZ, "No newline", 11, 0);
1150
1151 RegCloseKey(hkey);
1152
1153 delete_key(HKEY_CLASSES_ROOT, KEY_BASE);
1154 }
1155
1156 static void test_invalid_import(void)
1157 {
1158 LONG lr;
1159 HKEY hkey;
1160 DWORD dword = 0x8;
1161
1162 lr = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
1163 ok(lr == ERROR_SUCCESS || lr == ERROR_FILE_NOT_FOUND, "RegDeleteKeyA failed: %d\n", lr);
1164
1165 exec_import_str("REGEDIT4\n\n"
1166 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1167 "\"TestNoEndQuote\"=\"Asdffdsa\n");
1168 open_key(HKEY_CURRENT_USER, KEY_BASE, KEY_SET_VALUE, &hkey);
1169 verify_reg_nonexist(hkey, "TestNoEndQuote");
1170
1171 exec_import_str("REGEDIT4\n\n"
1172 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1173 "\"TestNoBeginQuote\"=Asdffdsa\"\n");
1174 verify_reg_nonexist(hkey, "TestNoBeginQuote");
1175
1176 exec_import_str("REGEDIT4\n\n"
1177 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1178 "\"TestNoQuotes\"=Asdffdsa\n");
1179 verify_reg_nonexist(hkey, "TestNoQuotes");
1180
1181 exec_import_str("REGEDIT4\n\n"
1182 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1183 "\"NameNoEndQuote=\"Asdffdsa\"\n");
1184 verify_reg_nonexist(hkey, "NameNoEndQuote");
1185
1186 exec_import_str("REGEDIT4\n\n"
1187 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1188 "NameNoBeginQuote\"=\"Asdffdsa\"\n");
1189 verify_reg_nonexist(hkey, "NameNoBeginQuote");
1190
1191 exec_import_str("REGEDIT4\n\n"
1192 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1193 "NameNoQuotes=\"Asdffdsa\"\n");
1194 verify_reg_nonexist(hkey, "NameNoQuotes");
1195
1196 exec_import_str("REGEDIT4\n\n"
1197 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1198 "\"MixedQuotes=Asdffdsa\"\n");
1199 verify_reg_nonexist(hkey, "MixedQuotes");
1200 verify_reg_nonexist(hkey, "MixedQuotes=Asdffdsa");
1201
1202 /* Test import with non-standard registry file headers */
1203 exec_import_str("REGEDIT3\n\n"
1204 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1205 "\"Test1\"=\"Value\"\n");
1206 verify_reg_nonexist(hkey, "Test1");
1207
1208 exec_import_str("regedit4\n\n"
1209 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1210 "\"Test2\"=\"Value\"\n");
1211 verify_reg_nonexist(hkey, "Test2");
1212
1213 exec_import_str("Regedit4\n\n"
1214 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1215 "\"Test3\"=\"Value\"\n");
1216 verify_reg_nonexist(hkey, "Test3");
1217
1218 exec_import_str("REGEDIT 4\n\n"
1219 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1220 "\"Test4\"=\"Value\"\n");
1221 verify_reg_nonexist(hkey, "Test4");
1222
1223 exec_import_str("REGEDIT4FOO\n\n"
1224 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1225 "\"Test5\"=\"Value\"\n");
1226 verify_reg_nonexist(hkey, "Test5");
1227
1228 exec_import_str("REGEDIT4 FOO\n\n"
1229 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1230 "\"Test6\"=\"Value\"\n");
1231 verify_reg_nonexist(hkey, "Test6");
1232
1233 exec_import_str("REGEDIT5\n\n"
1234 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1235 "\"Test7\"=\"Value\"\n");
1236 verify_reg_nonexist(hkey, "Test7");
1237
1238 exec_import_str("Windows Registry Editor Version 4.00\n\n"
1239 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1240 "\"Test8\"=\"Value\"\n");
1241 verify_reg_nonexist(hkey, "Test8");
1242
1243 exec_import_str("Windows Registry Editor Version 5\n\n"
1244 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1245 "\"Test9\"=\"Value\"\n");
1246 verify_reg_nonexist(hkey, "Test9");
1247
1248 exec_import_str("WINDOWS REGISTRY EDITOR VERSION 5.00\n\n"
1249 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1250 "\"Test10\"=\"Value\"\n");
1251 verify_reg_nonexist(hkey, "Test10");
1252
1253 exec_import_str("Windows Registry Editor version 5.00\n\n"
1254 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1255 "\"Test11\"=\"Value\"\n");
1256 verify_reg_nonexist(hkey, "Test11");
1257
1258 /* Test multi-line import with incorrect comma placement */
1259 exec_import_str("REGEDIT4\n\n"
1260 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1261 "\"Multi-Line1\"=hex(7):4c,69,6e,65,20\\\n"
1262 ",63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1263 verify_reg_nonexist(hkey, "Multi-Line1");
1264
1265 exec_import_str("REGEDIT4\n\n"
1266 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1267 "\"Multi-Line2\"=hex(7):4c,69,6e,65,20\\\n"
1268 " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1269 verify_reg_nonexist(hkey, "Multi-Line2");
1270
1271 exec_import_str("Windows Registry Editor Version 5.00\n\n"
1272 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1273 "\"Multi-Line3\"=hex(7):4c,69,6e,65,20\\\n"
1274 ",63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1275 verify_reg_nonexist(hkey, "Multi-Line3");
1276
1277 exec_import_str("Windows Registry Editor Version 5.00\n\n"
1278 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1279 "\"Multi-Line4\"=hex(7):4c,69,6e,65,20\\\n"
1280 " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1281 verify_reg_nonexist(hkey, "Multi-Line4");
1282
1283 exec_import_str("REGEDIT4\n\n"
1284 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1285 "\"Test12a\"=dword:\n"
1286 "\"Test12b\"=dword:hello\n"
1287 "\"Test12c\"=dword:123456789\n"
1288 "\"Test12d\"=dword:012345678\n"
1289 "\"Test12e\"=dword:000000001\n\n");
1290 verify_reg_nonexist(hkey, "Test12a");
1291 verify_reg_nonexist(hkey, "Test12b");
1292 verify_reg_nonexist(hkey, "Test12c");
1293 verify_reg_nonexist(hkey, "Test12d");
1294 verify_reg_nonexist(hkey, "Test12e");
1295
1296 exec_import_str("REGEDIT4\n\n"
1297 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1298 "\"Test13a\"=dword:12345678abc\n"
1299 "\"Test13b\"=dword:12345678 abc\n\n");
1300 verify_reg_nonexist(hkey, "Test13a");
1301 verify_reg_nonexist(hkey, "Test13b");
1302
1303 exec_import_str("REGEDIT4\n\n"
1304 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1305 "\"Test14a\"=dword:0x123\n"
1306 "\"Test14b\"=dword:123 456\n"
1307 "\"Test14c\"=dword:1234 5678\n\n");
1308 verify_reg_nonexist(hkey, "Test14a");
1309 verify_reg_nonexist(hkey, "Test14b");
1310 verify_reg_nonexist(hkey, "Test14c");
1311
1312 exec_import_str("REGEDIT4\n\n"
1313 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1314 "\"Test15a\"=\"foo\"bar\"\n"
1315 "\"Test15b\"=\"foo\"\"bar\"\n\n");
1316 verify_reg_nonexist(hkey, "Test15a");
1317 verify_reg_nonexist(hkey, "Test15b");
1318
1319 exec_import_str("REGEDIT4\n\n"
1320 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1321 "\"Test16a\"=\n"
1322 "\"Test16b\"=\\\"\n"
1323 "\"Test16c\"=\\\"Value\\\"\n"
1324 "\"Test16d\"=\\\"Value\"\n\n");
1325 verify_reg_nonexist(hkey, "Test16a");
1326 verify_reg_nonexist(hkey, "Test16b");
1327 verify_reg_nonexist(hkey, "Test16c");
1328 verify_reg_nonexist(hkey, "Test16d");
1329
1330 /* Test key name and value name concatenation */
1331 exec_import_str("REGEDIT4\n\n"
1332 "[HKEY_CURRENT_USER\\" KEY_BASE "\\\n"
1333 "Subkey1]\n");
1334 verify_key_nonexist(hkey, "Subkey1");
1335
1336 exec_import_str("REGEDIT4\n\n"
1337 "[HKEY_CURRENT_USER\\" KEY_BASE "\n"
1338 "\\Subkey2]\n");
1339 verify_key_nonexist(hkey, "Subkey2");
1340
1341 exec_import_str("REGEDIT4\n\n"
1342 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1343 "\"Test\\\n"
1344 "17a\"=\"Value 1\"\n"
1345 "\"Test17b\"=\"Value 2\"\n"
1346 "\"Test\n"
1347 "\\17c\"=\"Value 3\"\n\n");
1348 verify_reg_nonexist(hkey, "Test17a");
1349 verify_reg(hkey, "Test17b", REG_SZ, "Value 2", 8, 0);
1350 verify_reg_nonexist(hkey, "Test17c");
1351
1352 exec_import_str("REGEDIT4\n\n"
1353 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1354 "\"Test18a\"=dword:1234\\\n"
1355 "5678\n"
1356 "\"Test18b\"=\"Test \\\n"
1357 "Value\"\n\n");
1358 verify_reg_nonexist(hkey, "Test18a");
1359 verify_reg_nonexist(hkey, "Test18b");
1360
1361 /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
1362 exec_import_str("REGEDIT4\n\n"
1363 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1364 "\"Test19a\"=hex(0):56,00,61,00,6c,00\\\n"
1365 ",75,00,65,00,00,00\n"
1366 "\"Test19b\"=hex(0):56,00,61,00,6c,00\\\n"
1367 " ,75,00,65,00,00,00\n"
1368 "\"Test19c\"=hex(0):56,00,61,00,6c,00\\\n"
1369 " 75,00,65,00,00,00\n"
1370 "\"Test19d\"=hex(0):56,00,61,00,6c,00,7\\\n"
1371 "5,00,65,00,00,00\n"
1372 "\"Test19e\"=hex(0):56,00,61,00,6c,00,7\\\n"
1373 " 5,00,65,00,00,00\n"
1374 "\"Test19f\"=hex(0):56,00,61,00,\\;comment\n"
1375 " 6c,00,75,00,\\#comment\n"
1376 " 65,00,00,00\n\n");
1377 verify_reg_nonexist(hkey, "Test19a");
1378 verify_reg_nonexist(hkey, "Test19b");
1379 verify_reg_nonexist(hkey, "Test19c");
1380 verify_reg_nonexist(hkey, "Test19d");
1381 verify_reg_nonexist(hkey, "Test19e");
1382 verify_reg_nonexist(hkey, "Test19f");
1383
1384 exec_import_str("REGEDIT4\n\n"
1385 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1386 "\"Test20a\"=hex(2):25,50,41\\\n"
1387 ",54,48,25,00\n"
1388 "\"Test20b\"=hex(2):25,50,41\\\n"
1389 " ,54,48,25,00\n"
1390 "\"Test20c\"=hex(2):25,50,41\\\n"
1391 " 54,48,25,00\n"
1392 "\"Test20d\"=hex(2):25,50,4\\\n"
1393 "1,54,48,25,00\n"
1394 "\"Test20e\"=hex(2):25,50,4\\\n"
1395 " 1,54,48,25,00\n"
1396 "\"Test20f\"=hex(2):25,50,41,\\;comment\n"
1397 " 54,48,\\#comment\n"
1398 " 25,00\n\n");
1399 verify_reg_nonexist(hkey, "Test20a");
1400 verify_reg_nonexist(hkey, "Test20b");
1401 verify_reg_nonexist(hkey, "Test20c");
1402 verify_reg_nonexist(hkey, "Test20d");
1403 verify_reg_nonexist(hkey, "Test20e");
1404 verify_reg_nonexist(hkey, "Test20f");
1405
1406 exec_import_str("REGEDIT4\n\n"
1407 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1408 "\"Test21a\"=hex:11,22,33,44\\\n"
1409 ",55,66,77,88\n"
1410 "\"Test21b\"=hex:11,22,33,44\\\n"
1411 " ,55,66,77,88\n"
1412 "\"Test21c\"=hex:11,22,33,44\\\n"
1413 " 55,66,77,88\n"
1414 "\"Test21d\"=hex:11,22,33,4\\\n"
1415 "4,55,66,77,88\n"
1416 "\"Test21e\"=hex:11,22,33,4\\\n"
1417 " 4,55,66,77,88\n"
1418 "\"Test21f\"=hex:11,22,33,\\;comment\n"
1419 " 44,55,66,\\#comment\n"
1420 " 77,88\n\n");
1421 verify_reg_nonexist(hkey, "Test21a");
1422 verify_reg_nonexist(hkey, "Test21b");
1423 verify_reg_nonexist(hkey, "Test21c");
1424 verify_reg_nonexist(hkey, "Test21d");
1425 verify_reg_nonexist(hkey, "Test21e");
1426 verify_reg_nonexist(hkey, "Test21f");
1427
1428 /* Test support for characters greater than 0xff */
1429 exec_import_str("REGEDIT4\n\n"
1430 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1431 "\"Wine22a\"=hex(0):25,50,100,54,48,25,00\n"
1432 "\"Wine22b\"=hex(0):25,1a4,100,164,124,25,00\n\n");
1433 verify_reg_nonexist(hkey, "Wine22a");
1434 verify_reg_nonexist(hkey, "Wine22b");
1435
1436 /* Test the effect of backslashes in hex data */
1437 exec_import_str("REGEDIT4\n\n"
1438 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1439 "\"Wine23a\"=hex(2):25,48\\,4f,4d,45,25,00\n"
1440 "\"Wine23b\"=hex(2):25,48,\\4f,4d,45,25,00\n"
1441 "\"Wine23c\"=hex(2):25,48\\ ,4f,4d,45,25,00\n"
1442 "\"Wine23d\"=hex(2):25,48,\\ 4f,4d,45,25,00\n"
1443 "\"Wine23e\"=hex(2):\\25,48,4f,4d,45,25,00\n"
1444 "\"Wine23f\"=hex(2):\\ 25,48,4f,4d,45,25,00\n"
1445 "\"Wine23g\"=hex(2):25,48,4\\f,4d,45,25,00\n"
1446 "\"Wine23h\"=hex(2):25,48,4\\\n"
1447 " f,4d,45,25,00\n"
1448 "\"Wine23i\"=hex(2):25,50,\\,41,54,48,25,00\n"
1449 "\"Wine23j\"=hex(2):25,48,4f,4d,45,25,5c,\\\\\n"
1450 " 25,50,41,54,48,25,00\n"
1451 "\"Wine23k\"=hex(2):,\\\n"
1452 " 25,48,4f,4d,45,25,00\n\n");
1453 verify_reg_nonexist(hkey, "Wine23a");
1454 verify_reg_nonexist(hkey, "Wine23b");
1455 verify_reg_nonexist(hkey, "Wine23c");
1456 verify_reg_nonexist(hkey, "Wine23d");
1457 verify_reg_nonexist(hkey, "Wine23e");
1458 verify_reg_nonexist(hkey, "Wine23f");
1459 verify_reg_nonexist(hkey, "Wine23g");
1460 verify_reg_nonexist(hkey, "Wine23h");
1461 verify_reg_nonexist(hkey, "Wine23i");
1462 verify_reg_nonexist(hkey, "Wine23j");
1463 verify_reg_nonexist(hkey, "Wine23k");
1464
1465 exec_import_str("REGEDIT4\n\n"
1466 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1467 "\"Wine24a\"=hex(2):4c,69,6e,65,20,\\\n"
1468 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1]\n");
1469 verify_reg_nonexist(hkey, "Wine24a");
1470 verify_key_nonexist(hkey, "Subkey1");
1471
1472 exec_import_str("REGEDIT4\n\n"
1473 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1474 "\"Wine24b\"=hex(2):4c,69,6e,65,20\\\n"
1475 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2]\n");
1476 verify_reg_nonexist(hkey, "Wine24b");
1477 verify_key(hkey, "Subkey2");
1478
1479 delete_key(hkey, "Subkey2");
1480
1481 exec_import_str("REGEDIT4\n\n"
1482 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1483 "\"Wine25a\"=hex(2):4c,69,6e,65,20,\\\n"
1484 "\"Wine25b\"=\"Test value\"\n"
1485
1486 "\"Wine25c\"=hex(2):4c,69,6e,65,20,\\\n"
1487 ";comment\n"
1488 "\"Wine25d\"=\"Test value\"\n"
1489
1490 "\"Wine25e\"=hex(2):4c,69,6e,65,20,\\\n"
1491 "#comment\n"
1492 "\"Wine25f\"=\"Test value\"\n"
1493
1494 "\"Wine25g\"=hex(2):4c,69,6e,65,20,\\\n\n"
1495 "\"Wine25h\"=\"Test value\"\n"
1496
1497 "\"Wine25i\"=hex(2):4c,69,6e,65,20\\\n"
1498 "\"Wine25j\"=\"Test value\"\n\n");
1499 verify_reg_nonexist(hkey, "Wine25a");
1500 verify_reg_nonexist(hkey, "Wine25b");
1501 verify_reg_nonexist(hkey, "Wine25c");
1502 verify_reg_nonexist(hkey, "Wine25d");
1503 verify_reg_nonexist(hkey, "Wine25e");
1504 verify_reg(hkey, "Wine25f", REG_SZ, "Test value", 11, 0);
1505 verify_reg_nonexist(hkey, "Wine25g");
1506 verify_reg_nonexist(hkey, "Wine25h");
1507 verify_reg_nonexist(hkey, "Wine25i");
1508 verify_reg(hkey, "Wine25j", REG_SZ, "Test value", 11, 0);
1509
1510 exec_import_str("REGEDIT4\n\n"
1511 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1512 "\"Wine26a\"=hex(2):4c,69,6e,65,20,\\\n"
1513 "\"Wine26b\"=dword:00000008\n"
1514
1515 "\"Wine26c\"=hex(2):4c,69,6e,65,20,\\\n"
1516 ";comment\n"
1517 "\"Wine26d\"=dword:00000008\n"
1518
1519 "\"Wine26e\"=hex(2):4c,69,6e,65,20,\\\n"
1520 "#comment\n"
1521 "\"Wine26f\"=dword:00000008\n"
1522
1523 "\"Wine26g\"=hex(2):4c,69,6e,65,20,\\\n\n"
1524 "\"Wine26h\"=dword:00000008\n"
1525
1526 "\"Wine26i\"=hex(2):4c,69,6e,65,20\\\n"
1527 "\"Wine26j\"=dword:00000008\n\n");
1528 verify_reg_nonexist(hkey, "Wine26a");
1529 verify_reg_nonexist(hkey, "Wine26b");
1530 verify_reg_nonexist(hkey, "Wine26c");
1531 verify_reg_nonexist(hkey, "Wine26d");
1532 verify_reg_nonexist(hkey, "Wine26e");
1533 verify_reg(hkey, "Wine26f", REG_DWORD, &dword, sizeof(dword), 0);
1534 verify_reg_nonexist(hkey, "Wine26g");
1535 verify_reg_nonexist(hkey, "Wine26h");
1536 verify_reg_nonexist(hkey, "Wine26i");
1537 verify_reg(hkey, "Wine26j", REG_DWORD, &dword, sizeof(dword), 0);
1538
1539 exec_import_str("REGEDIT4\n\n"
1540 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1541 "\"Wine27a\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
1542 "\"Wine27b\"=hex(2):25,50,41,54,48,25,00\n"
1543
1544 "\"Wine27c\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
1545 ";comment\n"
1546 "\"Wine27d\"=hex(2):25,50,41,54,48,25,00\n"
1547
1548 "\"Wine27e\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
1549 "#comment\n"
1550 "\"Wine27f\"=hex(2):25,50,41,54,48,25,00\n"
1551
1552 "\"Wine27g\"=hex(2):25,48,4f,4d,45,25,5c,\\\n\n"
1553 "\"Wine27h\"=hex(2):25,50,41,54,48,25,00\n"
1554
1555 "\"Wine27i\"=hex(2):25,48,4f,4d,45,25,5c\\\n"
1556 "\"Wine27j\"=hex(2):25,50,41,54,48,25,00\n\n");
1557 verify_reg_nonexist(hkey, "Wine27a");
1558 verify_reg_nonexist(hkey, "Wine27b");
1559 verify_reg_nonexist(hkey, "Wine27c");
1560 verify_reg_nonexist(hkey, "Wine27d");
1561 verify_reg_nonexist(hkey, "Wine27e");
1562 verify_reg(hkey, "Wine27f", REG_EXPAND_SZ, "%PATH%", 7, 0);
1563 verify_reg_nonexist(hkey, "Wine27g");
1564 verify_reg_nonexist(hkey, "Wine27h");
1565 verify_reg_nonexist(hkey, "Wine27i");
1566 verify_reg(hkey, "Wine27j", REG_EXPAND_SZ, "%PATH%", 7, 0);
1567
1568 exec_import_str("REGEDIT4\n\n"
1569 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1570 "\"Wine28a\"=hex(2):4c,69,6e,65,20,\\\n"
1571 "@=\"Default value 1\"\n\n");
1572 verify_reg_nonexist(hkey, "Wine28a");
1573 verify_reg_nonexist(hkey, NULL);
1574
1575 exec_import_str("REGEDIT4\n\n"
1576 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1577 "\"Wine28b\"=hex(2):4c,69,6e,65,20,\\\n"
1578 ";comment\n"
1579 "@=\"Default value 2\"\n\n");
1580 verify_reg_nonexist(hkey, "Wine28b");
1581 verify_reg_nonexist(hkey, NULL);
1582
1583 exec_import_str("REGEDIT4\n\n"
1584 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1585 "\"Wine28c\"=hex(2):4c,69,6e,65,20,\\\n"
1586 "#comment\n"
1587 "@=\"Default value 3\"\n\n");
1588 verify_reg_nonexist(hkey, "Wine28c");
1589 verify_reg(hkey, NULL, REG_SZ, "Default value 3", 16, 0);
1590
1591 delete_value(hkey, NULL);
1592
1593 exec_import_str("REGEDIT4\n\n"
1594 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1595 "\"Wine28d\"=hex(2):4c,69,6e,65,20,\\\n\n"
1596 "@=\"Default value 4\"\n\n");
1597 verify_reg_nonexist(hkey, "Wine28d");
1598 verify_reg_nonexist(hkey, NULL);
1599
1600 exec_import_str("REGEDIT4\n\n"
1601 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1602 "\"Wine28e\"=hex(2):4c,69,6e,65,20\\\n"
1603 "@=\"Default value 5\"\n\n");
1604 verify_reg_nonexist(hkey, "Wine28e");
1605 verify_reg(hkey, NULL, REG_SZ, "Default value 5", 16, 0);
1606
1607 exec_import_str("REGEDIT4\n\n"
1608 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1609 "\"Wine29a\"=hex:11,22,33,\\\n"
1610 "\\\n"
1611 " 44,55,66\n"
1612 "\"Wine29b\"=hex:11,22,33,\\\n"
1613 " \\\n"
1614 " 44,55,66\n\n");
1615 verify_reg_nonexist(hkey, "Wine29a");
1616 verify_reg_nonexist(hkey, "Wine29b");
1617
1618 exec_import_str("REGEDIT4\n\n"
1619 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1620 "\"Wine30a\"=hex(0):25,48,4f,4d,45,25,5c,/\n"
1621 " 25,50,41,54,48,25,00\n"
1622 "\"Wine30b\"=hex(0):25,48,4f,4d,45,25,5c/\n"
1623 " 25,50,41,54,48,25,00\n\n");
1624 verify_reg_nonexist(hkey, "Wine30a");
1625 verify_reg_nonexist(hkey, "Wine30b");
1626
1627 exec_import_str("REGEDIT4\n\n"
1628 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1629 "\"Wine31\"=hex(7):4c,69,6e,65,20\\");
1630 verify_reg_nonexist(hkey, "Wine31");
1631
1632 exec_import_str("REGEDIT4\n\n"
1633 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1634 "\"Wine32a\"=hex(7):4c,69,6e,65,20,\\\n"
1635 " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1636 "\"Wine32b\"=hex(7):4c,69,6e,65,20,\\\n"
1637 " 63,,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1638 verify_reg_nonexist(hkey, "Wine32a");
1639 verify_reg_nonexist(hkey, "Wine32b");
1640
1641 RegCloseKey(hkey);
1642
1643 delete_key(HKEY_CURRENT_USER, KEY_BASE);
1644 }
1645
1646 static void test_invalid_import_unicode(void)
1647 {
1648 LONG lr;
1649 HKEY hkey;
1650 DWORD dword = 0x8;
1651
1652 lr = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
1653 ok(lr == ERROR_SUCCESS || lr == ERROR_FILE_NOT_FOUND, "RegDeleteKeyA failed: %d\n", lr);
1654
1655 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1656 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1657 "\"TestNoEndQuote\"=\"Asdffdsa\n");
1658 open_key(HKEY_CURRENT_USER, KEY_BASE, KEY_SET_VALUE, &hkey);
1659 verify_reg_nonexist(hkey, "TestNoEndQuote");
1660
1661 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1662 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1663 "\"TestNoBeginQuote\"=Asdffdsa\"\n");
1664 verify_reg_nonexist(hkey, "TestNoBeginQuote");
1665
1666 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1667 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1668 "\"TestNoQuotes\"=Asdffdsa\n");
1669 verify_reg_nonexist(hkey, "TestNoQuotes");
1670
1671 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1672 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1673 "\"NameNoEndQuote=\"Asdffdsa\"\n");
1674 verify_reg_nonexist(hkey, "NameNoEndQuote");
1675
1676 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1677 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1678 "NameNoBeginQuote\"=\"Asdffdsa\"\n");
1679 verify_reg_nonexist(hkey, "NameNoBeginQuote");
1680
1681 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1682 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1683 "NameNoQuotes=\"Asdffdsa\"\n");
1684 verify_reg_nonexist(hkey, "NameNoQuotes");
1685
1686 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1687 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1688 "\"MixedQuotes=Asdffdsa\"\n");
1689 verify_reg_nonexist(hkey, "MixedQuotes");
1690 verify_reg_nonexist(hkey, "MixedQuotes=Asdffdsa");
1691
1692 /* Test import with non-standard registry file headers */
1693 exec_import_wstr("\xef\xbb\xbfREGEDIT3\n\n"
1694 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1695 "\"Test1\"=\"Value\"\n");
1696 verify_reg_nonexist(hkey, "Test1");
1697
1698 exec_import_wstr("\xef\xbb\xbfregedit4\n\n"
1699 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1700 "\"Test2\"=\"Value\"\n");
1701 verify_reg_nonexist(hkey, "Test2");
1702
1703 exec_import_wstr("\xef\xbb\xbfRegedit4\n\n"
1704 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1705 "\"Test3\"=\"Value\"\n");
1706 verify_reg_nonexist(hkey, "Test3");
1707
1708 exec_import_wstr("\xef\xbb\xbfREGEDIT 4\n\n"
1709 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1710 "\"Test4\"=\"Value\"\n");
1711 verify_reg_nonexist(hkey, "Test4");
1712
1713 exec_import_wstr("\xef\xbb\xbfREGEDIT4FOO\n\n"
1714 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1715 "\"Test5\"=\"Value\"\n");
1716 verify_reg_nonexist(hkey, "Test5");
1717
1718 exec_import_wstr("\xef\xbb\xbfREGEDIT4 FOO\n\n"
1719 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1720 "\"Test6\"=\"Value\"\n");
1721 verify_reg_nonexist(hkey, "Test6");
1722
1723 exec_import_wstr("\xef\xbb\xbfREGEDIT5\n\n"
1724 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1725 "\"Test7\"=\"Value\"\n");
1726 verify_reg_nonexist(hkey, "Test7");
1727
1728 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 4.00\n\n"
1729 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1730 "\"Test8\"=\"Value\"\n");
1731 verify_reg_nonexist(hkey, "Test8");
1732
1733 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5\n\n"
1734 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1735 "\"Test9\"=\"Value\"\n");
1736 verify_reg_nonexist(hkey, "Test9");
1737
1738 exec_import_wstr("\xef\xbb\xbfWINDOWS REGISTRY EDITOR VERSION 5.00\n\n"
1739 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1740 "\"Test10\"=\"Value\"\n");
1741 verify_reg_nonexist(hkey, "Test10");
1742
1743 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor version 5.00\n\n"
1744 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1745 "\"Test11\"=\"Value\"\n");
1746 verify_reg_nonexist(hkey, "Test11");
1747
1748 /* Test multi-line import with incorrect comma placement */
1749 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1750 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1751 "\"Multi-Line1\"=hex(7):4c,00,69,00,6e,00,65,00,20,00\\\n"
1752 ",63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
1753 "65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
1754 verify_reg_nonexist(hkey, "Multi-Line1");
1755
1756 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1757 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1758 "\"Multi-Line2\"=hex(7):4c,00,69,00,6e,00,65,00,20,00\\\n"
1759 " ,63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
1760 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
1761 verify_reg_nonexist(hkey, "Multi-Line2");
1762
1763 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1764 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1765 "\"Multi-Line3\"=hex(7):4c,00,69,00,6e,00,65,00,20,00\\\n"
1766 ",63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
1767 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
1768 verify_reg_nonexist(hkey, "Multi-Line3");
1769
1770 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1771 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1772 "\"Multi-Line4\"=hex(7):4c,00,69,00,6e,00,65,00,20,00\\\n"
1773 ", 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
1774 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
1775 verify_reg_nonexist(hkey, "Multi-Line4");
1776
1777 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1778 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1779 "\"Test12a\"=dword:\n"
1780 "\"Test12b\"=dword:hello\n"
1781 "\"Test12c\"=dword:123456789\n"
1782 "\"Test12d\"=dword:012345678\n"
1783 "\"Test12e\"=dword:000000001\n\n");
1784 verify_reg_nonexist(hkey, "Test12a");
1785 verify_reg_nonexist(hkey, "Test12b");
1786 verify_reg_nonexist(hkey, "Test12c");
1787 verify_reg_nonexist(hkey, "Test12d");
1788 verify_reg_nonexist(hkey, "Test12e");
1789
1790 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1791 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1792 "\"Test13a\"=dword:12345678abc\n"
1793 "\"Test13b\"=dword:12345678 abc\n\n");
1794 verify_reg_nonexist(hkey, "Test13a");
1795 verify_reg_nonexist(hkey, "Test13b");
1796
1797 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1798 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1799 "\"Test14a\"=dword:0x123\n"
1800 "\"Test14b\"=dword:123 456\n"
1801 "\"Test14c\"=dword:1234 5678\n\n");
1802 verify_reg_nonexist(hkey, "Test14a");
1803 verify_reg_nonexist(hkey, "Test14b");
1804 verify_reg_nonexist(hkey, "Test14c");
1805
1806 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1807 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1808 "\"Test15a\"=\"foo\"bar\"\n"
1809 "\"Test15b\"=\"foo\"\"bar\"\n\n");
1810 verify_reg_nonexist(hkey, "Test15a");
1811 verify_reg_nonexist(hkey, "Test15b");
1812
1813 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1814 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1815 "\"Test16a\"=\n"
1816 "\"Test16b\"=\\\"\n"
1817 "\"Test16c\"=\\\"Value\\\"\n"
1818 "\"Test16d\"=\\\"Value\"\n\n");
1819 verify_reg_nonexist(hkey, "Test16a");
1820 verify_reg_nonexist(hkey, "Test16b");
1821 verify_reg_nonexist(hkey, "Test16c");
1822 verify_reg_nonexist(hkey, "Test16d");
1823
1824 /* Test key name and value name concatenation */
1825 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1826 "[HKEY_CURRENT_USER\\" KEY_BASE "\\\n"
1827 "Subkey1]\n");
1828 verify_key_nonexist(hkey, "Subkey1");
1829
1830 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1831 "[HKEY_CURRENT_USER\\" KEY_BASE "\n"
1832 "\\Subkey2]\n");
1833 verify_key_nonexist(hkey, "Subkey2");
1834
1835 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1836 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1837 "\"Test\\\n"
1838 "17a\"=\"Value 1\"\n"
1839 "\"Test17b\"=\"Value 2\"\n"
1840 "\"Test\n"
1841 "\\17c\"=\"Value 3\"\n\n");
1842 verify_reg_nonexist(hkey, "Test17a");
1843 verify_reg(hkey, "Test17b", REG_SZ, "Value 2", 8, 0);
1844 verify_reg_nonexist(hkey, "Test17c");
1845
1846 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1847 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1848 "\"Test18a\"=dword:1234\\\n"
1849 "5678\n"
1850 "\"Test18b\"=\"Test \\\n"
1851 "Value\"\n\n");
1852 verify_reg_nonexist(hkey, "Test18a");
1853 verify_reg_nonexist(hkey, "Test18b");
1854
1855 /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
1856 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1857 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1858 "\"Test19a\"=hex(0):56,00,61,00,6c,00\\\n"
1859 ",75,00,65,00,00,00\n"
1860 "\"Test19b\"=hex(0):56,00,61,00,6c,00\\\n"
1861 " ,75,00,65,00,00,00\n"
1862 "\"Test19c\"=hex(0):56,00,61,00,6c,00\\\n"
1863 " 75,00,65,00,00,00\n"
1864 "\"Test19d\"=hex(0):56,00,61,00,6c,00,7\\\n"
1865 "5,00,65,00,00,00\n"
1866 "\"Test19e\"=hex(0):56,00,61,00,6c,00,7\\\n"
1867 " 5,00,65,00,00,00\n"
1868 "\"Test19f\"=hex(0):56,00,61,00,\\;comment\n"
1869 " 6c,00,75,00,\\#comment\n"
1870 " 65,00,00,00\n\n");
1871 verify_reg_nonexist(hkey, "Test19a");
1872 verify_reg_nonexist(hkey, "Test19b");
1873 verify_reg_nonexist(hkey, "Test19c");
1874 verify_reg_nonexist(hkey, "Test19d");
1875 verify_reg_nonexist(hkey, "Test19e");
1876 verify_reg_nonexist(hkey, "Test19f");
1877
1878 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1879 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1880 "\"Test20a\"=hex(2):25,00,50,00,41,00\\\n"
1881 ",54,00,48,00,25,00,00,00\n"
1882 "\"Test20b\"=hex(2):25,00,50,00,41,00\\\n"
1883 " ,54,00,48,00,25,00,00,00\n"
1884 "\"Test20c\"=hex(2):25,00,50,00,41,00\\\n"
1885 " 54,00,48,00,25,00,00,00\n"
1886 "\"Test20d\"=hex(2):25,00,50,00,4\\\n"
1887 "1,00,54,00,48,00,25,00,00,00\n"
1888 "\"Test20e\"=hex(2):25,00,50,00,4\\\n"
1889 " 1,00,54,00,48,00,25,00,00\n"
1890 "\"Test20f\"=hex(2):25,00,50,00,41,00,\\;comment\n"
1891 " 54,00,48,00,\\#comment\n"
1892 " 25,00,00,00\n\n");
1893 verify_reg_nonexist(hkey, "Test20a");
1894 verify_reg_nonexist(hkey, "Test20b");
1895 verify_reg_nonexist(hkey, "Test20c");
1896 verify_reg_nonexist(hkey, "Test20d");
1897 verify_reg_nonexist(hkey, "Test20e");
1898 verify_reg_nonexist(hkey, "Test20f");
1899
1900 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1901 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1902 "\"Test21a\"=hex:11,22,33,44\\\n"
1903 ",55,66,77,88\n"
1904 "\"Test21b\"=hex:11,22,33,44\\\n"
1905 " ,55,66,77,88\n"
1906 "\"Test21c\"=hex:11,22,33,44\\\n"
1907 " 55,66,77,88\n"
1908 "\"Test21d\"=hex:11,22,33,4\\\n"
1909 "4,55,66,77,88\n"
1910 "\"Test21e\"=hex:11,22,33,4\\\n"
1911 " 4,55,66,77,88\n"
1912 "\"Test21f\"=hex:11,22,33,\\;comment\n"
1913 " 44,55,66,\\#comment\n"
1914 " 77,88\n\n");
1915 verify_reg_nonexist(hkey, "Test21a");
1916 verify_reg_nonexist(hkey, "Test21b");
1917 verify_reg_nonexist(hkey, "Test21c");
1918 verify_reg_nonexist(hkey, "Test21d");
1919 verify_reg_nonexist(hkey, "Test21e");
1920 verify_reg_nonexist(hkey, "Test21f");
1921
1922 /* Test support for characters greater than 0xff */
1923 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1924 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1925 "\"Wine22a\"=hex(0):25,50,100,54,48,25,00\n"
1926 "\"Wine22b\"=hex(0):25,1a4,100,164,124,25,00\n\n");
1927 verify_reg_nonexist(hkey, "Wine22a");
1928 verify_reg_nonexist(hkey, "Wine22b");
1929
1930 /* Test the effect of backslashes in hex data */
1931 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1932 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1933 "\"Wine23a\"=hex(2):25,00,48\\,00,4f,00,4d,00,45,00,25,00,00,00\n"
1934 "\"Wine23b\"=hex(2):25,00,48,00,\\4f,00,4d,00,45,00,25,00,00,00\n"
1935 "\"Wine23c\"=hex(2):25,00,48\\ ,00,4f,00,4d,00,45,00,25,00,00,00\n"
1936 "\"Wine23d\"=hex(2):25,00,48,00,\\ 4f,00,4d,00,45,00,25,00,00,00\n"
1937 "\"Wine23e\"=hex(2):\\25,00,48,00,4f,00,4d,00,45,00,25,00,00,00\n"
1938 "\"Wine23f\"=hex(2):\\ 25,00,48,00,4f,00,4d,00,45,00,25,00,00,00\n"
1939 "\"Wine23g\"=hex(2):25,00,48,00,4\\f,00,4d,00,45,00,25,00,00,00\n"
1940 "\"Wine23h\"=hex(2):25,00,48,00,4\\\n"
1941 " f,00,4d,00,45,00,25,00,00,00\n"
1942 "\"Wine23i\"=hex(2):25,00,50,00,\\,41,00,54,00,48,00,25,00,00,00\n"
1943 "\"Wine23j\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\\\n"
1944 " 25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
1945 "\"Wine23k\"=hex(2):,\\\n"
1946 " 25,00,48,00,4f,00,4d,00,45,00,25,00,00,00\n\n");
1947 verify_reg_nonexist(hkey, "Wine23a");
1948 verify_reg_nonexist(hkey, "Wine23b");
1949 verify_reg_nonexist(hkey, "Wine23c");
1950 verify_reg_nonexist(hkey, "Wine23d");
1951 verify_reg_nonexist(hkey, "Wine23e");
1952 verify_reg_nonexist(hkey, "Wine23f");
1953 verify_reg_nonexist(hkey, "Wine23g");
1954 verify_reg_nonexist(hkey, "Wine23h");
1955 verify_reg_nonexist(hkey, "Wine23i");
1956 verify_reg_nonexist(hkey, "Wine23j");
1957 verify_reg_nonexist(hkey, "Wine23k");
1958
1959 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1960 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1961 "\"Wine24a\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
1962 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1]\n");
1963 verify_reg_nonexist(hkey, "Wine24a");
1964 verify_key_nonexist(hkey, "Subkey1");
1965
1966 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1967 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1968 "\"Wine24b\"=hex(2):4c,00,69,00,6e,00,65,00,20,00\\\n"
1969 "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2]\n");
1970 verify_reg_nonexist(hkey, "Wine24b");
1971 verify_key(hkey, "Subkey2");
1972
1973 delete_key(hkey, "Subkey2");
1974
1975 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1976 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1977 "\"Wine25a\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
1978 "\"Wine25b\"=\"Test value\"\n"
1979
1980 "\"Wine25c\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
1981 ";comment\n"
1982 "\"Wine25d\"=\"Test value\"\n"
1983
1984 "\"Wine25e\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
1985 "#comment\n"
1986 "\"Wine25f\"=\"Test value\"\n"
1987
1988 "\"Wine25g\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n\n"
1989 "\"Wine25h\"=\"Test value\"\n"
1990
1991 "\"Wine25i\"=hex(2):4c,00,69,00,6e,00,65,00,20,00\\\n"
1992 "\"Wine25j\"=\"Test value\"\n\n");
1993 verify_reg_nonexist(hkey, "Wine25a");
1994 verify_reg_nonexist(hkey, "Wine25b");
1995 verify_reg_nonexist(hkey, "Wine25c");
1996 verify_reg_nonexist(hkey, "Wine25d");
1997 verify_reg_nonexist(hkey, "Wine25e");
1998 verify_reg(hkey, "Wine25f", REG_SZ, "Test value", 11, 0);
1999 verify_reg_nonexist(hkey, "Wine25g");
2000 verify_reg_nonexist(hkey, "Wine25h");
2001 verify_reg_nonexist(hkey, "Wine25i");
2002 verify_reg(hkey, "Wine25j", REG_SZ, "Test value", 11, 0);
2003
2004 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2005 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2006 "\"Wine26a\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2007 "\"Wine26b\"=dword:00000008\n"
2008
2009 "\"Wine26c\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2010 ";comment\n"
2011 "\"Wine26d\"=dword:00000008\n"
2012
2013 "\"Wine26e\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2014 "#comment\n"
2015 "\"Wine26f\"=dword:00000008\n"
2016
2017 "\"Wine26g\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n\n"
2018 "\"Wine26h\"=dword:00000008\n"
2019
2020 "\"Wine26i\"=hex(2):4c,00,69,00,6e,00,65,00,20,00\\\n"
2021 "\"Wine26j\"=dword:00000008\n\n");
2022 verify_reg_nonexist(hkey, "Wine26a");
2023 verify_reg_nonexist(hkey, "Wine26b");
2024 verify_reg_nonexist(hkey, "Wine26c");
2025 verify_reg_nonexist(hkey, "Wine26d");
2026 verify_reg_nonexist(hkey, "Wine26e");
2027 verify_reg(hkey, "Wine26f", REG_DWORD, &dword, sizeof(dword), 0);
2028 verify_reg_nonexist(hkey, "Wine26g");
2029 verify_reg_nonexist(hkey, "Wine26h");
2030 verify_reg_nonexist(hkey, "Wine26i");
2031 verify_reg(hkey, "Wine26j", REG_DWORD, &dword, sizeof(dword), 0);
2032
2033 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2034 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2035 "\"Wine27a\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\n"
2036 "\"Wine27b\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2037
2038 "\"Wine27c\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\n"
2039 ";comment\n"
2040 "\"Wine27d\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2041
2042 "\"Wine27e\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\n"
2043 "#comment\n"
2044 "\"Wine27f\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2045
2046 "\"Wine27g\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\n\n"
2047 "\"Wine27h\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2048
2049 "\"Wine27i\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00\\\n"
2050 "\"Wine27j\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n\n");
2051 verify_reg_nonexist(hkey, "Wine27a");
2052 verify_reg_nonexist(hkey, "Wine27b");
2053 verify_reg_nonexist(hkey, "Wine27c");
2054 verify_reg_nonexist(hkey, "Wine27d");
2055 verify_reg_nonexist(hkey, "Wine27e");
2056 verify_reg(hkey, "Wine27f", REG_EXPAND_SZ, "%PATH%", 7, 0);
2057 verify_reg_nonexist(hkey, "Wine27g");
2058 verify_reg_nonexist(hkey, "Wine27h");
2059 verify_reg_nonexist(hkey, "Wine27i");
2060 verify_reg(hkey, "Wine27j", REG_EXPAND_SZ, "%PATH%", 7, 0);
2061
2062 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2063 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2064 "\"Wine28a\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2065 "@=\"Default value 1\"\n\n");
2066 verify_reg_nonexist(hkey, "Wine28a");
2067 verify_reg_nonexist(hkey, NULL);
2068
2069 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2070 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2071 "\"Wine28b\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2072 ";comment\n"
2073 "@=\"Default value 2\"\n\n");
2074 verify_reg_nonexist(hkey, "Wine28b");
2075 verify_reg_nonexist(hkey, NULL);
2076
2077 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2078 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2079 "\"Wine28c\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2080 "#comment\n"
2081 "@=\"Default value 3\"\n\n");
2082 verify_reg_nonexist(hkey, "Wine28c");
2083 verify_reg(hkey, NULL, REG_SZ, "Default value 3", 16, 0);
2084
2085 delete_value(hkey, NULL);
2086
2087 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2088 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2089 "\"Wine28d\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n\n"
2090 "@=\"Default value 4\"\n\n");
2091 verify_reg_nonexist(hkey, "Wine28d");
2092 verify_reg_nonexist(hkey, NULL);
2093
2094 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2095 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2096 "\"Wine28e\"=hex(2):4c,00,69,00,6e,00,65,00,20,00\\\n"
2097 "@=\"Default value 5\"\n\n");
2098 verify_reg_nonexist(hkey, "Wine28e");
2099 verify_reg(hkey, NULL, REG_SZ, "Default value 5", 16, 0);
2100
2101 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2102 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2103 "\"Wine29a\"=hex:11,22,33,\\\n"
2104 "\\\n"
2105 " 44,55,66\n"
2106 "\"Wine29b\"=hex:11,22,33,\\\n"
2107 " \\\n"
2108 " 44,55,66\n\n");
2109 verify_reg_nonexist(hkey, "Wine29a");
2110 verify_reg_nonexist(hkey, "Wine29b");
2111
2112 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2113 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2114 "\"Wine30a\"=hex(0):25,48,4f,4d,45,25,5c,/\n"
2115 " 25,50,41,54,48,25,00\n"
2116 "\"Wine30b\"=hex(0):25,48,4f,4d,45,25,5c/\n"
2117 " 25,50,41,54,48,25,00\n\n");
2118 verify_reg_nonexist(hkey, "Wine30a");
2119 verify_reg_nonexist(hkey, "Wine30b");
2120
2121 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2122 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2123 "\"Wine31\"=hex(7):4c,00,69,00,6e,00,65,00,20,00\\");
2124 verify_reg_nonexist(hkey, "Wine31");
2125
2126 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2127 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2128 "\"Wine32a\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2129 " ,63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
2130 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
2131 "\"Wine32b\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2132 " 63,00,,6f,00,6e,00,63,00,61,00,74,00,\\\n"
2133 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2134 verify_reg_nonexist(hkey, "Wine32a");
2135 verify_reg_nonexist(hkey, "Wine32b");
2136
2137 RegCloseKey(hkey);
2138
2139 delete_key(HKEY_CURRENT_USER, KEY_BASE);
2140 }
2141
2142 static void test_invalid_import_31(void)
2143 {
2144 HKEY hkey;
2145 LONG lr;
2146
2147 /* Check if regedit.exe is running with elevated privileges */
2148 lr = RegCreateKeyExA(HKEY_CLASSES_ROOT, KEY_BASE, 0, NULL, REG_OPTION_NON_VOLATILE,
2149 KEY_READ, NULL, &hkey, NULL);
2150 if (lr == ERROR_ACCESS_DENIED)
2151 {
2152 win_skip("regedit.exe is not running with elevated privileges; "
2153 "skipping Windows 3.1 invalid import tests\n");
2154 return;
2155 }
2156
2157 /* Test character validity at the start of the line */
2158 exec_import_str("REGEDIT\r\n"
2159 " HKEY_CLASSES_ROOT\\" KEY_BASE " = Value1a\r\n");
2160 verify_reg_nonexist(hkey, "");
2161
2162 exec_import_str("REGEDIT\r\n"
2163 " HKEY_CLASSES_ROOT\\" KEY_BASE " = Value1b\r\n");
2164 verify_reg_nonexist(hkey, "");
2165
2166 exec_import_str("REGEDIT\r\n"
2167 "\tHKEY_CLASSES_ROOT\\" KEY_BASE " = Value1c\r\n");
2168 verify_reg_nonexist(hkey, "");
2169
2170 exec_import_str("REGEDIT\r\n"
2171 ";HKEY_CLASSES_ROOT\\" KEY_BASE " = Value2a\r\n");
2172 verify_reg_nonexist(hkey, "");
2173
2174 exec_import_str("REGEDIT\r\n"
2175 "#HKEY_CLASSES_ROOT\\" KEY_BASE " = Value2b\r\n");
2176 verify_reg_nonexist(hkey, "");
2177
2178 /* Test case sensitivity */
2179 exec_import_str("REGEDIT\r\n"
2180 "hkey_classes_root\\" KEY_BASE " = Value3a\r\n");
2181 verify_reg_nonexist(hkey, "");
2182
2183 exec_import_str("REGEDIT\r\n"
2184 "hKEY_CLASSES_ROOT\\" KEY_BASE " = Value3b\r\n");
2185 verify_reg_nonexist(hkey, "");
2186
2187 exec_import_str("REGEDIT\r\n"
2188 "Hkey_Classes_Root\\" KEY_BASE " = Value3c\r\n");
2189 verify_reg_nonexist(hkey, "");
2190
2191 RegCloseKey(hkey);
2192
2193 delete_key(HKEY_CLASSES_ROOT, KEY_BASE);
2194 }
2195
2196 static void test_comments(void)
2197 {
2198 LONG lr;
2199 HKEY hkey;
2200 DWORD dword;
2201
2202 lr = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
2203 ok(lr == ERROR_SUCCESS || lr == ERROR_FILE_NOT_FOUND, "RegDeleteKeyA failed: %d\n", lr);
2204
2205 exec_import_str("REGEDIT4\n\n"
2206 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2207 "#comment\\\n"
2208 "\"Wine1\"=\"Line 1\"\n"
2209 ";comment\\\n"
2210 "\"Wine2\"=\"Line 2\"\n\n");
2211 open_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
2212 verify_reg(hkey, "Wine1", REG_SZ, "Line 1", 7, 0);
2213 verify_reg(hkey, "Wine2", REG_SZ, "Line 2", 7, 0);
2214
2215 exec_import_str("REGEDIT4\n\n"
2216 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2217 "\"Wine3\"=\"Value 1\"#comment\n"
2218 "\"Wine4\"=\"Value 2\";comment\n"
2219 "\"Wine5\"=dword:01020304 #comment\n"
2220 "\"Wine6\"=dword:02040608 ;comment\n\n");
2221 verify_reg_nonexist(hkey, "Wine3");
2222 verify_reg(hkey, "Wine4", REG_SZ, "Value 2", 8, 0);
2223 verify_reg_nonexist(hkey, "Wine5");
2224 dword = 0x2040608;
2225 verify_reg(hkey, "Wine6", REG_DWORD, &dword, sizeof(dword), 0);
2226
2227 exec_import_str("REGEDIT4\n\n"
2228 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2229 "\"Wine7\"=hex(7):4c,69,6e,65,20,\\\n"
2230 " #comment\n"
2231 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
2232 "\"Wine8\"=\"A valid line\"\n"
2233 "\"Wine9\"=hex(7):4c,69,6e,65,20,\\\n"
2234 " ;comment\n"
2235 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
2236 "\"Wine10\"=\"Another valid line\"\n\n");
2237 verify_reg_nonexist(hkey, "Wine7");
2238 verify_reg(hkey, "Wine8", REG_SZ, "A valid line", 13, 0);
2239 verify_reg(hkey, "Wine9", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2240 verify_reg(hkey, "Wine10", REG_SZ, "Another valid line", 19, 0);
2241
2242 exec_import_str("REGEDIT4\n\n"
2243 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2244 "#\"Comment1\"=\"Value 1\"\n"
2245 ";\"Comment2\"=\"Value 2\"\n"
2246 " #\"Comment3\"=\"Value 3\"\n"
2247 " ;\"Comment4\"=\"Value 4\"\n"
2248 "\"Wine11\"=\"Value 6\"#\"Comment5\"=\"Value 5\"\n"
2249 "\"Wine12\"=\"Value 7\";\"Comment6\"=\"Value 6\"\n\n");
2250 verify_reg_nonexist(hkey, "Comment1");
2251 verify_reg_nonexist(hkey, "Comment2");
2252 verify_reg_nonexist(hkey, "Comment3");
2253 verify_reg_nonexist(hkey, "Comment4");
2254 verify_reg_nonexist(hkey, "Wine11");
2255 verify_reg_nonexist(hkey, "Comment5");
2256 verify_reg(hkey, "Wine12", REG_SZ, "Value 7", 8, 0);
2257 verify_reg_nonexist(hkey, "Comment6");
2258
2259 exec_import_str("REGEDIT4\n\n"
2260 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2261 "\"Wine13\"=#\"Value 8\"\n"
2262 "\"Wine14\"=;\"Value 9\"\n"
2263 "\"Wine15\"=\"#comment1\"\n"
2264 "\"Wine16\"=\";comment2\"\n"
2265 "\"Wine17\"=\"Value#comment3\"\n"
2266 "\"Wine18\"=\"Value;comment4\"\n"
2267 "\"Wine19\"=\"Value #comment5\"\n"
2268 "\"Wine20\"=\"Value ;comment6\"\n"
2269 "\"Wine21\"=#dword:00000001\n"
2270 "\"Wine22\"=;dword:00000002\n"
2271 "\"Wine23\"=dword:00000003#comment\n"
2272 "\"Wine24\"=dword:00000004;comment\n\n");
2273 verify_reg_nonexist(hkey, "Wine13");
2274 verify_reg_nonexist(hkey, "Wine14");
2275 verify_reg(hkey, "Wine15", REG_SZ, "#comment1", 10, 0);
2276 verify_reg(hkey, "Wine16", REG_SZ, ";comment2", 10, 0);
2277 verify_reg(hkey, "Wine17", REG_SZ, "Value#comment3", 15, 0);
2278 verify_reg(hkey, "Wine18", REG_SZ, "Value;comment4", 15, 0);
2279 verify_reg(hkey, "Wine19", REG_SZ, "Value #comment5", 16, 0);
2280 verify_reg(hkey, "Wine20", REG_SZ, "Value ;comment6", 16, 0);
2281 verify_reg_nonexist(hkey, "Wine21");
2282 verify_reg_nonexist(hkey, "Wine22");
2283 verify_reg_nonexist(hkey, "Wine23");
2284 dword = 0x00000004;
2285 verify_reg(hkey, "Wine24", REG_DWORD, &dword, sizeof(dword), 0);
2286
2287 exec_import_str("REGEDIT4\n\n"
2288 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2289 "\"Wine25a\"=dword:1234;5678\n"
2290 "\"Wine25b\"=dword:1234 ;5678\n"
2291 "\"Wine25c\"=dword:1234#5678\n"
2292 "\"Wine25d\"=dword:1234 #5678\n\n");
2293 dword = 0x1234;
2294 verify_reg(hkey, "Wine25a", REG_DWORD, &dword, sizeof(dword), 0);
2295 verify_reg(hkey, "Wine25b", REG_DWORD, &dword, sizeof(dword), 0);
2296 verify_reg_nonexist(hkey, "Wine25c");
2297 verify_reg_nonexist(hkey, "Wine25d");
2298
2299 exec_import_str("REGEDIT4\n\n"
2300 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2301 "\"Wine26a\"=\"Value1\" ;comment\n"
2302 "\"Wine26b\"=\"Value2\"\t\t;comment\n"
2303 "\"Wine26c\"=\"Value3\" #comment\n"
2304 "\"Wine26d\"=\"Value4\"\t\t#comment\n\n");
2305 verify_reg(hkey, "Wine26a", REG_SZ, "Value1", 7, 0);
2306 verify_reg(hkey, "Wine26b", REG_SZ, "Value2", 7, 0);
2307 verify_reg_nonexist(hkey, "Wine26c");
2308 verify_reg_nonexist(hkey, "Wine26d");
2309
2310 exec_import_str("REGEDIT4\n\n"
2311 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2312 "\"Multi-Line1\"=hex(7):4c,69,6e,65,20,\\\n"
2313 " 63,6f,6e,\\;comment\n"
2314 " 63,61,74,\\;comment\n"
2315 " 65,6e,61,74,69,6f,6e,00,00\n\n");
2316 verify_reg(hkey, "Multi-Line1", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2317
2318 exec_import_str("REGEDIT4\n\n"
2319 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2320 "\"Multi-Line2\"=hex(7):4c,69,6e,65,20,\\\n"
2321 " 63,6f,6e,\\;comment\n"
2322 " 63,61,74,;comment\n"
2323 " 65,6e,61,74,69,6f,6e,00,00\n\n");
2324 verify_reg(hkey, "Multi-Line2", REG_MULTI_SZ, "Line concat", 12, 0);
2325
2326 exec_import_str("REGEDIT4\n\n"
2327 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2328 "\"Multi-Line3\"=hex(7):4c,69,6e,\\;comment\n"
2329 " 65,20,\\;comment\n"
2330 " 63,6f,6e,\\;comment\n"
2331 " 63,61,74,\\;comment\n"
2332 " 65,6e,61,74,69,6f,6e,00,00\n\n");
2333 verify_reg(hkey, "Multi-Line3", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2334
2335 exec_import_str("REGEDIT4\n\n"
2336 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2337 "\"Multi-Line4\"=hex(7):4c,69,6e,\\;#comment\n"
2338 " 65,20,\\;#comment\n"
2339 " 63,6f,6e,\\;#comment\n"
2340 " 63,61,74,\\;#comment\n"
2341 " 65,6e,61,74,69,6f,6e,00,00\n\n");
2342 verify_reg(hkey, "Multi-Line4", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2343
2344 exec_import_str("REGEDIT4\n\n"
2345 "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2346 "\"Multi-Line5\"=hex(7):4c,69,6e,\\;comment\n"
2347 " 65,20,\\;comment\n"
2348 " 63,6f,6e,\\;comment\n"
2349 " 63,61,74,\\#comment\n"