2 * Copyright 2010 Andrew Eikum for CodeWeavers
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.
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.
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
21 #include "wine/test.h"
23 #define lok ok_(__FILE__,line)
25 #define run_regedit_exe(c) run_regedit_exe_(__LINE__,c)
26 static BOOL
run_regedit_exe_(unsigned line
, const char *cmd
)
28 STARTUPINFOA si
= {sizeof(STARTUPINFOA
)};
29 PROCESS_INFORMATION pi
;
33 si
.dwFlags
= STARTF_USESTDHANDLES
;
34 si
.hStdInput
= INVALID_HANDLE_VALUE
;
35 si
.hStdOutput
= INVALID_HANDLE_VALUE
;
36 si
.hStdError
= INVALID_HANDLE_VALUE
;
39 if (!CreateProcessA(NULL
, cmdline
, NULL
, NULL
, TRUE
, 0, NULL
, NULL
, &si
, &pi
))
42 ret
= WaitForSingleObject(pi
.hProcess
, 10000);
43 if (ret
== WAIT_TIMEOUT
)
44 TerminateProcess(pi
.hProcess
, 1);
46 CloseHandle(pi
.hThread
);
47 CloseHandle(pi
.hProcess
);
48 return (ret
!= WAIT_TIMEOUT
);
51 static BOOL
write_file(const void *str
, DWORD size
)
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
)
63 ret
= WriteFile(file
, str
, size
, &written
, NULL
);
64 ok(ret
, "WriteFile failed: %u\n", GetLastError());
70 #define exec_import_str(c) import_reg(__LINE__,c,FALSE)
71 #define exec_import_wstr(c) import_reg(__LINE__,c,TRUE)
73 static BOOL
import_reg(unsigned line
, const char *contents
, BOOL unicode
)
78 lenA
= strlen(contents
);
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
);
88 ret
= write_file(wstr
, size
);
89 HeapFree(GetProcessHeap(), 0, wstr
);
92 ret
= write_file(contents
, lenA
);
94 if (!ret
) return FALSE
;
96 run_regedit_exe("regedit.exe /s test.reg");
98 ret
= DeleteFileA("test.reg");
99 lok(ret
, "DeleteFile failed: %u\n", GetLastError());
104 #define TODO_REG_TYPE (0x0001u)
105 #define TODO_REG_SIZE (0x0002u)
106 #define TODO_REG_DATA (0x0004u)
107 #define TODO_REG_COMPARE (0x0008u)
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
)
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
)
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
);
131 todo_wine_if (todo
& TODO_REG_DATA
)
132 lok(memcmp(data
, exp_data
, size
) == 0, "got wrong data\n");
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
)
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
);
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
)
151 lr
= RegOpenKeyExA(base
, path
, 0, KEY_READ
|sam
, hkey
);
152 lok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: %d\n", lr
);
155 #define close_key(k) close_key_(__LINE__,k)
156 static void close_key_(unsigned line
, HKEY hkey
)
160 lr
= RegCloseKey(hkey
);
161 lok(lr
== ERROR_SUCCESS
, "RegCloseKey failed: %d\n", lr
);
164 #define verify_key(k,s) verify_key_(__LINE__,k,s)
165 static void verify_key_(unsigned line
, HKEY key_base
, const char *subkey
)
170 lr
= RegOpenKeyExA(key_base
, subkey
, 0, KEY_READ
, &hkey
);
171 lok(lr
== ERROR_SUCCESS
, "RegOpenKeyExA failed: got %d\n", lr
);
177 #define verify_key_nonexist(k,s) verify_key_nonexist_(__LINE__,k,s)
178 static void verify_key_nonexist_(unsigned line
, HKEY key_base
, const char *subkey
)
183 lr
= RegOpenKeyExA(key_base
, subkey
, 0, KEY_READ
, &hkey
);
184 lok(lr
== ERROR_FILE_NOT_FOUND
, "registry key '%s' shouldn't exist; got %d, expected 2\n",
191 #define add_key(k,p,s) add_key_(__LINE__,k,p,s)
192 static void add_key_(unsigned line
, const HKEY hkey
, const char *path
, HKEY
*subkey
)
196 lr
= RegCreateKeyExA(hkey
, path
, 0, NULL
, REG_OPTION_NON_VOLATILE
,
197 KEY_READ
|KEY_WRITE
, NULL
, subkey
, NULL
);
198 lok(lr
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %d\n", lr
);
201 #define delete_key(k,p) delete_key_(__LINE__,k,p)
202 static void delete_key_(unsigned line
, const HKEY hkey
, const char *path
)
208 lr
= RegDeleteKeyA(hkey
, path
);
209 lok(lr
== ERROR_SUCCESS
, "RegDeleteKeyA failed: %d\n", lr
);
213 static LONG
delete_tree(const HKEY key
, const char *subkey
)
217 char *subkey_name
= NULL
;
218 DWORD max_subkey_len
, subkey_len
;
219 static const char empty
[1];
221 ret
= RegOpenKeyExA(key
, subkey
, 0, KEY_READ
, &hkey
);
224 ret
= RegQueryInfoKeyA(hkey
, NULL
, NULL
, NULL
, NULL
, &max_subkey_len
,
225 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
226 if (ret
) goto cleanup
;
230 subkey_name
= HeapAlloc(GetProcessHeap(), 0, max_subkey_len
);
233 ret
= ERROR_NOT_ENOUGH_MEMORY
;
239 subkey_len
= max_subkey_len
;
240 ret
= RegEnumKeyExA(hkey
, 0, subkey_name
, &subkey_len
, NULL
, NULL
, NULL
, NULL
);
241 if (ret
== ERROR_NO_MORE_ITEMS
) break;
242 if (ret
) goto cleanup
;
243 ret
= delete_tree(hkey
, subkey_name
);
244 if (ret
) goto cleanup
;
247 ret
= RegDeleteKeyA(hkey
, empty
);
250 HeapFree(GetProcessHeap(), 0, subkey_name
);
255 #define add_value(k,n,t,d,s) add_value_(__LINE__,k,n,t,d,s)
256 static void add_value_(unsigned line
, HKEY hkey
, const char *name
, DWORD type
,
257 const void *data
, size_t size
)
261 lr
= RegSetValueExA(hkey
, name
, 0, type
, (const BYTE
*)data
, size
);
262 lok(lr
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", lr
);
265 #define delete_value(k,n) delete_value_(__LINE__,k,n)
266 static void delete_value_(unsigned line
, const HKEY hkey
, const char *name
)
270 lr
= RegDeleteValueA(hkey
, name
);
271 lok(lr
== ERROR_SUCCESS
, "RegDeleteValueA failed: %d\n", lr
);
274 #define KEY_BASE "Software\\Wine\\regedit_test"
276 static void test_basic_import(void)
279 DWORD dword
= 0x17, type
, size
;
280 char exp_binary
[] = {0xAA,0xBB,0xCC,0x11};
285 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
286 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
288 exec_import_str("REGEDIT4\n\n"
289 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
290 "\"TestValue\"=\"AValue\"\n");
291 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
292 verify_reg(hkey
, "TestValue", REG_SZ
, "AValue", 7, 0);
294 exec_import_str("REGEDIT4\r\n\r\n"
295 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
296 "\"TestValue2\"=\"BValue\"\r\n");
297 verify_reg(hkey
, "TestValue2", REG_SZ
, "BValue", 7, 0);
299 exec_import_str("Windows Registry Editor Version 5.00\n\n"
300 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
301 "\"TestValue3\"=\"Value\"\n");
302 verify_reg(hkey
, "TestValue3", REG_SZ
, "Value", 6, 0);
304 exec_import_str("REGEDIT4\r\r"
305 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r"
306 "\"TestValue4\"=\"DValue\"\r");
307 verify_reg(hkey
, "TestValue4", REG_SZ
, "DValue", 7, 0);
309 exec_import_str("Windows Registry Editor Version 5.00\r\r"
310 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r"
311 "\"TestValue5\"=\"Value\"\r");
312 verify_reg(hkey
, "TestValue5", REG_SZ
, "Value", 6, 0);
314 exec_import_str("REGEDIT4\n\n"
315 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
316 "\"TestDword\"=dword:00000017\n");
317 verify_reg(hkey
, "TestDword", REG_DWORD
, &dword
, sizeof(dword
), 0);
319 exec_import_str("REGEDIT4\n\n"
320 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
321 "\"TestBinary\"=hex:aa,bb,cc,11\n");
322 verify_reg(hkey
, "TestBinary", REG_BINARY
, exp_binary
, sizeof(exp_binary
), 0);
324 exec_import_str("REGEDIT4\n\n"
325 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
326 "\"With=Equals\"=\"asdf\"\n");
327 verify_reg(hkey
, "With=Equals", REG_SZ
, "asdf", 5, 0);
329 exec_import_str("REGEDIT4\n\n"
330 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
331 "\"Empty string\"=\"\"\n"
332 "\"\"=\"Default registry value\"\n\n");
333 verify_reg(hkey
, "Empty string", REG_SZ
, "", 1, 0);
334 verify_reg(hkey
, NULL
, REG_SZ
, "Default registry value", 23, 0);
336 exec_import_str("REGEDIT4\n\n"
337 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
338 "\"Line1\"=\"Value1\"\n\n"
339 "\"Line2\"=\"Value2\"\n\n\n"
340 "\"Line3\"=\"Value3\"\n\n\n\n"
341 "\"Line4\"=\"Value4\"\n\n");
342 verify_reg(hkey
, "Line1", REG_SZ
, "Value1", 7, 0);
343 verify_reg(hkey
, "Line2", REG_SZ
, "Value2", 7, 0);
344 verify_reg(hkey
, "Line3", REG_SZ
, "Value3", 7, 0);
345 verify_reg(hkey
, "Line4", REG_SZ
, "Value4", 7, 0);
347 exec_import_str("REGEDIT4\n\n"
348 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
349 "\"Wine1\"=dword:00000782\n\n"
350 "\"Wine2\"=\"Test Value\"\n"
351 "\"Wine3\"=hex(7):4c,69,6e,65,20,\\\n"
352 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
356 "\"Wine4\"=dword:12345678\n\n");
358 verify_reg(hkey
, "Wine1", REG_DWORD
, &dword
, sizeof(dword
), 0);
359 verify_reg(hkey
, "Wine2", REG_SZ
, "Test Value", 11, 0);
360 verify_reg(hkey
, "Wine3", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
361 verify_reg(hkey
, "", REG_SZ
, "Test", 5, 0);
363 verify_reg(hkey
, "Wine4", REG_DWORD
, &dword
, sizeof(dword
), 0);
365 exec_import_str("REGEDIT4\n\n"
366 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
367 "\"Wine5\"=\"No newline\"");
368 verify_reg(hkey
, "Wine5", REG_SZ
, "No newline", 11, 0);
370 exec_import_str("REGEDIT4\n\n"
371 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
372 "\"Wine6\"=dword:00000050\n\n"
373 "\"Wine7\"=\"No newline\"");
375 verify_reg(hkey
, "Wine6", REG_DWORD
, &dword
, sizeof(dword
), 0);
376 verify_reg(hkey
, "Wine7", REG_SZ
, "No newline", 11, 0);
378 exec_import_str("REGEDIT4\n\n"
379 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
380 "\"Wine8a\"=dword:1\n"
381 "\"Wine8b\"=dword:4444\n\n");
383 verify_reg(hkey
, "Wine8a", REG_DWORD
, &dword
, sizeof(dword
), 0);
385 verify_reg(hkey
, "Wine8b", REG_DWORD
, &dword
, sizeof(dword
), 0);
387 exec_import_str("REGEDIT4\n\n"
388 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
389 "\"Wine9a\"=hex(2):4c,69,6e,65,00\n"
390 "\"Wine9b\"=\"Value 1\"\n"
391 "\"Wine9c\"=hex(2):4c,69,6e,65\\\n"
392 "\"Wine9d\"=\"Value 2\"\n"
393 "\"Wine9e\"=hex(2):4c,69,6e,65,\\\n"
394 "\"Wine9f\"=\"Value 3\"\n"
395 "\"Wine9g\"=\"Value 4\"\n\n");
396 verify_reg(hkey
, "Wine9a", REG_EXPAND_SZ
, "Line", 5, 0);
397 verify_reg(hkey
, "Wine9b", REG_SZ
, "Value 1", 8, 0);
398 verify_reg_nonexist(hkey
, "Wine9c");
399 verify_reg(hkey
, "Wine9d", REG_SZ
, "Value 2", 8, 0);
400 verify_reg_nonexist(hkey
, "Wine9e");
401 verify_reg_nonexist(hkey
, "Wine9f");
402 verify_reg(hkey
, "Wine9g", REG_SZ
, "Value 4", 8, 0);
404 exec_import_str("REGEDIT4\n\n"
405 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
406 "\"double\\\"quote\"=\"valid \\\"or\\\" not\"\n"
407 "\"single'quote\"=dword:00000008\n\n");
408 verify_reg(hkey
, "double\"quote", REG_SZ
, "valid \"or\" not", 15, 0);
410 verify_reg(hkey
, "single'quote", REG_DWORD
, &dword
, sizeof(dword
), 0);
412 /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
413 exec_import_str("REGEDIT4\n\n"
414 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
415 "\"Wine10a\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n"
416 "\"Wine10b\"=hex(0):56,00,61,00,6c,00,\\\n"
417 " 75,00,65,00,00,00\n"
418 "\"Wine10c\"=hex(0):56,00,61,00,\\;comment\n"
421 "\"Wine10d\"=hex(0):56,00,61,00,\\;comment\n"
424 "\"Wine10e\"=hex(0):56,00,61,00,\\;comment\n"
425 " 6c,00,75,00,;comment\n"
427 verify_reg(hkey
, "Wine10a", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
428 verify_reg(hkey
, "Wine10b", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
429 verify_reg(hkey
, "Wine10c", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
430 verify_reg(hkey
, "Wine10d", REG_NONE
, "V\0a\0l\0u", 8, 0);
431 verify_reg(hkey
, "Wine10e", REG_NONE
, "V\0a\0l\0u", 8, 0);
433 exec_import_str("REGEDIT4\n\n"
434 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
435 "\"Wine11a\"=hex(2):25,50,41,54,48,25,00\n"
436 "\"Wine11b\"=hex(2):25,50,41,\\\n"
438 "\"Wine11c\"=hex(2):25,50,41,\\;comment\n"
441 "\"Wine11d\"=hex(2):25,50,41,\\;comment\n"
444 "\"Wine11e\"=hex(2):25,50,41,\\;comment\n"
447 verify_reg(hkey
, "Wine11a", REG_EXPAND_SZ
, "%PATH%", 7, 0);
448 verify_reg(hkey
, "Wine11b", REG_EXPAND_SZ
, "%PATH%", 7, 0);
449 verify_reg(hkey
, "Wine11c", REG_EXPAND_SZ
, "%PATH%", 7, 0);
451 size
= sizeof(buffer
);
452 lr
= RegQueryValueExA(hkey
, "Wine11d", 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");
458 size
= sizeof(buffer
);
459 memset(buffer
, '-', size
);
460 lr
= RegQueryValueExA(hkey
, "Wine11e", NULL
, &type
, (BYTE
*)&buffer
, &size
);
461 ok(lr
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", lr
);
462 ok(type
== REG_EXPAND_SZ
, "got wrong type %u, expected %u\n", type
, REG_EXPAND_SZ
);
463 ok(size
== 6 || broken(size
== 5) /* Win2k */, "got wrong size %u, expected 6\n", size
);
464 ok(memcmp(buffer
, "%PATH", size
) == 0, "got wrong data\n");
466 exec_import_str("REGEDIT4\n\n"
467 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
468 "\"Wine12a\"=hex:11,22,33,44,55,66,77,88\n"
469 "\"Wine12b\"=hex:11,22,33,44,\\\n"
471 "\"Wine12c\"=hex:11,22,33,44,\\;comment\n"
474 "\"Wine12d\"=hex:11,22,33,44,\\;comment\n"
477 "\"Wine12e\"=hex:11,22,33,44,\\;comment\n"
480 hex
[0] = 0x11; hex
[1] = 0x22; hex
[2] = 0x33; hex
[3] = 0x44;
481 hex
[4] = 0x55; hex
[5] = 0x66; hex
[6] = 0x77; hex
[7] = 0x88;
482 verify_reg(hkey
, "Wine12a", REG_BINARY
, hex
, sizeof(hex
), 0);
483 verify_reg(hkey
, "Wine12b", REG_BINARY
, hex
, sizeof(hex
), 0);
484 verify_reg(hkey
, "Wine12c", REG_BINARY
, hex
, sizeof(hex
), 0);
485 verify_reg(hkey
, "Wine12d", REG_BINARY
, hex
, 6, 0);
486 verify_reg(hkey
, "Wine12e", REG_BINARY
, hex
, 6, 0);
488 /* Test import with subkeys */
489 exec_import_str("REGEDIT4\n\n"
490 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey\"1]\n"
491 "\"Wine\\\\31\"=\"Test value\"\n\n");
492 open_key(hkey
, "Subkey\"1", 0, &subkey
);
493 verify_reg(subkey
, "Wine\\31", REG_SZ
, "Test value", 11, 0);
495 delete_key(hkey
, "Subkey\"1");
497 exec_import_str("REGEDIT4\n\n"
498 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey/2]\n"
499 "\"123/\\\"4;'5\"=\"Random value name\"\n\n");
500 open_key(hkey
, "Subkey/2", 0, &subkey
);
501 verify_reg(subkey
, "123/\"4;'5", REG_SZ
, "Random value name", 18, 0);
503 delete_key(hkey
, "Subkey/2");
505 /* Test the accepted range of the hex-based data types */
506 exec_import_str("REGEDIT4\n\n"
507 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
508 "\"Wine13a\"=hex(0):56,61,6c,75,65,00\n"
509 "\"Wine13b\"=hex(10):56,61,6c,75,65,00\n"
510 "\"Wine13c\"=hex(100):56,61,6c,75,65,00\n"
511 "\"Wine13d\"=hex(1000):56,61,6c,75,65,00\n"
512 "\"Wine13e\"=hex(7fff):56,61,6c,75,65,00\n"
513 "\"Wine13f\"=hex(ffff):56,61,6c,75,65,00\n"
514 "\"Wine13g\"=hex(7fffffff):56,61,6c,75,65,00\n"
515 "\"Wine13h\"=hex(ffffffff):56,61,6c,75,65,00\n"
516 "\"Wine13i\"=hex(100000000):56,61,6c,75,65,00\n"
517 "\"Wine13j\"=hex(0x2):56,61,6c,75,65,00\n"
518 "\"Wine13k\"=hex(0X2):56,61,6c,75,65,00\n"
519 "\"Wine13l\"=hex(x2):56,61,6c,75,65,00\n\n");
520 verify_reg(hkey
, "Wine13a", REG_NONE
, "Value", 6, 0);
521 verify_reg(hkey
, "Wine13b", 0x10, "Value", 6, 0);
522 verify_reg(hkey
, "Wine13c", 0x100, "Value", 6, 0);
523 verify_reg(hkey
, "Wine13d", 0x1000, "Value", 6, 0);
524 verify_reg(hkey
, "Wine13e", 0x7fff, "Value", 6, 0);
525 verify_reg(hkey
, "Wine13f", 0xffff, "Value", 6, 0);
526 verify_reg(hkey
, "Wine13g", 0x7fffffff, "Value", 6, 0);
527 verify_reg(hkey
, "Wine13h", 0xffffffff, "Value", 6, 0);
528 verify_reg_nonexist(hkey
, "Wine13i");
529 verify_reg_nonexist(hkey
, "Wine13j");
530 verify_reg_nonexist(hkey
, "Wine13k");
531 verify_reg_nonexist(hkey
, "Wine13l");
533 exec_import_str("REGEDIT4\n\n"
534 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
535 "\"Wine14a\"=hex(7):4c,69,6e,65,20, \\\n"
536 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
537 "\"Wine14b\"=hex(7):4c,69,6e,65,20,\t\\\n"
538 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
539 verify_reg(hkey
, "Wine14a", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
540 verify_reg(hkey
, "Wine14b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
542 exec_import_str("REGEDIT4\n\n"
543 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
544 "\"Wine15\"=hex(2):25,50,41,54,48,25,00,\n\n");
545 verify_reg(hkey
, "Wine15", REG_EXPAND_SZ
, "%PATH%", 7, 0);
547 exec_import_str("REGEDIT4\n\n"
548 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
549 "\"Wine16\"=hex(2):\\\n"
550 " 25,48,4f,4d,45,25,00\n\n");
551 verify_reg(hkey
, "Wine16", REG_EXPAND_SZ
, "%HOME%", 7, 0);
553 exec_import_str("REGEDIT4\n\n"
554 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
555 "\"Wine17a\"=hex(0):56,61,6c,75,65,\\");
556 verify_reg(hkey
, "Wine17a", REG_NONE
, "Value", 5, 0);
558 exec_import_str("REGEDIT4\n\n"
559 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
560 "\"Wine17b\"=hex(2):25,50,41,54,48,25,\\");
561 verify_reg(hkey
, "Wine17b", REG_EXPAND_SZ
, "%PATH%", 7, 0);
563 exec_import_str("REGEDIT4\n\n"
564 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
565 "\"Wine17c\"=hex:11,22,33,44,55,\\");
566 verify_reg(hkey
, "Wine17c", REG_BINARY
, hex
, 5, 0);
568 exec_import_str("REGEDIT4\n\n"
569 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
570 "\"Wine17d\"=hex(7):4c,69,6e,65,\\");
571 verify_reg(hkey
, "Wine17d", REG_MULTI_SZ
, "Line", 5, 0);
573 exec_import_str("REGEDIT4\n\n"
574 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
575 "\"Wine17e\"=hex(100):56,61,6c,75,65,\\");
576 verify_reg(hkey
, "Wine17e", 0x100, "Value", 5, 0);
578 exec_import_str("REGEDIT4\n\n"
579 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
580 "\"Wine18a\"=hex(7):4c,69,6e,65,00,00\n"
581 "\"Wine18b\"=hex(7):4c,69,6e,65,20,\\\n"
582 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
583 "\"Wine18c\"=hex(7):4c,69,6e,65,20,\\;comment\n"
584 " 63,6f,6e,63,61,74,\\\n"
585 " 65,6e,61,74,69,6f,6e,00,00\n"
586 "\"Wine18d\"=hex(7):4c,69,6e,65,20,\\;comment\n"
587 " 63,6f,6e,63,61,74,\n"
588 " 65,6e,61,74,69,6f,6e,00,00\n"
589 "\"Wine18e\"=hex(7):4c,69,6e,65,20,\\\n"
590 " 63,6f,6e,63,61,74,;comment\n"
591 " 65,6e,61,74,69,6f,6e,00,00\n\n");
592 verify_reg(hkey
, "Wine18a", REG_MULTI_SZ
, "Line\0", 6, 0);
593 verify_reg(hkey
, "Wine18b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
594 verify_reg(hkey
, "Wine18c", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
596 size
= sizeof(buffer
);
597 memset(buffer
, '-', size
);
598 lr
= RegQueryValueExA(hkey
, "Wine18d", NULL
, &type
, (BYTE
*)&buffer
, &size
);
599 ok(lr
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", lr
);
600 ok(type
== REG_MULTI_SZ
, "got wrong type %u, expected %u\n", type
, REG_MULTI_SZ
);
601 ok(size
== 12 || broken(size
== 11) /* Win2k */, "got wrong size %u, expected 12\n", size
);
602 ok(memcmp(buffer
, "Line concat", size
) == 0, "got wrong data\n");
604 size
= sizeof(buffer
);
605 memset(buffer
, '-', size
);
606 lr
= RegQueryValueExA(hkey
, "Wine18e", NULL
, &type
, (BYTE
*)&buffer
, &size
);
607 ok(lr
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", lr
);
608 ok(type
== REG_MULTI_SZ
, "got wrong type %u, expected %u\n", type
, REG_MULTI_SZ
);
609 ok(size
== 12 || broken(size
== 11) /* Win2k */, "got wrong size %u, expected 12\n", size
);
610 ok(memcmp(buffer
, "Line concat", size
) == 0, "got wrong data\n");
612 exec_import_str("REGEDIT4\n\n"
613 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
614 "\"Wine19a\"=hex(100):25,50,41,54,48,25,00\n"
615 "\"Wine19b\"=hex(100):25,50,41,\\\n"
617 "\"Wine19c\"=hex(100):25,50,41,\\;comment\n"
620 "\"Wine19d\"=hex(100):25,50,41,\\;comment\n"
623 "\"Wine19e\"=hex(100):25,50,41,\\;comment\n"
626 verify_reg(hkey
, "Wine19a", 0x100, "%PATH%", 7, 0);
627 verify_reg(hkey
, "Wine19b", 0x100, "%PATH%", 7, 0);
628 verify_reg(hkey
, "Wine19c", 0x100, "%PATH%", 7, 0);
629 verify_reg(hkey
, "Wine19d", 0x100, "%PATH", 5, 0);
630 verify_reg(hkey
, "Wine19e", 0x100, "%PATH", 5, 0);
632 /* Test null-termination of REG_EXPAND_SZ and REG_MULTI_SZ data*/
633 exec_import_str("REGEDIT4\n\n"
634 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
635 "\"Wine20a\"=hex(7):4c,69,6e,65\n"
636 "\"Wine20b\"=hex(7):4c,69,6e,65,\n"
637 "\"Wine20c\"=hex(7):4c,69,6e,65,00\n"
638 "\"Wine20d\"=hex(7):4c,69,6e,65,00,\n"
639 "\"Wine20e\"=hex(7):4c,69,6e,65,00,00\n"
640 "\"Wine20f\"=hex(7):4c,69,6e,65,00,00,\n\n");
641 verify_reg(hkey
, "Wine20a", REG_MULTI_SZ
, "Line", 5, 0);
642 verify_reg(hkey
, "Wine20b", REG_MULTI_SZ
, "Line", 5, 0);
643 verify_reg(hkey
, "Wine20c", REG_MULTI_SZ
, "Line", 5, 0);
644 verify_reg(hkey
, "Wine20d", REG_MULTI_SZ
, "Line", 5, 0);
645 verify_reg(hkey
, "Wine20e", REG_MULTI_SZ
, "Line\0", 6, 0);
646 verify_reg(hkey
, "Wine20f", REG_MULTI_SZ
, "Line\0", 6, 0);
648 exec_import_str("REGEDIT4\n\n"
649 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
650 "\"Wine21a\"=hex(2):25,50,41,54,48,25\n"
651 "\"Wine21b\"=hex(2):25,50,41,54,48,25,\n"
652 "\"Wine21c\"=hex(2):25,50,41,54,48,25,00\n"
653 "\"Wine21d\"=hex(2):25,50,41,54,48,25,00,\n\n");
654 verify_reg(hkey
, "Wine21a", REG_EXPAND_SZ
, "%PATH%", 7, 0);
655 verify_reg(hkey
, "Wine21b", REG_EXPAND_SZ
, "%PATH%", 7, 0);
656 verify_reg(hkey
, "Wine21c", REG_EXPAND_SZ
, "%PATH%", 7, 0);
657 verify_reg(hkey
, "Wine21d", REG_EXPAND_SZ
, "%PATH%", 7, 0);
659 exec_import_str("REGEDIT4\n\n"
660 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
661 "\"Wine22a\"=hex(1):\n"
662 "\"Wine22b\"=hex(2):\n"
663 "\"Wine22c\"=hex(3):\n"
664 "\"Wine22d\"=hex(4):\n"
665 "\"Wine22e\"=hex(7):\n"
666 "\"Wine22f\"=hex(100):\n"
667 "\"Wine22g\"=hex(abcd):\n"
669 "\"Wine22i\"=hex(0):\n\n");
670 verify_reg(hkey
, "Wine22a", REG_SZ
, NULL
, 0, 0);
671 verify_reg(hkey
, "Wine22b", REG_EXPAND_SZ
, NULL
, 0, 0);
672 verify_reg(hkey
, "Wine22c", REG_BINARY
, NULL
, 0, 0);
673 verify_reg(hkey
, "Wine22d", REG_DWORD
, NULL
, 0, 0);
674 verify_reg(hkey
, "Wine22e", REG_MULTI_SZ
, NULL
, 0, 0);
675 verify_reg(hkey
, "Wine22f", 0x100, NULL
, 0, 0);
676 verify_reg(hkey
, "Wine22g", 0xabcd, NULL
, 0, 0);
677 verify_reg(hkey
, "Wine22h", REG_BINARY
, NULL
, 0, 0);
678 verify_reg(hkey
, "Wine22i", REG_NONE
, NULL
, 0, 0);
680 /* Test with escaped null characters */
681 exec_import_str("REGEDIT4\n\n"
682 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
683 "\"Wine23a\"=\"\\\\0\"\n"
684 "\"Wine23b\"=\"\\\\0\\\\0\"\n"
685 "\"Wine23c\"=\"Value1\\\\0\"\n"
686 "\"Wine23d\"=\"Value2\\\\0\\\\0\\\\0\\\\0\"\n"
687 "\"Wine23e\"=\"Value3\\\\0Value4\"\n"
688 "\"Wine23f\"=\"\\\\0Value5\"\n\n");
689 verify_reg(hkey
, "Wine23a", REG_SZ
, "\\0", 3, 0);
690 verify_reg(hkey
, "Wine23b", REG_SZ
, "\\0\\0", 5, 0);
691 verify_reg(hkey
, "Wine23c", REG_SZ
, "Value1\\0", 9, 0);
692 verify_reg(hkey
, "Wine23d", REG_SZ
, "Value2\\0\\0\\0\\0", 15, 0);
693 verify_reg(hkey
, "Wine23e", REG_SZ
, "Value3\\0Value4", 15, 0);
694 verify_reg(hkey
, "Wine23f", REG_SZ
, "\\0Value5", 9, 0);
696 /* Test forward and back slashes */
697 exec_import_str("REGEDIT4\n\n"
698 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
699 "\"count/up\"=\"one/two/three\"\n"
700 "\"\\\\foo\\\\bar\"=\"\"\n\n"
701 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\https://winehq.org]\n\n");
702 verify_reg(hkey
, "count/up", REG_SZ
, "one/two/three", 14, 0);
703 verify_reg(hkey
, "\\foo\\bar", REG_SZ
, "", 1, 0);
704 verify_key(hkey
, "https://winehq.org");
708 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
711 static void test_basic_import_unicode(void)
714 DWORD dword
= 0x17, type
, size
;
715 char exp_binary
[] = {0xAA,0xBB,0xCC,0x11};
720 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
721 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
723 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
724 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
725 "\"TestValue\"=\"AValue\"\n");
726 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
727 verify_reg(hkey
, "TestValue", REG_SZ
, "AValue", 7, 0);
729 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
730 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
731 "\"TestValue2\"=\"BValue\"\r\n");
732 verify_reg(hkey
, "TestValue2", REG_SZ
, "BValue", 7, 0);
734 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
735 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
736 "\"TestValue3\"=\"Value\"\n");
737 verify_reg(hkey
, "TestValue3", REG_SZ
, "Value", 6, 0);
739 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\r\r"
740 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r"
741 "\"TestValue4\"=\"DValue\"\r");
742 verify_reg(hkey
, "TestValue4", REG_SZ
, "DValue", 7, 0);
744 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\r\r"
745 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r"
746 "\"TestValue5\"=\"Value\"\r");
747 verify_reg(hkey
, "TestValue5", REG_SZ
, "Value", 6, 0);
749 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
750 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
751 "\"TestDword\"=dword:00000017\n");
752 verify_reg(hkey
, "TestDword", REG_DWORD
, &dword
, sizeof(dword
), 0);
754 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
755 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
756 "\"TestBinary\"=hex:aa,bb,cc,11\n");
757 verify_reg(hkey
, "TestBinary", REG_BINARY
, exp_binary
, sizeof(exp_binary
), 0);
759 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
760 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
761 "\"With=Equals\"=\"asdf\"\n");
762 verify_reg(hkey
, "With=Equals", REG_SZ
, "asdf", 5, 0);
764 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
765 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
766 "\"Empty string\"=\"\"\n"
767 "\"\"=\"Default registry value\"\n\n");
768 verify_reg(hkey
, "Empty string", REG_SZ
, "", 1, 0);
769 verify_reg(hkey
, NULL
, REG_SZ
, "Default registry value", 23, 0);
771 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
772 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
773 "\"Line1\"=\"Value1\"\n\n"
774 "\"Line2\"=\"Value2\"\n\n\n"
775 "\"Line3\"=\"Value3\"\n\n\n\n"
776 "\"Line4\"=\"Value4\"\n\n");
777 verify_reg(hkey
, "Line1", REG_SZ
, "Value1", 7, 0);
778 verify_reg(hkey
, "Line2", REG_SZ
, "Value2", 7, 0);
779 verify_reg(hkey
, "Line3", REG_SZ
, "Value3", 7, 0);
780 verify_reg(hkey
, "Line4", REG_SZ
, "Value4", 7, 0);
782 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
783 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
784 "\"Wine1\"=dword:00000782\n\n"
785 "\"Wine2\"=\"Test Value\"\n"
786 "\"Wine3\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
787 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
788 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
792 "\"Wine4\"=dword:12345678\n\n");
794 verify_reg(hkey
, "Wine1", REG_DWORD
, &dword
, sizeof(dword
), 0);
795 verify_reg(hkey
, "Wine2", REG_SZ
, "Test Value", 11, 0);
796 verify_reg(hkey
, "Wine3", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
797 verify_reg(hkey
, "", REG_SZ
, "Test", 5, 0);
799 verify_reg(hkey
, "Wine4", REG_DWORD
, &dword
, sizeof(dword
), 0);
801 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
802 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
803 "\"Wine5\"=\"No newline\"");
804 verify_reg(hkey
, "Wine5", REG_SZ
, "No newline", 11, 0);
806 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
807 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
808 "\"Wine6\"=dword:00000050\n\n"
809 "\"Wine7\"=\"No newline\"");
811 verify_reg(hkey
, "Wine6", REG_DWORD
, &dword
, sizeof(dword
), 0);
812 verify_reg(hkey
, "Wine7", REG_SZ
, "No newline", 11, 0);
814 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
815 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
816 "\"Wine8a\"=dword:1\n"
817 "\"Wine8b\"=dword:4444\n\n");
819 verify_reg(hkey
, "Wine8a", REG_DWORD
, &dword
, sizeof(dword
), 0);
821 verify_reg(hkey
, "Wine8b", REG_DWORD
, &dword
, sizeof(dword
), 0);
823 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
824 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
825 "\"Wine9a\"=hex(2):4c,00,69,00,6e,00,65,00,00,00\n"
826 "\"Wine9b\"=\"Value 1\"\n"
827 "\"Wine9c\"=hex(2):4c,00,69,00,6e,00,65,00\\\n"
828 "\"Wine9d\"=\"Value 2\"\n"
829 "\"Wine9e\"=hex(2):4c,00,69,00,6e,00,65,00,\\\n"
830 "\"Wine9f\"=\"Value 3\"\n"
831 "\"Wine9g\"=\"Value 4\"\n\n");
832 verify_reg(hkey
, "Wine9a", REG_EXPAND_SZ
, "Line", 5, 0);
833 verify_reg(hkey
, "Wine9b", REG_SZ
, "Value 1", 8, 0);
834 verify_reg_nonexist(hkey
, "Wine9c");
835 verify_reg(hkey
, "Wine9d", REG_SZ
, "Value 2", 8, 0);
836 verify_reg_nonexist(hkey
, "Wine9e");
837 verify_reg_nonexist(hkey
, "Wine9f");
838 verify_reg(hkey
, "Wine9g", REG_SZ
, "Value 4", 8, 0);
840 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
841 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
842 "\"double\\\"quote\"=\"valid \\\"or\\\" not\"\n"
843 "\"single'quote\"=dword:00000008\n\n");
844 verify_reg(hkey
, "double\"quote", REG_SZ
, "valid \"or\" not", 15, 0);
846 verify_reg(hkey
, "single'quote", REG_DWORD
, &dword
, sizeof(dword
), 0);
848 /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
849 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
850 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
851 "\"Wine10a\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n"
852 "\"Wine10b\"=hex(0):56,00,61,00,6c,00,\\\n"
853 " 75,00,65,00,00,00\n"
854 "\"Wine10c\"=hex(0):56,00,61,00,\\;comment\n"
857 "\"Wine10d\"=hex(0):56,00,61,00,\\;comment\n"
860 "\"Wine10e\"=hex(0):56,00,61,00,\\;comment\n"
861 " 6c,00,75,00,;comment\n"
863 verify_reg(hkey
, "Wine10a", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
864 verify_reg(hkey
, "Wine10b", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
865 verify_reg(hkey
, "Wine10c", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
866 verify_reg(hkey
, "Wine10d", REG_NONE
, "V\0a\0l\0u", 8, 0);
867 verify_reg(hkey
, "Wine10e", REG_NONE
, "V\0a\0l\0u", 8, 0);
869 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
870 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
871 "\"Wine11a\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
872 "\"Wine11b\"=hex(2):25,00,50,00,41,00,\\\n"
873 " 54,00,48,00,25,00,00,00\n"
874 "\"Wine11c\"=hex(2):25,00,50,00,41,00,\\;comment\n"
877 "\"Wine11d\"=hex(2):25,00,50,00,41,00,\\;comment\n"
880 "\"Wine11e\"=hex(2):25,00,50,00,41,00,\\;comment\n"
881 " 54,00,48,00,;comment\n"
883 verify_reg(hkey
, "Wine11a", REG_EXPAND_SZ
, "%PATH%", 7, 0);
884 verify_reg(hkey
, "Wine11b", REG_EXPAND_SZ
, "%PATH%", 7, 0);
885 verify_reg(hkey
, "Wine11c", REG_EXPAND_SZ
, "%PATH%", 7, 0);
887 size
= sizeof(buffer
);
888 lr
= RegQueryValueExA(hkey
, "Wine11d", NULL
, &type
, (BYTE
*)&buffer
, &size
);
889 ok(lr
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", lr
);
890 ok(type
== REG_EXPAND_SZ
, "got wrong type %u, expected %u\n", type
, REG_EXPAND_SZ
);
891 ok(size
== 6 || broken(size
== 5) /* Win2k */, "got wrong size %u, expected 6\n", size
);
892 ok(memcmp(buffer
, "%PATH", size
) == 0, "got wrong data\n");
894 size
= sizeof(buffer
);
895 memset(buffer
, '-', size
);
896 lr
= RegQueryValueExA(hkey
, "Wine11e", NULL
, &type
, (BYTE
*)&buffer
, &size
);
897 ok(lr
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", lr
);
898 ok(type
== REG_EXPAND_SZ
, "got wrong type %u, expected %u\n", type
, REG_EXPAND_SZ
);
899 ok(size
== 6 || broken(size
== 5) /* Win2k */, "got wrong size %u, expected 6\n", size
);
900 ok(memcmp(buffer
, "%PATH", size
) == 0, "got wrong data\n");
902 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
903 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
904 "\"Wine12a\"=hex:11,22,33,44,55,66,77,88\n"
905 "\"Wine12b\"=hex:11,22,33,44,\\\n"
907 "\"Wine12c\"=hex:11,22,33,44,\\;comment\n"
910 "\"Wine12d\"=hex:11,22,33,44,\\;comment\n"
913 "\"Wine12e\"=hex:11,22,33,44,\\;comment\n"
916 hex
[0] = 0x11; hex
[1] = 0x22; hex
[2] = 0x33; hex
[3] = 0x44;
917 hex
[4] = 0x55; hex
[5] = 0x66; hex
[6] = 0x77; hex
[7] = 0x88;
918 verify_reg(hkey
, "Wine12a", REG_BINARY
, hex
, sizeof(hex
), 0);
919 verify_reg(hkey
, "Wine12b", REG_BINARY
, hex
, sizeof(hex
), 0);
920 verify_reg(hkey
, "Wine12c", REG_BINARY
, hex
, sizeof(hex
), 0);
921 verify_reg(hkey
, "Wine12d", REG_BINARY
, hex
, 6, 0);
922 verify_reg(hkey
, "Wine12e", REG_BINARY
, hex
, 6, 0);
924 /* Test import with subkeys */
925 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
926 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey\"1]\n"
927 "\"Wine\\\\31\"=\"Test value\"\n\n");
928 open_key(hkey
, "Subkey\"1", 0, &subkey
);
929 verify_reg(subkey
, "Wine\\31", REG_SZ
, "Test value", 11, 0);
931 delete_key(hkey
, "Subkey\"1");
933 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
934 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey/2]\n"
935 "\"123/\\\"4;'5\"=\"Random value name\"\n\n");
936 open_key(hkey
, "Subkey/2", 0, &subkey
);
937 verify_reg(subkey
, "123/\"4;'5", REG_SZ
, "Random value name", 18, 0);
939 delete_key(hkey
, "Subkey/2");
941 /* Test the accepted range of the hex-based data types */
942 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
943 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
944 "\"Wine13a\"=hex(0):56,61,6c,75,65,00\n"
945 "\"Wine13b\"=hex(10):56,61,6c,75,65,00\n"
946 "\"Wine13c\"=hex(100):56,61,6c,75,65,00\n"
947 "\"Wine13d\"=hex(1000):56,61,6c,75,65,00\n"
948 "\"Wine13e\"=hex(7fff):56,61,6c,75,65,00\n"
949 "\"Wine13f\"=hex(ffff):56,61,6c,75,65,00\n"
950 "\"Wine13g\"=hex(7fffffff):56,61,6c,75,65,00\n"
951 "\"Wine13h\"=hex(ffffffff):56,61,6c,75,65,00\n"
952 "\"Wine13i\"=hex(100000000):56,61,6c,75,65,00\n"
953 "\"Wine13j\"=hex(0x2):56,61,6c,75,65,00\n"
954 "\"Wine13k\"=hex(0X2):56,61,6c,75,65,00\n"
955 "\"Wine13l\"=hex(x2):56,61,6c,75,65,00\n\n");
956 verify_reg(hkey
, "Wine13a", REG_NONE
, "Value", 6, 0);
957 verify_reg(hkey
, "Wine13b", 0x10, "Value", 6, 0);
958 verify_reg(hkey
, "Wine13c", 0x100, "Value", 6, 0);
959 verify_reg(hkey
, "Wine13d", 0x1000, "Value", 6, 0);
960 verify_reg(hkey
, "Wine13e", 0x7fff, "Value", 6, 0);
961 verify_reg(hkey
, "Wine13f", 0xffff, "Value", 6, 0);
962 verify_reg(hkey
, "Wine13g", 0x7fffffff, "Value", 6, 0);
963 verify_reg(hkey
, "Wine13h", 0xffffffff, "Value", 6, 0);
964 verify_reg_nonexist(hkey
, "Wine13i");
965 verify_reg_nonexist(hkey
, "Wine13j");
966 verify_reg_nonexist(hkey
, "Wine13k");
967 verify_reg_nonexist(hkey
, "Wine13l");
969 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
970 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
971 "\"Wine14a\"=hex(7):4c,00,69,00,6e,00,65,00,20,00, \\\n"
972 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
973 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
974 "\"Wine14b\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\t\\\n"
975 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
976 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
977 verify_reg(hkey
, "Wine14a", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
978 verify_reg(hkey
, "Wine14b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
980 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
981 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
982 "\"Wine15\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00,\n\n");
983 verify_reg(hkey
, "Wine15", REG_EXPAND_SZ
, "%PATH%", 7, 0);
985 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
986 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
987 "\"Wine16\"=hex(2):\\\n"
988 " 25,00,48,00,4f,00,4d,00,45,00,25,00,00,00\n\n");
989 verify_reg(hkey
, "Wine16", REG_EXPAND_SZ
, "%HOME%", 7, 0);
991 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
992 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
993 "\"Wine17a\"=hex(0):56,61,6c,75,65,\\");
994 verify_reg(hkey
, "Wine17a", REG_NONE
, "Value", 5, 0);
996 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
997 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
998 "\"Wine17b\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,\\");
999 verify_reg(hkey
, "Wine17b", REG_EXPAND_SZ
, "%PATH%", 7, 0);
1001 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1002 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1003 "\"Wine17c\"=hex:11,22,33,44,55,\\");
1004 verify_reg(hkey
, "Wine17c", REG_BINARY
, hex
, 5, 0);
1006 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1007 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1008 "\"Wine17d\"=hex(7):4c,00,69,00,6e,00,65,00,\\");
1009 verify_reg(hkey
, "Wine17d", REG_MULTI_SZ
, "Line", 5, 0);
1011 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1012 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1013 "\"Wine17e\"=hex(100):56,61,6c,75,65,\\");
1014 verify_reg(hkey
, "Wine17e", 0x100, "Value", 5, 0);
1016 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1017 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1018 "\"Wine18a\"=hex(7):4c,00,69,00,6e,00,65,00,00,00,00,00\n"
1019 "\"Wine18b\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
1020 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
1021 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
1022 "\"Wine18c\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\;comment\n"
1023 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
1024 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
1025 "\"Wine18d\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\;comment\n"
1026 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\n"
1027 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
1028 "\"Wine18e\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
1029 " 63,00,6f,00,6e,00,63,00,61,00,74,00,;comment\n"
1030 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
1031 verify_reg(hkey
, "Wine18a", REG_MULTI_SZ
, "Line\0", 6, 0);
1032 verify_reg(hkey
, "Wine18b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1033 verify_reg(hkey
, "Wine18c", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
1035 size
= sizeof(buffer
);
1036 memset(buffer
, '-', size
);
1037 lr
= RegQueryValueExA(hkey
, "Wine18d", NULL
, &type
, (BYTE
*)&buffer
, &size
);
1038 ok(lr
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", lr
);
1039 ok(type
== REG_MULTI_SZ
, "got wrong type %u, expected %u\n", type
, REG_MULTI_SZ
);
1040 ok(size
== 12 || broken(size
== 11) /* Win2k */, "got wrong size %u, expected 12\n", size
);
1041 ok(memcmp(buffer
, "Line concat", size
) == 0, "got wrong data\n");
1043 size
= sizeof(buffer
);
1044 memset(buffer
, '-', size
);
1045 lr
= RegQueryValueExA(hkey
, "Wine18e", NULL
, &type
, (BYTE
*)&buffer
, &size
);
1046 ok(lr
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", lr
);
1047 ok(type
== REG_MULTI_SZ
, "got wrong type %u, expected %u\n", type
, REG_MULTI_SZ
);
1048 ok(size
== 12 || broken(size
== 11) /* Win2k */, "got wrong size %u, expected 12\n", size
);
1049 ok(memcmp(buffer
, "Line concat", size
) == 0, "got wrong data\n");
1051 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1052 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1053 "\"Wine19a\"=hex(100):25,50,41,54,48,25,00\n"
1054 "\"Wine19b\"=hex(100):25,50,41,\\\n"
1056 "\"Wine19c\"=hex(100):25,50,41,\\;comment\n"
1059 "\"Wine19d\"=hex(100):25,50,41,\\;comment\n"
1062 "\"Wine19e\"=hex(100):25,50,41,\\;comment\n"
1065 verify_reg(hkey
, "Wine19a", 0x100, "%PATH%", 7, 0);
1066 verify_reg(hkey
, "Wine19b", 0x100, "%PATH%", 7, 0);
1067 verify_reg(hkey
, "Wine19c", 0x100, "%PATH%", 7, 0);
1068 verify_reg(hkey
, "Wine19d", 0x100, "%PATH", 5, 0);
1069 verify_reg(hkey
, "Wine19e", 0x100, "%PATH", 5, 0);
1071 /* Test null-termination of REG_EXPAND_SZ and REG_MULTI_SZ data*/
1072 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1073 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1074 "\"Wine20a\"=hex(7):4c,00,69,00,6e,00,65,00\n"
1075 "\"Wine20b\"=hex(7):4c,00,69,00,6e,00,65,00,\n"
1076 "\"Wine20c\"=hex(7):4c,00,69,00,6e,00,65,00,00,00\n"
1077 "\"Wine20d\"=hex(7):4c,00,69,00,6e,00,65,00,00,00,\n"
1078 "\"Wine20e\"=hex(7):4c,00,69,00,6e,00,65,00,00,00,00,00\n"
1079 "\"Wine20f\"=hex(7):4c,00,69,00,6e,00,65,00,00,00,00,00,\n\n");
1080 verify_reg(hkey
, "Wine20a", REG_MULTI_SZ
, "Line", 5, 0);
1081 verify_reg(hkey
, "Wine20b", REG_MULTI_SZ
, "Line", 5, 0);
1082 verify_reg(hkey
, "Wine20c", REG_MULTI_SZ
, "Line", 5, 0);
1083 verify_reg(hkey
, "Wine20d", REG_MULTI_SZ
, "Line", 5, 0);
1084 verify_reg(hkey
, "Wine20e", REG_MULTI_SZ
, "Line\0", 6, 0);
1085 verify_reg(hkey
, "Wine20f", REG_MULTI_SZ
, "Line\0", 6, 0);
1087 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1088 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1089 "\"Wine21a\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00\n"
1090 "\"Wine21b\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,\n"
1091 "\"Wine21c\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
1092 "\"Wine21d\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00,\n\n");
1093 verify_reg(hkey
, "Wine21a", REG_EXPAND_SZ
, "%PATH%", 7, 0);
1094 verify_reg(hkey
, "Wine21b", REG_EXPAND_SZ
, "%PATH%", 7, 0);
1095 verify_reg(hkey
, "Wine21c", REG_EXPAND_SZ
, "%PATH%", 7, 0);
1096 verify_reg(hkey
, "Wine21d", REG_EXPAND_SZ
, "%PATH%", 7, 0);
1098 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1099 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1100 "\"Wine22a\"=hex(1):\n"
1101 "\"Wine22b\"=hex(2):\n"
1102 "\"Wine22c\"=hex(3):\n"
1103 "\"Wine22d\"=hex(4):\n"
1104 "\"Wine22e\"=hex(7):\n"
1105 "\"Wine22f\"=hex(100):\n"
1106 "\"Wine22g\"=hex(abcd):\n"
1107 "\"Wine22h\"=hex:\n"
1108 "\"Wine22i\"=hex(0):\n\n");
1109 verify_reg(hkey
, "Wine22a", REG_SZ
, NULL
, 0, 0);
1110 verify_reg(hkey
, "Wine22b", REG_EXPAND_SZ
, NULL
, 0, 0);
1111 verify_reg(hkey
, "Wine22c", REG_BINARY
, NULL
, 0, 0);
1112 verify_reg(hkey
, "Wine22d", REG_DWORD
, NULL
, 0, 0);
1113 verify_reg(hkey
, "Wine22e", REG_MULTI_SZ
, NULL
, 0, 0);
1114 verify_reg(hkey
, "Wine22f", 0x100, NULL
, 0, 0);
1115 verify_reg(hkey
, "Wine22g", 0xabcd, NULL
, 0, 0);
1116 verify_reg(hkey
, "Wine22h", REG_BINARY
, NULL
, 0, 0);
1117 verify_reg(hkey
, "Wine22i", REG_NONE
, NULL
, 0, 0);
1119 /* Test with escaped null characters */
1120 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1121 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1122 "\"Wine23a\"=\"\\\\0\"\n"
1123 "\"Wine23b\"=\"\\\\0\\\\0\"\n"
1124 "\"Wine23c\"=\"Value1\\\\0\"\n"
1125 "\"Wine23d\"=\"Value2\\\\0\\\\0\\\\0\\\\0\"\n"
1126 "\"Wine23e\"=\"Value3\\\\0Value4\"\n"
1127 "\"Wine23f\"=\"\\\\0Value5\"\n\n");
1128 verify_reg(hkey
, "Wine23a", REG_SZ
, "\\0", 3, 0);
1129 verify_reg(hkey
, "Wine23b", REG_SZ
, "\\0\\0", 5, 0);
1130 verify_reg(hkey
, "Wine23c", REG_SZ
, "Value1\\0", 9, 0);
1131 verify_reg(hkey
, "Wine23d", REG_SZ
, "Value2\\0\\0\\0\\0", 15, 0);
1132 verify_reg(hkey
, "Wine23e", REG_SZ
, "Value3\\0Value4", 15, 0);
1133 verify_reg(hkey
, "Wine23f", REG_SZ
, "\\0Value5", 9, 0);
1135 /* Test forward and back slashes */
1136 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1137 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1138 "\"count/up\"=\"one/two/three\"\n"
1139 "\"\\\\foo\\\\bar\"=\"\"\n\n"
1140 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\https://winehq.org]\n\n");
1141 verify_reg(hkey
, "count/up", REG_SZ
, "one/two/three", 14, 0);
1142 verify_reg(hkey
, "\\foo\\bar", REG_SZ
, "", 1, 0);
1143 verify_key(hkey
, "https://winehq.org");
1147 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
1150 static void test_basic_import_31(void)
1155 RegCreateKeyExA(HKEY_CLASSES_ROOT
, KEY_BASE
, 0, NULL
, REG_OPTION_NON_VOLATILE
,
1156 KEY_READ
|KEY_SET_VALUE
, NULL
, &hkey
, &dispos
);
1158 if (dispos
== REG_OPENED_EXISTING_KEY
)
1159 delete_value(hkey
, NULL
);
1161 /* Test simple value */
1162 exec_import_str("REGEDIT\r\n"
1163 "HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value0\r\n");
1164 verify_reg(hkey
, "", REG_SZ
, "Value0", 7, 0);
1166 /* Test proper handling of spaces and equals signs */
1167 exec_import_str("REGEDIT\r\n"
1168 "HKEY_CLASSES_ROOT\\" KEY_BASE
" =Value1\r\n");
1169 verify_reg(hkey
, "", REG_SZ
, "Value1", 7, 0);
1171 exec_import_str("REGEDIT\r\n"
1172 "HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value2\r\n");
1173 verify_reg(hkey
, "", REG_SZ
, " Value2", 8, 0);
1175 exec_import_str("REGEDIT\r\n"
1176 "HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value3 \r\n");
1177 verify_reg(hkey
, "", REG_SZ
, "Value3 ", 8, 0);
1179 exec_import_str("REGEDIT\r\n"
1180 "HKEY_CLASSES_ROOT\\" KEY_BASE
" Value4\r\n");
1181 verify_reg(hkey
, "", REG_SZ
, "Value4", 7, 0);
1183 exec_import_str("REGEDIT\r\n"
1184 "HKEY_CLASSES_ROOT\\" KEY_BASE
" Value5\r\n");
1185 verify_reg(hkey
, "", REG_SZ
, "Value5", 7, 0);
1187 exec_import_str("REGEDIT\r\n"
1188 "HKEY_CLASSES_ROOT\\" KEY_BASE
"\r\n");
1189 verify_reg(hkey
, "", REG_SZ
, "", 1, 0);
1191 exec_import_str("REGEDIT\r\n"
1192 "HKEY_CLASSES_ROOT\\" KEY_BASE
" \r\n");
1193 verify_reg(hkey
, "", REG_SZ
, "", 1, 0);
1195 exec_import_str("REGEDIT\r\n"
1196 "HKEY_CLASSES_ROOT\\" KEY_BASE
" = No newline");
1197 verify_reg(hkey
, "", REG_SZ
, "No newline", 11, 0);
1201 delete_key(HKEY_CLASSES_ROOT
, KEY_BASE
);
1204 static void test_invalid_import(void)
1209 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
1210 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
1212 exec_import_str("REGEDIT4\n\n"
1213 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1214 "\"TestNoEndQuote\"=\"Asdffdsa\n");
1215 open_key(HKEY_CURRENT_USER
, KEY_BASE
, KEY_SET_VALUE
, &hkey
);
1216 verify_reg_nonexist(hkey
, "TestNoEndQuote");
1218 exec_import_str("REGEDIT4\n\n"
1219 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1220 "\"TestNoBeginQuote\"=Asdffdsa\"\n");
1221 verify_reg_nonexist(hkey
, "TestNoBeginQuote");
1223 exec_import_str("REGEDIT4\n\n"
1224 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1225 "\"TestNoQuotes\"=Asdffdsa\n");
1226 verify_reg_nonexist(hkey
, "TestNoQuotes");
1228 exec_import_str("REGEDIT4\n\n"
1229 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1230 "\"NameNoEndQuote=\"Asdffdsa\"\n");
1231 verify_reg_nonexist(hkey
, "NameNoEndQuote");
1233 exec_import_str("REGEDIT4\n\n"
1234 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1235 "NameNoBeginQuote\"=\"Asdffdsa\"\n");
1236 verify_reg_nonexist(hkey
, "NameNoBeginQuote");
1238 exec_import_str("REGEDIT4\n\n"
1239 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1240 "NameNoQuotes=\"Asdffdsa\"\n");
1241 verify_reg_nonexist(hkey
, "NameNoQuotes");
1243 exec_import_str("REGEDIT4\n\n"
1244 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1245 "\"MixedQuotes=Asdffdsa\"\n");
1246 verify_reg_nonexist(hkey
, "MixedQuotes");
1247 verify_reg_nonexist(hkey
, "MixedQuotes=Asdffdsa");
1249 /* Test import with non-standard registry file headers */
1250 exec_import_str("REGEDIT3\n\n"
1251 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1252 "\"Test1\"=\"Value\"\n");
1253 verify_reg_nonexist(hkey
, "Test1");
1255 exec_import_str("regedit4\n\n"
1256 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1257 "\"Test2\"=\"Value\"\n");
1258 verify_reg_nonexist(hkey
, "Test2");
1260 exec_import_str("Regedit4\n\n"
1261 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1262 "\"Test3\"=\"Value\"\n");
1263 verify_reg_nonexist(hkey
, "Test3");
1265 exec_import_str("REGEDIT 4\n\n"
1266 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1267 "\"Test4\"=\"Value\"\n");
1268 verify_reg_nonexist(hkey
, "Test4");
1270 exec_import_str("REGEDIT4FOO\n\n"
1271 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1272 "\"Test5\"=\"Value\"\n");
1273 verify_reg_nonexist(hkey
, "Test5");
1275 exec_import_str("REGEDIT4 FOO\n\n"
1276 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1277 "\"Test6\"=\"Value\"\n");
1278 verify_reg_nonexist(hkey
, "Test6");
1280 exec_import_str("REGEDIT5\n\n"
1281 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1282 "\"Test7\"=\"Value\"\n");
1283 verify_reg_nonexist(hkey
, "Test7");
1285 exec_import_str("Windows Registry Editor Version 4.00\n\n"
1286 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1287 "\"Test8\"=\"Value\"\n");
1288 verify_reg_nonexist(hkey
, "Test8");
1290 exec_import_str("Windows Registry Editor Version 5\n\n"
1291 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1292 "\"Test9\"=\"Value\"\n");
1293 verify_reg_nonexist(hkey
, "Test9");
1295 exec_import_str("WINDOWS REGISTRY EDITOR VERSION 5.00\n\n"
1296 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1297 "\"Test10\"=\"Value\"\n");
1298 verify_reg_nonexist(hkey
, "Test10");
1300 exec_import_str("Windows Registry Editor version 5.00\n\n"
1301 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1302 "\"Test11\"=\"Value\"\n");
1303 verify_reg_nonexist(hkey
, "Test11");
1305 /* Test multi-line import with incorrect comma placement */
1306 exec_import_str("REGEDIT4\n\n"
1307 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1308 "\"Multi-Line1\"=hex(7):4c,69,6e,65,20\\\n"
1309 ",63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1310 verify_reg_nonexist(hkey
, "Multi-Line1");
1312 exec_import_str("REGEDIT4\n\n"
1313 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1314 "\"Multi-Line2\"=hex(7):4c,69,6e,65,20\\\n"
1315 " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1316 verify_reg_nonexist(hkey
, "Multi-Line2");
1318 exec_import_str("Windows Registry Editor Version 5.00\n\n"
1319 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1320 "\"Multi-Line3\"=hex(7):4c,69,6e,65,20\\\n"
1321 ",63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1322 verify_reg_nonexist(hkey
, "Multi-Line3");
1324 exec_import_str("Windows Registry Editor Version 5.00\n\n"
1325 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1326 "\"Multi-Line4\"=hex(7):4c,69,6e,65,20\\\n"
1327 " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1328 verify_reg_nonexist(hkey
, "Multi-Line4");
1330 exec_import_str("REGEDIT4\n\n"
1331 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1332 "\"Test12a\"=dword:\n"
1333 "\"Test12b\"=dword:hello\n"
1334 "\"Test12c\"=dword:123456789\n"
1335 "\"Test12d\"=dword:012345678\n"
1336 "\"Test12e\"=dword:000000001\n\n");
1337 verify_reg_nonexist(hkey
, "Test12a");
1338 verify_reg_nonexist(hkey
, "Test12b");
1339 verify_reg_nonexist(hkey
, "Test12c");
1340 verify_reg_nonexist(hkey
, "Test12d");
1341 verify_reg_nonexist(hkey
, "Test12e");
1343 exec_import_str("REGEDIT4\n\n"
1344 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1345 "\"Test13a\"=dword:12345678abc\n"
1346 "\"Test13b\"=dword:12345678 abc\n\n");
1347 verify_reg_nonexist(hkey
, "Test13a");
1348 verify_reg_nonexist(hkey
, "Test13b");
1350 exec_import_str("REGEDIT4\n\n"
1351 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1352 "\"Test14a\"=dword:0x123\n"
1353 "\"Test14b\"=dword:123 456\n"
1354 "\"Test14c\"=dword:1234 5678\n\n");
1355 verify_reg_nonexist(hkey
, "Test14a");
1356 verify_reg_nonexist(hkey
, "Test14b");
1357 verify_reg_nonexist(hkey
, "Test14c");
1359 exec_import_str("REGEDIT4\n\n"
1360 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1361 "\"Test15a\"=\"foo\"bar\"\n"
1362 "\"Test15b\"=\"foo\"\"bar\"\n\n");
1363 verify_reg_nonexist(hkey
, "Test15a");
1364 verify_reg_nonexist(hkey
, "Test15b");
1366 exec_import_str("REGEDIT4\n\n"
1367 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1369 "\"Test16b\"=\\\"\n"
1370 "\"Test16c\"=\\\"Value\\\"\n"
1371 "\"Test16d\"=\\\"Value\"\n\n");
1372 verify_reg_nonexist(hkey
, "Test16a");
1373 verify_reg_nonexist(hkey
, "Test16b");
1374 verify_reg_nonexist(hkey
, "Test16c");
1375 verify_reg_nonexist(hkey
, "Test16d");
1377 /* Test key name and value name concatenation */
1378 exec_import_str("REGEDIT4\n\n"
1379 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\\n"
1381 verify_key_nonexist(hkey
, "Subkey1");
1383 exec_import_str("REGEDIT4\n\n"
1384 "[HKEY_CURRENT_USER\\" KEY_BASE
"\n"
1386 verify_key_nonexist(hkey
, "Subkey2");
1388 exec_import_str("REGEDIT4\n\n"
1389 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1391 "17a\"=\"Value 1\"\n"
1392 "\"Test17b\"=\"Value 2\"\n"
1394 "\\17c\"=\"Value 3\"\n\n");
1395 verify_reg_nonexist(hkey
, "Test17a");
1396 verify_reg(hkey
, "Test17b", REG_SZ
, "Value 2", 8, 0);
1397 verify_reg_nonexist(hkey
, "Test17c");
1399 exec_import_str("REGEDIT4\n\n"
1400 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1401 "\"Test18a\"=dword:1234\\\n"
1403 "\"Test18b\"=\"Test \\\n"
1405 verify_reg_nonexist(hkey
, "Test18a");
1406 verify_reg_nonexist(hkey
, "Test18b");
1408 /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
1409 exec_import_str("REGEDIT4\n\n"
1410 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1411 "\"Test19a\"=hex(0):56,00,61,00,6c,00\\\n"
1412 ",75,00,65,00,00,00\n"
1413 "\"Test19b\"=hex(0):56,00,61,00,6c,00\\\n"
1414 " ,75,00,65,00,00,00\n"
1415 "\"Test19c\"=hex(0):56,00,61,00,6c,00\\\n"
1416 " 75,00,65,00,00,00\n"
1417 "\"Test19d\"=hex(0):56,00,61,00,6c,00,7\\\n"
1418 "5,00,65,00,00,00\n"
1419 "\"Test19e\"=hex(0):56,00,61,00,6c,00,7\\\n"
1420 " 5,00,65,00,00,00\n"
1421 "\"Test19f\"=hex(0):56,00,61,00,\\;comment\n"
1422 " 6c,00,75,00,\\#comment\n"
1423 " 65,00,00,00\n\n");
1424 verify_reg_nonexist(hkey
, "Test19a");
1425 verify_reg_nonexist(hkey
, "Test19b");
1426 verify_reg_nonexist(hkey
, "Test19c");
1427 verify_reg_nonexist(hkey
, "Test19d");
1428 verify_reg_nonexist(hkey
, "Test19e");
1429 verify_reg_nonexist(hkey
, "Test19f");
1431 exec_import_str("REGEDIT4\n\n"
1432 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1433 "\"Test20a\"=hex(2):25,50,41\\\n"
1435 "\"Test20b\"=hex(2):25,50,41\\\n"
1437 "\"Test20c\"=hex(2):25,50,41\\\n"
1439 "\"Test20d\"=hex(2):25,50,4\\\n"
1441 "\"Test20e\"=hex(2):25,50,4\\\n"
1443 "\"Test20f\"=hex(2):25,50,41,\\;comment\n"
1444 " 54,48,\\#comment\n"
1446 verify_reg_nonexist(hkey
, "Test20a");
1447 verify_reg_nonexist(hkey
, "Test20b");
1448 verify_reg_nonexist(hkey
, "Test20c");
1449 verify_reg_nonexist(hkey
, "Test20d");
1450 verify_reg_nonexist(hkey
, "Test20e");
1451 verify_reg_nonexist(hkey
, "Test20f");
1453 exec_import_str("REGEDIT4\n\n"
1454 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1455 "\"Test21a\"=hex:11,22,33,44\\\n"
1457 "\"Test21b\"=hex:11,22,33,44\\\n"
1459 "\"Test21c\"=hex:11,22,33,44\\\n"
1461 "\"Test21d\"=hex:11,22,33,4\\\n"
1463 "\"Test21e\"=hex:11,22,33,4\\\n"
1465 "\"Test21f\"=hex:11,22,33,\\;comment\n"
1466 " 44,55,66,\\#comment\n"
1468 verify_reg_nonexist(hkey
, "Test21a");
1469 verify_reg_nonexist(hkey
, "Test21b");
1470 verify_reg_nonexist(hkey
, "Test21c");
1471 verify_reg_nonexist(hkey
, "Test21d");
1472 verify_reg_nonexist(hkey
, "Test21e");
1473 verify_reg_nonexist(hkey
, "Test21f");
1475 /* Test support for characters greater than 0xff */
1476 exec_import_str("REGEDIT4\n\n"
1477 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1478 "\"Wine22a\"=hex(0):25,50,100,54,48,25,00\n"
1479 "\"Wine22b\"=hex(0):25,1a4,100,164,124,25,00\n\n");
1480 verify_reg_nonexist(hkey
, "Wine22a");
1481 verify_reg_nonexist(hkey
, "Wine22b");
1483 /* Test the effect of backslashes in hex data */
1484 exec_import_str("REGEDIT4\n\n"
1485 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1486 "\"Wine23a\"=hex(2):25,48\\,4f,4d,45,25,00\n"
1487 "\"Wine23b\"=hex(2):25,48,\\4f,4d,45,25,00\n"
1488 "\"Wine23c\"=hex(2):25,48\\ ,4f,4d,45,25,00\n"
1489 "\"Wine23d\"=hex(2):25,48,\\ 4f,4d,45,25,00\n"
1490 "\"Wine23e\"=hex(2):\\25,48,4f,4d,45,25,00\n"
1491 "\"Wine23f\"=hex(2):\\ 25,48,4f,4d,45,25,00\n"
1492 "\"Wine23g\"=hex(2):25,48,4\\f,4d,45,25,00\n"
1493 "\"Wine23h\"=hex(2):25,48,4\\\n"
1495 "\"Wine23i\"=hex(2):25,50,\\,41,54,48,25,00\n"
1496 "\"Wine23j\"=hex(2):25,48,4f,4d,45,25,5c,\\\\\n"
1497 " 25,50,41,54,48,25,00\n"
1498 "\"Wine23k\"=hex(2):,\\\n"
1499 " 25,48,4f,4d,45,25,00\n\n");
1500 verify_reg_nonexist(hkey
, "Wine23a");
1501 verify_reg_nonexist(hkey
, "Wine23b");
1502 verify_reg_nonexist(hkey
, "Wine23c");
1503 verify_reg_nonexist(hkey
, "Wine23d");
1504 verify_reg_nonexist(hkey
, "Wine23e");
1505 verify_reg_nonexist(hkey
, "Wine23f");
1506 verify_reg_nonexist(hkey
, "Wine23g");
1507 verify_reg_nonexist(hkey
, "Wine23h");
1508 verify_reg_nonexist(hkey
, "Wine23i");
1509 verify_reg_nonexist(hkey
, "Wine23j");
1510 verify_reg_nonexist(hkey
, "Wine23k");
1512 exec_import_str("REGEDIT4\n\n"
1513 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1514 "\"Wine24a\"=hex(2):4c,69,6e,65,20,\\\n"
1515 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1]\n");
1516 verify_reg_nonexist(hkey
, "Wine24a");
1517 verify_key_nonexist(hkey
, "Subkey1");
1519 exec_import_str("REGEDIT4\n\n"
1520 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1521 "\"Wine24b\"=hex(2):4c,69,6e,65,20\\\n"
1522 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2]\n");
1523 verify_reg_nonexist(hkey
, "Wine24b");
1524 verify_key(hkey
, "Subkey2");
1526 delete_key(hkey
, "Subkey2");
1528 exec_import_str("REGEDIT4\n\n"
1529 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1530 "\"Wine25a\"=hex(2):4c,69,6e,65,20,\\\n"
1531 "\"Wine25b\"=\"Test value\"\n"
1533 "\"Wine25c\"=hex(2):4c,69,6e,65,20,\\\n"
1535 "\"Wine25d\"=\"Test value\"\n"
1537 "\"Wine25e\"=hex(2):4c,69,6e,65,20,\\\n"
1539 "\"Wine25f\"=\"Test value\"\n"
1541 "\"Wine25g\"=hex(2):4c,69,6e,65,20,\\\n\n"
1542 "\"Wine25h\"=\"Test value\"\n"
1544 "\"Wine25i\"=hex(2):4c,69,6e,65,20\\\n"
1545 "\"Wine25j\"=\"Test value\"\n\n");
1546 verify_reg_nonexist(hkey
, "Wine25a");
1547 verify_reg_nonexist(hkey
, "Wine25b");
1548 verify_reg_nonexist(hkey
, "Wine25c");
1549 verify_reg_nonexist(hkey
, "Wine25d");
1550 verify_reg_nonexist(hkey
, "Wine25e");
1551 verify_reg(hkey
, "Wine25f", REG_SZ
, "Test value", 11, 0);
1552 verify_reg_nonexist(hkey
, "Wine25g");
1553 verify_reg_nonexist(hkey
, "Wine25h");
1554 verify_reg_nonexist(hkey
, "Wine25i");
1555 verify_reg(hkey
, "Wine25j", REG_SZ
, "Test value", 11, 0);
1557 exec_import_str("REGEDIT4\n\n"
1558 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1559 "\"Wine26a\"=hex(2):4c,69,6e,65,20,\\\n"
1560 "\"Wine26b\"=dword:00000008\n"
1562 "\"Wine26c\"=hex(2):4c,69,6e,65,20,\\\n"
1564 "\"Wine26d\"=dword:00000008\n"
1566 "\"Wine26e\"=hex(2):4c,69,6e,65,20,\\\n"
1568 "\"Wine26f\"=dword:00000008\n"
1570 "\"Wine26g\"=hex(2):4c,69,6e,65,20,\\\n\n"
1571 "\"Wine26h\"=dword:00000008\n"
1573 "\"Wine26i\"=hex(2):4c,69,6e,65,20\\\n"
1574 "\"Wine26j\"=dword:00000008\n\n");
1575 verify_reg_nonexist(hkey
, "Wine26a");
1576 verify_reg_nonexist(hkey
, "Wine26b");
1577 verify_reg_nonexist(hkey
, "Wine26c");
1578 verify_reg_nonexist(hkey
, "Wine26d");
1579 verify_reg_nonexist(hkey
, "Wine26e");
1580 verify_reg(hkey
, "Wine26f", REG_DWORD
, &dword
, sizeof(dword
), 0);
1581 verify_reg_nonexist(hkey
, "Wine26g");
1582 verify_reg_nonexist(hkey
, "Wine26h");
1583 verify_reg_nonexist(hkey
, "Wine26i");
1584 verify_reg(hkey
, "Wine26j", REG_DWORD
, &dword
, sizeof(dword
), 0);
1586 exec_import_str("REGEDIT4\n\n"
1587 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1588 "\"Wine27a\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
1589 "\"Wine27b\"=hex(2):25,50,41,54,48,25,00\n"
1591 "\"Wine27c\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
1593 "\"Wine27d\"=hex(2):25,50,41,54,48,25,00\n"
1595 "\"Wine27e\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
1597 "\"Wine27f\"=hex(2):25,50,41,54,48,25,00\n"
1599 "\"Wine27g\"=hex(2):25,48,4f,4d,45,25,5c,\\\n\n"
1600 "\"Wine27h\"=hex(2):25,50,41,54,48,25,00\n"
1602 "\"Wine27i\"=hex(2):25,48,4f,4d,45,25,5c\\\n"
1603 "\"Wine27j\"=hex(2):25,50,41,54,48,25,00\n\n");
1604 verify_reg_nonexist(hkey
, "Wine27a");
1605 verify_reg_nonexist(hkey
, "Wine27b");
1606 verify_reg_nonexist(hkey
, "Wine27c");
1607 verify_reg_nonexist(hkey
, "Wine27d");
1608 verify_reg_nonexist(hkey
, "Wine27e");
1609 verify_reg(hkey
, "Wine27f", REG_EXPAND_SZ
, "%PATH%", 7, 0);
1610 verify_reg_nonexist(hkey
, "Wine27g");
1611 verify_reg_nonexist(hkey
, "Wine27h");
1612 verify_reg_nonexist(hkey
, "Wine27i");
1613 verify_reg(hkey
, "Wine27j", REG_EXPAND_SZ
, "%PATH%", 7, 0);
1615 exec_import_str("REGEDIT4\n\n"
1616 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1617 "\"Wine28a\"=hex(2):4c,69,6e,65,20,\\\n"
1618 "@=\"Default value 1\"\n\n");
1619 verify_reg_nonexist(hkey
, "Wine28a");
1620 verify_reg_nonexist(hkey
, NULL
);
1622 exec_import_str("REGEDIT4\n\n"
1623 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1624 "\"Wine28b\"=hex(2):4c,69,6e,65,20,\\\n"
1626 "@=\"Default value 2\"\n\n");
1627 verify_reg_nonexist(hkey
, "Wine28b");
1628 verify_reg_nonexist(hkey
, NULL
);
1630 exec_import_str("REGEDIT4\n\n"
1631 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1632 "\"Wine28c\"=hex(2):4c,69,6e,65,20,\\\n"
1634 "@=\"Default value 3\"\n\n");
1635 verify_reg_nonexist(hkey
, "Wine28c");
1636 verify_reg(hkey
, NULL
, REG_SZ
, "Default value 3", 16, 0);
1638 delete_value(hkey
, NULL
);
1640 exec_import_str("REGEDIT4\n\n"
1641 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1642 "\"Wine28d\"=hex(2):4c,69,6e,65,20,\\\n\n"
1643 "@=\"Default value 4\"\n\n");
1644 verify_reg_nonexist(hkey
, "Wine28d");
1645 verify_reg_nonexist(hkey
, NULL
);
1647 exec_import_str("REGEDIT4\n\n"
1648 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1649 "\"Wine28e\"=hex(2):4c,69,6e,65,20\\\n"
1650 "@=\"Default value 5\"\n\n");
1651 verify_reg_nonexist(hkey
, "Wine28e");
1652 verify_reg(hkey
, NULL
, REG_SZ
, "Default value 5", 16, 0);
1654 exec_import_str("REGEDIT4\n\n"
1655 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1656 "\"Wine29a\"=hex:11,22,33,\\\n"
1659 "\"Wine29b\"=hex:11,22,33,\\\n"
1662 verify_reg_nonexist(hkey
, "Wine29a");
1663 verify_reg_nonexist(hkey
, "Wine29b");
1665 exec_import_str("REGEDIT4\n\n"
1666 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1667 "\"Wine30a\"=hex(0):25,48,4f,4d,45,25,5c,/\n"
1668 " 25,50,41,54,48,25,00\n"
1669 "\"Wine30b\"=hex(0):25,48,4f,4d,45,25,5c/\n"
1670 " 25,50,41,54,48,25,00\n\n");
1671 verify_reg_nonexist(hkey
, "Wine30a");
1672 verify_reg_nonexist(hkey
, "Wine30b");
1674 exec_import_str("REGEDIT4\n\n"
1675 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1676 "\"Wine31\"=hex(7):4c,69,6e,65,20\\");
1677 verify_reg_nonexist(hkey
, "Wine31");
1679 exec_import_str("REGEDIT4\n\n"
1680 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1681 "\"Wine32a\"=hex(7):4c,69,6e,65,20,\\\n"
1682 " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1683 "\"Wine32b\"=hex(7):4c,69,6e,65,20,\\\n"
1684 " 63,,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n");
1685 verify_reg_nonexist(hkey
, "Wine32a");
1686 verify_reg_nonexist(hkey
, "Wine32b");
1688 /* Test with embedded null characters */
1689 exec_import_str("REGEDIT4\n\n"
1690 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1691 "\"Wine33a\"=\"\\0\"\n"
1692 "\"Wine33b\"=\"\\0\\0\"\n"
1693 "\"Wine33c\"=\"Value1\\0\"\n"
1694 "\"Wine33d\"=\"Value2\\0\\0\\0\\0\"\n"
1695 "\"Wine33e\"=\"Value3\\0Value4\"\n"
1696 "\"Wine33f\"=\"\\0Value5\"\n\n");
1697 verify_reg_nonexist(hkey
, "Wine33a");
1698 verify_reg_nonexist(hkey
, "Wine33b");
1699 verify_reg_nonexist(hkey
, "Wine33c");
1700 verify_reg_nonexist(hkey
, "Wine33d");
1701 verify_reg_nonexist(hkey
, "Wine33e");
1702 verify_reg_nonexist(hkey
, "Wine33f");
1706 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
1709 static void test_invalid_import_unicode(void)
1714 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
1715 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
1717 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1718 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1719 "\"TestNoEndQuote\"=\"Asdffdsa\n");
1720 open_key(HKEY_CURRENT_USER
, KEY_BASE
, KEY_SET_VALUE
, &hkey
);
1721 verify_reg_nonexist(hkey
, "TestNoEndQuote");
1723 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1724 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1725 "\"TestNoBeginQuote\"=Asdffdsa\"\n");
1726 verify_reg_nonexist(hkey
, "TestNoBeginQuote");
1728 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1729 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1730 "\"TestNoQuotes\"=Asdffdsa\n");
1731 verify_reg_nonexist(hkey
, "TestNoQuotes");
1733 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1734 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1735 "\"NameNoEndQuote=\"Asdffdsa\"\n");
1736 verify_reg_nonexist(hkey
, "NameNoEndQuote");
1738 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1739 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1740 "NameNoBeginQuote\"=\"Asdffdsa\"\n");
1741 verify_reg_nonexist(hkey
, "NameNoBeginQuote");
1743 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1744 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1745 "NameNoQuotes=\"Asdffdsa\"\n");
1746 verify_reg_nonexist(hkey
, "NameNoQuotes");
1748 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1749 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1750 "\"MixedQuotes=Asdffdsa\"\n");
1751 verify_reg_nonexist(hkey
, "MixedQuotes");
1752 verify_reg_nonexist(hkey
, "MixedQuotes=Asdffdsa");
1754 /* Test import with non-standard registry file headers */
1755 exec_import_wstr("\xef\xbb\xbfREGEDIT3\n\n"
1756 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1757 "\"Test1\"=\"Value\"\n");
1758 verify_reg_nonexist(hkey
, "Test1");
1760 exec_import_wstr("\xef\xbb\xbfregedit4\n\n"
1761 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1762 "\"Test2\"=\"Value\"\n");
1763 verify_reg_nonexist(hkey
, "Test2");
1765 exec_import_wstr("\xef\xbb\xbfRegedit4\n\n"
1766 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1767 "\"Test3\"=\"Value\"\n");
1768 verify_reg_nonexist(hkey
, "Test3");
1770 exec_import_wstr("\xef\xbb\xbfREGEDIT 4\n\n"
1771 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1772 "\"Test4\"=\"Value\"\n");
1773 verify_reg_nonexist(hkey
, "Test4");
1775 exec_import_wstr("\xef\xbb\xbfREGEDIT4FOO\n\n"
1776 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1777 "\"Test5\"=\"Value\"\n");
1778 verify_reg_nonexist(hkey
, "Test5");
1780 exec_import_wstr("\xef\xbb\xbfREGEDIT4 FOO\n\n"
1781 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1782 "\"Test6\"=\"Value\"\n");
1783 verify_reg_nonexist(hkey
, "Test6");
1785 exec_import_wstr("\xef\xbb\xbfREGEDIT5\n\n"
1786 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1787 "\"Test7\"=\"Value\"\n");
1788 verify_reg_nonexist(hkey
, "Test7");
1790 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 4.00\n\n"
1791 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1792 "\"Test8\"=\"Value\"\n");
1793 verify_reg_nonexist(hkey
, "Test8");
1795 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5\n\n"
1796 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1797 "\"Test9\"=\"Value\"\n");
1798 verify_reg_nonexist(hkey
, "Test9");
1800 exec_import_wstr("\xef\xbb\xbfWINDOWS REGISTRY EDITOR VERSION 5.00\n\n"
1801 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1802 "\"Test10\"=\"Value\"\n");
1803 verify_reg_nonexist(hkey
, "Test10");
1805 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor version 5.00\n\n"
1806 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1807 "\"Test11\"=\"Value\"\n");
1808 verify_reg_nonexist(hkey
, "Test11");
1810 /* Test multi-line import with incorrect comma placement */
1811 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1812 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1813 "\"Multi-Line1\"=hex(7):4c,00,69,00,6e,00,65,00,20,00\\\n"
1814 ",63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
1815 "65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
1816 verify_reg_nonexist(hkey
, "Multi-Line1");
1818 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1819 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1820 "\"Multi-Line2\"=hex(7):4c,00,69,00,6e,00,65,00,20,00\\\n"
1821 " ,63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
1822 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
1823 verify_reg_nonexist(hkey
, "Multi-Line2");
1825 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1826 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1827 "\"Multi-Line3\"=hex(7):4c,00,69,00,6e,00,65,00,20,00\\\n"
1828 ",63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
1829 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
1830 verify_reg_nonexist(hkey
, "Multi-Line3");
1832 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1833 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1834 "\"Multi-Line4\"=hex(7):4c,00,69,00,6e,00,65,00,20,00\\\n"
1835 ", 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
1836 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
1837 verify_reg_nonexist(hkey
, "Multi-Line4");
1839 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1840 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1841 "\"Test12a\"=dword:\n"
1842 "\"Test12b\"=dword:hello\n"
1843 "\"Test12c\"=dword:123456789\n"
1844 "\"Test12d\"=dword:012345678\n"
1845 "\"Test12e\"=dword:000000001\n\n");
1846 verify_reg_nonexist(hkey
, "Test12a");
1847 verify_reg_nonexist(hkey
, "Test12b");
1848 verify_reg_nonexist(hkey
, "Test12c");
1849 verify_reg_nonexist(hkey
, "Test12d");
1850 verify_reg_nonexist(hkey
, "Test12e");
1852 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1853 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1854 "\"Test13a\"=dword:12345678abc\n"
1855 "\"Test13b\"=dword:12345678 abc\n\n");
1856 verify_reg_nonexist(hkey
, "Test13a");
1857 verify_reg_nonexist(hkey
, "Test13b");
1859 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1860 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1861 "\"Test14a\"=dword:0x123\n"
1862 "\"Test14b\"=dword:123 456\n"
1863 "\"Test14c\"=dword:1234 5678\n\n");
1864 verify_reg_nonexist(hkey
, "Test14a");
1865 verify_reg_nonexist(hkey
, "Test14b");
1866 verify_reg_nonexist(hkey
, "Test14c");
1868 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1869 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1870 "\"Test15a\"=\"foo\"bar\"\n"
1871 "\"Test15b\"=\"foo\"\"bar\"\n\n");
1872 verify_reg_nonexist(hkey
, "Test15a");
1873 verify_reg_nonexist(hkey
, "Test15b");
1875 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1876 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1878 "\"Test16b\"=\\\"\n"
1879 "\"Test16c\"=\\\"Value\\\"\n"
1880 "\"Test16d\"=\\\"Value\"\n\n");
1881 verify_reg_nonexist(hkey
, "Test16a");
1882 verify_reg_nonexist(hkey
, "Test16b");
1883 verify_reg_nonexist(hkey
, "Test16c");
1884 verify_reg_nonexist(hkey
, "Test16d");
1886 /* Test key name and value name concatenation */
1887 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1888 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\\n"
1890 verify_key_nonexist(hkey
, "Subkey1");
1892 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1893 "[HKEY_CURRENT_USER\\" KEY_BASE
"\n"
1895 verify_key_nonexist(hkey
, "Subkey2");
1897 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1898 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1900 "17a\"=\"Value 1\"\n"
1901 "\"Test17b\"=\"Value 2\"\n"
1903 "\\17c\"=\"Value 3\"\n\n");
1904 verify_reg_nonexist(hkey
, "Test17a");
1905 verify_reg(hkey
, "Test17b", REG_SZ
, "Value 2", 8, 0);
1906 verify_reg_nonexist(hkey
, "Test17c");
1908 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1909 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1910 "\"Test18a\"=dword:1234\\\n"
1912 "\"Test18b\"=\"Test \\\n"
1914 verify_reg_nonexist(hkey
, "Test18a");
1915 verify_reg_nonexist(hkey
, "Test18b");
1917 /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
1918 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1919 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1920 "\"Test19a\"=hex(0):56,00,61,00,6c,00\\\n"
1921 ",75,00,65,00,00,00\n"
1922 "\"Test19b\"=hex(0):56,00,61,00,6c,00\\\n"
1923 " ,75,00,65,00,00,00\n"
1924 "\"Test19c\"=hex(0):56,00,61,00,6c,00\\\n"
1925 " 75,00,65,00,00,00\n"
1926 "\"Test19d\"=hex(0):56,00,61,00,6c,00,7\\\n"
1927 "5,00,65,00,00,00\n"
1928 "\"Test19e\"=hex(0):56,00,61,00,6c,00,7\\\n"
1929 " 5,00,65,00,00,00\n"
1930 "\"Test19f\"=hex(0):56,00,61,00,\\;comment\n"
1931 " 6c,00,75,00,\\#comment\n"
1932 " 65,00,00,00\n\n");
1933 verify_reg_nonexist(hkey
, "Test19a");
1934 verify_reg_nonexist(hkey
, "Test19b");
1935 verify_reg_nonexist(hkey
, "Test19c");
1936 verify_reg_nonexist(hkey
, "Test19d");
1937 verify_reg_nonexist(hkey
, "Test19e");
1938 verify_reg_nonexist(hkey
, "Test19f");
1940 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1941 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1942 "\"Test20a\"=hex(2):25,00,50,00,41,00\\\n"
1943 ",54,00,48,00,25,00,00,00\n"
1944 "\"Test20b\"=hex(2):25,00,50,00,41,00\\\n"
1945 " ,54,00,48,00,25,00,00,00\n"
1946 "\"Test20c\"=hex(2):25,00,50,00,41,00\\\n"
1947 " 54,00,48,00,25,00,00,00\n"
1948 "\"Test20d\"=hex(2):25,00,50,00,4\\\n"
1949 "1,00,54,00,48,00,25,00,00,00\n"
1950 "\"Test20e\"=hex(2):25,00,50,00,4\\\n"
1951 " 1,00,54,00,48,00,25,00,00\n"
1952 "\"Test20f\"=hex(2):25,00,50,00,41,00,\\;comment\n"
1953 " 54,00,48,00,\\#comment\n"
1954 " 25,00,00,00\n\n");
1955 verify_reg_nonexist(hkey
, "Test20a");
1956 verify_reg_nonexist(hkey
, "Test20b");
1957 verify_reg_nonexist(hkey
, "Test20c");
1958 verify_reg_nonexist(hkey
, "Test20d");
1959 verify_reg_nonexist(hkey
, "Test20e");
1960 verify_reg_nonexist(hkey
, "Test20f");
1962 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1963 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1964 "\"Test21a\"=hex:11,22,33,44\\\n"
1966 "\"Test21b\"=hex:11,22,33,44\\\n"
1968 "\"Test21c\"=hex:11,22,33,44\\\n"
1970 "\"Test21d\"=hex:11,22,33,4\\\n"
1972 "\"Test21e\"=hex:11,22,33,4\\\n"
1974 "\"Test21f\"=hex:11,22,33,\\;comment\n"
1975 " 44,55,66,\\#comment\n"
1977 verify_reg_nonexist(hkey
, "Test21a");
1978 verify_reg_nonexist(hkey
, "Test21b");
1979 verify_reg_nonexist(hkey
, "Test21c");
1980 verify_reg_nonexist(hkey
, "Test21d");
1981 verify_reg_nonexist(hkey
, "Test21e");
1982 verify_reg_nonexist(hkey
, "Test21f");
1984 /* Test support for characters greater than 0xff */
1985 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1986 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1987 "\"Wine22a\"=hex(0):25,50,100,54,48,25,00\n"
1988 "\"Wine22b\"=hex(0):25,1a4,100,164,124,25,00\n\n");
1989 verify_reg_nonexist(hkey
, "Wine22a");
1990 verify_reg_nonexist(hkey
, "Wine22b");
1992 /* Test the effect of backslashes in hex data */
1993 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
1994 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
1995 "\"Wine23a\"=hex(2):25,00,48\\,00,4f,00,4d,00,45,00,25,00,00,00\n"
1996 "\"Wine23b\"=hex(2):25,00,48,00,\\4f,00,4d,00,45,00,25,00,00,00\n"
1997 "\"Wine23c\"=hex(2):25,00,48\\ ,00,4f,00,4d,00,45,00,25,00,00,00\n"
1998 "\"Wine23d\"=hex(2):25,00,48,00,\\ 4f,00,4d,00,45,00,25,00,00,00\n"
1999 "\"Wine23e\"=hex(2):\\25,00,48,00,4f,00,4d,00,45,00,25,00,00,00\n"
2000 "\"Wine23f\"=hex(2):\\ 25,00,48,00,4f,00,4d,00,45,00,25,00,00,00\n"
2001 "\"Wine23g\"=hex(2):25,00,48,00,4\\f,00,4d,00,45,00,25,00,00,00\n"
2002 "\"Wine23h\"=hex(2):25,00,48,00,4\\\n"
2003 " f,00,4d,00,45,00,25,00,00,00\n"
2004 "\"Wine23i\"=hex(2):25,00,50,00,\\,41,00,54,00,48,00,25,00,00,00\n"
2005 "\"Wine23j\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\\\n"
2006 " 25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2007 "\"Wine23k\"=hex(2):,\\\n"
2008 " 25,00,48,00,4f,00,4d,00,45,00,25,00,00,00\n\n");
2009 verify_reg_nonexist(hkey
, "Wine23a");
2010 verify_reg_nonexist(hkey
, "Wine23b");
2011 verify_reg_nonexist(hkey
, "Wine23c");
2012 verify_reg_nonexist(hkey
, "Wine23d");
2013 verify_reg_nonexist(hkey
, "Wine23e");
2014 verify_reg_nonexist(hkey
, "Wine23f");
2015 verify_reg_nonexist(hkey
, "Wine23g");
2016 verify_reg_nonexist(hkey
, "Wine23h");
2017 verify_reg_nonexist(hkey
, "Wine23i");
2018 verify_reg_nonexist(hkey
, "Wine23j");
2019 verify_reg_nonexist(hkey
, "Wine23k");
2021 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2022 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2023 "\"Wine24a\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2024 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1]\n");
2025 verify_reg_nonexist(hkey
, "Wine24a");
2026 verify_key_nonexist(hkey
, "Subkey1");
2028 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2029 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2030 "\"Wine24b\"=hex(2):4c,00,69,00,6e,00,65,00,20,00\\\n"
2031 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2]\n");
2032 verify_reg_nonexist(hkey
, "Wine24b");
2033 verify_key(hkey
, "Subkey2");
2035 delete_key(hkey
, "Subkey2");
2037 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2038 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2039 "\"Wine25a\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2040 "\"Wine25b\"=\"Test value\"\n"
2042 "\"Wine25c\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2044 "\"Wine25d\"=\"Test value\"\n"
2046 "\"Wine25e\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2048 "\"Wine25f\"=\"Test value\"\n"
2050 "\"Wine25g\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n\n"
2051 "\"Wine25h\"=\"Test value\"\n"
2053 "\"Wine25i\"=hex(2):4c,00,69,00,6e,00,65,00,20,00\\\n"
2054 "\"Wine25j\"=\"Test value\"\n\n");
2055 verify_reg_nonexist(hkey
, "Wine25a");
2056 verify_reg_nonexist(hkey
, "Wine25b");
2057 verify_reg_nonexist(hkey
, "Wine25c");
2058 verify_reg_nonexist(hkey
, "Wine25d");
2059 verify_reg_nonexist(hkey
, "Wine25e");
2060 verify_reg(hkey
, "Wine25f", REG_SZ
, "Test value", 11, 0);
2061 verify_reg_nonexist(hkey
, "Wine25g");
2062 verify_reg_nonexist(hkey
, "Wine25h");
2063 verify_reg_nonexist(hkey
, "Wine25i");
2064 verify_reg(hkey
, "Wine25j", REG_SZ
, "Test value", 11, 0);
2066 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2067 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2068 "\"Wine26a\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2069 "\"Wine26b\"=dword:00000008\n"
2071 "\"Wine26c\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2073 "\"Wine26d\"=dword:00000008\n"
2075 "\"Wine26e\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2077 "\"Wine26f\"=dword:00000008\n"
2079 "\"Wine26g\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n\n"
2080 "\"Wine26h\"=dword:00000008\n"
2082 "\"Wine26i\"=hex(2):4c,00,69,00,6e,00,65,00,20,00\\\n"
2083 "\"Wine26j\"=dword:00000008\n\n");
2084 verify_reg_nonexist(hkey
, "Wine26a");
2085 verify_reg_nonexist(hkey
, "Wine26b");
2086 verify_reg_nonexist(hkey
, "Wine26c");
2087 verify_reg_nonexist(hkey
, "Wine26d");
2088 verify_reg_nonexist(hkey
, "Wine26e");
2089 verify_reg(hkey
, "Wine26f", REG_DWORD
, &dword
, sizeof(dword
), 0);
2090 verify_reg_nonexist(hkey
, "Wine26g");
2091 verify_reg_nonexist(hkey
, "Wine26h");
2092 verify_reg_nonexist(hkey
, "Wine26i");
2093 verify_reg(hkey
, "Wine26j", REG_DWORD
, &dword
, sizeof(dword
), 0);
2095 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2096 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2097 "\"Wine27a\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\n"
2098 "\"Wine27b\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2100 "\"Wine27c\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\n"
2102 "\"Wine27d\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2104 "\"Wine27e\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\n"
2106 "\"Wine27f\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2108 "\"Wine27g\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\n\n"
2109 "\"Wine27h\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2111 "\"Wine27i\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00\\\n"
2112 "\"Wine27j\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n\n");
2113 verify_reg_nonexist(hkey
, "Wine27a");
2114 verify_reg_nonexist(hkey
, "Wine27b");
2115 verify_reg_nonexist(hkey
, "Wine27c");
2116 verify_reg_nonexist(hkey
, "Wine27d");
2117 verify_reg_nonexist(hkey
, "Wine27e");
2118 verify_reg(hkey
, "Wine27f", REG_EXPAND_SZ
, "%PATH%", 7, 0);
2119 verify_reg_nonexist(hkey
, "Wine27g");
2120 verify_reg_nonexist(hkey
, "Wine27h");
2121 verify_reg_nonexist(hkey
, "Wine27i");
2122 verify_reg(hkey
, "Wine27j", REG_EXPAND_SZ
, "%PATH%", 7, 0);
2124 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2125 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2126 "\"Wine28a\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2127 "@=\"Default value 1\"\n\n");
2128 verify_reg_nonexist(hkey
, "Wine28a");
2129 verify_reg_nonexist(hkey
, NULL
);
2131 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2132 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2133 "\"Wine28b\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2135 "@=\"Default value 2\"\n\n");
2136 verify_reg_nonexist(hkey
, "Wine28b");
2137 verify_reg_nonexist(hkey
, NULL
);
2139 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2140 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2141 "\"Wine28c\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2143 "@=\"Default value 3\"\n\n");
2144 verify_reg_nonexist(hkey
, "Wine28c");
2145 verify_reg(hkey
, NULL
, REG_SZ
, "Default value 3", 16, 0);
2147 delete_value(hkey
, NULL
);
2149 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2150 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2151 "\"Wine28d\"=hex(2):4c,00,69,00,6e,00,65,00,20,00,\\\n\n"
2152 "@=\"Default value 4\"\n\n");
2153 verify_reg_nonexist(hkey
, "Wine28d");
2154 verify_reg_nonexist(hkey
, NULL
);
2156 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2157 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2158 "\"Wine28e\"=hex(2):4c,00,69,00,6e,00,65,00,20,00\\\n"
2159 "@=\"Default value 5\"\n\n");
2160 verify_reg_nonexist(hkey
, "Wine28e");
2161 verify_reg(hkey
, NULL
, REG_SZ
, "Default value 5", 16, 0);
2163 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2164 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2165 "\"Wine29a\"=hex:11,22,33,\\\n"
2168 "\"Wine29b\"=hex:11,22,33,\\\n"
2171 verify_reg_nonexist(hkey
, "Wine29a");
2172 verify_reg_nonexist(hkey
, "Wine29b");
2174 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2175 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2176 "\"Wine30a\"=hex(0):25,48,4f,4d,45,25,5c,/\n"
2177 " 25,50,41,54,48,25,00\n"
2178 "\"Wine30b\"=hex(0):25,48,4f,4d,45,25,5c/\n"
2179 " 25,50,41,54,48,25,00\n\n");
2180 verify_reg_nonexist(hkey
, "Wine30a");
2181 verify_reg_nonexist(hkey
, "Wine30b");
2183 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2184 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2185 "\"Wine31\"=hex(7):4c,00,69,00,6e,00,65,00,20,00\\");
2186 verify_reg_nonexist(hkey
, "Wine31");
2188 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2189 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2190 "\"Wine32a\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2191 " ,63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
2192 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
2193 "\"Wine32b\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2194 " 63,00,,6f,00,6e,00,63,00,61,00,74,00,\\\n"
2195 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2196 verify_reg_nonexist(hkey
, "Wine32a");
2197 verify_reg_nonexist(hkey
, "Wine32b");
2199 /* Test with embedded null characters */
2200 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2201 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2202 "\"Wine33a\"=\"\\0\"\n"
2203 "\"Wine33b\"=\"\\0\\0\"\n"
2204 "\"Wine33c\"=\"Value1\\0\"\n"
2205 "\"Wine33d\"=\"Value2\\0\\0\\0\\0\"\n"
2206 "\"Wine33e\"=\"Value3\\0Value4\"\n"
2207 "\"Wine33f\"=\"\\0Value5\"\n\n");
2208 verify_reg_nonexist(hkey
, "Wine33a");
2209 verify_reg_nonexist(hkey
, "Wine33b");
2210 verify_reg_nonexist(hkey
, "Wine33c");
2211 verify_reg_nonexist(hkey
, "Wine33d");
2212 verify_reg_nonexist(hkey
, "Wine33e");
2213 verify_reg_nonexist(hkey
, "Wine33f");
2217 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
2220 static void test_invalid_import_31(void)
2225 RegCreateKeyExA(HKEY_CLASSES_ROOT
, KEY_BASE
, 0, NULL
, REG_OPTION_NON_VOLATILE
,
2226 KEY_READ
|KEY_SET_VALUE
, NULL
, &hkey
, &dispos
);
2228 if (dispos
== REG_OPENED_EXISTING_KEY
)
2229 delete_value(hkey
, NULL
);
2231 /* Test character validity at the start of the line */
2232 exec_import_str("REGEDIT\r\n"
2233 " HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value1a\r\n");
2234 verify_reg_nonexist(hkey
, "");
2236 exec_import_str("REGEDIT\r\n"
2237 " HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value1b\r\n");
2238 verify_reg_nonexist(hkey
, "");
2240 exec_import_str("REGEDIT\r\n"
2241 "\tHKEY_CLASSES_ROOT\\" KEY_BASE
" = Value1c\r\n");
2242 verify_reg_nonexist(hkey
, "");
2244 exec_import_str("REGEDIT\r\n"
2245 ";HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value2a\r\n");
2246 verify_reg_nonexist(hkey
, "");
2248 exec_import_str("REGEDIT\r\n"
2249 "#HKEY_CLASSES_ROOT\\" KEY_BASE
" = Value2b\r\n");
2250 verify_reg_nonexist(hkey
, "");
2252 /* Test case sensitivity */
2253 exec_import_str("REGEDIT\r\n"
2254 "hkey_classes_root\\" KEY_BASE
" = Value3a\r\n");
2255 verify_reg_nonexist(hkey
, "");
2257 exec_import_str("REGEDIT\r\n"
2258 "hKEY_CLASSES_ROOT\\" KEY_BASE
" = Value3b\r\n");
2259 verify_reg_nonexist(hkey
, "");
2261 exec_import_str("REGEDIT\r\n"
2262 "Hkey_Classes_Root\\" KEY_BASE
" = Value3c\r\n");
2263 verify_reg_nonexist(hkey
, "");
2267 delete_key(HKEY_CLASSES_ROOT
, KEY_BASE
);
2270 static void test_comments(void)
2275 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
2276 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
2278 exec_import_str("REGEDIT4\n\n"
2279 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2281 "\"Wine1\"=\"Line 1\"\n"
2283 "\"Wine2\"=\"Line 2\"\n\n");
2284 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
2285 verify_reg(hkey
, "Wine1", REG_SZ
, "Line 1", 7, 0);
2286 verify_reg(hkey
, "Wine2", REG_SZ
, "Line 2", 7, 0);
2288 exec_import_str("REGEDIT4\n\n"
2289 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2290 "\"Wine3\"=\"Value 1\"#comment\n"
2291 "\"Wine4\"=\"Value 2\";comment\n"
2292 "\"Wine5\"=dword:01020304 #comment\n"
2293 "\"Wine6\"=dword:02040608 ;comment\n\n");
2294 verify_reg_nonexist(hkey
, "Wine3");
2295 verify_reg(hkey
, "Wine4", REG_SZ
, "Value 2", 8, 0);
2296 verify_reg_nonexist(hkey
, "Wine5");
2298 verify_reg(hkey
, "Wine6", REG_DWORD
, &dword
, sizeof(dword
), 0);
2300 exec_import_str("REGEDIT4\n\n"
2301 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2302 "\"Wine7\"=hex(7):4c,69,6e,65,20,\\\n"
2304 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
2305 "\"Wine8\"=\"A valid line\"\n"
2306 "\"Wine9\"=hex(7):4c,69,6e,65,20,\\\n"
2308 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
2309 "\"Wine10\"=\"Another valid line\"\n\n");
2310 verify_reg_nonexist(hkey
, "Wine7");
2311 verify_reg(hkey
, "Wine8", REG_SZ
, "A valid line", 13, 0);
2312 verify_reg(hkey
, "Wine9", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2313 verify_reg(hkey
, "Wine10", REG_SZ
, "Another valid line", 19, 0);
2315 exec_import_str("REGEDIT4\n\n"
2316 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2317 "#\"Comment1\"=\"Value 1\"\n"
2318 ";\"Comment2\"=\"Value 2\"\n"
2319 " #\"Comment3\"=\"Value 3\"\n"
2320 " ;\"Comment4\"=\"Value 4\"\n"
2321 "\"Wine11\"=\"Value 6\"#\"Comment5\"=\"Value 5\"\n"
2322 "\"Wine12\"=\"Value 7\";\"Comment6\"=\"Value 6\"\n\n");
2323 verify_reg_nonexist(hkey
, "Comment1");
2324 verify_reg_nonexist(hkey
, "Comment2");
2325 verify_reg_nonexist(hkey
, "Comment3");
2326 verify_reg_nonexist(hkey
, "Comment4");
2327 verify_reg_nonexist(hkey
, "Wine11");
2328 verify_reg_nonexist(hkey
, "Comment5");
2329 verify_reg(hkey
, "Wine12", REG_SZ
, "Value 7", 8, 0);
2330 verify_reg_nonexist(hkey
, "Comment6");
2332 exec_import_str("REGEDIT4\n\n"
2333 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2334 "\"Wine13\"=#\"Value 8\"\n"
2335 "\"Wine14\"=;\"Value 9\"\n"
2336 "\"Wine15\"=\"#comment1\"\n"
2337 "\"Wine16\"=\";comment2\"\n"
2338 "\"Wine17\"=\"Value#comment3\"\n"
2339 "\"Wine18\"=\"Value;comment4\"\n"
2340 "\"Wine19\"=\"Value #comment5\"\n"
2341 "\"Wine20\"=\"Value ;comment6\"\n"
2342 "\"Wine21\"=#dword:00000001\n"
2343 "\"Wine22\"=;dword:00000002\n"
2344 "\"Wine23\"=dword:00000003#comment\n"
2345 "\"Wine24\"=dword:00000004;comment\n\n");
2346 verify_reg_nonexist(hkey
, "Wine13");
2347 verify_reg_nonexist(hkey
, "Wine14");
2348 verify_reg(hkey
, "Wine15", REG_SZ
, "#comment1", 10, 0);
2349 verify_reg(hkey
, "Wine16", REG_SZ
, ";comment2", 10, 0);
2350 verify_reg(hkey
, "Wine17", REG_SZ
, "Value#comment3", 15, 0);
2351 verify_reg(hkey
, "Wine18", REG_SZ
, "Value;comment4", 15, 0);
2352 verify_reg(hkey
, "Wine19", REG_SZ
, "Value #comment5", 16, 0);
2353 verify_reg(hkey
, "Wine20", REG_SZ
, "Value ;comment6", 16, 0);
2354 verify_reg_nonexist(hkey
, "Wine21");
2355 verify_reg_nonexist(hkey
, "Wine22");
2356 verify_reg_nonexist(hkey
, "Wine23");
2358 verify_reg(hkey
, "Wine24", REG_DWORD
, &dword
, sizeof(dword
), 0);
2360 exec_import_str("REGEDIT4\n\n"
2361 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2362 "\"Wine25a\"=dword:1234;5678\n"
2363 "\"Wine25b\"=dword:1234 ;5678\n"
2364 "\"Wine25c\"=dword:1234#5678\n"
2365 "\"Wine25d\"=dword:1234 #5678\n\n");
2367 verify_reg(hkey
, "Wine25a", REG_DWORD
, &dword
, sizeof(dword
), 0);
2368 verify_reg(hkey
, "Wine25b", REG_DWORD
, &dword
, sizeof(dword
), 0);
2369 verify_reg_nonexist(hkey
, "Wine25c");
2370 verify_reg_nonexist(hkey
, "Wine25d");
2372 exec_import_str("REGEDIT4\n\n"
2373 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2374 "\"Wine26a\"=\"Value1\" ;comment\n"
2375 "\"Wine26b\"=\"Value2\"\t\t;comment\n"
2376 "\"Wine26c\"=\"Value3\" #comment\n"
2377 "\"Wine26d\"=\"Value4\"\t\t#comment\n\n");
2378 verify_reg(hkey
, "Wine26a", REG_SZ
, "Value1", 7, 0);
2379 verify_reg(hkey
, "Wine26b", REG_SZ
, "Value2", 7, 0);
2380 verify_reg_nonexist(hkey
, "Wine26c");
2381 verify_reg_nonexist(hkey
, "Wine26d");
2383 exec_import_str("REGEDIT4\n\n"
2384 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2385 "\"Multi-Line1\"=hex(7):4c,69,6e,65,20,\\\n"
2386 " 63,6f,6e,\\;comment\n"
2387 " 63,61,74,\\;comment\n"
2388 " 65,6e,61,74,69,6f,6e,00,00\n\n");
2389 verify_reg(hkey
, "Multi-Line1", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2391 exec_import_str("REGEDIT4\n\n"
2392 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2393 "\"Multi-Line2\"=hex(7):4c,69,6e,65,20,\\\n"
2394 " 63,6f,6e,\\;comment\n"
2395 " 63,61,74,;comment\n"
2396 " 65,6e,61,74,69,6f,6e,00,00\n\n");
2397 verify_reg(hkey
, "Multi-Line2", REG_MULTI_SZ
, "Line concat", 12, 0);
2399 exec_import_str("REGEDIT4\n\n"
2400 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2401 "\"Multi-Line3\"=hex(7):4c,69,6e,\\;comment\n"
2402 " 65,20,\\;comment\n"
2403 " 63,6f,6e,\\;comment\n"
2404 " 63,61,74,\\;comment\n"
2405 " 65,6e,61,74,69,6f,6e,00,00\n\n");
2406 verify_reg(hkey
, "Multi-Line3", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2408 exec_import_str("REGEDIT4\n\n"
2409 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2410 "\"Multi-Line4\"=hex(7):4c,69,6e,\\;#comment\n"
2411 " 65,20,\\;#comment\n"
2412 " 63,6f,6e,\\;#comment\n"
2413 " 63,61,74,\\;#comment\n"
2414 " 65,6e,61,74,69,6f,6e,00,00\n\n");
2415 verify_reg(hkey
, "Multi-Line4", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2417 exec_import_str("REGEDIT4\n\n"
2418 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2419 "\"Multi-Line5\"=hex(7):4c,69,6e,\\;comment\n"
2420 " 65,20,\\;comment\n"
2421 " 63,6f,6e,\\;comment\n"
2422 " 63,61,74,\\#comment\n"
2423 " 65,6e,61,74,69,6f,6e,00,00\n\n");
2424 verify_reg_nonexist(hkey
, "Multi-Line5");
2426 exec_import_str("REGEDIT4\n\n"
2427 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2428 "\"Multi-Line6\"=hex(7):4c,69,6e,65,20,\\\n"
2429 " 63,6f,6e,\\;comment\n"
2431 " 65,6e,\\;comment\n\n"
2432 " 61,74,69,6f,6e,00,00\n\n");
2433 verify_reg(hkey
, "Multi-Line6", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2435 exec_import_str("REGEDIT4\n\n"
2436 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2437 "\"Wine27a\"=hex(2):25,50,41,54,48,25,00 ;comment\n"
2438 "\"Wine27b\"=hex(2):25,50,41,54,48,25,00\t;comment\n"
2439 "\"Wine27c\"=hex(2):25,50,41,54,48,25,00 #comment\n"
2440 "\"Wine27d\"=hex(2):25,50,41,54,48,25,00\t#comment\n\n");
2441 verify_reg(hkey
, "Wine27a", REG_EXPAND_SZ
, "%PATH%", 7, 0);
2442 verify_reg(hkey
, "Wine27b", REG_EXPAND_SZ
, "%PATH%", 7, 0);
2443 verify_reg_nonexist(hkey
, "Wine27c");
2444 verify_reg_nonexist(hkey
, "Wine27d");
2446 exec_import_str("REGEDIT4\n\n"
2447 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2448 "\"Wine28a\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
2449 " 25,50,41,54,48,25,00\n"
2450 "\"Wine28b\"=hex(2):25,48,4f,4d,45,25,5c\\\n"
2451 " 25,50,41,54,48,25,00\n"
2452 "\"Wine28c\"=hex(2):25,48,4f,4d,45,25,5c, \\ ;comment\n"
2453 " 25,50,41,54,48,25,00\n"
2454 "\"Wine28d\"=hex(2):25,48,4f,4d,45,25,5c \\ ;comment\n"
2455 " 25,50,41,54,48,25,00\n"
2456 "\"Wine28e\"=hex(2):25,48,4f,4d,45,25,5c,\\\t ;comment\n"
2457 " 25,50,41,54,48,25,00\n"
2458 "\"Wine28f\"=hex(2):25,48,4f,4d,45,25,5c\\\t ;comment\n"
2459 " 25,50,41,54,48,25,00\n\n");
2460 verify_reg(hkey
, "Wine28a", REG_EXPAND_SZ
, "%HOME%\\%PATH%", 14, 0);
2461 verify_reg_nonexist(hkey
, "Wine28b");
2462 verify_reg(hkey
, "Wine28c", REG_EXPAND_SZ
, "%HOME%\\%PATH%", 14, 0);
2463 verify_reg_nonexist(hkey
, "Wine28d");
2464 verify_reg(hkey
, "Wine28e", REG_EXPAND_SZ
, "%HOME%\\%PATH%", 14, 0);
2465 verify_reg_nonexist(hkey
, "Wine28f");
2467 exec_import_str("REGEDIT4\n\n"
2468 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2469 "\"Wine29a\"=hex(7):4c,69,6e,65,20,\\\n"
2470 " 63,6f,6e,63,61,74,\\\n"
2472 " 65,6e,\\;comment\n"
2473 " 61,74,69,6f,6e,00,00\n\n");
2474 verify_reg(hkey
, "Wine29a", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2476 exec_import_str("REGEDIT4\n\n"
2477 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2478 "\"Wine29b\"=hex(7):4c,69,6e,65,20,\\\n"
2479 " 63,6f,6e,63,61,74,\\\n"
2481 " 65,6e,\\;comment\n"
2482 " 61,74,69,6f,6e,00,00\n\n");
2483 verify_reg(hkey
, "Wine29b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2485 exec_import_str("REGEDIT4\n\n"
2486 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2487 "\"Wine29c\"=hex(7):4c,69,6e,65,20,\\\n"
2488 " 63,6f,6e,63,61,74,\\\n"
2490 " 65,6e,\\;comment\n"
2491 " 61,74,69,6f,6e,00,00\n\n");
2492 verify_reg_nonexist(hkey
, "Wine29c");
2494 exec_import_str("REGEDIT4\n\n"
2495 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2496 "\"Wine29d\"=hex(7):4c,69,6e,65,20,\\\n"
2497 " 63,6f,6e,63,61,74,\\\n"
2499 " 65,6e,\\;comment\n"
2500 " 61,74,69,6f,6e,00,00\n\n");
2501 verify_reg_nonexist(hkey
, "Wine29d");
2505 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
2508 static void test_comments_unicode(void)
2513 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
2514 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
2516 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2517 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2519 "\"Wine1\"=\"Line 1\"\n"
2521 "\"Wine2\"=\"Line 2\"\n\n");
2522 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
2523 verify_reg(hkey
, "Wine1", REG_SZ
, "Line 1", 7, 0);
2524 verify_reg(hkey
, "Wine2", REG_SZ
, "Line 2", 7, 0);
2526 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2527 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2528 "\"Wine3\"=\"Value 1\"#comment\n"
2529 "\"Wine4\"=\"Value 2\";comment\n"
2530 "\"Wine5\"=dword:01020304 #comment\n"
2531 "\"Wine6\"=dword:02040608 ;comment\n\n");
2532 verify_reg_nonexist(hkey
, "Wine3");
2533 verify_reg(hkey
, "Wine4", REG_SZ
, "Value 2", 8, 0);
2534 verify_reg_nonexist(hkey
, "Wine5");
2536 verify_reg(hkey
, "Wine6", REG_DWORD
, &dword
, sizeof(dword
), 0);
2538 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2539 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2540 "\"Wine7\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2542 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
2543 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
2544 "\"Wine8\"=\"A valid line\"\n"
2545 "\"Wine9\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2547 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
2548 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
2549 "\"Wine10\"=\"Another valid line\"\n\n");
2550 verify_reg_nonexist(hkey
, "Wine7");
2551 verify_reg(hkey
, "Wine8", REG_SZ
, "A valid line", 13, 0);
2552 verify_reg(hkey
, "Wine9", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2553 verify_reg(hkey
, "Wine10", REG_SZ
, "Another valid line", 19, 0);
2555 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2556 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2557 "#\"Comment1\"=\"Value 1\"\n"
2558 ";\"Comment2\"=\"Value 2\"\n"
2559 " #\"Comment3\"=\"Value 3\"\n"
2560 " ;\"Comment4\"=\"Value 4\"\n"
2561 "\"Wine11\"=\"Value 6\"#\"Comment5\"=\"Value 5\"\n"
2562 "\"Wine12\"=\"Value 7\";\"Comment6\"=\"Value 6\"\n\n");
2563 verify_reg_nonexist(hkey
, "Comment1");
2564 verify_reg_nonexist(hkey
, "Comment2");
2565 verify_reg_nonexist(hkey
, "Comment3");
2566 verify_reg_nonexist(hkey
, "Comment4");
2567 verify_reg_nonexist(hkey
, "Wine11");
2568 verify_reg_nonexist(hkey
, "Comment5");
2569 verify_reg(hkey
, "Wine12", REG_SZ
, "Value 7", 8, 0);
2570 verify_reg_nonexist(hkey
, "Comment6");
2572 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2573 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2574 "\"Wine13\"=#\"Value 8\"\n"
2575 "\"Wine14\"=;\"Value 9\"\n"
2576 "\"Wine15\"=\"#comment1\"\n"
2577 "\"Wine16\"=\";comment2\"\n"
2578 "\"Wine17\"=\"Value#comment3\"\n"
2579 "\"Wine18\"=\"Value;comment4\"\n"
2580 "\"Wine19\"=\"Value #comment5\"\n"
2581 "\"Wine20\"=\"Value ;comment6\"\n"
2582 "\"Wine21\"=#dword:00000001\n"
2583 "\"Wine22\"=;dword:00000002\n"
2584 "\"Wine23\"=dword:00000003#comment\n"
2585 "\"Wine24\"=dword:00000004;comment\n\n");
2586 verify_reg_nonexist(hkey
, "Wine13");
2587 verify_reg_nonexist(hkey
, "Wine14");
2588 verify_reg(hkey
, "Wine15", REG_SZ
, "#comment1", 10, 0);
2589 verify_reg(hkey
, "Wine16", REG_SZ
, ";comment2", 10, 0);
2590 verify_reg(hkey
, "Wine17", REG_SZ
, "Value#comment3", 15, 0);
2591 verify_reg(hkey
, "Wine18", REG_SZ
, "Value;comment4", 15, 0);
2592 verify_reg(hkey
, "Wine19", REG_SZ
, "Value #comment5", 16, 0);
2593 verify_reg(hkey
, "Wine20", REG_SZ
, "Value ;comment6", 16, 0);
2594 verify_reg_nonexist(hkey
, "Wine21");
2595 verify_reg_nonexist(hkey
, "Wine22");
2596 verify_reg_nonexist(hkey
, "Wine23");
2598 verify_reg(hkey
, "Wine24", REG_DWORD
, &dword
, sizeof(dword
), 0);
2600 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2601 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2602 "\"Wine25a\"=dword:1234;5678\n"
2603 "\"Wine25b\"=dword:1234 ;5678\n"
2604 "\"Wine25c\"=dword:1234#5678\n"
2605 "\"Wine25d\"=dword:1234 #5678\n\n");
2607 verify_reg(hkey
, "Wine25a", REG_DWORD
, &dword
, sizeof(dword
), 0);
2608 verify_reg(hkey
, "Wine25b", REG_DWORD
, &dword
, sizeof(dword
), 0);
2609 verify_reg_nonexist(hkey
, "Wine25c");
2610 verify_reg_nonexist(hkey
, "Wine25d");
2612 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2613 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2614 "\"Wine26a\"=\"Value1\" ;comment\n"
2615 "\"Wine26b\"=\"Value2\"\t\t;comment\n"
2616 "\"Wine26c\"=\"Value3\" #comment\n"
2617 "\"Wine26d\"=\"Value4\"\t\t#comment\n\n");
2618 verify_reg(hkey
, "Wine26a", REG_SZ
, "Value1", 7, 0);
2619 verify_reg(hkey
, "Wine26b", REG_SZ
, "Value2", 7, 0);
2620 verify_reg_nonexist(hkey
, "Wine26c");
2621 verify_reg_nonexist(hkey
, "Wine26d");
2623 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2624 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2625 "\"Multi-Line1\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2626 " 63,00,6f,00,6e,00,\\;comment\n"
2627 " 63,00,61,00,74,00,\\;comment\n"
2628 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2629 verify_reg(hkey
, "Multi-Line1", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2631 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2632 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2633 "\"Multi-Line2\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2634 " 63,00,6f,00,6e,00,\\;comment\n"
2635 " 63,00,61,00,74,00,;comment\n"
2636 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2637 verify_reg(hkey
, "Multi-Line2", REG_MULTI_SZ
, "Line concat", 12, 0);
2639 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2640 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2641 "\"Multi-Line3\"=hex(7):4c,00,69,00,6e,00,\\;comment\n"
2642 " 65,00,20,00,\\;comment\n"
2643 " 63,00,6f,00,6e,00,\\;comment\n"
2644 " 63,00,61,00,74,00,\\;comment\n"
2645 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2646 verify_reg(hkey
, "Multi-Line3", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2648 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2649 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2650 "\"Multi-Line4\"=hex(7):4c,00,69,00,6e,00,\\;#comment\n"
2651 " 65,00,20,00,\\;#comment\n"
2652 " 63,00,6f,00,6e,00,\\;#comment\n"
2653 " 63,00,61,00,74,00,\\;#comment\n"
2654 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2655 verify_reg(hkey
, "Multi-Line4", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2657 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2658 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2659 "\"Multi-Line5\"=hex(7):4c,00,69,00,6e,00,\\;comment\n"
2660 " 65,00,20,00,\\;comment\n"
2661 " 63,00,6f,00,6e,00,\\;comment\n"
2662 " 63,00,61,00,74,00,\\#comment\n"
2663 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2664 verify_reg_nonexist(hkey
, "Multi-Line5");
2666 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2667 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2668 "\"Multi-Line6\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2669 " 63,00,6f,00,6e,00,\\;comment\n"
2670 " 63,00,61,00,74,00,\\\n\n"
2671 " 65,00,6e,00,\\;comment\n\n"
2672 " 61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2673 verify_reg(hkey
, "Multi-Line6", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2675 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2676 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2677 "\"Wine27a\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00 ;comment\n"
2678 "\"Wine27b\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\t;comment\n"
2679 "\"Wine27c\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00 #comment\n"
2680 "\"Wine27d\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\t#comment\n\n");
2681 verify_reg(hkey
, "Wine27a", REG_EXPAND_SZ
, "%PATH%", 7, 0);
2682 verify_reg(hkey
, "Wine27b", REG_EXPAND_SZ
, "%PATH%", 7, 0);
2683 verify_reg_nonexist(hkey
, "Wine27c");
2684 verify_reg_nonexist(hkey
, "Wine27d");
2686 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2687 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2688 "\"Wine28a\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\n"
2689 " 25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2690 "\"Wine28b\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00\\\n"
2691 " 25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2692 "\"Wine28c\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00, \\ ;comment\n"
2693 " 25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2694 "\"Wine28d\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00 \\ ;comment\n"
2695 " 25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2696 "\"Wine28e\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,\\\t ;comment\n"
2697 " 25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
2698 "\"Wine28f\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00\\\t ;comment\n"
2699 " 25,00,50,00,41,00,54,00,48,00,25,00,00,00\n\n");
2700 verify_reg(hkey
, "Wine28a", REG_EXPAND_SZ
, "%HOME%\\%PATH%", 14, 0);
2701 verify_reg_nonexist(hkey
, "Wine28b");
2702 verify_reg(hkey
, "Wine28c", REG_EXPAND_SZ
, "%HOME%\\%PATH%", 14, 0);
2703 verify_reg_nonexist(hkey
, "Wine28d");
2704 verify_reg(hkey
, "Wine28e", REG_EXPAND_SZ
, "%HOME%\\%PATH%", 14, 0);
2705 verify_reg_nonexist(hkey
, "Wine28f");
2707 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2708 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2709 "\"Wine29a\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2710 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
2712 " 65,00,6e,00,\\;comment\n"
2713 " 61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2714 verify_reg(hkey
, "Wine29a", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2716 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2717 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2718 "\"Wine29b\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2719 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
2721 " 65,00,6e,00,\\;comment\n"
2722 " 61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2723 verify_reg(hkey
, "Wine29b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2725 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2726 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2727 "\"Wine29c\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2728 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
2730 " 65,00,6e,00,\\;comment\n"
2731 " 61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2732 verify_reg_nonexist(hkey
, "Wine29c");
2734 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2735 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2736 "\"Wine29d\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2737 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
2739 " 65,00,6e,00,\\;comment\n"
2740 " 61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2741 verify_reg_nonexist(hkey
, "Wine29d");
2745 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
2748 static void test_import_with_whitespace(void)
2753 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
2754 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
2756 exec_import_str(" REGEDIT4\n\n"
2757 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n");
2759 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
2761 exec_import_str(" REGEDIT4\n\n"
2762 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2763 "\"Wine1a\"=\"Value\"\n\n");
2764 verify_reg(hkey
, "Wine1a", REG_SZ
, "Value", 6, 0);
2766 exec_import_str("\tREGEDIT4\n\n"
2767 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2768 "\"Wine1b\"=\"Value\"\n\n");
2769 verify_reg(hkey
, "Wine1b", REG_SZ
, "Value", 6, 0);
2771 exec_import_str(" \t REGEDIT4\n\n"
2772 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2773 "\"Wine1c\"=\"Value\"\n\n");
2774 verify_reg(hkey
, "Wine1c", REG_SZ
, "Value", 6, 0);
2776 exec_import_str("REGEDIT4\n\n"
2777 " [HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2778 "\"Wine2a\"=\"Value\"\n\n");
2779 verify_reg(hkey
, "Wine2a", REG_SZ
, "Value", 6, 0);
2781 exec_import_str("REGEDIT4\n\n"
2782 "\t[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2783 "\"Wine2b\"=\"Value\"\n\n");
2784 verify_reg(hkey
, "Wine2b", REG_SZ
, "Value", 6, 0);
2786 exec_import_str("REGEDIT4\n\n"
2787 " \t [HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2788 "\"Wine2c\"=\"Value\"\n\n");
2789 verify_reg(hkey
, "Wine2c", REG_SZ
, "Value", 6, 0);
2791 exec_import_str("REGEDIT4\n\n"
2792 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2793 " \"Wine3a\"=\"Two leading spaces\"\n\n");
2794 verify_reg(hkey
, "Wine3a", REG_SZ
, "Two leading spaces", 19, 0);
2796 exec_import_str("REGEDIT4\n\n"
2797 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2798 "\t\"Wine3b\"=\"One leading tab\"\n\n");
2799 verify_reg(hkey
, "Wine3b", REG_SZ
, "One leading tab", 16, 0);
2801 exec_import_str("REGEDIT4\n\n"
2802 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2803 " \t \"Wine3c\"=\"Space, tab, space\"\n\n");
2804 verify_reg(hkey
, "Wine3c", REG_SZ
, "Space, tab, space", 18, 0);
2806 exec_import_str(" REGEDIT4\n\n"
2807 "\t\t\t[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2808 "\t \"Wine4a\"=\"Tab and four spaces\"\n"
2809 " \"Wine4b\"=dword:00112233\n"
2810 "\t \t \t \t \t \t \"Wine4c\"=hex(7):4c,69,6e,65,20,\\\n"
2811 " 63,6f,6e,\\;comment\n"
2812 "\t\t\t\t63,61,74,\\;comment\n"
2813 " \t65,6e,61,74,69,6f,6e,00,00\n\n");
2814 verify_reg(hkey
, "Wine4a", REG_SZ
, "Tab and four spaces", 20, 0);
2816 verify_reg(hkey
, "Wine4b", REG_DWORD
, &dword
, sizeof(dword
), 0);
2817 verify_reg(hkey
, "Wine4c", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2819 exec_import_str(" REGEDIT4\n\n"
2820 "\t[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2821 " \"Wine5a\"=\"Leading spaces\"\n"
2822 "\t\t\"Wine5b\"\t\t=\"Leading tabs\"\n"
2823 "\t \"Wine5c\"=\t \"Tabs and spaces\"\n"
2824 " \"Wine5d\" \t = \t \"More whitespace\"\n\n");
2825 verify_reg(hkey
, "Wine5a", REG_SZ
, "Leading spaces", 15, 0);
2826 verify_reg(hkey
, "Wine5b", REG_SZ
, "Leading tabs", 13, 0);
2827 verify_reg(hkey
, "Wine5c", REG_SZ
, "Tabs and spaces", 16, 0);
2828 verify_reg(hkey
, "Wine5d", REG_SZ
, "More whitespace", 16, 0);
2830 exec_import_str("REGEDIT4\n\n"
2831 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2832 "\" Wine6a\"=\"Leading spaces\"\n"
2833 "\"\t\tWine6b\"=\"Leading tabs\"\n"
2834 " \" Wine6c \" = \" Spaces everywhere \" \n\n");
2835 verify_reg(hkey
, " Wine6a", REG_SZ
, "Leading spaces", 15, 0);
2836 verify_reg(hkey
, "\t\tWine6b", REG_SZ
, "Leading tabs", 13, 0);
2837 verify_reg(hkey
, " Wine6c ", REG_SZ
, " Spaces everywhere ", 22, 0);
2839 exec_import_str("REGEDIT4\n\n"
2840 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2841 "\"Wine7a\"=\" Four spaces in the data\"\n"
2842 "\"Wine7b\"=\"\t\tTwo tabs in the data\"\n\n");
2843 verify_reg(hkey
, "Wine7a", REG_SZ
, " Four spaces in the data", 28, 0);
2844 verify_reg(hkey
, "Wine7b", REG_SZ
, "\t\tTwo tabs in the data", 23, 0);
2846 exec_import_str("REGEDIT4\n\n"
2847 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2848 "\"Wine8a\"=\"Trailing spaces\" \n"
2849 "\"Wine8b\"=\"Trailing tabs and spaces\"\t \t\n\n");
2850 verify_reg(hkey
, "Wine8a", REG_SZ
, "Trailing spaces", 16, 0);
2851 verify_reg(hkey
, "Wine8b", REG_SZ
, "Trailing tabs and spaces", 25, 0);
2853 exec_import_str("REGEDIT4\n\n"
2854 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2855 "\"Wine9a\"=dword: 00000008\n"
2856 "\"Wine9b\"=dword:\t\t00000008\n\n");
2858 verify_reg(hkey
, "Wine9a", REG_DWORD
, &dword
, sizeof(dword
), 0);
2859 verify_reg(hkey
, "Wine9b", REG_DWORD
, &dword
, sizeof(dword
), 0);
2861 exec_import_str("REGEDIT4\n\n"
2862 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2863 "@ = \"Test Value\"\n\n");
2864 verify_reg(hkey
, "", REG_SZ
, "Test Value", 11, 0);
2866 exec_import_str("REGEDIT4\n\n"
2867 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2868 "\t@\t=\tdword:\t00000008\t\n\n");
2869 verify_reg(hkey
, "", REG_DWORD
, &dword
, sizeof(DWORD
), 0);
2871 exec_import_str("REGEDIT4\n\n"
2872 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2873 "\"Wine10a\"=hex(7):4c,69,6e,65,20,\\\n"
2875 " 63,61,74,\\\n\n\n"
2877 " 61,74,69,6f,6e,00,00\n\n");
2878 verify_reg(hkey
, "Wine10a", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2880 exec_import_str("REGEDIT4\n\n"
2881 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2882 "\"Wine10b\"=hex(7):4c,69,6e,65,20,\\\n"
2884 " 63,61,74,\\\n\t\n\t\n"
2885 " 65,6e,\\\n\t \t\n\t \t\n\t \t\n"
2886 " 61,74,69,6f,6e,00,00\n\n");
2887 verify_reg(hkey
, "Wine10b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2891 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
2894 static void test_import_with_whitespace_unicode(void)
2899 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
2900 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
2902 exec_import_wstr("\xef\xbb\xbf Windows Registry Editor Version 5.00\n\n"
2903 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n");
2905 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
2907 exec_import_wstr("\xef\xbb\xbf Windows Registry Editor Version 5.00\n\n"
2908 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2909 "\"Wine1a\"=\"Value\"\n\n");
2910 verify_reg(hkey
, "Wine1a", REG_SZ
, "Value", 6, 0);
2912 exec_import_wstr("\xef\xbb\xbf\tWindows Registry Editor Version 5.00\n\n"
2913 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2914 "\"Wine1b\"=\"Value\"\n\n");
2915 verify_reg(hkey
, "Wine1b", REG_SZ
, "Value", 6, 0);
2917 exec_import_wstr("\xef\xbb\xbf \t Windows Registry Editor Version 5.00\n\n"
2918 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2919 "\"Wine1c\"=\"Value\"\n\n");
2920 verify_reg(hkey
, "Wine1c", REG_SZ
, "Value", 6, 0);
2922 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2923 " [HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2924 "\"Wine2a\"=\"Value\"\n\n");
2925 verify_reg(hkey
, "Wine2a", REG_SZ
, "Value", 6, 0);
2927 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2928 "\t[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2929 "\"Wine2b\"=\"Value\"\n\n");
2930 verify_reg(hkey
, "Wine2b", REG_SZ
, "Value", 6, 0);
2932 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2933 " \t [HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2934 "\"Wine2c\"=\"Value\"\n\n");
2935 verify_reg(hkey
, "Wine2c", REG_SZ
, "Value", 6, 0);
2937 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2938 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2939 " \"Wine3a\"=\"Two leading spaces\"\n\n");
2940 verify_reg(hkey
, "Wine3a", REG_SZ
, "Two leading spaces", 19, 0);
2942 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2943 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2944 "\t\"Wine3b\"=\"One leading tab\"\n\n");
2945 verify_reg(hkey
, "Wine3b", REG_SZ
, "One leading tab", 16, 0);
2947 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2948 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2949 " \t \"Wine3c\"=\"Space, tab, space\"\n\n");
2950 verify_reg(hkey
, "Wine3c", REG_SZ
, "Space, tab, space", 18, 0);
2952 exec_import_wstr("\xef\xbb\xbf Windows Registry Editor Version 5.00\n\n"
2953 "\t\t\t[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2954 "\t \"Wine4a\"=\"Tab and four spaces\"\n"
2955 " \"Wine4b\"=dword:00112233\n"
2956 "\t \t \t \t \t \t \"Wine4c\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2957 " 63,00,6f,00,6e,00,\\;comment\n"
2958 "\t\t\t\t63,00,61,00,74,00,\\;comment\n"
2959 " \t65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
2960 verify_reg(hkey
, "Wine4a", REG_SZ
, "Tab and four spaces", 20, 0);
2962 verify_reg(hkey
, "Wine4b", REG_DWORD
, &dword
, sizeof(dword
), 0);
2963 verify_reg(hkey
, "Wine4c", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
2965 exec_import_wstr("\xef\xbb\xbf Windows Registry Editor Version 5.00\n\n"
2966 "\t[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2967 " \"Wine5a\"=\"Leading spaces\"\n"
2968 "\t\t\"Wine5b\"\t\t=\"Leading tabs\"\n"
2969 "\t \"Wine5c\"=\t \"Tabs and spaces\"\n"
2970 " \"Wine5d\" \t = \t \"More whitespace\"\n\n");
2971 verify_reg(hkey
, "Wine5a", REG_SZ
, "Leading spaces", 15, 0);
2972 verify_reg(hkey
, "Wine5b", REG_SZ
, "Leading tabs", 13, 0);
2973 verify_reg(hkey
, "Wine5c", REG_SZ
, "Tabs and spaces", 16, 0);
2974 verify_reg(hkey
, "Wine5d", REG_SZ
, "More whitespace", 16, 0);
2976 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2977 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2978 "\" Wine6a\"=\"Leading spaces\"\n"
2979 "\"\t\tWine6b\"=\"Leading tabs\"\n"
2980 " \" Wine6c \" = \" Spaces everywhere \" \n\n");
2981 verify_reg(hkey
, " Wine6a", REG_SZ
, "Leading spaces", 15, 0);
2982 verify_reg(hkey
, "\t\tWine6b", REG_SZ
, "Leading tabs", 13, 0);
2983 verify_reg(hkey
, " Wine6c ", REG_SZ
, " Spaces everywhere ", 22, 0);
2985 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2986 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2987 "\"Wine7a\"=\" Four spaces in the data\"\n"
2988 "\"Wine7b\"=\"\t\tTwo tabs in the data\"\n\n");
2989 verify_reg(hkey
, "Wine7a", REG_SZ
, " Four spaces in the data", 28, 0);
2990 verify_reg(hkey
, "Wine7b", REG_SZ
, "\t\tTwo tabs in the data", 23, 0);
2992 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2993 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
2994 "\"Wine8a\"=\"Trailing spaces\" \n"
2995 "\"Wine8b\"=\"Trailing tabs and spaces\"\t \t\n\n");
2996 verify_reg(hkey
, "Wine8a", REG_SZ
, "Trailing spaces", 16, 0);
2997 verify_reg(hkey
, "Wine8b", REG_SZ
, "Trailing tabs and spaces", 25, 0);
2999 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3000 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3001 "\"Wine9a\"=dword: 00000008\n"
3002 "\"Wine9b\"=dword:\t\t00000008\n\n");
3004 verify_reg(hkey
, "Wine9a", REG_DWORD
, &dword
, sizeof(dword
), 0);
3005 verify_reg(hkey
, "Wine9b", REG_DWORD
, &dword
, sizeof(dword
), 0);
3007 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3008 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3009 "@ = \"Test Value\"\n\n");
3010 verify_reg(hkey
, "", REG_SZ
, "Test Value", 11, 0);
3012 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3013 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3014 "\t@\t=\tdword:\t00000008\t\n\n");
3015 verify_reg(hkey
, "", REG_DWORD
, &dword
, sizeof(DWORD
), 0);
3017 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3018 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3019 "\"Wine10a\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
3020 " 63,00,6f,00,6e,00,\\\n\n"
3021 " 63,00,61,00,74,00,\\\n\n\n"
3022 " 65,00,6e,00,\\\n\n\n\n"
3023 " 61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
3024 verify_reg(hkey
, "Wine10a", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
3026 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3027 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3028 "\"Wine10b\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
3029 " 63,00,6f,00,6e,00,\\\n \n"
3030 " 63,00,61,00,74,00,\\\n\t\n\t\n"
3031 " 65,00,6e,00,\\\n\t \t\n\t \t\n\t \t\n"
3032 " 61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n");
3033 verify_reg(hkey
, "Wine10b", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
3037 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3040 static void test_key_creation_and_deletion(void)
3044 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
3045 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
3047 exec_import_str("REGEDIT4\n\n"
3048 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n");
3050 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
3052 /* Test key creation */
3053 exec_import_str("REGEDIT4\n\n"
3054 "HKEY_CURRENT_USER\\" KEY_BASE
"\\No_Opening_Bracket]\n");
3055 verify_key_nonexist(hkey
, "No_Opening_Bracket");
3057 exec_import_str("REGEDIT4\n\n"
3058 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\No_Closing_Bracket\n");
3059 verify_key_nonexist(hkey
, "No_Closing_Bracket");
3061 exec_import_str("REGEDIT4\n\n"
3062 "[ HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1a]\n");
3063 verify_key_nonexist(hkey
, "Subkey1a");
3065 exec_import_str("REGEDIT4\n\n"
3066 "[\tHKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1b]\n");
3067 verify_key_nonexist(hkey
, "Subkey1b");
3069 exec_import_str("REGEDIT4\n\n"
3070 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1c ]\n");
3071 verify_key(hkey
, "Subkey1c ");
3072 delete_key(hkey
, "Subkey1c ");
3074 exec_import_str("REGEDIT4\n\n"
3075 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1d\t]\n");
3076 verify_key(hkey
, "Subkey1d\t");
3077 delete_key(hkey
, "Subkey1d\t");
3079 exec_import_str("REGEDIT4\n\n"
3080 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1e\\]\n"
3081 "\"Wine\"=\"Test value\"\n\n");
3082 verify_key(hkey
, "Subkey1e\\");
3083 verify_key(hkey
, "Subkey1e");
3084 open_key(hkey
, "Subkey1e", 0, &subkey
);
3085 verify_reg(subkey
, "Wine", REG_SZ
, "Test value", 11, 0);
3087 delete_key(hkey
, "Subkey1e");
3089 exec_import_str("REGEDIT4\n\n"
3090 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1f\\\\]\n"
3091 "\"Wine\"=\"Test value\"\n\n");
3092 verify_key(hkey
, "Subkey1f\\\\");
3093 verify_key(hkey
, "Subkey1f\\");
3094 verify_key(hkey
, "Subkey1f");
3095 open_key(hkey
, "Subkey1f\\\\", 0, &subkey
);
3096 verify_reg(subkey
, "Wine", REG_SZ
, "Test value", 11, 0);
3098 delete_key(hkey
, "Subkey1f\\\\");
3100 exec_import_str("REGEDIT4\n\n"
3101 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1g\\\\\\\\]\n"
3102 "\"Wine\"=\"Test value\"\n\n");
3103 verify_key(hkey
, "Subkey1g\\\\\\\\");
3104 verify_key(hkey
, "Subkey1g\\\\");
3105 verify_key(hkey
, "Subkey1g\\");
3106 verify_key(hkey
, "Subkey1g");
3107 open_key(hkey
, "Subkey1g\\\\", 0, &subkey
);
3108 verify_reg(subkey
, "Wine", REG_SZ
, "Test value", 11, 0);
3110 delete_key(hkey
, "Subkey1g\\\\");
3112 /* Test key deletion. We start by creating some registry keys. */
3113 exec_import_str("REGEDIT4\n\n"
3114 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n\n"
3115 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n\n");
3116 verify_key(hkey
, "Subkey2a");
3117 verify_key(hkey
, "Subkey2b");
3119 exec_import_str("REGEDIT4\n\n"
3120 "[ -HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n");
3121 verify_key(hkey
, "Subkey2a");
3123 exec_import_str("REGEDIT4\n\n"
3124 "[\t-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n");
3125 verify_key(hkey
, "Subkey2b");
3127 exec_import_str("REGEDIT4\n\n"
3128 "[- HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n");
3129 verify_key(hkey
, "Subkey2a");
3131 exec_import_str("REGEDIT4\n\n"
3132 "[-\tHKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n");
3133 verify_key(hkey
, "Subkey2b");
3135 exec_import_str("REGEDIT4\n\n"
3136 "[-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n\n"
3137 "[-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n\n");
3138 verify_key_nonexist(hkey
, "Subkey2a");
3139 verify_key_nonexist(hkey
, "Subkey2b");
3141 /* Test case sensitivity when creating and deleting registry keys. */
3142 exec_import_str("REGEDIT4\n\n"
3143 "[hkey_CURRENT_user\\" KEY_BASE
"\\Subkey3a]\n\n"
3144 "[HkEy_CuRrEnT_uSeR\\" KEY_BASE
"\\SuBkEy3b]\n\n");
3145 verify_key(hkey
, "Subkey3a");
3146 verify_key(hkey
, "Subkey3b");
3148 exec_import_str("REGEDIT4\n\n"
3149 "[-HKEY_current_USER\\" KEY_BASE
"\\sUBKEY3A]\n\n"
3150 "[-hKeY_cUrReNt_UsEr\\" KEY_BASE
"\\sUbKeY3B]\n\n");
3151 verify_key_nonexist(hkey
, "Subkey3a");
3152 verify_key_nonexist(hkey
, "Subkey3b");
3154 /* Test mixed key creation and deletion. We start by creating a subkey. */
3155 exec_import_str("REGEDIT4\n\n"
3156 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey4a]\n\n");
3157 verify_key(hkey
, "Subkey4a");
3159 exec_import_str("REGEDIT4\n\n"
3160 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n"
3161 "[-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey4a]\n"
3162 "\"Wine1a\"=dword:12345678\n\n");
3163 verify_key_nonexist(hkey
, "Subkey4a");
3164 verify_reg_nonexist(hkey
, "Wine1a");
3166 exec_import_str("REGEDIT4\n\n"
3167 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n"
3168 "[HKEY_CURRENT_USERS\\" KEY_BASE
"\\Subkey4b]\n"
3169 "\"Wine1b\"=dword:12345678\n\n");
3170 verify_key_nonexist(hkey
, "Subkey4b");
3171 verify_reg_nonexist(hkey
, "Wine1b");
3175 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3178 static void test_key_creation_and_deletion_unicode(void)
3182 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
3183 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
3185 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3186 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n");
3188 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
3190 /* Test key creation */
3191 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3192 "HKEY_CURRENT_USER\\" KEY_BASE
"\\No_Opening_Bracket]\n");
3193 verify_key_nonexist(hkey
, "No_Opening_Bracket");
3195 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3196 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\No_Closing_Bracket\n");
3197 verify_key_nonexist(hkey
, "No_Closing_Bracket");
3199 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3200 "[ HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1a]\n");
3201 verify_key_nonexist(hkey
, "Subkey1a");
3203 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3204 "[\tHKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1b]\n");
3205 verify_key_nonexist(hkey
, "Subkey1b");
3207 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3208 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1c ]\n");
3209 verify_key(hkey
, "Subkey1c ");
3210 delete_key(hkey
, "Subkey1c ");
3212 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3213 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1d\t]\n");
3214 verify_key(hkey
, "Subkey1d\t");
3215 delete_key(hkey
, "Subkey1d\t");
3217 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3218 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1e\\]\n"
3219 "\"Wine\"=\"Test value\"\n\n");
3220 verify_key(hkey
, "Subkey1e\\");
3221 verify_key(hkey
, "Subkey1e");
3222 open_key(hkey
, "Subkey1e", 0, &subkey
);
3223 verify_reg(subkey
, "Wine", REG_SZ
, "Test value", 11, 0);
3225 delete_key(hkey
, "Subkey1e");
3227 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3228 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1f\\\\]\n"
3229 "\"Wine\"=\"Test value\"\n\n");
3230 verify_key(hkey
, "Subkey1f\\\\");
3231 verify_key(hkey
, "Subkey1f\\");
3232 verify_key(hkey
, "Subkey1f");
3233 open_key(hkey
, "Subkey1f\\\\", 0, &subkey
);
3234 verify_reg(subkey
, "Wine", REG_SZ
, "Test value", 11, 0);
3236 delete_key(hkey
, "Subkey1f\\\\");
3238 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3239 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1g\\\\\\\\]\n"
3240 "\"Wine\"=\"Test value\"\n\n");
3241 verify_key(hkey
, "Subkey1g\\\\\\\\");
3242 verify_key(hkey
, "Subkey1g\\\\");
3243 verify_key(hkey
, "Subkey1g\\");
3244 verify_key(hkey
, "Subkey1g");
3245 open_key(hkey
, "Subkey1g\\\\", 0, &subkey
);
3246 verify_reg(subkey
, "Wine", REG_SZ
, "Test value", 11, 0);
3248 delete_key(hkey
, "Subkey1g\\\\");
3250 /* Test key deletion. We start by creating some registry keys. */
3251 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3252 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n\n"
3253 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n\n");
3254 verify_key(hkey
, "Subkey2a");
3255 verify_key(hkey
, "Subkey2b");
3257 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3258 "[ -HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n");
3259 verify_key(hkey
, "Subkey2a");
3261 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3262 "[\t-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n");
3263 verify_key(hkey
, "Subkey2b");
3265 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3266 "[- HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n");
3267 verify_key(hkey
, "Subkey2a");
3269 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3270 "[-\tHKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n");
3271 verify_key(hkey
, "Subkey2b");
3273 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3274 "[-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\n\n"
3275 "[-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2b]\n\n");
3276 verify_key_nonexist(hkey
, "Subkey2a");
3277 verify_key_nonexist(hkey
, "Subkey2b");
3279 /* Test case sensitivity when creating and deleting registry keys. */
3280 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3281 "[hkey_CURRENT_user\\" KEY_BASE
"\\Subkey3a]\n\n"
3282 "[HkEy_CuRrEnT_uSeR\\" KEY_BASE
"\\SuBkEy3b]\n\n");
3283 verify_key(hkey
, "Subkey3a");
3284 verify_key(hkey
, "Subkey3b");
3286 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3287 "[-HKEY_current_USER\\" KEY_BASE
"\\sUBKEY3A]\n\n"
3288 "[-hKeY_cUrReNt_UsEr\\" KEY_BASE
"\\sUbKeY3B]\n\n");
3289 verify_key_nonexist(hkey
, "Subkey3a");
3290 verify_key_nonexist(hkey
, "Subkey3b");
3292 /* Test mixed key creation and deletion. We start by creating a subkey. */
3293 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3294 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey4a]\n\n");
3295 verify_key(hkey
, "Subkey4a");
3297 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3298 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n"
3299 "[-HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey4a]\n"
3300 "\"Wine1a\"=dword:12345678\n\n");
3301 verify_key_nonexist(hkey
, "Subkey4a");
3302 verify_reg_nonexist(hkey
, "Wine1a");
3304 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3305 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n"
3306 "[HKEY_CURRENT_USERS\\" KEY_BASE
"\\Subkey4b]\n"
3307 "\"Wine1b\"=dword:12345678\n\n");
3308 verify_key_nonexist(hkey
, "Subkey4b");
3309 verify_reg_nonexist(hkey
, "Wine1b");
3313 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3316 static void test_value_deletion(void)
3320 BYTE hex
[4] = {0x11, 0x22, 0x33, 0x44};
3322 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
3323 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
3325 exec_import_str("REGEDIT4\n\n"
3326 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n");
3328 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
3330 /* Test value deletion. We start by creating some registry values. */
3331 exec_import_str("REGEDIT4\n\n"
3332 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3333 "\"Wine46a\"=\"Test Value\"\n"
3334 "\"Wine46b\"=dword:00000008\n"
3335 "\"Wine46c\"=hex:11,22,33,44\n"
3336 "\"Wine46d\"=hex(7):4c,69,6e,65,20,\\\n"
3337 " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
3338 "\"Wine46e\"=hex(2):25,50,41,54,48,25,00\n"
3339 "\"Wine46f\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n\n");
3340 verify_reg(hkey
, "Wine46a", REG_SZ
, "Test Value", 11, 0);
3341 verify_reg(hkey
, "Wine46b", REG_DWORD
, &dword
, sizeof(dword
), 0);
3342 verify_reg(hkey
, "Wine46c", REG_BINARY
, hex
, 4, 0);
3343 verify_reg(hkey
, "Wine46d", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
3344 verify_reg(hkey
, "Wine46e", REG_EXPAND_SZ
, "%PATH%", 7, 0);
3345 verify_reg(hkey
, "Wine46f", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
3347 exec_import_str("REGEDIT4\n\n"
3348 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3351 "\"Wine46c\"= \t-\t \n"
3352 "\"Wine46d\"=-\"Test\"\n"
3353 "\"Wine46e\"=- ;comment\n"
3354 "\"Wine46f\"=- #comment\n\n");
3355 verify_reg_nonexist(hkey
, "Wine46a");
3356 verify_reg_nonexist(hkey
, "Wine46b");
3357 verify_reg_nonexist(hkey
, "Wine46c");
3358 verify_reg(hkey
, "Wine46d", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
3359 verify_reg_nonexist(hkey
, "Wine46e");
3360 verify_reg(hkey
, "Wine46f", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
3364 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3368 static void test_value_deletion_unicode(void)
3372 BYTE hex
[4] = {0x11, 0x22, 0x33, 0x44};
3374 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
3375 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
3377 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3378 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n\n");
3380 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
3382 /* Test value deletion. We start by creating some registry values. */
3383 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3384 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3385 "\"Wine46a\"=\"Test Value\"\n"
3386 "\"Wine46b\"=dword:00000008\n"
3387 "\"Wine46c\"=hex:11,22,33,44\n"
3388 "\"Wine46d\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
3389 " 63,00,6f,00,6e,00,63,00,61,00,74,00,\\\n"
3390 " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
3391 "\"Wine46e\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
3392 "\"Wine46f\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n\n");
3393 verify_reg(hkey
, "Wine46a", REG_SZ
, "Test Value", 11, 0);
3394 verify_reg(hkey
, "Wine46b", REG_DWORD
, &dword
, sizeof(dword
), 0);
3395 verify_reg(hkey
, "Wine46c", REG_BINARY
, hex
, 4, 0);
3396 verify_reg(hkey
, "Wine46d", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
3397 verify_reg(hkey
, "Wine46e", REG_EXPAND_SZ
, "%PATH%", 7, 0);
3398 verify_reg(hkey
, "Wine46f", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
3400 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3401 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3404 "\"Wine46c\"= \t-\t \n"
3405 "\"Wine46d\"=-\"Test\"\n"
3406 "\"Wine46e\"=- ;comment\n"
3407 "\"Wine46f\"=- #comment\n\n");
3408 verify_reg_nonexist(hkey
, "Wine46a");
3409 verify_reg_nonexist(hkey
, "Wine46b");
3410 verify_reg_nonexist(hkey
, "Wine46c");
3411 verify_reg(hkey
, "Wine46d", REG_MULTI_SZ
, "Line concatenation\0", 20, 0);
3412 verify_reg_nonexist(hkey
, "Wine46e");
3413 verify_reg(hkey
, "Wine46f", REG_NONE
, "V\0a\0l\0u\0e\0\0", 12, 0);
3417 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3420 #define compare_export(f,e,todo) compare_export_(__LINE__,f,e,todo)
3421 static BOOL
compare_export_(unsigned line
, const char *filename
, const char *expected
, DWORD todo
)
3425 WCHAR
*fbuf
= NULL
, *wstr
= NULL
;
3429 fp
= fopen(filename
, "rb");
3430 if (!fp
) return FALSE
;
3432 if (fseek(fp
, 0, SEEK_END
)) goto error
;
3433 file_size
= ftell(fp
);
3434 if (file_size
== -1) goto error
;
3437 fbuf
= HeapAlloc(GetProcessHeap(), 0, file_size
+ sizeof(WCHAR
));
3438 if (!fbuf
) goto error
;
3440 fread(fbuf
, file_size
, 1, fp
);
3441 fbuf
[file_size
/sizeof(WCHAR
)] = 0;
3444 len
= MultiByteToWideChar(CP_UTF8
, 0, expected
, -1, NULL
, 0);
3445 wstr
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
3446 if (!wstr
) goto exit
;
3447 MultiByteToWideChar(CP_UTF8
, 0, expected
, -1, wstr
, len
);
3449 todo_wine_if (todo
& TODO_REG_COMPARE
)
3450 lok(!lstrcmpW(fbuf
, wstr
), "export data does not match expected data\n");
3452 ret
= DeleteFileA(filename
);
3453 lok(ret
, "DeleteFile failed: %u\n", GetLastError());
3456 HeapFree(GetProcessHeap(), 0, fbuf
);
3457 HeapFree(GetProcessHeap(), 0, wstr
);
3465 static void test_export(void)
3471 const char *empty_key_test
=
3472 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3473 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n\r\n";
3475 const char *simple_test
=
3476 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3477 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
3478 "\"DWORD\"=dword:00000100\r\n"
3479 "\"String\"=\"Your text here...\"\r\n\r\n";
3481 const char *complex_test
=
3482 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3483 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
3484 "\"DWORD\"=dword:00000100\r\n"
3485 "\"String\"=\"Your text here...\"\r\n\r\n"
3486 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1]\r\n"
3487 "\"Binary\"=hex:11,22,33,44\r\n"
3488 "\"Undefined hex\"=hex(100):25,50,41,54,48,25,00\r\n\r\n"
3489 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a]\r\n"
3490 "\"double\\\"quote\"=\"\\\"Hello, World!\\\"\"\r\n"
3491 "\"single'quote\"=dword:00000008\r\n\r\n"
3492 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2a\\Subkey2b]\r\n"
3493 "@=\"Default value name\"\r\n"
3494 "\"Multiple strings\"=hex(7):4c,00,69,00,6e,00,65,00,31,00,00,00,4c,00,69,00,6e,\\\r\n"
3495 " 00,65,00,32,00,00,00,4c,00,69,00,6e,00,65,00,33,00,00,00,00,00\r\n\r\n"
3496 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey3a]\r\n"
3497 "\"Backslash\"=\"Use \\\\\\\\ to escape a backslash\"\r\n\r\n"
3498 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey3a\\Subkey3b]\r\n\r\n"
3499 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey3a\\Subkey3b\\Subkey3c]\r\n"
3500 "\"String expansion\"=hex(2):25,00,48,00,4f,00,4d,00,45,00,25,00,5c,00,25,00,50,\\\r\n"
3501 " 00,41,00,54,00,48,00,25,00,00,00\r\n"
3502 "\"Zero data type\"=hex(0):56,61,6c,75,65,00\r\n\r\n"
3503 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey4]\r\n"
3504 "@=dword:12345678\r\n"
3505 "\"43981\"=hex(abcd):56,61,6c,75,65,00\r\n\r\n";
3507 const char *key_order_test
=
3508 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3509 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n\r\n"
3510 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey1]\r\n\r\n"
3511 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\Subkey2]\r\n\r\n";
3513 const char *value_order_test
=
3514 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3515 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
3516 "\"Value 2\"=\"I was added first!\"\r\n"
3517 "\"Value 1\"=\"I was added second!\"\r\n\r\n";
3519 const char *empty_hex_test
=
3520 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3521 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
3522 "\"Wine1a\"=hex(0):\r\n"
3523 "\"Wine1b\"=\"\"\r\n"
3524 "\"Wine1c\"=hex(2):\r\n"
3525 "\"Wine1d\"=hex:\r\n"
3526 "\"Wine1e\"=hex(4):\r\n"
3527 "\"Wine1f\"=hex(7):\r\n"
3528 "\"Wine1g\"=hex(100):\r\n"
3529 "\"Wine1h\"=hex(abcd):\r\n\r\n";
3531 const char *empty_hex_test2
=
3532 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3533 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
3534 "\"Wine2a\"=\"\"\r\n"
3535 "\"Wine2b\"=hex:\r\n"
3536 "\"Wine2c\"=hex(4):\r\n\r\n";
3538 const char *hex_types_test
=
3539 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3540 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
3541 "\"Wine3a\"=\"Value\"\r\n"
3542 "\"Wine3b\"=hex:12,34,56,78\r\n"
3543 "\"Wine3c\"=dword:10203040\r\n\r\n";
3545 const char *embedded_null_test
=
3546 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3547 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
3548 "\"Wine4a\"=dword:00000005\r\n"
3549 "\"Wine4b\"=\"\"\r\n"
3550 "\"Wine4c\"=\"Value\"\r\n"
3551 "\"Wine4d\"=\"\"\r\n"
3552 "\"Wine4e\"=dword:00000100\r\n"
3553 "\"Wine4f\"=\"\"\r\n"
3554 "\"Wine4g\"=\"Value2\"\r\n"
3555 "\"Wine4h\"=\"abc\"\r\n\r\n";
3557 const char *slashes_test
=
3558 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3559 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
3560 "\"count/up\"=\"one/two/three\"\r\n"
3561 "\"\\\\foo\\\\bar\"=\"\"\r\n\r\n"
3562 "[HKEY_CURRENT_USER\\" KEY_BASE
"\\https://winehq.org]\r\n\r\n";
3564 const char *escaped_null_test
=
3565 "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n"
3566 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\r\n"
3567 "\"Wine5a\"=\"\\\\0\"\r\n"
3568 "\"Wine5b\"=\"\\\\0\\\\0\"\r\n"
3569 "\"Wine5c\"=\"Value1\\\\0\"\r\n"
3570 "\"Wine5d\"=\"Value2\\\\0\\\\0\\\\0\\\\0\"\r\n"
3571 "\"Wine5e\"=\"Value3\\\\0Value4\"\r\n"
3572 "\"Wine5f\"=\"\\\\0Value5\"\r\n\r\n";
3574 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
3575 verify_key_nonexist(HKEY_CURRENT_USER
, KEY_BASE
);
3577 /* Test registry export with an empty key */
3578 add_key(HKEY_CURRENT_USER
, KEY_BASE
, &hkey
);
3580 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3581 ok(compare_export("file.reg", empty_key_test
, 0), "compare_export() failed\n");
3583 /* Test registry export with a simple data structure */
3585 add_value(hkey
, "DWORD", REG_DWORD
, &dword
, sizeof(dword
));
3586 add_value(hkey
, "String", REG_SZ
, "Your text here...", 18);
3588 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3589 ok(compare_export("file.reg", simple_test
, 0), "compare_export() failed\n");
3591 /* Test registry export with a complex data structure */
3592 add_key(hkey
, "Subkey1", &subkey
);
3593 add_value(subkey
, "Binary", REG_BINARY
, "\x11\x22\x33\x44", 4);
3594 add_value(subkey
, "Undefined hex", 0x100, "%PATH%", 7);
3597 add_key(hkey
, "Subkey2a", &subkey
);
3598 add_value(subkey
, "double\"quote", REG_SZ
, "\"Hello, World!\"", 16);
3600 add_value(subkey
, "single'quote", REG_DWORD
, &dword
, sizeof(dword
));
3603 add_key(hkey
, "Subkey2a\\Subkey2b", &subkey
);
3604 add_value(subkey
, NULL
, REG_SZ
, "Default value name", 19);
3605 add_value(subkey
, "Multiple strings", REG_MULTI_SZ
, "Line1\0Line2\0Line3\0", 19);
3608 add_key(hkey
, "Subkey3a", &subkey
);
3609 add_value(subkey
, "Backslash", REG_SZ
, "Use \\\\ to escape a backslash", 29);
3612 add_key(hkey
, "Subkey3a\\Subkey3b\\Subkey3c", &subkey
);
3613 add_value(subkey
, "String expansion", REG_EXPAND_SZ
, "%HOME%\\%PATH%", 14);
3614 add_value(subkey
, "Zero data type", REG_NONE
, "Value", 6);
3617 add_key(hkey
, "Subkey4", &subkey
);
3619 add_value(subkey
, NULL
, REG_DWORD
, &dword
, sizeof(dword
));
3620 add_value(subkey
, "43981", 0xabcd, "Value", 6);
3624 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3625 ok(compare_export("file.reg", complex_test
, 0), "compare_export() failed\n");
3626 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
3628 /* Test the export order of registry keys */
3629 add_key(HKEY_CURRENT_USER
, KEY_BASE
, &hkey
);
3630 add_key(hkey
, "Subkey2", &subkey
);
3632 add_key(hkey
, "Subkey1", &subkey
);
3635 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3636 ok(compare_export("file.reg", key_order_test
, 0), "compare_export() failed\n");
3637 delete_key(hkey
, "Subkey1");
3638 delete_key(hkey
, "Subkey2");
3640 /* Test the export order of registry values. Windows exports registry values
3641 * in order of creation; Wine uses alphabetical order.
3643 add_value(hkey
, "Value 2", REG_SZ
, "I was added first!", 19);
3644 add_value(hkey
, "Value 1", REG_SZ
, "I was added second!", 20);
3647 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3648 ok(compare_export("file.reg", value_order_test
, TODO_REG_COMPARE
), "compare_export() failed\n");
3649 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3651 /* Test registry export with empty hex data */
3652 add_key(HKEY_CURRENT_USER
, KEY_BASE
, &hkey
);
3653 add_value(hkey
, "Wine1a", REG_NONE
, NULL
, 0);
3654 add_value(hkey
, "Wine1b", REG_SZ
, NULL
, 0);
3655 add_value(hkey
, "Wine1c", REG_EXPAND_SZ
, NULL
, 0);
3656 add_value(hkey
, "Wine1d", REG_BINARY
, NULL
, 0);
3657 add_value(hkey
, "Wine1e", REG_DWORD
, NULL
, 0);
3658 add_value(hkey
, "Wine1f", REG_MULTI_SZ
, NULL
, 0);
3659 add_value(hkey
, "Wine1g", 0x100, NULL
, 0);
3660 add_value(hkey
, "Wine1h", 0xabcd, NULL
, 0);
3663 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3664 ok(compare_export("file.reg", empty_hex_test
, 0), "compare_export() failed\n");
3665 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3667 /* Test registry export after importing alternative registry data types */
3668 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3669 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3670 "\"Wine2a\"=hex(1):\n"
3671 "\"Wine2b\"=hex(3):\n"
3672 "\"Wine2c\"=hex(4):\n\n");
3673 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
3674 verify_reg(hkey
, "Wine2a", REG_SZ
, NULL
, 0, 0);
3675 verify_reg(hkey
, "Wine2b", REG_BINARY
, NULL
, 0, 0);
3676 verify_reg(hkey
, "Wine2c", REG_DWORD
, NULL
, 0, 0);
3679 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3680 ok(compare_export("file.reg", empty_hex_test2
, 0), "compare_export() failed\n");
3681 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3683 /* Test registry export with embedded null characters */
3684 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3685 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3686 "\"Wine3a\"=hex(1):56,00,61,00,6c,00,75,00,65,00,00,00\n"
3687 "\"Wine3b\"=hex(3):12,34,56,78\n"
3688 "\"Wine3c\"=hex(4):40,30,20,10\n\n");
3689 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
3690 verify_reg(hkey
, "Wine3a", REG_SZ
, "Value", 6, 0);
3691 memcpy(hex
, "\x12\x34\x56\x78", 4);
3692 verify_reg(hkey
, "Wine3b", REG_BINARY
, hex
, 4, 0);
3694 verify_reg(hkey
, "Wine3c", REG_DWORD
, &dword
, sizeof(dword
), 0);
3697 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3698 ok(compare_export("file.reg", hex_types_test
, 0), "compare_export() failed\n");
3699 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3701 exec_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3702 "[HKEY_CURRENT_USER\\" KEY_BASE
"]\n"
3703 "\"Wine4a\"=dword:00000005\n"
3704 "\"Wine4b\"=hex(1):00,00,00,00,00,00,00,00\n"
3705 "\"Wine4c\"=\"Value\"\n"
3706 "\"Wine4d\"=hex(1):00,00,61,00,62,00,63,00\n"
3707 "\"Wine4e\"=dword:00000100\n"
3708 "\"Wine4f\"=hex(1):00,00,56,00,61,00,6c,00,75,00,65,00,00,00\n"
3709 "\"Wine4g\"=\"Value2\"\n"
3710 "\"Wine4h\"=hex(1):61,00,62,00,63,00,00,00, \\\n"
3711 " 64,00,65,00,66,00,00,00\n\n");
3712 open_key(HKEY_CURRENT_USER
, KEY_BASE
, 0, &hkey
);
3714 verify_reg(hkey
, "Wine4a", REG_DWORD
, &dword
, sizeof(dword
), 0);
3715 verify_reg(hkey
, "Wine4b", REG_SZ
, "\0\0\0\0\0\0\0", 4, 0);
3716 verify_reg(hkey
, "Wine4c", REG_SZ
, "Value", 6, 0);
3717 verify_reg(hkey
, "Wine4d", REG_SZ
, "\0abc", 5, 0);
3719 verify_reg(hkey
, "Wine4e", REG_DWORD
, &dword
, sizeof(dword
), 0);
3720 verify_reg(hkey
, "Wine4f", REG_SZ
, "\0Value", 7, 0);
3721 verify_reg(hkey
, "Wine4g", REG_SZ
, "Value2", 7, 0);
3722 verify_reg(hkey
, "Wine4h", REG_SZ
, "abc\0def", 8, 0);
3725 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3726 ok(compare_export("file.reg", embedded_null_test
, 0), "compare_export() failed\n");
3727 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3729 /* Test registry export with forward and back slashes */
3730 add_key(HKEY_CURRENT_USER
, KEY_BASE
, &hkey
);
3731 add_key(hkey
, "https://winehq.org", &subkey
);
3733 add_value(hkey
, "count/up", REG_SZ
, "one/two/three", 14);
3734 add_value(hkey
, "\\foo\\bar", REG_SZ
, "", 1);
3737 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3738 ok(compare_export("file.reg", slashes_test
, TODO_REG_COMPARE
), "compare_export() failed\n");
3739 delete_tree(HKEY_CURRENT_USER
, KEY_BASE
);
3741 /* Test registry export with escaped null characters */
3742 add_key(HKEY_CURRENT_USER
, KEY_BASE
, &hkey
);
3743 add_value(hkey
, "Wine5a", REG_SZ
, "\\0", 3);
3744 add_value(hkey
, "Wine5b", REG_SZ
, "\\0\\0", 5);
3745 add_value(hkey
, "Wine5c", REG_SZ
, "Value1\\0", 9);
3746 add_value(hkey
, "Wine5d", REG_SZ
, "Value2\\0\\0\\0\\0", 15);
3747 add_value(hkey
, "Wine5e", REG_SZ
, "Value3\\0Value4", 15);
3748 add_value(hkey
, "Wine5f", REG_SZ
, "\\0Value5", 9);
3751 run_regedit_exe("regedit.exe /e file.reg HKEY_CURRENT_USER\\" KEY_BASE
);
3752 ok(compare_export("file.reg", escaped_null_test
, 0), "compare_export() failed\n");
3753 delete_key(HKEY_CURRENT_USER
, KEY_BASE
);
3761 /* Check if regedit.exe is running with elevated privileges */
3762 err
= RegDeleteKeyA(HKEY_CLASSES_ROOT
, KEY_BASE
);
3763 if (err
== ERROR_ACCESS_DENIED
)
3765 win_skip("User is a non-elevated admin; skipping regedit tests.\n");
3768 if (err
== ERROR_FILE_NOT_FOUND
)
3770 if (RegCreateKeyExA(HKEY_CLASSES_ROOT
, KEY_BASE
, 0, NULL
, REG_OPTION_NON_VOLATILE
,
3771 KEY_READ
, NULL
, &hkey
, NULL
))
3773 win_skip("User is a non-elevated admin; skipping regedit tests.\n");
3777 RegDeleteKeyA(HKEY_CLASSES_ROOT
, KEY_BASE
);
3780 test_basic_import();
3781 test_basic_import_unicode();
3782 test_basic_import_31();
3783 test_invalid_import();
3784 test_invalid_import_unicode();
3785 test_invalid_import_31();
3787 test_comments_unicode();
3788 test_import_with_whitespace();
3789 test_import_with_whitespace_unicode();
3790 test_key_creation_and_deletion();
3791 test_key_creation_and_deletion_unicode();
3792 test_value_deletion();
3793 test_value_deletion_unicode();