ReactOS  0.4.14-dev-297-g23e575c
reg.c
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Akihiro Sagawa
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include <stdio.h>
20 #include <windows.h>
21 #include "wine/test.h"
22 
23 #define lok ok_(__FILE__,line)
24 #define KEY_BASE "Software\\Wine\\reg_test"
25 #define REG_EXIT_SUCCESS 0
26 #define REG_EXIT_FAILURE 1
27 #define TODO_REG_TYPE (0x0001u)
28 #define TODO_REG_SIZE (0x0002u)
29 #define TODO_REG_DATA (0x0004u)
30 #define TODO_REG_COMPARE (0x0008u)
31 
32 #define run_reg_exe(c,r) run_reg_exe_(__LINE__,c,r)
33 static BOOL run_reg_exe_(unsigned line, const char *cmd, DWORD *rc)
34 {
35  STARTUPINFOA si = {sizeof(STARTUPINFOA)};
37  BOOL bret;
38  DWORD ret;
39  char cmdline[256];
40 
45 
46  strcpy(cmdline, cmd);
47  if (!CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
48  return FALSE;
49 
50  ret = WaitForSingleObject(pi.hProcess, 10000);
51  if (ret == WAIT_TIMEOUT)
52  TerminateProcess(pi.hProcess, 1);
53 
54  bret = GetExitCodeProcess(pi.hProcess, rc);
55  lok(bret, "GetExitCodeProcess failed: %d\n", GetLastError());
56 
57  CloseHandle(pi.hThread);
58  CloseHandle(pi.hProcess);
59  return bret;
60 }
61 
62 #define verify_reg(k,v,t,d,s,todo) verify_reg_(__LINE__,k,v,t,d,s,todo)
63 static void verify_reg_(unsigned line, HKEY hkey, const char* value,
64  DWORD exp_type, const void *exp_data, DWORD exp_size, DWORD todo)
65 {
66  DWORD type, size;
67  BYTE data[256];
68  LONG err;
69 
70  size = sizeof(data);
71  memset(data, 0xdd, size);
72  err = RegQueryValueExA(hkey, value, NULL, &type, data, &size);
73  lok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
74  if (err != ERROR_SUCCESS)
75  return;
76 
78  lok(type == exp_type, "got wrong type %d, expected %d\n", type, exp_type);
80  lok(size == exp_size, "got wrong size %d, expected %d\n", size, exp_size);
81  if (exp_data)
82  {
84  lok(memcmp(data, exp_data, size) == 0, "got wrong data\n");
85  }
86 }
87 
88 #define verify_reg_nonexist(k,v) verify_reg_nonexist_(__LINE__,k,v)
89 static void verify_reg_nonexist_(unsigned line, HKEY hkey, const char *value)
90 {
91  LONG err;
92 
94  lok(err == ERROR_FILE_NOT_FOUND, "registry value '%s' shouldn't exist; got %d, expected 2\n",
95  (value && *value) ? value : "(Default)", err);
96 }
97 
98 #define open_key(b,p,s,k) open_key_(__LINE__,b,p,s,k)
99 static void open_key_(unsigned line, const HKEY base, const char *path, const DWORD sam, HKEY *hkey)
100 {
101  LONG err;
102 
103  err = RegOpenKeyExA(base, path, 0, KEY_READ|sam, hkey);
104  lok(err == ERROR_SUCCESS, "RegOpenKeyExA failed: %d\n", err);
105 }
106 
107 #define verify_key(k,s) verify_key_(__LINE__,k,s)
108 static void verify_key_(unsigned line, HKEY key_base, const char *subkey)
109 {
110  HKEY hkey;
111  LONG err;
112 
113  err = RegOpenKeyExA(key_base, subkey, 0, KEY_READ, &hkey);
114  lok(err == ERROR_SUCCESS, "RegOpenKeyExA failed: got %d\n", err);
115 
116  if (hkey)
117  RegCloseKey(hkey);
118 }
119 
120 #define verify_key_nonexist(k,s) verify_key_nonexist_(__LINE__,k,s)
121 static void verify_key_nonexist_(unsigned line, HKEY key_base, const char *subkey)
122 {
123  HKEY hkey;
124  LONG err;
125 
126  err = RegOpenKeyExA(key_base, subkey, 0, KEY_READ, &hkey);
127  lok(err == ERROR_FILE_NOT_FOUND, "registry key '%s' shouldn't exist; got %d, expected 2\n",
128  subkey, err);
129 
130  if (hkey)
131  RegCloseKey(hkey);
132 }
133 
134 #define add_key(k,p,s) add_key_(__LINE__,k,p,s)
135 static void add_key_(unsigned line, const HKEY hkey, const char *path, HKEY *subkey)
136 {
137  LONG err;
138 
140  KEY_READ|KEY_WRITE, NULL, subkey, NULL);
141  lok(err == ERROR_SUCCESS, "RegCreateKeyExA failed: %d\n", err);
142 }
143 
144 #define delete_key(k,p) delete_key_(__LINE__,k,p)
145 static void delete_key_(unsigned line, const HKEY hkey, const char *path)
146 {
147  if (path && *path)
148  {
149  LONG err;
150 
151  err = RegDeleteKeyA(hkey, path);
152  lok(err == ERROR_SUCCESS, "RegDeleteKeyA failed: %d\n", err);
153  }
154 }
155 
156 static LONG delete_tree(const HKEY key, const char *subkey)
157 {
158  HKEY hkey;
159  LONG ret;
160  char *subkey_name = NULL;
161  DWORD max_subkey_len, subkey_len;
162  static const char empty[1];
163 
164  ret = RegOpenKeyExA(key, subkey, 0, KEY_READ, &hkey);
165  if (ret) return ret;
166 
167  ret = RegQueryInfoKeyA(hkey, NULL, NULL, NULL, NULL, &max_subkey_len,
168  NULL, NULL, NULL, NULL, NULL, NULL);
169  if (ret) goto cleanup;
170 
171  max_subkey_len++;
172 
173  subkey_name = HeapAlloc(GetProcessHeap(), 0, max_subkey_len);
174  if (!subkey_name)
175  {
177  goto cleanup;
178  }
179 
180  for (;;)
181  {
182  subkey_len = max_subkey_len;
183  ret = RegEnumKeyExA(hkey, 0, subkey_name, &subkey_len, NULL, NULL, NULL, NULL);
184  if (ret == ERROR_NO_MORE_ITEMS) break;
185  if (ret) goto cleanup;
186  ret = delete_tree(hkey, subkey_name);
187  if (ret) goto cleanup;
188  }
189 
190  ret = RegDeleteKeyA(hkey, empty);
191 
192 cleanup:
193  HeapFree(GetProcessHeap(), 0, subkey_name);
194  RegCloseKey(hkey);
195  return ret;
196 }
197 
198 #define add_value(k,n,t,d,s) add_value_(__LINE__,k,n,t,d,s)
199 static void add_value_(unsigned line, HKEY hkey, const char *name, DWORD type,
200  const void *data, size_t size)
201 {
202  LONG err;
203 
204  err = RegSetValueExA(hkey, name, 0, type, (const BYTE *)data, size);
205  lok(err == ERROR_SUCCESS, "RegSetValueExA failed: %d\n", err);
206 }
207 
208 #define delete_value(k,n) delete_value_(__LINE__,k,n)
209 static void delete_value_(unsigned line, const HKEY hkey, const char *name)
210 {
211  LONG err;
212 
213  err = RegDeleteValueA(hkey, name);
214  lok(err == ERROR_SUCCESS, "RegDeleteValueA failed: %d\n", err);
215 }
216 
217 static void test_add(void)
218 {
219  HKEY hkey;
220  LONG err;
221  DWORD r, dword, type, size;
222  char buffer[22];
223 
224  run_reg_exe("reg add", &r);
225  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
226 
227  run_reg_exe("reg add /?", &r);
228  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
229 
230  run_reg_exe("reg add /h", &r);
231  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
232 
233  run_reg_exe("reg add -H", &r);
234  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
235 
237  ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
238 
240 
241  run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
242  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
243 
244  open_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
245 
246  /* Test empty type */
247  run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\" /d WineTest /f", &r);
248  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
249 
250  /* Test input key formats */
251  run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
252  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
253  err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest0");
254  ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", err);
255 
256  run_reg_exe("reg add \\\\HKCU\\" KEY_BASE "\\keytest1 /f", &r);
257  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
258  err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest1");
259  ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", err);
260 
261  run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r);
262  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
263  "got exit code %u\n", r);
264  err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest2");
265  ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
266  "got exit code %d\n", err);
267 
268  run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);
269  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
270  verify_key(hkey, "keytest3");
271  delete_key(hkey, "keytest3");
272 
273  run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest4 /f", &r);
274  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
275  verify_key(hkey, "keytest4");
276  delete_key(hkey, "keytest4");
277 
278  /* REG_NONE */
279  run_reg_exe("reg add HKCU\\" KEY_BASE " /v none0 /d deadbeef /t REG_NONE /f", &r);
280  ok(r == REG_EXIT_SUCCESS, "got exit code %d\n", r);
281  verify_reg(hkey, "none0", REG_NONE, "d\0e\0a\0d\0b\0e\0e\0f\0\0", 18, 0);
282 
283  run_reg_exe("reg add HKCU\\" KEY_BASE " /v none1 /t REG_NONE /f", &r);
284  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
285  verify_reg(hkey, "none1", REG_NONE, "\0", 2, 0);
286 
287  run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_NONE /f", &r);
288  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
289  verify_reg(hkey, NULL, REG_NONE, "\0", 2, 0);
290 
291  /* REG_SZ */
292  run_reg_exe("reg add HKCU\\" KEY_BASE " /d WineTest /f", &r);
293  ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
294  "got exit code %d, expected 0\n", r);
295  if (r == REG_EXIT_SUCCESS)
296  verify_reg(hkey, "", REG_SZ, "WineTest", 9, 0);
297  else
298  win_skip("broken reg.exe detected\n");
299 
300  run_reg_exe("reg add HKCU\\" KEY_BASE " /v test /d deadbeef /f", &r);
301  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
302  verify_reg(hkey, "test", REG_SZ, "deadbeef", 9, 0);
303 
304  run_reg_exe("reg add HKCU\\" KEY_BASE " /v test /f", &r);
305  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
306  verify_reg(hkey, "test", REG_SZ, "", 1, 0);
307 
308  run_reg_exe("reg add HKCU\\" KEY_BASE " /v test1 /t REG_SZ /f /d", &r);
309  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
310 
311  run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /d WineTEST /f", &r);
312  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
313  verify_reg(hkey, "", REG_SZ, "WineTEST", 9, 0);
314 
315  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test2 /f", &r);
316  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
317  verify_reg(hkey, "test2", REG_SZ, "", 1, 0);
318 
319  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test3 /f /d \"\"", &r);
320  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
321  verify_reg(hkey, "test3", REG_SZ, "", 1, 0);
322 
323  run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /f", &r);
324  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
325  verify_reg(hkey, NULL, REG_SZ, "", 1, 0);
326 
327  run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_SZ /f", &r);
328  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
329  verify_reg(hkey, NULL, REG_SZ, "", 1, 0);
330 
331  /* REG_EXPAND_SZ */
332  run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand0 /t REG_EXpand_sz /d \"dead%PATH%beef\" /f", &r);
333  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
334  verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, 0);
335 
336  run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand1 /t REG_EXpand_sz /d \"dead^%PATH^%beef\" /f", &r);
337  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
338  verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, 0);
339 
340  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
341  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
342  verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, 0);
343 
344  run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
345  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
346  verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, 0);
347 
348  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand3 /f /d \"\"", &r);
349  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
350  verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, 0);
351 
352  run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_EXPAND_SZ /f", &r);
353  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
354  verify_reg(hkey, NULL, REG_EXPAND_SZ, "", 1, 0);
355 
356  /* REG_BINARY */
357  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin0 /f", &r);
358  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
359  verify_reg(hkey, "bin0", REG_BINARY, buffer, 0, 0);
360 
361  run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_BINARY /d deadbeef /f", &r);
362  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
363  dword = 0xefbeadde;
364  verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), 0);
365 
366  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin1 /f /d 0xDeAdBeEf", &r);
367  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
368  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin2 /f /d x01", &r);
369  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
370  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin3 /f /d 01x", &r);
371  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
372 
373  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin4 /f /d DeAdBeEf0DD", &r);
374  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
375  /* Remaining nibble prefixed */
376  buffer[0] = 0x0d; buffer[1] = 0xea; buffer[2] = 0xdb;
377  buffer[3] = 0xee; buffer[4] = 0xf0; buffer[5] = 0xdd;
378  /* Remaining nibble suffixed on winXP */
379  buffer[6] = 0xde; buffer[7] = 0xad; buffer[8] = 0xbe;
380  buffer[9] = 0xef; buffer[10] = 0x0d; buffer[11] = 0xd0;
381  size = 6;
382  err = RegQueryValueExA(hkey, "bin4", NULL, &type, (void *) (buffer+12), &size);
383  ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
384  ok(type == REG_BINARY, "got wrong type %u\n", type);
385  ok(size == 6, "got wrong size %u\n", size);
386  ok(memcmp(buffer, buffer+12, 6) == 0 ||
387  broken(memcmp(buffer+6, buffer+12, 6) == 0 /* WinXP */), "got wrong data\n");
388 
389  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin5 /d \"\" /f", &r);
390  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
391  verify_reg(hkey, "bin5", REG_BINARY, buffer, 0, 0);
392 
393  run_reg_exe("reg add HKCU\\" KEY_BASE " /v bin6 /t REG_BINARY /f /d", &r);
394  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
395 
396  run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_BINARY /f", &r);
397  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
398  verify_reg(hkey, NULL, REG_BINARY, buffer, 0, 0);
399 
400  /* REG_DWORD */
401  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /f /d 12345678", &r);
402  ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
403  "got exit code %d, expected 0\n", r);
404  dword = 12345678;
405  if (r == REG_EXIT_SUCCESS)
406  verify_reg(hkey, "", REG_DWORD, &dword, sizeof(dword), 0);
407  else
408  win_skip("broken reg.exe detected\n");
409 
410  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword0 /t REG_DWORD /f /d", &r);
411  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
412  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword1 /t REG_DWORD /f", &r);
413  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
414  "got exit code %d, expected 1\n", r);
415  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
416  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
417  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword3 /t REG_DWORD /d deadbeef /f", &r);
418  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
419  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword4 /t REG_DWORD /d 123xyz /f", &r);
420  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
421 
422  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword5 /t reg_dword /d 12345678 /f", &r);
423  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
424  dword = 12345678;
425  verify_reg(hkey, "dword5", REG_DWORD, &dword, sizeof(dword), 0);
426 
427  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword6 /t REG_DWORD /D 0123 /f", &r);
428  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
429  size = sizeof(dword);
430  err = RegQueryValueExA(hkey, "dword6", NULL, &type, (LPBYTE)&dword, &size);
431  ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
432  ok(type == REG_DWORD, "got wrong type %d, expected %d\n", type, REG_DWORD);
433  ok(size == sizeof(DWORD), "got wrong size %d, expected %d\n", size, (int)sizeof(DWORD));
434  ok(dword == 123 || broken(dword == 0123 /* WinXP */), "got wrong data %d, expected 123\n", dword);
435 
436  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword7 /t reg_dword /d 0xabcdefg /f", &r);
437  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
438 
439  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0xdeadbeef /f", &r);
440  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
441  dword = 0xdeadbeef;
442  verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword), 0);
443 
444  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword9 /f /d -1", &r);
445  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
446  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword10 /f /d -0x1", &r);
447  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
448 
449  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0x01ffffffff /f", &r);
450  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %d\n", r);
451 
452  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword12 /t REG_DWORD /d 0xffffffff /f", &r);
453  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
454  dword = ~0u;
455  verify_reg(hkey, "dword12", REG_DWORD, &dword, sizeof(dword), 0);
456 
457  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword13 /t REG_DWORD /d 00x123 /f", &r);
458  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
459 
460  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword14 /t REG_DWORD /d 0X123 /f", &r);
461  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
462  dword = 0x123;
463  verify_reg(hkey, "dword14", REG_DWORD, &dword, sizeof(dword), 0);
464 
465  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword15 /t REG_DWORD /d 4294967296 /f", &r);
466  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
467 
468  run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_DWORD /f", &r);
469  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
470 
471  /* REG_DWORD_LITTLE_ENDIAN */
472  run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_LE /t REG_DWORD_LITTLE_ENDIAN /d 456 /f", &r);
473  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
474  dword = 456;
475  verify_reg(hkey, "DWORD_LE", REG_DWORD_LITTLE_ENDIAN, &dword, sizeof(dword), 0);
476 
477  /* REG_DWORD_BIG_ENDIAN */
478  run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE /t REG_DWORD_BIG_ENDIAN /d 456 /f", &r);
479  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
480  dword = 456;
481  verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), 0);
482  /* REG_DWORD_BIG_ENDIAN is broken in every version of windows. It behaves like
483  * an ordinary REG_DWORD - that is little endian. GG */
484 
485  run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE2 /t REG_DWORD_BIG_ENDIAN /f /d", &r);
486  ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
487 
488  run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE3 /t REG_DWORD_BIG_ENDIAN /f", &r);
489  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
490 
491  run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_DWORD_BIG_ENDIAN /f", &r);
492  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
493 
494  /* REG_MULTI_SZ */
495  run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi0 /t REG_MULTI_SZ /d \"three\\0little\\0strings\" /f", &r);
496  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
497  memcpy(buffer, "three\0little\0strings\0", 22);
498  verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, 0);
499 
500  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi1 /s \"#\" /d \"three#little#strings\" /f", &r);
501  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
502  verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, 0);
503 
504  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi2 /d \"\" /f", &r);
505  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
506  verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, 0);
507 
508  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
509  ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
510  verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, 0);
511 
512  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
513  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
514  verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
515 
516  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
517  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
518  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi6 /s \"\\0\" /d \"three\\0little\\0strings\" /f", &r);
519  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
520  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
521  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
522  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
523  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
524  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
525  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
526  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi10 /s \"#\" /d \"#a\" /f", &r);
527  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
528 
529  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi11 /s \"#\" /d \"a#\" /f", &r);
530  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
531  buffer[0]='a'; buffer[1]=0; buffer[2]=0;
532  verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, 0);
533 
534  run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi12 /t REG_MULTI_SZ /f /d", &r);
535  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
536 
537  run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi13 /t REG_MULTI_SZ /f /s", &r);
538  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
539 
540  run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi14 /t REG_MULTI_SZ /d \"\\0a\" /f", &r);
541  ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
542 
543  run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi15 /t REG_MULTI_SZ /d \"a\\0\" /f", &r);
544  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
545  verify_reg(hkey, "multi15", REG_MULTI_SZ, buffer, 3, 0);
546 
547  run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi16 /d \"two\\0\\0strings\" /f", &r);
548  ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
549 
550  run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi17 /t REG_MULTI_SZ /s \"#\" /d \"#\" /f", &r);
551  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
552  buffer[0] = 0; buffer[1] = 0;
553  verify_reg(hkey, "multi17", REG_MULTI_SZ, buffer, 2, 0);
554 
555  run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi18 /t REG_MULTI_SZ /d \"\\0\" /f", &r);
556  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
557  verify_reg(hkey, "multi18", REG_MULTI_SZ, buffer, 2, 0);
558 
559  run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi19 /t REG_MULTI_SZ /s \"#\" /d \"two\\0#strings\" /f", &r);
560  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
561  verify_reg(hkey, "multi19", REG_MULTI_SZ, "two\\0\0strings\0", 15, 0);
562 
563  run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi20 /t REG_MULTI_SZ /s \"#\" /d \"two#\\0strings\" /f", &r);
564  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
565  verify_reg(hkey, "multi20", REG_MULTI_SZ, "two\0\\0strings\0", 15, 0);
566 
567  run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi21 /t REG_MULTI_SZ /s \"#\" /d \"two\\0\\0strings\" /f", &r);
568  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
569  verify_reg(hkey, "multi21", REG_MULTI_SZ, "two\\0\\0strings\0", 16, 0);
570 
571  run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_MULTI_SZ /f", &r);
572  ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
573  verify_reg(hkey, NULL, REG_MULTI_SZ, buffer, 1, 0);
574 
575  RegCloseKey(hkey);
576 
577  /* Test duplicate switches */
578  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup1 /t REG_DWORD /d 123 /f /t REG_SZ", &r);
579  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
580  "got exit code %u, expected 1\n", r);
581 
582  run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup2 /t REG_DWORD /d 123 /f /d 456", &r);
583  ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
584 
585  /* Test invalid switches */
586  run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid1 /a", &r);
587  ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
588 
589  run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid2 /ae", &r);
590  ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
591 
592  run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid3 /", &r);
593  ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
594 
595  run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid4 -", &r);
596  ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
597 
599 }
600 
601 static void test_delete(void)
602 {
603  HKEY hkey, hsubkey;
604  LONG err;
605  DWORD r;
606  const DWORD deadbeef = 0xdeadbeef;
607 
609  ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
610 
611  run_reg_exe("reg delete", &r);
612  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
613 
614  run_reg_exe("reg delete /?", &r);
615  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
616 
617  run_reg_exe("reg delete /h", &r);
618  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
619 
620  run_reg_exe("reg delete -H", &r);
621  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
622 
624  add_value(hkey, "foo", REG_DWORD, &deadbeef, sizeof(deadbeef));
625  add_value(hkey, "bar", REG_DWORD, &deadbeef, sizeof(deadbeef));
626  add_value(hkey, NULL, REG_DWORD, &deadbeef, sizeof(deadbeef));
627 
628  add_key(hkey, "subkey", &hsubkey);
629  RegCloseKey(hsubkey);
630 
631  run_reg_exe("reg delete HKCU\\" KEY_BASE " /v bar /f", &r);
632  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
633  verify_reg_nonexist(hkey, "bar");
634 
635  run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /f", &r);
636  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
637  verify_reg_nonexist(hkey, "");
638 
639  run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r);
640  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
641  verify_reg_nonexist(hkey, "foo");
642  verify_key(hkey, "subkey");
643 
644  RegCloseKey(hkey);
645 
646  run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
647  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
649 
650  run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
651  ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
652 }
653 
654 static void test_query(void)
655 {
656  DWORD r;
657  HKEY key, subkey;
658  LONG err;
659  const char hello[] = "Hello";
660  const char world[] = "World";
661  const char empty1[] = "Empty1";
662  const char empty2[] = "Empty2";
663  const DWORD dword1 = 0x123;
664  const DWORD dword2 = 0xabc;
665 
667  ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
668 
669  run_reg_exe("reg query", &r);
670  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
671 
672  run_reg_exe("reg query /?", &r);
673  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
674 
675  run_reg_exe("reg query /h", &r);
676  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
677 
678  run_reg_exe("reg query -H", &r);
679  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
680 
681  /* Create a test key */
683 
684  run_reg_exe("reg query HKCU\\" KEY_BASE " /ve", &r);
685  ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
686  "got exit code %d, expected 0\n", r);
687 
688  add_value(key, "Test", REG_SZ, hello, sizeof(hello));
689  add_value(key, "Wine", REG_DWORD, &dword1, sizeof(dword1));
690  add_value(key, NULL, REG_SZ, empty1, sizeof(empty1));
691 
692  run_reg_exe("reg query HKCU\\" KEY_BASE, &r);
693  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
694 
695  run_reg_exe("reg query HKCU\\" KEY_BASE " /v", &r);
696  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
697 
698  run_reg_exe("reg query HKCU\\" KEY_BASE " /v Missing", &r);
699  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
700 
701  run_reg_exe("reg query HKCU\\" KEY_BASE " /v Test", &r);
702  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
703 
704  run_reg_exe("reg query HKCU\\" KEY_BASE " /v Wine", &r);
705  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
706 
707  run_reg_exe("reg query HKCU\\" KEY_BASE " /ve", &r);
708  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
709 
710  /* Create a test subkey */
711  add_key(key, "Subkey", &subkey);
712  add_value(subkey, "Test", REG_SZ, world, sizeof(world));
713  add_value(subkey, "Wine", REG_DWORD, &dword2, sizeof(dword2));
714  add_value(subkey, NULL, REG_SZ, empty2, sizeof(empty2));
715 
716  err = RegCloseKey(subkey);
717  ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
718 
719  run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey", &r);
720  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
721 
722  run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey /v Test", &r);
723  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
724 
725  run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey /v Wine", &r);
726  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
727 
728  run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey /ve", &r);
729  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
730 
731  /* Test recursion */
732  run_reg_exe("reg query HKCU\\" KEY_BASE " /s", &r);
733  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
734 
735  run_reg_exe("reg query HKCU\\" KEY_BASE " /v Test /s", &r);
736  ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */,
737  "got exit code %d, expected 0\n", r);
738 
739  run_reg_exe("reg query HKCU\\" KEY_BASE " /v Wine /s", &r);
740  ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */,
741  "got exit code %d, expected 0\n", r);
742 
743  run_reg_exe("reg query HKCU\\" KEY_BASE " /ve /s", &r);
744  ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */,
745  "got exit code %d, expected 0\n", r);
746 
747  /* Clean-up, then query */
748  delete_key(key, "subkey");
749 
750  err = RegCloseKey(key);
751  ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
752 
753  run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey", &r);
754  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
755 
757 
758  run_reg_exe("reg query HKCU\\" KEY_BASE, &r);
759  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
760 }
761 
762 static void test_v_flags(void)
763 {
764  DWORD r;
765 
766  run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /ve", &r);
767  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
768 
769  run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /ve", &r);
770  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
771 
772  run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /va", &r);
773  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
774 
775  run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /va", &r);
776  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
777 
778  /* No /v argument */
779  run_reg_exe("reg add HKCU\\" KEY_BASE " /v", &r);
780  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
781 
782  run_reg_exe("reg add HKCU\\" KEY_BASE " /d Test /f /v", &r);
783  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
784 
785  run_reg_exe("reg delete HKCU\\" KEY_BASE " /v", &r);
786  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
787 
788  run_reg_exe("reg delete HKCU\\" KEY_BASE " /f /v", &r);
789  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
790 
791  /* Multiple /v switches */
792  run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /t REG_DWORD /d 0x1 /v Test /f", &r);
793  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
794 
795  run_reg_exe("reg delete HKCU\\" KEY_BASE " /v Wine /v Test /f", &r);
796  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
797 }
798 
799 static BOOL write_file(const void *str, DWORD size)
800 {
801  HANDLE file;
802  BOOL ret;
803  DWORD written;
804 
805  file = CreateFileA("test.reg", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
807  ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
808  if (file == INVALID_HANDLE_VALUE)
809  return FALSE;
810 
811  ret = WriteFile(file, str, size, &written, NULL);
812  ok(ret, "WriteFile failed: %u\n", GetLastError());
813  CloseHandle(file);
814 
815  return ret;
816 }
817 
818 #define test_import_str(c,r) import_reg(__LINE__,c,FALSE,r)
819 #define test_import_wstr(c,r) import_reg(__LINE__,c,TRUE,r)
820 
821 static BOOL import_reg(unsigned line, const char *contents, BOOL unicode, DWORD *rc)
822 {
823  int lenA;
824  BOOL ret;
825 
826  lenA = strlen(contents);
827 
828  if (unicode)
829  {
830  int len = MultiByteToWideChar(CP_UTF8, 0, contents, lenA, NULL, 0);
831  int size = len * sizeof(WCHAR);
832  WCHAR *wstr = HeapAlloc(GetProcessHeap(), 0, size);
833  if (!wstr) return FALSE;
834  MultiByteToWideChar(CP_UTF8, 0, contents, lenA, wstr, len);
835 
836  ret = write_file(wstr, size);
837  HeapFree(GetProcessHeap(), 0, wstr);
838  }
839  else
840  ret = write_file(contents, lenA);
841 
842  if (!ret) return FALSE;
843 
844  run_reg_exe("reg import test.reg", rc);
845 
846  ret = DeleteFileA("test.reg");
847  lok(ret, "DeleteFile failed: %u\n", GetLastError());
848 
849  return ret;
850 }
851 
852 static void test_import(void)
853 {
854  DWORD r, dword = 0x123, type, size;
855  char buffer[24];
856  HKEY hkey, subkey = NULL;
857  LONG err;
858  BYTE hex[8];
859 
861  ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
862 
863  run_reg_exe("reg import", &r);
864  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
865 
866  run_reg_exe("reg import /?", &r);
867  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
868 
869  run_reg_exe("reg import /h", &r);
870  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
871 
872  run_reg_exe("reg import -H", &r);
873  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
874 
875  run_reg_exe("reg import missing.reg", &r);
876  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
877 
878  run_reg_exe("reg import a.reg b.reg", &r);
879  ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
880 
881  /* Test file contents */
882  test_import_str("regedit\n", &r);
883  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
884  "got exit code %d, expected 1\n", r);
885 
886  test_import_str("regedit4\n", &r);
887  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
888  "got exit code %d, expected 1\n", r);
889 
890  test_import_str("REGEDIT", &r);
891  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
892 
893  test_import_str("REGEDIT\n", &r);
894  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
895 
896  test_import_str("REGEDIT4\n", &r);
897  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
898 
899  test_import_str(" REGEDIT4\n", &r);
900  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
901 
902  test_import_str("\tREGEDIT4\n", &r);
903  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
904 
905  test_import_str("\nREGEDIT4\n", &r);
906  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
907  "got exit code %d, expected 1\n", r);
908 
909  test_import_str("AREGEDIT4\n", &r);
910  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
911  "got exit code %d, expected 1\n", r);
912 
913  test_import_str("1REGEDIT4\n", &r);
914  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
915  "got exit code %d, expected 1\n", r);
916 
917  test_import_str("REGEDIT3\n", &r);
918  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
919 
920  test_import_str("REGEDIT5\n", &r);
921  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
922 
923  test_import_str("REGEDIT9\n", &r);
924  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
925 
926  test_import_str("REGEDIT 4\n", &r);
927  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
928 
929  test_import_str("REGEDIT4 FOO\n", &r);
930  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
931 
932  test_import_str("REGEDIT4\n"
933  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n", &r);
934  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
935 
937 
938  test_import_str("REGEDIT4\n"
939  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
940  "\"Wine\"=dword:00000123\n\n", &r);
941  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
942  verify_reg(hkey, "Wine", REG_DWORD, &dword, sizeof(dword), 0);
943 
944  test_import_str("REGEDIT4\n"
945  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
946  "@=\"Test string\"\n\n", &r);
947  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
948  verify_reg(hkey, NULL, REG_SZ, "Test string", 12, 0);
949 
950  test_import_str("REGEDIT3\n\n"
951  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
952  "\"Test1\"=\"Value\"\n", &r);
953  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
954  verify_reg_nonexist(hkey, "Test1");
955 
956  test_import_str("regedit4\n\n"
957  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
958  "\"Test2\"=\"Value\"\n", &r);
959  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
960  "got exit code %d, expected 1\n", r);
961  verify_reg_nonexist(hkey, "Test2");
962 
963  test_import_str("Regedit4\n\n"
964  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
965  "\"Test3\"=\"Value\"\n", &r);
966  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
967  "got exit code %d, expected 1\n", r);
968  verify_reg_nonexist(hkey, "Test3");
969 
970  test_import_str("REGEDIT 4\n\n"
971  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
972  "\"Test4\"=\"Value\"\n", &r);
973  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
974  verify_reg_nonexist(hkey, "Test4");
975 
976  test_import_str("REGEDIT4FOO\n\n"
977  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
978  "\"Test5\"=\"Value\"\n", &r);
979  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
980  verify_reg_nonexist(hkey, "Test5");
981 
982  test_import_str("REGEDIT4 FOO\n\n"
983  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
984  "\"Test6\"=\"Value\"\n", &r);
985  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
986  verify_reg_nonexist(hkey, "Test6");
987 
988  test_import_str("REGEDIT5\n\n"
989  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
990  "\"Test7\"=\"Value\"\n", &r);
991  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
992  verify_reg_nonexist(hkey, "Test7");
993 
994  test_import_str("REGEDIT9\n\n"
995  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
996  "\"Test8\"=\"Value\"\n", &r);
997  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
998  verify_reg_nonexist(hkey, "Test8");
999 
1000  test_import_str("Windows Registry Editor Version 4.00\n\n"
1001  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1002  "\"Test9\"=\"Value\"\n", &r);
1003  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1004  "got exit code %d, expected 1\n", r);
1005  verify_reg_nonexist(hkey, "Test9");
1006 
1007  test_import_str("Windows Registry Editor Version 5\n\n"
1008  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1009  "\"Test10\"=\"Value\"\n", &r);
1010  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1011  "got exit code %d, expected 1\n", r);
1012  verify_reg_nonexist(hkey, "Test10");
1013 
1014  test_import_str("WINDOWS REGISTRY EDITOR VERSION 5.00\n\n"
1015  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1016  "\"Test11\"=\"Value\"\n", &r);
1017  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1018  "got exit code %d, expected 1\n", r);
1019  verify_reg_nonexist(hkey, "Test11");
1020 
1021  test_import_str("Windows Registry Editor version 5.00\n\n"
1022  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1023  "\"Test12\"=\"Value\"\n", &r);
1024  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1025  "got exit code %d, expected 1\n", r);
1026  verify_reg_nonexist(hkey, "Test12");
1027 
1028  test_import_str("REGEDIT4\n"
1029  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1030  "\"Test1\"=\"Value1\"\n", &r);
1031  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1032  verify_reg(hkey, "Test1", REG_SZ, "Value1", 7, 0);
1033 
1034  test_import_str("REGEDIT4\n"
1035  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1036  "\"Test2\"=\"Value2\"\n\n", &r);
1037  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1038  verify_reg(hkey, "Test2", REG_SZ, "Value2", 7, 0);
1039 
1040  test_import_str("REGEDIT4\n\n"
1041  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1042  "\"Test3\"=\"Value3\"\n\n", &r);
1043  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1044  verify_reg(hkey, "Test3", REG_SZ, "Value3", 7, 0);
1045 
1046  test_import_str("Windows Registry Editor Version 4.00\n", &r);
1047  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
1048  "got exit code %d, expected 1\n", r);
1049 
1050  test_import_str("Windows Registry Editor Version 5.00\n", &r);
1051  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1052 
1053  test_import_str("Windows Registry Editor Version 5.00\n"
1054  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1055  "\"Test4\"=\"Value4\"\n", &r);
1056  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1057  verify_reg(hkey, "Test4", REG_SZ, "Value4", 7, 0);
1058 
1059  test_import_str("Windows Registry Editor Version 5.00\n"
1060  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1061  "\"Test5\"=\"Value5\"\n\n", &r);
1062  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1063  verify_reg(hkey, "Test5", REG_SZ, "Value5", 7, 0);
1064 
1065  test_import_str("Windows Registry Editor Version 5.00\n\n"
1066  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1067  "\"Test6\"=\"Value6\"\n\n", &r);
1068  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1069  verify_reg(hkey, "Test6", REG_SZ, "Value6", 7, 0);
1070 
1071  test_import_str("REGEDIT4\n\n"
1072  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1073  "\"Line1\"=\"Value1\"\n\n"
1074  "\"Line2\"=\"Value2\"\n\n\n"
1075  "\"Line3\"=\"Value3\"\n\n\n\n"
1076  "\"Line4\"=\"Value4\"\n\n", &r);
1077  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1078  verify_reg(hkey, "Line1", REG_SZ, "Value1", 7, 0);
1079  verify_reg(hkey, "Line2", REG_SZ, "Value2", 7, 0);
1080  verify_reg(hkey, "Line3", REG_SZ, "Value3", 7, 0);
1081  verify_reg(hkey, "Line4", REG_SZ, "Value4", 7, 0);
1082 
1083  test_import_str("REGEDIT4\n\n"
1084  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1085  "\"Wine1\"=dword:00000782\n\n"
1086  "\"Wine2\"=\"Test Value\"\n"
1087  "\"Wine3\"=hex(7):4c,69,6e,65,20,\\\n"
1088  " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1089  "#comment\n"
1090  "@=\"Test\"\n"
1091  ";comment\n\n"
1092  "\"Wine4\"=dword:12345678\n\n", &r);
1093  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1094  dword = 0x782;
1095  verify_reg(hkey, "Wine1", REG_DWORD, &dword, sizeof(dword), 0);
1096  verify_reg(hkey, "Wine2", REG_SZ, "Test Value", 11, 0);
1097  verify_reg(hkey, "Wine3", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1098  verify_reg(hkey, "", REG_SZ, "Test", 5, 0);
1099  dword = 0x12345678;
1100  verify_reg(hkey, "Wine4", REG_DWORD, &dword, sizeof(dword), 0);
1101 
1102  test_import_str("REGEDIT4\n\n"
1103  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1104  "\"Wine5\"=\"No newline\"", &r);
1105  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1106  err = RegQueryValueExA(hkey, "Wine5", NULL, NULL, NULL, NULL);
1107  ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND /* WinXP */),
1108  "got %d, expected 0\n", err);
1109  if (err == ERROR_SUCCESS)
1110  verify_reg(hkey, "Wine5", REG_SZ, "No newline", 11, 0);
1111 
1112  test_import_str("REGEDIT4\n\n"
1113  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1114  "\"Wine6\"=dword:00000050\n\n"
1115  "\"Wine7\"=\"No newline\"", &r);
1116  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1117  dword = 0x50;
1118  verify_reg(hkey, "Wine6", REG_DWORD, &dword, sizeof(dword), 0);
1119  err = RegQueryValueExA(hkey, "Wine7", NULL, NULL, NULL, NULL);
1120  ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND /* WinXP */),
1121  "got %d, expected 0\n", err);
1122  if (err == ERROR_SUCCESS)
1123  verify_reg(hkey, "Wine7", REG_SZ, "No newline", 11, 0);
1124 
1125  test_import_str("REGEDIT4\n\n"
1126  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1127  "#comment\\\n"
1128  "\"Wine8\"=\"Line 1\"\n"
1129  ";comment\\\n"
1130  "\"Wine9\"=\"Line 2\"\n\n", &r);
1131  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1132  verify_reg(hkey, "Wine8", REG_SZ, "Line 1", 7, 0);
1133  verify_reg(hkey, "Wine9", REG_SZ, "Line 2", 7, 0);
1134 
1135  test_import_str("REGEDIT4\n\n"
1136  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1137  "\"Wine10\"=\"Value 1\"#comment\n"
1138  "\"Wine11\"=\"Value 2\";comment\n"
1139  "\"Wine12\"=dword:01020304 #comment\n"
1140  "\"Wine13\"=dword:02040608 ;comment\n\n", &r);
1141  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1142  verify_reg_nonexist(hkey, "Wine10");
1143  verify_reg(hkey, "Wine11", REG_SZ, "Value 2", 8, 0);
1144  verify_reg_nonexist(hkey, "Wine12");
1145  dword = 0x2040608;
1146  verify_reg(hkey, "Wine13", REG_DWORD, &dword, sizeof(dword), 0);
1147 
1148  test_import_str("REGEDIT4\n\n"
1149  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1150  "\"Wine14\"=hex(7):4c,69,6e,65,20,\\\n"
1151  " #comment\n"
1152  " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1153  "\"Wine15\"=\"A valid line\"\n"
1154  "\"Wine16\"=hex(7):4c,69,6e,65,20,\\\n"
1155  " ;comment\n"
1156  " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1157  "\"Wine17\"=\"Another valid line\"\n\n", &r);
1158  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1159  verify_reg_nonexist(hkey, "Wine14");
1160  verify_reg(hkey, "Wine15", REG_SZ, "A valid line", 13, 0);
1161  verify_reg(hkey, "Wine16", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1162  verify_reg(hkey, "Wine17", REG_SZ, "Another valid line", 19, 0);
1163 
1164  test_import_str("REGEDIT4\n\n"
1165  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1166  "#\"Comment1\"=\"Value 1\"\n"
1167  ";\"Comment2\"=\"Value 2\"\n"
1168  " #\"Comment3\"=\"Value 3\"\n"
1169  " ;\"Comment4\"=\"Value 4\"\n"
1170  "\"Wine18\"=\"Value 6\"#\"Comment5\"=\"Value 5\"\n"
1171  "\"Wine19\"=\"Value 7\";\"Comment6\"=\"Value 6\"\n\n", &r);
1172  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1173  verify_reg_nonexist(hkey, "Comment1");
1174  verify_reg_nonexist(hkey, "Comment2");
1175  verify_reg_nonexist(hkey, "Comment3");
1176  verify_reg_nonexist(hkey, "Comment4");
1177  verify_reg_nonexist(hkey, "Wine18");
1178  verify_reg_nonexist(hkey, "Comment5");
1179  verify_reg(hkey, "Wine19", REG_SZ, "Value 7", 8, 0);
1180  verify_reg_nonexist(hkey, "Comment6");
1181 
1182  test_import_str("REGEDIT4\n\n"
1183  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1184  "\"Wine20\"=#\"Value 8\"\n"
1185  "\"Wine21\"=;\"Value 9\"\n"
1186  "\"Wine22\"=\"#comment1\"\n"
1187  "\"Wine23\"=\";comment2\"\n"
1188  "\"Wine24\"=\"Value#comment3\"\n"
1189  "\"Wine25\"=\"Value;comment4\"\n"
1190  "\"Wine26\"=\"Value #comment5\"\n"
1191  "\"Wine27\"=\"Value ;comment6\"\n"
1192  "\"Wine28\"=#dword:00000001\n"
1193  "\"Wine29\"=;dword:00000002\n"
1194  "\"Wine30\"=dword:00000003#comment\n"
1195  "\"Wine31\"=dword:00000004;comment\n\n", &r);
1196  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1197  verify_reg_nonexist(hkey, "Wine20");
1198  verify_reg_nonexist(hkey, "Wine21");
1199  verify_reg(hkey, "Wine22", REG_SZ, "#comment1", 10, 0);
1200  verify_reg(hkey, "Wine23", REG_SZ, ";comment2", 10, 0);
1201  verify_reg(hkey, "Wine24", REG_SZ, "Value#comment3", 15, 0);
1202  verify_reg(hkey, "Wine25", REG_SZ, "Value;comment4", 15, 0);
1203  verify_reg(hkey, "Wine26", REG_SZ, "Value #comment5", 16, 0);
1204  verify_reg(hkey, "Wine27", REG_SZ, "Value ;comment6", 16, 0);
1205  verify_reg_nonexist(hkey, "Wine28");
1206  verify_reg_nonexist(hkey, "Wine29");
1207  verify_reg_nonexist(hkey, "Wine30");
1208  dword = 0x00000004;
1209  verify_reg(hkey, "Wine31", REG_DWORD, &dword, sizeof(dword), 0);
1210 
1211  test_import_str("REGEDIT4\n\n"
1212  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1213  "\"Multi-Line1\"=hex(7):4c,69,6e,65,20,\\\n"
1214  " 63,6f,6e,\\;comment\n"
1215  " 63,61,74,\\;comment\n"
1216  " 65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1217  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1218  verify_reg(hkey, "Multi-Line1", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1219 
1220  test_import_str("REGEDIT4\n\n"
1221  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1222  "\"Multi-Line2\"=hex(7):4c,69,6e,65,20,\\\n"
1223  " 63,6f,6e,\\;comment\n"
1224  " 63,61,74,;comment\n"
1225  " 65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1226  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1227  verify_reg(hkey, "Multi-Line2", REG_MULTI_SZ, "Line concat", 12, 0);
1228 
1229  test_import_str("REGEDIT4\n\n"
1230  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1231  "\"Multi-Line3\"=hex(7):4c,69,6e,65,20\\\n"
1232  ",63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1233  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1234  verify_reg_nonexist(hkey, "Multi-Line3");
1235 
1236  test_import_str("REGEDIT4\n\n"
1237  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1238  "\"Multi-Line4\"=hex(7):4c,69,6e,65,20\\\n"
1239  " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1240  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1241  verify_reg_nonexist(hkey, "Multi-Line4");
1242 
1243  test_import_str("Windows Registry Editor Version 5.00\n\n"
1244  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1245  "\"Multi-Line5\"=hex(7):4c,69,6e,65,20\\\n"
1246  ",63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1247  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1248  verify_reg_nonexist(hkey, "Multi-Line5");
1249 
1250  test_import_str("Windows Registry Editor Version 5.00\n\n"
1251  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1252  "\"Multi-Line6\"=hex(7):4c,69,6e,65,20\\\n"
1253  " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1254  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1255  verify_reg_nonexist(hkey, "Multi-Line6");
1256 
1257  test_import_str("REGEDIT4\n\n"
1258  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1259  "\"Multi-Line7\"=hex(7):4c,69,6e,\\;comment\n"
1260  " 65,20,\\;comment\n"
1261  " 63,6f,6e,\\;comment\n"
1262  " 63,61,74,\\;comment\n"
1263  " 65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1264  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1265  verify_reg(hkey, "Multi-Line7", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1266 
1267  test_import_str("REGEDIT4\n\n"
1268  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1269  "\"Multi-Line8\"=hex(7):4c,69,6e,\\;#comment\n"
1270  " 65,20,\\;#comment\n"
1271  " 63,6f,6e,\\;#comment\n"
1272  " 63,61,74,\\;#comment\n"
1273  " 65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1274  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1275  verify_reg(hkey, "Multi-Line8", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1276 
1277  test_import_str("REGEDIT4\n\n"
1278  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1279  "\"Multi-Line9\"=hex(7):4c,69,6e,\\;comment\n"
1280  " 65,20,\\;comment\n"
1281  " 63,6f,6e,\\;comment\n"
1282  " 63,61,74,\\#comment\n"
1283  " 65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1284  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1285  verify_reg_nonexist(hkey, "Multi-Line9");
1286 
1287  test_import_str("REGEDIT4\n\n"
1288  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1289  "\"Multi-Line10\"=hex(7):4c,69,6e,65,20,\\\n"
1290  " 63,6f,6e,\\;comment\n"
1291  " 63,61,74,\\\n\n"
1292  " 65,6e,\\;comment\n\n"
1293  " 61,74,69,6f,6e,00,00\n\n", &r);
1294  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1295  verify_reg(hkey, "Multi-Line10", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1296 
1297  test_import_str("REGEDIT4\n\n"
1298  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1299  "\"Wine32a\"=dword:1\n"
1300  "\"Wine32b\"=dword:4444\n\n", &r);
1301  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1302  dword = 0x1;
1303  verify_reg(hkey, "Wine32a", REG_DWORD, &dword, sizeof(dword), 0);
1304  dword = 0x4444;
1305  verify_reg(hkey, "Wine32b", REG_DWORD, &dword, sizeof(dword), 0);
1306 
1307  test_import_str("REGEDIT4\n\n"
1308  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1309  "\"Wine33a\"=dword:\n"
1310  "\"Wine33b\"=dword:hello\n"
1311  "\"Wine33c\"=dword:123456789\n"
1312  "\"Wine33d\"=dword:012345678\n"
1313  "\"Wine33e\"=dword:000000001\n\n", &r);
1314  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1315  verify_reg_nonexist(hkey, "Wine33a");
1316  verify_reg_nonexist(hkey, "Wine33b");
1317  verify_reg_nonexist(hkey, "Wine33c");
1318  verify_reg_nonexist(hkey, "Wine33d");
1319  verify_reg_nonexist(hkey, "Wine33e");
1320 
1321  test_import_str("REGEDIT4\n\n"
1322  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1323  "\"Wine34a\"=dword:12345678abc\n"
1324  "\"Wine34b\"=dword:12345678 abc\n\n", &r);
1325  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1326  verify_reg_nonexist(hkey, "Wine34a");
1327  verify_reg_nonexist(hkey, "Wine34b");
1328 
1329  test_import_str("REGEDIT4\n\n"
1330  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1331  "\"Wine35a\"=dword:0x123\n"
1332  "\"Wine35b\"=dword:123 456\n"
1333  "\"Wine35c\"=dword:1234 5678\n\n", &r);
1334  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1335  verify_reg_nonexist(hkey, "Wine35a");
1336  verify_reg_nonexist(hkey, "Wine35b");
1337  verify_reg_nonexist(hkey, "Wine35c");
1338 
1339  test_import_str("REGEDIT4\n\n"
1340  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1341  "\"Wine36a\"=dword:1234;5678\n"
1342  "\"Wine36b\"=dword:1234 ;5678\n"
1343  "\"Wine36c\"=dword:1234#5678\n"
1344  "\"Wine36d\"=dword:1234 #5678\n\n", &r);
1345  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1346  dword = 0x1234;
1347  verify_reg(hkey, "Wine36a", REG_DWORD, &dword, sizeof(dword), 0);
1348  verify_reg(hkey, "Wine36b", REG_DWORD, &dword, sizeof(dword), 0);
1349  verify_reg_nonexist(hkey, "Wine36c");
1350  verify_reg_nonexist(hkey, "Wine36d");
1351 
1352  test_import_str("REGEDIT4\n\n"
1353  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1354  "\"Wine37a\"=\"foo\"bar\"\n"
1355  "\"Wine37b\"=\"foo\"\"bar\"\n\n", &r);
1356  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1357  verify_reg_nonexist(hkey, "Wine37a");
1358  verify_reg_nonexist(hkey, "Wine37b");
1359 
1360  test_import_str("REGEDIT4\n\n"
1361  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1362  "\"Empty string\"=\"\"\n"
1363  "\"\"=\"Default Value Name\"\n\n", &r);
1364  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1365  verify_reg(hkey, "Empty string", REG_SZ, "", 1, 0);
1366  verify_reg(hkey, NULL, REG_SZ, "Default Value Name", 19, 0);
1367 
1368  test_import_str("REGEDIT4\n\n"
1369  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1370  "\"Test38a\"=\n"
1371  "\"Test38b\"=\\\"\n"
1372  "\"Test38c\"=\\\"Value\\\"\n"
1373  "\"Test38d\"=\\\"Value\"\n\n", &r);
1374  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1375  verify_reg_nonexist(hkey, "Test38a");
1376  verify_reg_nonexist(hkey, "Test38b");
1377  verify_reg_nonexist(hkey, "Test38c");
1378  verify_reg_nonexist(hkey, "Test38d");
1379 
1380  test_import_str("REGEDIT4\n\n"
1381  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1382  "\"Wine39a\"=\"Value1\" ;comment\n"
1383  "\"Wine39b\"=\"Value2\"\t\t;comment\n"
1384  "\"Wine39c\"=\"Value3\" #comment\n"
1385  "\"Wine39d\"=\"Value4\"\t\t#comment\n\n", &r);
1386  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1387  verify_reg(hkey, "Wine39a", REG_SZ, "Value1", 7, 0);
1388  verify_reg(hkey, "Wine39b", REG_SZ, "Value2", 7, 0);
1389  verify_reg_nonexist(hkey, "Wine39c");
1390  verify_reg_nonexist(hkey, "Wine39d");
1391 
1392  test_import_str("REGEDIT4\n\n"
1393  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1394  "\"TestNoBeginQuote\"=Asdffdsa\"\n", &r);
1395  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1396  verify_reg_nonexist(hkey, "TestNoBeginQuote");
1397 
1398  test_import_str("REGEDIT4\n\n"
1399  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1400  "\"TestNoEndQuote\"=\"Asdffdsa\n", &r);
1401  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1402  verify_reg_nonexist(hkey, "TestNoEndQuote");
1403 
1404  test_import_str("REGEDIT4\n\n"
1405  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1406  "\"TestNoQuotes\"=Asdffdsa\n", &r);
1407  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1408  verify_reg_nonexist(hkey, "TestNoQuotes");
1409 
1410  test_import_str("REGEDIT4\n\n"
1411  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1412  "NameNoBeginQuote\"=\"Asdffdsa\"\n", &r);
1413  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1414  verify_reg_nonexist(hkey, "NameNoBeginQuote");
1415 
1416  test_import_str("REGEDIT4\n\n"
1417  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1418  "\"NameNoEndQuote=\"Asdffdsa\"\n", &r);
1419  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1420  verify_reg_nonexist(hkey, "NameNoEndQuote");
1421 
1422  test_import_str("REGEDIT4\n\n"
1423  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1424  "NameNoQuotes=\"Asdffdsa\"\n", &r);
1425  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1426  verify_reg_nonexist(hkey, "NameNoQuotes");
1427 
1428  test_import_str("REGEDIT4\n\n"
1429  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1430  "\"MixedQuotes=Asdffdsa\"\n", &r);
1431  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1432  verify_reg_nonexist(hkey, "MixedQuotes");
1433  verify_reg_nonexist(hkey, "MixedQuotes=Asdffdsa");
1434 
1435  test_import_str("REGEDIT4\n\n"
1436  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1437  "\"Wine40a\"=hex(2):4c,69,6e,65,00\n"
1438  "\"Wine40b\"=\"Value 1\"\n"
1439  "\"Wine40c\"=hex(2):4c,69,6e,65\\\n"
1440  "\"Wine40d\"=\"Value 2\"\n"
1441  "\"Wine40e\"=hex(2):4c,69,6e,65,\\\n"
1442  "\"Wine40f\"=\"Value 3\"\n"
1443  "\"Wine40g\"=\"Value 4\"\n\n", &r);
1444  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1445  verify_reg(hkey, "Wine40a", REG_EXPAND_SZ, "Line", 5, 0);
1446  verify_reg(hkey, "Wine40b", REG_SZ, "Value 1", 8, 0);
1447  verify_reg_nonexist(hkey, "Wine40c");
1448  verify_reg(hkey, "Wine40d", REG_SZ, "Value 2", 8, 0);
1449  verify_reg_nonexist(hkey, "Wine40e");
1450  verify_reg_nonexist(hkey, "Wine40f");
1451  verify_reg(hkey, "Wine40g", REG_SZ, "Value 4", 8, 0);
1452 
1453  test_import_str("REGEDIT4\n\n"
1454  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1455  "\"Wine41a\"=dword:1234\\\n"
1456  "5678\n"
1457  "\"Wine41b\"=\"Test \\\n"
1458  "Value\"\n\n", &r);
1459  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1460  verify_reg_nonexist(hkey, "Wine41a");
1461  verify_reg_nonexist(hkey, "Wine41b");
1462 
1463  test_import_str("REGEDIT4\n\n"
1464  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1465  "\"double\\\"quote\"=\"valid \\\"or\\\" not\"\n"
1466  "\"single'quote\"=dword:00000008\n\n", &r);
1467  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1468  verify_reg(hkey, "double\"quote", REG_SZ, "valid \"or\" not", 15, 0);
1469  dword = 0x00000008;
1470  verify_reg(hkey, "single'quote", REG_DWORD, &dword, sizeof(dword), 0);
1471 
1472  /* Test key name and value name concatenation */
1473  test_import_str("REGEDIT4\n\n"
1474  "[HKEY_CURRENT_USER\\" KEY_BASE "\\\n"
1475  "Subkey1]\n", &r);
1476  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1477  verify_key_nonexist(hkey, "Subkey1");
1478 
1479  test_import_str("REGEDIT4\n\n"
1480  "[HKEY_CURRENT_USER\\" KEY_BASE "\n"
1481  "\\Subkey2]\n", &r);
1482  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1483  verify_key_nonexist(hkey, "Subkey2");
1484 
1485  test_import_str("REGEDIT4\n\n"
1486  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1487  "\"Wine\\\n"
1488  "42a\"=\"Value 1\"\n"
1489  "\"Wine42b\"=\"Value 2\"\n"
1490  "\"Wine\n"
1491  "\\42c\"=\"Value 3\"\n\n", &r);
1492  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1493  verify_reg_nonexist(hkey, "Wine42a");
1494  verify_reg(hkey, "Wine42b", REG_SZ, "Value 2", 8, 0);
1495  verify_reg_nonexist(hkey, "Wine42c");
1496 
1497  /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
1498  test_import_str("REGEDIT4\n\n"
1499  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1500  "\"Wine43a\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n"
1501  "\"Wine43b\"=hex(0):56,00,61,00,6c,00,\\\n"
1502  " 75,00,65,00,00,00\n"
1503  "\"Wine43c\"=hex(0):56,00,61,00,6c,00\\\n"
1504  ",75,00,65,00,00,00\n"
1505  "\"Wine43d\"=hex(0):56,00,61,00,6c,00\\\n"
1506  " ,75,00,65,00,00,00\n"
1507  "\"Wine43e\"=hex(0):56,00,61,00,6c,00\\\n"
1508  " 75,00,65,00,00,00\n"
1509  "\"Wine43f\"=hex(0):56,00,61,00,6c,00,7\\\n"
1510  "5,00,65,00,00,00\n"
1511  "\"Wine43g\"=hex(0):56,00,61,00,6c,00,7\\\n"
1512  " 5,00,65,00,00,00\n"
1513  "\"Wine43h\"=hex(0):56,00,61,00,\\;comment\n"
1514  " 6c,00,75,00,\\\n"
1515  " 65,00,00,00\n"
1516  "\"Wine43i\"=hex(0):56,00,61,00,\\;comment\n"
1517  " 6c,00,75,00,\n"
1518  " 65,00,00,00\n"
1519  "\"Wine43j\"=hex(0):56,00,61,00,\\;comment\n"
1520  " 6c,00,75,00,;comment\n"
1521  " 65,00,00,00\n"
1522  "\"Wine43k\"=hex(0):56,00,61,00,\\;comment\n"
1523  " 6c,00,75,00,\\#comment\n"
1524  " 65,00,00,00\n\n", &r);
1525  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1526  verify_reg(hkey, "Wine43a", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
1527  verify_reg(hkey, "Wine43b", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
1528  verify_reg_nonexist(hkey, "Wine43c");
1529  verify_reg_nonexist(hkey, "Wine43d");
1530  verify_reg_nonexist(hkey, "Wine43e");
1531  verify_reg_nonexist(hkey, "Wine43f");
1532  verify_reg_nonexist(hkey, "Wine43g");
1533  verify_reg(hkey, "Wine43h", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
1534  verify_reg(hkey, "Wine43i", REG_NONE, "V\0a\0l\0u", 8, 0);
1535  verify_reg(hkey, "Wine43j", REG_NONE, "V\0a\0l\0u", 8, 0);
1536  verify_reg_nonexist(hkey, "Wine43k");
1537 
1538  test_import_str("REGEDIT4\n\n"
1539  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1540  "\"Wine44a\"=hex(2):25,50,41,54,48,25,00\n"
1541  "\"Wine44b\"=hex(2):25,50,41,\\\n"
1542  " 54,48,25,00\n"
1543  "\"Wine44c\"=hex(2):25,50,41\\\n"
1544  ",54,48,25,00\n"
1545  "\"Wine44d\"=hex(2):25,50,41\\\n"
1546  " ,54,48,25,00\n"
1547  "\"Wine44e\"=hex(2):25,50,41\\\n"
1548  " 54,48,25,00\n"
1549  "\"Wine44f\"=hex(2):25,50,4\\\n"
1550  "1,54,48,25,00\n"
1551  "\"Wine44g\"=hex(2):25,50,4\\\n"
1552  " 1,54,48,25,00\n"
1553  "\"Wine44h\"=hex(2):25,50,41,\\;comment\n"
1554  " 54,48,\\\n"
1555  " 25,00\n"
1556  "\"Wine44i\"=hex(2):25,50,41,\\;comment\n"
1557  " 54,48,\n"
1558  " 25,00\n"
1559  "\"Wine44j\"=hex(2):25,50,41,\\;comment\n"
1560  " 54,48,;comment\n"
1561  " 25,00\n"
1562  "\"Wine44k\"=hex(2):25,50,41,\\;comment\n"
1563  " 54,48,\\#comment\n"
1564  " 25,00\n\n", &r);
1565  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1566  verify_reg(hkey, "Wine44a", REG_EXPAND_SZ, "%PATH%", 7, 0);
1567  verify_reg(hkey, "Wine44b", REG_EXPAND_SZ, "%PATH%", 7, 0);
1568  verify_reg_nonexist(hkey, "Wine44c");
1569  verify_reg_nonexist(hkey, "Wine44d");
1570  verify_reg_nonexist(hkey, "Wine44e");
1571  verify_reg_nonexist(hkey, "Wine44f");
1572  verify_reg_nonexist(hkey, "Wine44g");
1573  verify_reg(hkey, "Wine44h", REG_EXPAND_SZ, "%PATH%", 7, 0);
1574  /* Wine44i */
1575  size = sizeof(buffer);
1576  err = RegQueryValueExA(hkey, "Wine44i", NULL, &type, (BYTE *)&buffer, &size);
1577  ok(err == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", err);
1578  ok(type == REG_EXPAND_SZ, "got wrong type %u, expected %u\n", type, REG_EXPAND_SZ);
1579  ok(size == 6 || broken(size == 5) /* WinXP */, "got wrong size %u, expected 6\n", size);
1580  ok(memcmp(buffer, "%PATH", size) == 0, "got wrong data\n");
1581  /* Wine44j */
1582  size = sizeof(buffer);
1583  memset(buffer, '-', size);
1584  err = RegQueryValueExA(hkey, "Wine44j", NULL, &type, (BYTE *)&buffer, &size);
1585  ok(err == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", err);
1586  ok(type == REG_EXPAND_SZ, "got wrong type %u, expected %u\n", type, REG_EXPAND_SZ);
1587  ok(size == 6 || broken(size == 5) /* WinXP */, "got wrong size %u, expected 6\n", size);
1588  ok(memcmp(buffer, "%PATH", size) == 0, "got wrong data\n");
1589  /* Wine44k */
1590  verify_reg_nonexist(hkey, "Wine44k");
1591 
1592  test_import_str("REGEDIT4\n\n"
1593  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1594  "\"Wine45a\"=hex:11,22,33,44,55,66,77,88\n"
1595  "\"Wine45b\"=hex:11,22,33,44,\\\n"
1596  " 55,66,77,88\n"
1597  "\"Wine45c\"=hex:11,22,33,44\\\n"
1598  ",55,66,77,88\n"
1599  "\"Wine45d\"=hex:11,22,33,44\\\n"
1600  " ,55,66,77,88\n"
1601  "\"Wine45e\"=hex:11,22,33,44\\\n"
1602  " 55,66,77,88\n"
1603  "\"Wine45f\"=hex:11,22,33,4\\\n"
1604  "4,55,66,77,88\n"
1605  "\"Wine45g\"=hex:11,22,33,4\\\n"
1606  " 4,55,66,77,88\n"
1607  "\"Wine45h\"=hex:11,22,33,44,\\;comment\n"
1608  " 55,66,\\\n"
1609  " 77,88\n"
1610  "\"Wine45i\"=hex:11,22,33,44,\\;comment\n"
1611  " 55,66,\n"
1612  " 77,88\n"
1613  "\"Wine45j\"=hex:11,22,33,44,\\;comment\n"
1614  " 55,66,;comment\n"
1615  " 77,88\n"
1616  "\"Wine45k\"=hex:11,22,33,\\;comment\n"
1617  " 44,55,66,\\#comment\n"
1618  " 77,88\n\n", &r);
1619  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1620  hex[0] = 0x11; hex[1] = 0x22; hex[2] = 0x33; hex[3] = 0x44;
1621  hex[4] = 0x55; hex[5] = 0x66; hex[6] = 0x77; hex[7] = 0x88;
1622  verify_reg(hkey, "Wine45a", REG_BINARY, hex, sizeof(hex), 0);
1623  verify_reg(hkey, "Wine45b", REG_BINARY, hex, sizeof(hex), 0);
1624  verify_reg_nonexist(hkey, "Wine45c");
1625  verify_reg_nonexist(hkey, "Wine45d");
1626  verify_reg_nonexist(hkey, "Wine45e");
1627  verify_reg_nonexist(hkey, "Wine45f");
1628  verify_reg_nonexist(hkey, "Wine45g");
1629  verify_reg(hkey, "Wine45h", REG_BINARY, hex, sizeof(hex), 0);
1630  verify_reg(hkey, "Wine45i", REG_BINARY, hex, 6, 0);
1631  verify_reg(hkey, "Wine45j", REG_BINARY, hex, 6, 0);
1632  verify_reg_nonexist(hkey, "Wine45k");
1633 
1634  /* Test import with subkeys */
1635  test_import_str("REGEDIT4\n\n"
1636  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey\"1]\n"
1637  "\"Wine\\\\31\"=\"Test value\"\n\n", &r);
1638  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1639  open_key(hkey, "Subkey\"1", 0, &subkey);
1640  verify_reg(subkey, "Wine\\31", REG_SZ, "Test value", 11, 0);
1641  err = RegCloseKey(subkey);
1642  ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1643  delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey\"1");
1644 
1645  test_import_str("REGEDIT4\n\n"
1646  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey/2]\n"
1647  "\"123/\\\"4;'5\"=\"Random value name\"\n\n", &r);
1648  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1649  open_key(hkey, "Subkey/2", 0, &subkey);
1650  verify_reg(subkey, "123/\"4;'5", REG_SZ, "Random value name", 18, 0);
1651  err = RegCloseKey(subkey);
1652  ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
1653  delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey/2");
1654 
1655  /* Test key creation */
1656  test_import_str("REGEDIT4\n\n"
1657  "HKEY_CURRENT_USER\\" KEY_BASE "\\No_Opening_Bracket]\n", &r);
1658  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1659  verify_key_nonexist(hkey, "No_Opening_Bracket");
1660 
1661  test_import_str("REGEDIT4\n\n"
1662  "[HKEY_CURRENT_USER\\" KEY_BASE "\\No_Closing_Bracket\n", &r);
1663  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1664  verify_key_nonexist(hkey, "No_Closing_Bracket");
1665 
1666  test_import_str("REGEDIT4\n\n"
1667  "[ HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1a]\n", &r);
1668  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1669  verify_key_nonexist(hkey, "Subkey1a");
1670 
1671  test_import_str("REGEDIT4\n\n"
1672  "[\tHKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1b]\n", &r);
1673  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1674  verify_key_nonexist(hkey, "Subkey1b");
1675 
1676  test_import_str("REGEDIT4\n\n"
1677  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1c ]\n", &r);
1678  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1679  verify_key(hkey, "Subkey1c ");
1680  delete_key(hkey, "Subkey1c ");
1681 
1682  test_import_str("REGEDIT4\n\n"
1683  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1d\t]\n", &r);
1684  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1685  verify_key(hkey, "Subkey1d\t");
1686  delete_key(hkey, "Subkey1d\t");
1687 
1688  test_import_str("REGEDIT4\n\n"
1689  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1e\\]\n"
1690  "\"Wine\"=\"Test value\"\n\n", &r);
1691  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1692  verify_key(hkey, "Subkey1e\\");
1693  verify_key(hkey, "Subkey1e");
1694  open_key(hkey, "Subkey1e", 0, &subkey);
1695  verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
1696  RegCloseKey(subkey);
1697  delete_key(hkey, "Subkey1e");
1698 
1699  test_import_str("REGEDIT4\n\n"
1700  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1f\\\\]\n"
1701  "\"Wine\"=\"Test value\"\n\n", &r);
1702  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1703  verify_key(hkey, "Subkey1f\\\\");
1704  verify_key(hkey, "Subkey1f\\");
1705  verify_key(hkey, "Subkey1f");
1706  open_key(hkey, "Subkey1f\\\\", 0, &subkey);
1707  verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
1708  RegCloseKey(subkey);
1709  delete_key(hkey, "Subkey1f\\\\");
1710 
1711  test_import_str("REGEDIT4\n\n"
1712  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1g\\\\\\\\]\n"
1713  "\"Wine\"=\"Test value\"\n\n", &r);
1714  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1715  verify_key(hkey, "Subkey1g\\\\\\\\");
1716  verify_key(hkey, "Subkey1g\\\\");
1717  verify_key(hkey, "Subkey1g\\");
1718  verify_key(hkey, "Subkey1g");
1719  open_key(hkey, "Subkey1g\\\\", 0, &subkey);
1720  verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
1721  RegCloseKey(subkey);
1722  delete_key(hkey, "Subkey1g\\\\");
1723 
1724  /* Test key deletion. We start by creating some registry keys. */
1725  test_import_str("REGEDIT4\n\n"
1726  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2a]\n\n"
1727  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2b]\n\n", &r);
1728  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1729  verify_key(hkey, "Subkey2a");
1730  verify_key(hkey, "Subkey2b");
1731 
1732  test_import_str("REGEDIT4\n\n"
1733  "[ -HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2a]\n", &r);
1734  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1735  verify_key(hkey, "Subkey2a");
1736 
1737  test_import_str("REGEDIT4\n\n"
1738  "[\t-HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2b]\n", &r);
1739  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1740  verify_key(hkey, "Subkey2b");
1741 
1742  test_import_str("REGEDIT4\n\n"
1743  "[- HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2a]\n", &r);
1744  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1745  verify_key(hkey, "Subkey2a");
1746 
1747  test_import_str("REGEDIT4\n\n"
1748  "[-\tHKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2b]\n", &r);
1749  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1750  verify_key(hkey, "Subkey2b");
1751 
1752  test_import_str("REGEDIT4\n\n"
1753  "[-HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2a]\n\n"
1754  "[-HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2b]\n\n", &r);
1755  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1756  verify_key_nonexist(hkey, "Subkey2a");
1757  verify_key_nonexist(hkey, "Subkey2b");
1758 
1759  /* Test case sensitivity when creating and deleting registry keys. */
1760  test_import_str("REGEDIT4\n\n"
1761  "[hkey_CURRENT_user\\" KEY_BASE "\\Subkey3a]\n\n"
1762  "[HkEy_CuRrEnT_uSeR\\" KEY_BASE "\\SuBkEy3b]\n\n", &r);
1763  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1764  verify_key(hkey, "Subkey3a");
1765  verify_key(hkey, "Subkey3b");
1766 
1767  test_import_str("REGEDIT4\n\n"
1768  "[-HKEY_current_USER\\" KEY_BASE "\\sUBKEY3A]\n\n"
1769  "[-hKeY_cUrReNt_UsEr\\" KEY_BASE "\\sUbKeY3B]\n\n", &r);
1770  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1771  verify_key_nonexist(hkey, "Subkey3a");
1772  verify_key_nonexist(hkey, "Subkey3b");
1773 
1774  /* Test mixed key creation and deletion. We start by creating a subkey. */
1775  test_import_str("REGEDIT4\n\n"
1776  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey4a]\n\n", &r);
1777  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1778  verify_key(hkey, "Subkey4a");
1779 
1780  test_import_str("REGEDIT4\n\n"
1781  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n\n"
1782  "[-HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey4a]\n"
1783  "\"Wine46a\"=dword:12345678\n\n", &r);
1784  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1785  verify_key_nonexist(hkey, "Subkey4a");
1786  verify_reg_nonexist(hkey, "Wine46a");
1787 
1788  test_import_str("REGEDIT4\n\n"
1789  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n\n"
1790  "[HKEY_CURRENT_USERS\\" KEY_BASE "\\Subkey4b]\n"
1791  "\"Wine46b\"=dword:12345678\n\n", &r);
1792  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1793  verify_key_nonexist(hkey, "Subkey4b");
1794  verify_reg_nonexist(hkey, "Wine46b");
1795 
1796  /* Test value deletion. We start by creating some registry values. */
1797  test_import_str("REGEDIT4\n\n"
1798  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1799  "\"Wine46a\"=\"Test Value\"\n"
1800  "\"Wine46b\"=dword:00000008\n"
1801  "\"Wine46c\"=hex:11,22,33,44\n"
1802  "\"Wine46d\"=hex(7):4c,69,6e,65,20,\\\n"
1803  " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1804  "\"Wine46e\"=hex(2):25,50,41,54,48,25,00\n"
1805  "\"Wine46f\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n\n", &r);
1806  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1807  verify_reg(hkey, "Wine46a", REG_SZ, "Test Value", 11, 0);
1808  verify_reg(hkey, "Wine46b", REG_DWORD, &dword, sizeof(dword), 0);
1809  verify_reg(hkey, "Wine46c", REG_BINARY, hex, 4, 0);
1810  verify_reg(hkey, "Wine46d", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1811  verify_reg(hkey, "Wine46e", REG_EXPAND_SZ, "%PATH%", 7, 0);
1812  verify_reg(hkey, "Wine46f", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
1813 
1814  test_import_str("REGEDIT4\n\n"
1815  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1816  "\"Wine46a\"=-\n"
1817  "\"Wine46b\"= -\n"
1818  "\"Wine46c\"= \t-\t \n"
1819  "\"Wine46d\"=-\"Test\"\n"
1820  "\"Wine46e\"=- ;comment\n"
1821  "\"Wine46f\"=- #comment\n\n", &r);
1822  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1823  verify_reg_nonexist(hkey, "Wine46a");
1824  verify_reg_nonexist(hkey, "Wine46b");
1825  verify_reg_nonexist(hkey, "Wine46c");
1826  verify_reg(hkey, "Wine46d", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1827  verify_reg_nonexist(hkey, "Wine46e");
1828  verify_reg(hkey, "Wine46f", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
1829 
1830  /* Test the accepted range of the hex-based data types */
1831  test_import_str("REGEDIT4\n\n"
1832  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1833  "\"Wine47a\"=hex(0):56,61,6c,75,65,00\n"
1834  "\"Wine47b\"=hex(10):56,61,6c,75,65,00\n"
1835  "\"Wine47c\"=hex(100):56,61,6c,75,65,00\n"
1836  "\"Wine47d\"=hex(1000):56,61,6c,75,65,00\n"
1837  "\"Wine47e\"=hex(7fff):56,61,6c,75,65,00\n"
1838  "\"Wine47f\"=hex(ffff):56,61,6c,75,65,00\n"
1839  "\"Wine47g\"=hex(7fffffff):56,61,6c,75,65,00\n"
1840  "\"Wine47h\"=hex(ffffffff):56,61,6c,75,65,00\n"
1841  "\"Wine47i\"=hex(100000000):56,61,6c,75,65,00\n"
1842  "\"Wine47j\"=hex(0x2):56,61,6c,75,65,00\n"
1843  "\"Wine47k\"=hex(0X2):56,61,6c,75,65,00\n"
1844  "\"Wine47l\"=hex(x2):56,61,6c,75,65,00\n\n", &r);
1845  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1846  verify_reg(hkey, "Wine47a", REG_NONE, "Value", 6, 0);
1847  verify_reg(hkey, "Wine47b", 0x10, "Value", 6, 0);
1848  verify_reg(hkey, "Wine47c", 0x100, "Value", 6, 0);
1849  verify_reg(hkey, "Wine47d", 0x1000, "Value", 6, 0);
1850  verify_reg(hkey, "Wine47e", 0x7fff, "Value", 6, 0);
1851  verify_reg(hkey, "Wine47f", 0xffff, "Value", 6, 0);
1852  verify_reg(hkey, "Wine47g", 0x7fffffff, "Value", 6, 0);
1853  verify_reg(hkey, "Wine47h", 0xffffffff, "Value", 6, 0);
1854  verify_reg_nonexist(hkey, "Wine47i");
1855  verify_reg_nonexist(hkey, "Wine47j");
1856  verify_reg_nonexist(hkey, "Wine47k");
1857  verify_reg_nonexist(hkey, "Wine47l");
1858 
1859  test_import_str("REGEDIT4\n\n"
1860  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1861  "\"Wine48a\"=hex(7):4c,69,6e,65,20, \\\n"
1862  " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
1863  "\"Wine48b\"=hex(7):4c,69,6e,65,20,\t\\\n"
1864  " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n", &r);
1865  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1866  verify_reg(hkey, "Wine48a", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1867  verify_reg(hkey, "Wine48b", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
1868 
1869  test_import_str("REGEDIT4\n\n"
1870  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1871  "\"Wine49\"=hex(2):25,50,41,54,48,25,00,\n\n", &r);
1872  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1873  verify_reg(hkey, "Wine49", REG_EXPAND_SZ, "%PATH%", 7, 0);
1874 
1875  test_import_str("REGEDIT4\n\n"
1876  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1877  "\"Wine50a\"=hex(2):25,50,41,54,48,25,00 ;comment\n"
1878  "\"Wine50b\"=hex(2):25,50,41,54,48,25,00\t;comment\n"
1879  "\"Wine50c\"=hex(2):25,50,41,54,48,25,00 #comment\n"
1880  "\"Wine50d\"=hex(2):25,50,41,54,48,25,00\t#comment\n\n", &r);
1881  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1882  verify_reg(hkey, "Wine50a", REG_EXPAND_SZ, "%PATH%", 7, 0);
1883  verify_reg(hkey, "Wine50b", REG_EXPAND_SZ, "%PATH%", 7, 0);
1884  verify_reg_nonexist(hkey, "Wine50c");
1885  verify_reg_nonexist(hkey, "Wine50d");
1886 
1887  /* Test support for characters greater than 0xff */
1888  test_import_str("REGEDIT4\n\n"
1889  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1890  "\"Wine51a\"=hex(0):25,50,100,54,48,25,00\n"
1891  "\"Wine51b\"=hex(0):25,1a4,100,164,124,25,00\n\n", &r);
1892  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1893  verify_reg_nonexist(hkey, "Wine51a");
1894  verify_reg_nonexist(hkey, "Wine51b");
1895 
1896  /* Test the effect of backslashes in hex data */
1897  test_import_str("REGEDIT4\n\n"
1898  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1899  "\"Wine52a\"=hex(2):25,48\\,4f,4d,45,25,00\n"
1900  "\"Wine52b\"=hex(2):25,48,\\4f,4d,45,25,00\n"
1901  "\"Wine52c\"=hex(2):25,48\\ ,4f,4d,45,25,00\n"
1902  "\"Wine52d\"=hex(2):25,48,\\ 4f,4d,45,25,00\n"
1903  "\"Wine52e\"=hex(2):\\25,48,4f,4d,45,25,00\n"
1904  "\"Wine52f\"=hex(2):\\ 25,48,4f,4d,45,25,00\n"
1905  "\"Wine52g\"=hex(2):25,48,4\\f,4d,45,25,00\n"
1906  "\"Wine52h\"=hex(2):25,48,4\\\n"
1907  " f,4d,45,25,00\n"
1908  "\"Wine52i\"=hex(2):25,50,\\,41,54,48,25,00\n"
1909  "\"Wine52j\"=hex(2):25,48,4f,4d,45,25,5c,\\\\\n"
1910  " 25,50,41,54,48,25,00\n"
1911  "\"Wine52k\"=hex(2):,\\\n"
1912  " 25,48,4f,4d,45,25,00\n"
1913  "\"Wine52l\"=hex(2):\\\n"
1914  " 25,48,4f,4d,45,25,00\n\n", &r);
1915  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1916  verify_reg_nonexist(hkey, "Wine52a");
1917  verify_reg_nonexist(hkey, "Wine52b");
1918  verify_reg_nonexist(hkey, "Wine52c");
1919  verify_reg_nonexist(hkey, "Wine52d");
1920  verify_reg_nonexist(hkey, "Wine52e");
1921  verify_reg_nonexist(hkey, "Wine52f");
1922  verify_reg_nonexist(hkey, "Wine52g");
1923  verify_reg_nonexist(hkey, "Wine52h");
1924  verify_reg_nonexist(hkey, "Wine52i");
1925  verify_reg_nonexist(hkey, "Wine52j");
1926  verify_reg_nonexist(hkey, "Wine52k");
1927  verify_reg(hkey, "Wine52l", REG_EXPAND_SZ, "%HOME%", 7, 0);
1928 
1929  test_import_str("REGEDIT4\n\n"
1930  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1931  "\"Wine53a\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
1932  " 25,50,41,54,48,25,00\n"
1933  "\"Wine53b\"=hex(2):25,48,4f,4d,45,25,5c\\\n"
1934  " 25,50,41,54,48,25,00\n"
1935  "\"Wine53c\"=hex(2):25,48,4f,4d,45,25,5c, \\ ;comment\n"
1936  " 25,50,41,54,48,25,00\n"
1937  "\"Wine53d\"=hex(2):25,48,4f,4d,45,25,5c \\ ;comment\n"
1938  " 25,50,41,54,48,25,00\n"
1939  "\"Wine53e\"=hex(2):25,48,4f,4d,45,25,5c,\\\t ;comment\n"
1940  " 25,50,41,54,48,25,00\n"
1941  "\"Wine53f\"=hex(2):25,48,4f,4d,45,25,5c\\\t ;comment\n"
1942  " 25,50,41,54,48,25,00\n\n", &r);
1943  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1944  verify_reg(hkey, "Wine53a", REG_EXPAND_SZ, "%HOME%\\%PATH%", 14, 0);
1945  verify_reg_nonexist(hkey, "Wine53b");
1946  verify_reg(hkey, "Wine53c", REG_EXPAND_SZ, "%HOME%\\%PATH%", 14, 0);
1947  verify_reg_nonexist(hkey, "Wine53d");
1948  verify_reg(hkey, "Wine53e", REG_EXPAND_SZ, "%HOME%\\%PATH%", 14, 0);
1949  verify_reg_nonexist(hkey, "Wine53f");
1950 
1951  test_import_str("REGEDIT4\n\n"
1952  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1953  "\"Wine54a\"=hex(2):4c,69,6e,65,20,\\\n"
1954  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1]\n", &r);
1955  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1956  verify_reg_nonexist(hkey, "Wine54a");
1957  verify_key_nonexist(hkey, "Subkey1");
1958 
1959  test_import_str("REGEDIT4\n\n"
1960  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1961  "\"Wine54b\"=hex(2):4c,69,6e,65,20\\\n"
1962  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey2]\n", &r);
1963  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1964  verify_reg_nonexist(hkey, "Wine54b");
1965  verify_key(hkey, "Subkey2");
1966 
1967  delete_key(hkey, "Subkey2");
1968 
1969  test_import_str("REGEDIT4\n\n"
1970  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
1971  "\"Wine55a\"=hex(2):4c,69,6e,65,20,\\\n"
1972  "\"Wine55b\"=\"Test value\"\n"
1973 
1974  "\"Wine55c\"=hex(2):4c,69,6e,65,20,\\\n"
1975  ";comment\n"
1976  "\"Wine55d\"=\"Test value\"\n"
1977 
1978  "\"Wine55e\"=hex(2):4c,69,6e,65,20,\\\n"
1979  "#comment\n"
1980  "\"Wine55f\"=\"Test value\"\n"
1981 
1982  "\"Wine55g\"=hex(2):4c,69,6e,65,20,\\\n\n"
1983  "\"Wine55h\"=\"Test value\"\n"
1984 
1985  "\"Wine55i\"=hex(2):4c,69,6e,65,20\\\n"
1986  "\"Wine55j\"=\"Test value\"\n\n", &r);
1987  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
1988  verify_reg_nonexist(hkey, "Wine55a");
1989  verify_reg_nonexist(hkey, "Wine55b");
1990  verify_reg_nonexist(hkey, "Wine55c");
1991  verify_reg_nonexist(hkey, "Wine55d");
1992  verify_reg_nonexist(hkey, "Wine55e");
1993  verify_reg(hkey, "Wine55f", REG_SZ, "Test value", 11, 0);
1994  verify_reg_nonexist(hkey, "Wine55g");
1995  verify_reg_nonexist(hkey, "Wine55h");
1996  verify_reg_nonexist(hkey, "Wine55i");
1997  verify_reg(hkey, "Wine55j", REG_SZ, "Test value", 11, 0);
1998 
1999  test_import_str("REGEDIT4\n\n"
2000  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2001  "\"Wine56a\"=hex(2):4c,69,6e,65,20,\\\n"
2002  "\"Wine56b\"=dword:00000008\n"
2003 
2004  "\"Wine56c\"=hex(2):4c,69,6e,65,20,\\\n"
2005  ";comment\n"
2006  "\"Wine56d\"=dword:00000008\n"
2007 
2008  "\"Wine56e\"=hex(2):4c,69,6e,65,20,\\\n"
2009  "#comment\n"
2010  "\"Wine56f\"=dword:00000008\n"
2011 
2012  "\"Wine56g\"=hex(2):4c,69,6e,65,20,\\\n\n"
2013  "\"Wine56h\"=dword:00000008\n"
2014 
2015  "\"Wine56i\"=hex(2):4c,69,6e,65,20\\\n"
2016  "\"Wine56j\"=dword:00000008\n\n", &r);
2017  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2018  verify_reg_nonexist(hkey, "Wine56a");
2019  verify_reg_nonexist(hkey, "Wine56b");
2020  verify_reg_nonexist(hkey, "Wine56c");
2021  verify_reg_nonexist(hkey, "Wine56d");
2022  verify_reg_nonexist(hkey, "Wine56e");
2023  verify_reg(hkey, "Wine56f", REG_DWORD, &dword, sizeof(dword), 0);
2024  verify_reg_nonexist(hkey, "Wine56g");
2025  verify_reg_nonexist(hkey, "Wine56h");
2026  verify_reg_nonexist(hkey, "Wine56i");
2027  verify_reg(hkey, "Wine56j", REG_DWORD, &dword, sizeof(dword), 0);
2028 
2029  test_import_str("REGEDIT4\n\n"
2030  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2031  "\"Wine57a\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
2032  "\"Wine57b\"=hex(2):25,50,41,54,48,25,00\n"
2033 
2034  "\"Wine57c\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
2035  ";comment\n"
2036  "\"Wine57d\"=hex(2):25,50,41,54,48,25,00\n"
2037 
2038  "\"Wine57e\"=hex(2):25,48,4f,4d,45,25,5c,\\\n"
2039  "#comment\n"
2040  "\"Wine57f\"=hex(2):25,50,41,54,48,25,00\n"
2041 
2042  "\"Wine57g\"=hex(2):25,48,4f,4d,45,25,5c,\\\n\n"
2043  "\"Wine57h\"=hex(2):25,50,41,54,48,25,00\n"
2044 
2045  "\"Wine57i\"=hex(2):25,48,4f,4d,45,25,5c\\\n"
2046  "\"Wine57j\"=hex(2):25,50,41,54,48,25,00\n\n", &r);
2047  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2048  verify_reg_nonexist(hkey, "Wine57a");
2049  verify_reg_nonexist(hkey, "Wine57b");
2050  verify_reg_nonexist(hkey, "Wine57c");
2051  verify_reg_nonexist(hkey, "Wine57d");
2052  verify_reg_nonexist(hkey, "Wine57e");
2053  verify_reg(hkey, "Wine57f", REG_EXPAND_SZ, "%PATH%", 7, 0);
2054  verify_reg_nonexist(hkey, "Wine57g");
2055  verify_reg_nonexist(hkey, "Wine57h");
2056  verify_reg_nonexist(hkey, "Wine57i");
2057  verify_reg(hkey, "Wine57j", REG_EXPAND_SZ, "%PATH%", 7, 0);
2058 
2059  delete_value(hkey, NULL);
2060 
2061  test_import_str("REGEDIT4\n\n"
2062  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2063  "\"Wine58a\"=hex(2):4c,69,6e,65,20,\\\n"
2064  "@=\"Default value 1\"\n\n", &r);
2065  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2066  verify_reg_nonexist(hkey, "Wine58a");
2067  verify_reg_nonexist(hkey, NULL);
2068 
2069  test_import_str("REGEDIT4\n\n"
2070  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2071  "\"Wine58b\"=hex(2):4c,69,6e,65,20,\\\n"
2072  ";comment\n"
2073  "@=\"Default value 2\"\n\n", &r);
2074  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2075  verify_reg_nonexist(hkey, "Wine58b");
2076  verify_reg_nonexist(hkey, NULL);
2077 
2078  test_import_str("REGEDIT4\n\n"
2079  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2080  "\"Wine58c\"=hex(2):4c,69,6e,65,20,\\\n"
2081  "#comment\n"
2082  "@=\"Default value 3\"\n\n", &r);
2083  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2084  verify_reg_nonexist(hkey, "Wine58c");
2085  verify_reg(hkey, NULL, REG_SZ, "Default value 3", 16, 0);
2086 
2087  delete_value(hkey, NULL);
2088 
2089  test_import_str("REGEDIT4\n\n"
2090  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2091  "\"Wine58d\"=hex(2):4c,69,6e,65,20,\\\n\n"
2092  "@=\"Default value 4\"\n\n", &r);
2093  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2094  verify_reg_nonexist(hkey, "Wine58d");
2095  verify_reg_nonexist(hkey, NULL);
2096 
2097  test_import_str("REGEDIT4\n\n"
2098  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2099  "\"Wine58e\"=hex(2):4c,69,6e,65,20\\\n"
2100  "@=\"Default value 5\"\n\n", &r);
2101  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2102  verify_reg_nonexist(hkey, "Wine58e");
2103  verify_reg(hkey, NULL, REG_SZ, "Default value 5", 16, 0);
2104 
2105  test_import_str("REGEDIT4\n\n"
2106  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2107  "\"Wine59a\"=hex:11,22,33,\\\n"
2108  "\\\n"
2109  " 44,55,66\n"
2110  "\"Wine59b\"=hex:11,22,33,\\\n"
2111  " \\\n"
2112  " 44,55,66\n\n", &r);
2113  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2114  verify_reg_nonexist(hkey, "Wine59a");
2115  verify_reg_nonexist(hkey, "Wine59b");
2116 
2117  test_import_str("REGEDIT4\n\n"
2118  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2119  "\"Wine60a\"=hex(7):4c,69,6e,65,20,\\\n"
2120  " 63,6f,6e,63,61,74,\\\n"
2121  ";comment\n"
2122  " 65,6e,\\;comment\n"
2123  " 61,74,69,6f,6e,00,00\n\n", &r);
2124  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2125  verify_reg(hkey, "Wine60a", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2126 
2127  test_import_str("REGEDIT4\n\n"
2128  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2129  "\"Wine60b\"=hex(7):4c,69,6e,65,20,\\\n"
2130  " 63,6f,6e,63,61,74,\\\n"
2131  " ;comment\n"
2132  " 65,6e,\\;comment\n"
2133  " 61,74,69,6f,6e,00,00\n\n", &r);
2134  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2135  verify_reg(hkey, "Wine60b", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2136 
2137  test_import_str("REGEDIT4\n\n"
2138  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2139  "\"Wine60c\"=hex(7):4c,69,6e,65,20,\\\n"
2140  " 63,6f,6e,63,61,74,\\\n"
2141  "#comment\n"
2142  " 65,6e,\\;comment\n"
2143  " 61,74,69,6f,6e,00,00\n\n", &r);
2144  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2145  verify_reg_nonexist(hkey, "Wine60c");
2146 
2147  test_import_str("REGEDIT4\n\n"
2148  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2149  "\"Wine60d\"=hex(7):4c,69,6e,65,20,\\\n"
2150  " 63,6f,6e,63,61,74,\\\n"
2151  " #comment\n"
2152  " 65,6e,\\;comment\n"
2153  " 61,74,69,6f,6e,00,00\n\n", &r);
2154  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2155  verify_reg_nonexist(hkey, "Wine60d");
2156 
2157  test_import_str("REGEDIT4\n\n"
2158  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2159  "\"Wine60e\"=hex(7):4c,69,6e,65,20,\\\n"
2160  " 63,6f,6e,\\\n\n"
2161  " 63,61,74,\\\n\n\n"
2162  " 65,6e,\\\n\n\n\n"
2163  " 61,74,69,6f,6e,00,00\n\n", &r);
2164  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2165  verify_reg(hkey, "Wine60e", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2166 
2167  test_import_str("REGEDIT4\n\n"
2168  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2169  "\"Wine60f\"=hex(7):4c,69,6e,65,20,\\\n"
2170  " 63,6f,6e,\\\n \n"
2171  " 63,61,74,\\\n\t\n\t\n"
2172  " 65,6e,\\\n\t \t\n\t \t\n\t \t\n"
2173  " 61,74,69,6f,6e,00,00\n\n", &r);
2174  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2175  verify_reg(hkey, "Wine60f", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2176 
2177  test_import_str("REGEDIT4\n\n"
2178  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2179  "\"Wine61a\"=hex(0):25,48,4f,4d,45,25,5c,/\n"
2180  " 25,50,41,54,48,25,00\n"
2181  "\"Wine61b\"=hex(0):25,48,4f,4d,45,25,5c/\n"
2182  " 25,50,41,54,48,25,00\n\n", &r);
2183  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2184  verify_reg_nonexist(hkey, "Wine61a");
2185  verify_reg_nonexist(hkey, "Wine61b");
2186 
2187  test_import_str("REGEDIT4\n\n"
2188  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2189  "\"Wine62a\"=hex(0):56,61,6c,75,65,\\", &r);
2190  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2191  err = RegQueryValueExA(hkey, "Wine62a", NULL, NULL, NULL, NULL);
2192  ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND) /* WinXP */,
2193  "got %u, expected 0\n", err);
2194  if (err == ERROR_SUCCESS)
2195  verify_reg(hkey, "Wine62a", REG_NONE, "Value", 5, 0);
2196 
2197  test_import_str("REGEDIT4\n\n"
2198  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2199  "\"Wine62b\"=hex(2):25,50,41,54,48,25,\\", &r);
2200  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2201  err = RegQueryValueExA(hkey, "Wine62b", NULL, NULL, NULL, NULL);
2202  ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND) /* WinXP */,
2203  "got %u, expected 0\n", err);
2204  if (err == ERROR_SUCCESS)
2205  verify_reg(hkey, "Wine62b", REG_EXPAND_SZ, "%PATH%", 7, 0);
2206 
2207  test_import_str("REGEDIT4\n\n"
2208  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2209  "\"Wine62c\"=hex:11,22,33,44,55,\\", &r);
2210  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2211  err = RegQueryValueExA(hkey, "Wine62c", NULL, NULL, NULL, NULL);
2212  ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND) /* WinXP */,
2213  "got %u, expected 0\n", err);
2214  if (err == ERROR_SUCCESS)
2215  verify_reg(hkey, "Wine62c", REG_BINARY, hex, 5, 0);
2216 
2217  test_import_str("REGEDIT4\n\n"
2218  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2219  "\"Wine62d\"=hex(7):4c,69,6e,65,\\", &r);
2220  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2221  err = RegQueryValueExA(hkey, "Wine62d", NULL, NULL, NULL, NULL);
2222  ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND) /* WinXP */,
2223  "got %u, expected 0\n", err);
2224  if (err == ERROR_SUCCESS)
2225  verify_reg(hkey, "Wine62d", REG_MULTI_SZ, "Line", 5, 0);
2226 
2227  test_import_str("REGEDIT4\n\n"
2228  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2229  "\"Wine62e\"=hex(100):56,61,6c,75,65,\\", &r);
2230  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2231  err = RegQueryValueExA(hkey, "Wine62e", NULL, NULL, NULL, NULL);
2232  ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND) /* WinXP */,
2233  "got %u, expected 0\n", err);
2234  if (err == ERROR_SUCCESS)
2235  verify_reg(hkey, "Wine62e", 0x100, "Value", 5, 0);
2236 
2237  test_import_str("REGEDIT4\n\n"
2238  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2239  "\"Wine62f\"=hex(7):4c,69,6e,65,20\\", &r);
2240  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2241  verify_reg_nonexist(hkey, "Wine62f");
2242 
2243  test_import_str("REGEDIT4\n\n"
2244  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2245  "\"Wine63a\"=hex(7):4c,69,6e,65,20,\\\n"
2246  " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
2247  "\"Wine63b\"=hex(7):4c,69,6e,65,20,\\\n"
2248  " 63,,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n", &r);
2249  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2250  verify_reg_nonexist(hkey, "Wine63a");
2251  verify_reg_nonexist(hkey, "Wine63b");
2252 
2253  test_import_str("REGEDIT4\n\n"
2254  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2255  "\"Wine64a\"=hex(7):4c,69,6e,65,00,00\n"
2256  "\"Wine64b\"=hex(7):4c,69,6e,65,20,\\\n"
2257  " 63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n"
2258  "\"Wine64c\"=hex(7):4c,69,6e,65,20,\\;comment\n"
2259  " 63,6f,6e,63,61,74,\\\n"
2260  " 65,6e,61,74,69,6f,6e,00,00\n"
2261  "\"Wine64d\"=hex(7):4c,69,6e,65,20,\\;comment\n"
2262  " 63,6f,6e,63,61,74,\n"
2263  " 65,6e,61,74,69,6f,6e,00,00\n"
2264  "\"Wine64e\"=hex(7):4c,69,6e,65,20,\\\n"
2265  " 63,6f,6e,63,61,74,;comment\n"
2266  " 65,6e,61,74,69,6f,6e,00,00\n\n", &r);
2267  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2268  verify_reg(hkey, "Wine64a", REG_MULTI_SZ, "Line\0", 6, 0);
2269  verify_reg(hkey, "Wine64b", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2270  verify_reg(hkey, "Wine64c", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2271  /* Wine64d */
2272  size = sizeof(buffer);
2273  err = RegQueryValueExA(hkey, "Wine64d", NULL, &type, (BYTE *)&buffer, &size);
2274  ok(err == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", err);
2275  ok(type == REG_MULTI_SZ, "got wrong type %u, expected %u\n", type, REG_MULTI_SZ);
2276  ok(size == 12 || broken(size == 11) /* WinXP */, "got wrong size %u, expected 12\n", size);
2277  ok(memcmp(buffer, "Line concat", size) == 0, "got wrong data\n");
2278  /* Wine64e */
2279  size = sizeof(buffer);
2280  err = RegQueryValueExA(hkey, "Wine64e", NULL, &type, (BYTE *)&buffer, &size);
2281  ok(err == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", err);
2282  ok(type == REG_MULTI_SZ, "got wrong type %u, expected %u\n", type, REG_MULTI_SZ);
2283  ok(size == 12 || broken(size == 11) /* WinXP */, "got wrong size %u, expected 12\n", size);
2284  ok(memcmp(buffer, "Line concat", size) == 0, "got wrong data\n");
2285 
2286  test_import_str("REGEDIT4\n\n"
2287  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2288  "\"Wine65a\"=hex(100):25,50,41,54,48,25,00\n"
2289  "\"Wine65b\"=hex(100):25,50,41,\\\n"
2290  " 54,48,25,00\n"
2291  "\"Wine65c\"=hex(100):25,50,41,\\;comment\n"
2292  " 54,48,\\\n"
2293  " 25,00\n"
2294  "\"Wine65d\"=hex(100):25,50,41,\\;comment\n"
2295  " 54,48,\n"
2296  " 25,00\n"
2297  "\"Wine65e\"=hex(100):25,50,41,\\;comment\n"
2298  " 54,48,;comment\n"
2299  " 25,00\n", &r);
2300  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2301  verify_reg(hkey, "Wine65a", 0x100, "%PATH%", 7, 0);
2302  verify_reg(hkey, "Wine65b", 0x100, "%PATH%", 7, 0);
2303  verify_reg(hkey, "Wine65c", 0x100, "%PATH%", 7, 0);
2304  verify_reg(hkey, "Wine65d", 0x100, "%PATH", 5, 0);
2305  verify_reg(hkey, "Wine65e", 0x100, "%PATH", 5, 0);
2306 
2307  /* Test null-termination of REG_EXPAND_SZ and REG_MULTI_SZ data*/
2308  test_import_str("REGEDIT4\n\n"
2309  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2310  "\"Wine66a\"=hex(7):4c,69,6e,65\n"
2311  "\"Wine66b\"=hex(7):4c,69,6e,65,\n"
2312  "\"Wine66c\"=hex(7):4c,69,6e,65,00\n"
2313  "\"Wine66d\"=hex(7):4c,69,6e,65,00,\n"
2314  "\"Wine66e\"=hex(7):4c,69,6e,65,00,00\n"
2315  "\"Wine66f\"=hex(7):4c,69,6e,65,00,00,\n\n", &r);
2316  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2317  verify_reg(hkey, "Wine66a", REG_MULTI_SZ, "Line", 5, 0);
2318  verify_reg(hkey, "Wine66b", REG_MULTI_SZ, "Line", 5, 0);
2319  verify_reg(hkey, "Wine66c", REG_MULTI_SZ, "Line", 5, 0);
2320  verify_reg(hkey, "Wine66d", REG_MULTI_SZ, "Line", 5, 0);
2321  verify_reg(hkey, "Wine66e", REG_MULTI_SZ, "Line\0", 6, 0);
2322  verify_reg(hkey, "Wine66f", REG_MULTI_SZ, "Line\0", 6, 0);
2323 
2324  test_import_str("REGEDIT4\n\n"
2325  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2326  "\"Wine67a\"=hex(2):25,50,41,54,48,25\n"
2327  "\"Wine67b\"=hex(2):25,50,41,54,48,25,\n"
2328  "\"Wine67c\"=hex(2):25,50,41,54,48,25,00\n"
2329  "\"Wine67d\"=hex(2):25,50,41,54,48,25,00,\n\n", &r);
2330  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2331  verify_reg(hkey, "Wine67a", REG_EXPAND_SZ, "%PATH%", 7, 0);
2332  verify_reg(hkey, "Wine67b", REG_EXPAND_SZ, "%PATH%", 7, 0);
2333  verify_reg(hkey, "Wine67c", REG_EXPAND_SZ, "%PATH%", 7, 0);
2334  verify_reg(hkey, "Wine67d", REG_EXPAND_SZ, "%PATH%", 7, 0);
2335 
2336  test_import_str("REGEDIT4\n\n"
2337  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2338  "\"Wine68a\"=hex(1):\n"
2339  "\"Wine68b\"=hex(2):\n"
2340  "\"Wine68c\"=hex(3):\n"
2341  "\"Wine68d\"=hex(4):\n"
2342  "\"Wine68e\"=hex(7):\n"
2343  "\"Wine68f\"=hex(100):\n"
2344  "\"Wine68g\"=hex(abcd):\n"
2345  "\"Wine68h\"=hex:\n"
2346  "\"Wine68i\"=hex(0):\n\n", &r);
2347  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2348  verify_reg(hkey, "Wine68a", REG_SZ, NULL, 0, 0);
2349  verify_reg(hkey, "Wine68b", REG_EXPAND_SZ, NULL, 0, 0);
2350  verify_reg(hkey, "Wine68c", REG_BINARY, NULL, 0, 0);
2351  verify_reg(hkey, "Wine68d", REG_DWORD, NULL, 0, 0);
2352  verify_reg(hkey, "Wine68e", REG_MULTI_SZ, NULL, 0, 0);
2353  verify_reg(hkey, "Wine68f", 0x100, NULL, 0, 0);
2354  verify_reg(hkey, "Wine68g", 0xabcd, NULL, 0, 0);
2355  verify_reg(hkey, "Wine68h", REG_BINARY, NULL, 0, 0);
2356  verify_reg(hkey, "Wine68i", REG_NONE, NULL, 0, 0);
2357 
2358  /* Test with embedded null characters */
2359  test_import_str("REGEDIT4\n\n"
2360  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2361  "\"Wine69a\"=\"\\0\n"
2362  "\"Wine69b\"=\"\\0\\0\n"
2363  "\"Wine69c\"=\"Value1\\0\n"
2364  "\"Wine69d\"=\"Value2\\0\\0\\0\\0\n"
2365  "\"Wine69e\"=\"Value3\\0Value4\n"
2366  "\"Wine69f\"=\"\\0Value4\n\n", &r);
2367  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2368  verify_reg_nonexist(hkey, "Wine69a");
2369  verify_reg_nonexist(hkey, "Wine69b");
2370  verify_reg_nonexist(hkey, "Wine69c");
2371  verify_reg_nonexist(hkey, "Wine69d");
2372  verify_reg_nonexist(hkey, "Wine69e");
2373  verify_reg_nonexist(hkey, "Wine69f");
2374 
2375  err = RegCloseKey(hkey);
2376  ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
2377 
2379 }
2380 
2381 static void test_unicode_import(void)
2382 {
2383  DWORD r, dword = 0x123, type, size;
2384  HKEY hkey, subkey;
2385  LONG err;
2386  char buffer[24];
2387  BYTE hex[8];
2388 
2390  ok(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
2391 
2392  test_import_wstr("REGEDIT\n", &r);
2393  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2394  "got exit code %d, expected 1\n", r);
2395 
2396  test_import_wstr("REGEDIT4\n", &r);
2397  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2398  "got exit code %d, expected 1\n", r);
2399 
2400  test_import_wstr("\xef\xbb\xbfREGEDIT", &r);
2401  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2402 
2403  test_import_wstr("\xef\xbb\xbfREGEDIT\n", &r);
2404  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2405 
2406  test_import_wstr("\xef\xbb\xbfREGEDIT4", &r);
2407  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2408 
2409  test_import_wstr("\xef\xbb\xbfREGEDIT4\n", &r);
2410  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2411 
2412  test_import_wstr("\xef\xbb\xbf REGEDIT4\n", &r);
2413  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2414 
2415  test_import_wstr("\xef\xbb\xbf\tREGEDIT4\n", &r);
2416  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2417 
2418  test_import_wstr("\xef\xbb\xbf\nREGEDIT4\n", &r);
2419  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2420  "got exit code %d, expected 1\n", r);
2421 
2422  test_import_wstr("\xef\xbb\xbfREGEDIT4\n"
2423  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n", &r);
2424  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2425 
2427 
2428  test_import_wstr("\xef\xbb\xbfREGEDIT3\n\n"
2429  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2430  "\"Test1\"=\"Value\"\n", &r);
2431  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2432  verify_reg_nonexist(hkey, "Test1");
2433 
2434  test_import_wstr("\xef\xbb\xbfregedit4\n\n"
2435  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2436  "\"Test2\"=\"Value\"\n", &r);
2437  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2438  "got exit code %d, expected 1\n", r);
2439  verify_reg_nonexist(hkey, "Test2");
2440 
2441  test_import_wstr("\xef\xbb\xbfRegedit4\n\n"
2442  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2443  "\"Test3\"=\"Value\"\n", &r);
2444  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2445  "got exit code %d, expected 1\n", r);
2446  verify_reg_nonexist(hkey, "Test3");
2447 
2448  test_import_wstr("\xef\xbb\xbfREGEDIT 4\n\n"
2449  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2450  "\"Test4\"=\"Value\"\n", &r);
2451  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2452  verify_reg_nonexist(hkey, "Test4");
2453 
2454  test_import_wstr("\xef\xbb\xbfREGEDIT4FOO\n\n"
2455  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2456  "\"Test5\"=\"Value\"\n", &r);
2457  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2458  verify_reg_nonexist(hkey, "Test5");
2459 
2460  test_import_wstr("\xef\xbb\xbfREGEDIT4 FOO\n\n"
2461  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2462  "\"Test6\"=\"Value\"\n", &r);
2463  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2464  verify_reg_nonexist(hkey, "Test6");
2465 
2466  test_import_wstr("\xef\xbb\xbfREGEDIT5\n\n"
2467  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2468  "\"Test7\"=\"Value\"\n", &r);
2469  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2470  verify_reg_nonexist(hkey, "Test7");
2471 
2472  test_import_wstr("\xef\xbb\xbfREGEDIT9\n\n"
2473  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2474  "\"Test8\"=\"Value\"\n", &r);
2475  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2476  verify_reg_nonexist(hkey, "Test8");
2477 
2478  test_import_wstr("\xef\xbb\xbfREGEDIT4\n"
2479  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2480  "\"Unicode1\"=\"Value1\"\n", &r);
2481  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2482  verify_reg(hkey, "Unicode1", REG_SZ, "Value1", 7, 0);
2483 
2484  test_import_wstr("\xef\xbb\xbfREGEDIT4\n"
2485  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2486  "\"Unicode2\"=\"Value2\"\n\n", &r);
2487  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2488  verify_reg(hkey, "Unicode2", REG_SZ, "Value2", 7, 0);
2489 
2490  test_import_wstr("\xef\xbb\xbfREGEDIT4\n\n"
2491  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2492  "\"Unicode3\"=\"Value3\"\n\n", &r);
2493  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2494  verify_reg(hkey, "Unicode3", REG_SZ, "Value3", 7, 0);
2495 
2496  test_import_wstr("Windows Registry Editor Version 4.00\n", &r);
2497  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2498  "got exit code %d, expected 1\n", r);
2499 
2500  test_import_wstr("Windows Registry Editor Version 5.00\n", &r);
2501  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2502  "got exit code %d, expected 1\n", r);
2503 
2504  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5\n", &r);
2505  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2506  "got exit code %d, expected 1\n", r);
2507 
2508  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00", &r);
2509  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2510 
2511  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n", &r);
2512  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2513 
2514  test_import_wstr("\xef\xbb\xbfWINDOWS Registry Editor Version 5.00\n", &r);
2515  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2516  "got exit code %d, expected 1\n", r);
2517 
2518  test_import_wstr("\xef\xbb\xbf Windows Registry Editor Version 5.00\n", &r);
2519  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2520 
2521  test_import_wstr("\xef\xbb\xbf\tWindows Registry Editor Version 5.00\n", &r);
2522  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2523 
2524  test_import_wstr("\xef\xbb\xbf\nWindows Registry Editor Version 5.00\n", &r);
2525  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2526  "got exit code %d, expected 1\n", r);
2527 
2528  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 4.00\n\n"
2529  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2530  "\"Test9\"=\"Value\"\n", &r);
2531  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2532  "got exit code %d, expected 1\n", r);
2533  verify_reg_nonexist(hkey, "Test9");
2534 
2535  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5\n\n"
2536  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2537  "\"Test10\"=\"Value\"\n", &r);
2538  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2539  "got exit code %d, expected 1\n", r);
2540  verify_reg_nonexist(hkey, "Test10");
2541 
2542  test_import_wstr("\xef\xbb\xbfWINDOWS REGISTRY EDITOR VERSION 5.00\n\n"
2543  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2544  "\"Test11\"=\"Value\"\n", &r);
2545  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2546  "got exit code %d, expected 1\n", r);
2547  verify_reg_nonexist(hkey, "Test11");
2548 
2549  test_import_wstr("\xef\xbb\xbfWindows Registry Editor version 5.00\n\n"
2550  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2551  "\"Test12\"=\"Value\"\n", &r);
2552  ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS) /* WinXP */,
2553  "got exit code %d, expected 1\n", r);
2554  verify_reg_nonexist(hkey, "Test12");
2555 
2556  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2557  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2558  "\"Wine\"=dword:00000123\n\n", &r);
2559  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2560  verify_reg(hkey, "Wine", REG_DWORD, &dword, sizeof(dword), 0);
2561 
2562  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2563  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2564  "@=\"Test string\"\n\n", &r);
2565  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2566  verify_reg(hkey, NULL, REG_SZ, "Test string", 12, 0);
2567 
2568  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n"
2569  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2570  "\"Unicode4\"=\"Value4\"\n", &r);
2571  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2572  verify_reg(hkey, "Unicode4", REG_SZ, "Value4", 7, 0);
2573 
2574  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n"
2575  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2576  "\"Unicode5\"=\"Value5\"\n\n", &r);
2577  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2578  verify_reg(hkey, "Unicode5", REG_SZ, "Value5", 7, 0);
2579 
2580  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2581  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2582  "\"Unicode6\"=\"Value6\"\n\n", &r);
2583  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2584  verify_reg(hkey, "Unicode6", REG_SZ, "Value6", 7, 0);
2585 
2586  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2587  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2588  "\"Line1\"=\"Value1\"\n\n"
2589  "\"Line2\"=\"Value2\"\n\n\n"
2590  "\"Line3\"=\"Value3\"\n\n\n\n"
2591  "\"Line4\"=\"Value4\"\n\n", &r);
2592  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2593  verify_reg(hkey, "Line1", REG_SZ, "Value1", 7, 0);
2594  verify_reg(hkey, "Line2", REG_SZ, "Value2", 7, 0);
2595  verify_reg(hkey, "Line3", REG_SZ, "Value3", 7, 0);
2596  verify_reg(hkey, "Line4", REG_SZ, "Value4", 7, 0);
2597 
2598  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2599  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2600  "\"Wine1\"=dword:00000782\n\n"
2601  "\"Wine2\"=\"Test Value\"\n"
2602  "\"Wine3\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,63,00,6f,00,6e,00,63,00,\\\n"
2603  " 61,00,74,00,65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
2604  "#comment\n"
2605  "@=\"Test\"\n"
2606  ";comment\n\n"
2607  "\"Wine4\"=dword:12345678\n\n", &r);
2608  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2609  dword = 0x782;
2610  verify_reg(hkey, "Wine1", REG_DWORD, &dword, sizeof(dword), 0);
2611  verify_reg(hkey, "Wine2", REG_SZ, "Test Value", 11, 0);
2612  verify_reg(hkey, "Wine3", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2613  verify_reg(hkey, "", REG_SZ, "Test", 5, 0);
2614  dword = 0x12345678;
2615  verify_reg(hkey, "Wine4", REG_DWORD, &dword, sizeof(dword), 0);
2616 
2617  test_import_wstr("\xef\xbb\xbfREGEDIT4\n\n"
2618  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2619  "\"Wine5\"=\"No newline\"", &r);
2620  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2621  err = RegQueryValueExA(hkey, "Wine5", NULL, NULL, NULL, NULL);
2622  ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND /* WinXP */),
2623  "got %d, expected 0\n", err);
2624  if (err == ERROR_SUCCESS)
2625  verify_reg(hkey, "Wine5", REG_SZ, "No newline", 11, 0);
2626 
2627  test_import_wstr("\xef\xbb\xbfREGEDIT4\n\n"
2628  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2629  "\"Wine6\"=dword:00000050\n\n"
2630  "\"Wine7\"=\"No newline\"", &r);
2631  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2632  dword = 0x50;
2633  verify_reg(hkey, "Wine6", REG_DWORD, &dword, sizeof(dword), 0);
2634  err = RegQueryValueExA(hkey, "Wine7", NULL, NULL, NULL, NULL);
2635  ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND /* WinXP */),
2636  "got %d, expected 0\n", err);
2637  if (err == ERROR_SUCCESS)
2638  verify_reg(hkey, "Wine7", REG_SZ, "No newline", 11, 0);
2639 
2640  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2641  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2642  "#comment\\\n"
2643  "\"Wine8\"=\"Line 1\"\n"
2644  ";comment\\\n"
2645  "\"Wine9\"=\"Line 2\"\n\n", &r);
2646  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2647  verify_reg(hkey, "Wine8", REG_SZ, "Line 1", 7, 0);
2648  verify_reg(hkey, "Wine9", REG_SZ, "Line 2", 7, 0);
2649 
2650  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2651  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2652  "\"Wine10\"=\"Value 1\"#comment\n"
2653  "\"Wine11\"=\"Value 2\";comment\n"
2654  "\"Wine12\"=dword:01020304 #comment\n"
2655  "\"Wine13\"=dword:02040608 ;comment\n\n", &r);
2656  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2657  verify_reg_nonexist(hkey, "Wine10");
2658  verify_reg(hkey, "Wine11", REG_SZ, "Value 2", 8, 0);
2659  verify_reg_nonexist(hkey, "Wine12");
2660  dword = 0x2040608;
2661  verify_reg(hkey, "Wine13", REG_DWORD, &dword, sizeof(dword), 0);
2662 
2663  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2664  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2665  "\"Wine14\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,63,00,6f,00,6e,00,63,00,\\\n"
2666  " #comment\n"
2667  " 61,00,74,00,65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
2668  "\"Wine15\"=\"A valid line\"\n"
2669  "\"Wine16\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,63,00,6f,00,6e,00,63,00,\\\n"
2670  " ;comment\n"
2671  " 61,00,74,00,65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n"
2672  "\"Wine17\"=\"Another valid line\"\n\n", &r);
2673  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2674  verify_reg_nonexist(hkey, "Wine14");
2675  verify_reg(hkey, "Wine15", REG_SZ, "A valid line", 13, 0);
2676  verify_reg(hkey, "Wine16", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2677  verify_reg(hkey, "Wine17", REG_SZ, "Another valid line", 19, 0);
2678 
2679  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2680  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2681  "#\"Comment1\"=\"Value 1\"\n"
2682  ";\"Comment2\"=\"Value 2\"\n"
2683  " #\"Comment3\"=\"Value 3\"\n"
2684  " ;\"Comment4\"=\"Value 4\"\n"
2685  "\"Wine18\"=\"Value 6\"#\"Comment5\"=\"Value 5\"\n"
2686  "\"Wine19\"=\"Value 7\";\"Comment6\"=\"Value 6\"\n\n", &r);
2687  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2688  verify_reg_nonexist(hkey, "Comment1");
2689  verify_reg_nonexist(hkey, "Comment2");
2690  verify_reg_nonexist(hkey, "Comment3");
2691  verify_reg_nonexist(hkey, "Comment4");
2692  verify_reg_nonexist(hkey, "Wine18");
2693  verify_reg_nonexist(hkey, "Comment5");
2694  verify_reg(hkey, "Wine19", REG_SZ, "Value 7", 8, 0);
2695  verify_reg_nonexist(hkey, "Comment6");
2696 
2697  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2698  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2699  "\"Wine20\"=#\"Value 8\"\n"
2700  "\"Wine21\"=;\"Value 9\"\n"
2701  "\"Wine22\"=\"#comment1\"\n"
2702  "\"Wine23\"=\";comment2\"\n"
2703  "\"Wine24\"=\"Value#comment3\"\n"
2704  "\"Wine25\"=\"Value;comment4\"\n"
2705  "\"Wine26\"=\"Value #comment5\"\n"
2706  "\"Wine27\"=\"Value ;comment6\"\n"
2707  "\"Wine28\"=#dword:00000001\n"
2708  "\"Wine29\"=;dword:00000002\n"
2709  "\"Wine30\"=dword:00000003#comment\n"
2710  "\"Wine31\"=dword:00000004;comment\n\n", &r);
2711  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2712  verify_reg_nonexist(hkey, "Wine20");
2713  verify_reg_nonexist(hkey, "Wine21");
2714  verify_reg(hkey, "Wine22", REG_SZ, "#comment1", 10, 0);
2715  verify_reg(hkey, "Wine23", REG_SZ, ";comment2", 10, 0);
2716  verify_reg(hkey, "Wine24", REG_SZ, "Value#comment3", 15, 0);
2717  verify_reg(hkey, "Wine25", REG_SZ, "Value;comment4", 15, 0);
2718  verify_reg(hkey, "Wine26", REG_SZ, "Value #comment5", 16, 0);
2719  verify_reg(hkey, "Wine27", REG_SZ, "Value ;comment6", 16, 0);
2720  verify_reg_nonexist(hkey, "Wine28");
2721  verify_reg_nonexist(hkey, "Wine29");
2722  verify_reg_nonexist(hkey, "Wine30");
2723  dword = 0x00000004;
2724  verify_reg(hkey, "Wine31", REG_DWORD, &dword, sizeof(dword), 0);
2725 
2726  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2727  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2728  "\"Wine32a\"=dword:1\n"
2729  "\"Wine32b\"=dword:4444\n\n", &r);
2730  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2731  dword = 0x1;
2732  verify_reg(hkey, "Wine32a", REG_DWORD, &dword, sizeof(dword), 0);
2733  dword = 0x4444;
2734  verify_reg(hkey, "Wine32b", REG_DWORD, &dword, sizeof(dword), 0);
2735 
2736  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2737  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2738  "\"Wine33a\"=dword:\n"
2739  "\"Wine33b\"=dword:hello\n"
2740  "\"Wine33c\"=dword:123456789\n"
2741  "\"Wine33d\"=dword:012345678\n"
2742  "\"Wine33e\"=dword:000000001\n\n", &r);
2743  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2744  verify_reg_nonexist(hkey, "Wine33a");
2745  verify_reg_nonexist(hkey, "Wine33b");
2746  verify_reg_nonexist(hkey, "Wine33c");
2747  verify_reg_nonexist(hkey, "Wine33d");
2748  verify_reg_nonexist(hkey, "Wine33e");
2749 
2750  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2751  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2752  "\"Wine34a\"=dword:12345678abc\n"
2753  "\"Wine34b\"=dword:12345678 abc\n\n", &r);
2754  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2755  verify_reg_nonexist(hkey, "Wine34a");
2756  verify_reg_nonexist(hkey, "Wine34b");
2757 
2758  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2759  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2760  "\"Wine35a\"=dword:0x123\n"
2761  "\"Wine35b\"=dword:123 456\n"
2762  "\"Wine35c\"=dword:1234 5678\n\n", &r);
2763  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2764  verify_reg_nonexist(hkey, "Wine35a");
2765  verify_reg_nonexist(hkey, "Wine35b");
2766  verify_reg_nonexist(hkey, "Wine35c");
2767 
2768  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2769  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2770  "\"Wine36a\"=dword:1234;5678\n"
2771  "\"Wine36b\"=dword:1234 ;5678\n"
2772  "\"Wine36c\"=dword:1234#5678\n"
2773  "\"Wine36d\"=dword:1234 #5678\n\n", &r);
2774  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2775  dword = 0x1234;
2776  verify_reg(hkey, "Wine36a", REG_DWORD, &dword, sizeof(dword), 0);
2777  verify_reg(hkey, "Wine36b", REG_DWORD, &dword, sizeof(dword), 0);
2778  verify_reg_nonexist(hkey, "Wine36c");
2779  verify_reg_nonexist(hkey, "Wine36d");
2780 
2781  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2782  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2783  "\"Wine37a\"=\"foo\"bar\"\n"
2784  "\"Wine37b\"=\"foo\"\"bar\"\n\n", &r);
2785  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2786  verify_reg_nonexist(hkey, "Wine37a");
2787  verify_reg_nonexist(hkey, "Wine37b");
2788 
2789  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2790  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2791  "\"Empty string\"=\"\"\n"
2792  "\"\"=\"Default registry value\"\n\n", &r);
2793  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2794  verify_reg(hkey, "Empty string", REG_SZ, "", 1, 0);
2795  verify_reg(hkey, NULL, REG_SZ, "Default registry value", 23, 0);
2796 
2797  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2798  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2799  "\"Test38a\"=\n"
2800  "\"Test38b\"=\\\"\n"
2801  "\"Test38c\"=\\\"Value\\\"\n"
2802  "\"Test38d\"=\\\"Value\"\n\n", &r);
2803  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2804  verify_reg_nonexist(hkey, "Test38a");
2805  verify_reg_nonexist(hkey, "Test38b");
2806  verify_reg_nonexist(hkey, "Test38c");
2807  verify_reg_nonexist(hkey, "Test38d");
2808 
2809  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2810  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2811  "\"Wine39a\"=\"Value1\" ;comment\n"
2812  "\"Wine39b\"=\"Value2\"\t\t;comment\n"
2813  "\"Wine39c\"=\"Value3\" #comment\n"
2814  "\"Wine39d\"=\"Value4\"\t\t#comment\n\n", &r);
2815  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2816  verify_reg(hkey, "Wine39a", REG_SZ, "Value1", 7, 0);
2817  verify_reg(hkey, "Wine39b", REG_SZ, "Value2", 7, 0);
2818  verify_reg_nonexist(hkey, "Wine39c");
2819  verify_reg_nonexist(hkey, "Wine39d");
2820 
2821  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2822  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2823  "\"TestNoBeginQuote\"=Asdffdsa\"\n", &r);
2824  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2825  verify_reg_nonexist(hkey, "TestNoBeginQuote");
2826 
2827  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2828  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2829  "\"TestNoEndQuote\"=\"Asdffdsa\n", &r);
2830  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2831  verify_reg_nonexist(hkey, "TestNoEndQuote");
2832 
2833  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2834  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2835  "\"TestNoQuotes\"=Asdffdsa\n", &r);
2836  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2837  verify_reg_nonexist(hkey, "TestNoQuotes");
2838 
2839  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2840  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2841  "NameNoBeginQuote\"=\"Asdffdsa\"\n", &r);
2842  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2843  verify_reg_nonexist(hkey, "NameNoBeginQuote");
2844 
2845  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2846  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2847  "\"NameNoEndQuote=\"Asdffdsa\"\n", &r);
2848  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2849  verify_reg_nonexist(hkey, "NameNoEndQuote");
2850 
2851  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2852  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2853  "NameNoQuotes=\"Asdffdsa\"\n", &r);
2854  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2855  verify_reg_nonexist(hkey, "NameNoQuotes");
2856 
2857  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2858  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2859  "\"MixedQuotes=Asdffdsa\"\n", &r);
2860  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2861  verify_reg_nonexist(hkey, "MixedQuotes");
2862  verify_reg_nonexist(hkey, "MixedQuotes=Asdffdsa");
2863 
2864  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2865  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2866  "\"Wine40a\"=hex(2):4c,00,69,00,6e,00,65,00,00,00\n"
2867  "\"Wine40b\"=\"Value 1\"\n"
2868  "\"Wine40c\"=hex(2):4c,00,69,00,6e,00,65,00\\\n"
2869  "\"Wine40d\"=\"Value 2\"\n"
2870  "\"Wine40e\"=hex(2):4c,00,69,00,6e,00,65,00,\\\n"
2871  "\"Wine40f\"=\"Value 3\"\n"
2872  "\"Wine40g\"=\"Value 4\"\n\n", &r);
2873  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2874  verify_reg(hkey, "Wine40a", REG_EXPAND_SZ, "Line", 5, 0);
2875  verify_reg(hkey, "Wine40b", REG_SZ, "Value 1", 8, 0);
2876  verify_reg_nonexist(hkey, "Wine40c");
2877  verify_reg(hkey, "Wine40d", REG_SZ, "Value 2", 8, 0);
2878  verify_reg_nonexist(hkey, "Wine40e");
2879  verify_reg_nonexist(hkey, "Wine40f");
2880  verify_reg(hkey, "Wine40g", REG_SZ, "Value 4", 8, 0);
2881 
2882  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2883  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2884  "\"Multi-Line1\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2885  " 63,00,6f,00,6e,00,\\;comment\n"
2886  " 63,00,61,00,74,00,\\;comment\n"
2887  " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n", &r);
2888  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2889  verify_reg(hkey, "Multi-Line1", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2890 
2891  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2892  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2893  "\"Multi-Line2\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2894  " 63,00,6f,00,6e,00,\\;comment\n"
2895  " 63,00,61,00,74,00,;comment\n"
2896  " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n", &r);
2897  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2898  verify_reg(hkey, "Multi-Line2", REG_MULTI_SZ, "Line concat", 12, 0);
2899 
2900  test_import_wstr("\xef\xbb\xbfREGEDIT4\n\n"
2901  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2902  "\"Multi-Line3\"=hex(7):4c,69,6e,65,20\\\n"
2903  ",63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n", &r);
2904  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2905  verify_reg_nonexist(hkey, "Multi-Line3");
2906 
2907  test_import_wstr("\xef\xbb\xbfREGEDIT4\n\n"
2908  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2909  "\"Multi-Line4\"=hex(7):4c,69,6e,65,20\\\n"
2910  " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n", &r);
2911  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2912  verify_reg_nonexist(hkey, "Multi-Line4");
2913 
2914  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2915  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2916  "\"Multi-Line5\"=hex(7):4c,69,6e,65,20\\\n"
2917  ",63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n", &r);
2918  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2919  verify_reg_nonexist(hkey, "Multi-Line5");
2920 
2921  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2922  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2923  "\"Multi-Line6\"=hex(7):4c,69,6e,65,20\\\n"
2924  " ,63,6f,6e,63,61,74,65,6e,61,74,69,6f,6e,00,00\n\n", &r);
2925  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2926  verify_reg_nonexist(hkey, "Multi-Line6");
2927 
2928  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2929  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2930  "\"Multi-Line7\"=hex(7):4c,00,69,00,6e,00,\\;comment\n"
2931  " 65,00,20,00,\\;comment\n"
2932  " 63,00,6f,00,6e,00,\\;comment\n"
2933  " 63,00,61,00,74,00,\\;comment\n"
2934  " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n", &r);
2935  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2936  verify_reg(hkey, "Multi-Line7", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2937 
2938  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2939  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2940  "\"Multi-Line8\"=hex(7):4c,00,69,00,6e,00,\\;#comment\n"
2941  " 65,00,20,00,\\;#comment\n"
2942  " 63,00,6f,00,6e,00,\\;#comment\n"
2943  " 63,00,61,00,74,00,\\;#comment\n"
2944  " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n", &r);
2945  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2946  verify_reg(hkey, "Multi-Line8", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2947 
2948  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2949  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2950  "\"Multi-Line9\"=hex(7):4c,00,69,00,6e,00,\\;comment\n"
2951  " 65,00,20,00,\\;comment\n"
2952  " 63,00,6f,00,6e,00,\\;comment\n"
2953  " 63,00,61,00,74,00,\\#comment\n"
2954  " 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n", &r);
2955  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2956  verify_reg_nonexist(hkey, "Multi-Line9");
2957 
2958  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2959  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2960  "\"Multi-Line10\"=hex(7):4c,00,69,00,6e,00,65,00,20,00,\\\n"
2961  " 63,00,6f,00,6e,00,\\;comment\n"
2962  " 63,00,61,00,74,00,\\\n\n"
2963  " 65,00,6e,00,\\;comment\n\n"
2964  " 61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n", &r);
2965  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2966  verify_reg(hkey, "Multi-Line10", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
2967 
2968  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2969  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2970  "\"Wine41a\"=dword:1234\\\n"
2971  "5678\n"
2972  "\"Wine41b\"=\"Test \\\n"
2973  "Value\"\n\n", &r);
2974  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2975  verify_reg_nonexist(hkey, "Wine41a");
2976  verify_reg_nonexist(hkey, "Wine41b");
2977 
2978  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2979  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
2980  "\"double\\\"quote\"=\"valid \\\"or\\\" not\"\n"
2981  "\"single'quote\"=dword:00000008\n\n", &r);
2982  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2983  verify_reg(hkey, "double\"quote", REG_SZ, "valid \"or\" not", 15, 0);
2984  dword = 0x00000008;
2985  verify_reg(hkey, "single'quote", REG_DWORD, &dword, sizeof(dword), 0);
2986 
2987  /* Test key name and value name concatenation */
2988  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2989  "[HKEY_CURRENT_USER\\" KEY_BASE "\\\n"
2990  "Subkey1]\n", &r);
2991  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2992  verify_key_nonexist(hkey, "Subkey1");
2993 
2994  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
2995  "[HKEY_CURRENT_USER\\" KEY_BASE "\n"
2996  "\\Subkey2]\n", &r);
2997  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
2998  verify_key_nonexist(hkey, "Subkey2");
2999 
3000  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3001  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
3002  "\"Wine\\\n"
3003  "42a\"=\"Value 1\"\n"
3004  "\"Wine42b\"=\"Value 2\"\n"
3005  "\"Wine\n"
3006  "\\42c\"=\"Value 3\"\n\n", &r);
3007  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3008  verify_reg_nonexist(hkey, "Wine42a");
3009  verify_reg(hkey, "Wine42b", REG_SZ, "Value 2", 8, 0);
3010  verify_reg_nonexist(hkey, "Wine42c");
3011 
3012  /* Test hex data concatenation for REG_NONE, REG_EXPAND_SZ and REG_BINARY */
3013  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3014  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
3015  "\"Wine43a\"=hex(0):56,00,61,00,6c,00,75,00,65,00,00,00\n"
3016  "\"Wine43b\"=hex(0):56,00,61,00,6c,00,\\\n"
3017  " 75,00,65,00,00,00\n"
3018  "\"Wine43c\"=hex(0):56,00,61,00,6c,00\\\n"
3019  ",75,00,65,00,00,00\n"
3020  "\"Wine43d\"=hex(0):56,00,61,00,6c,00\\\n"
3021  " ,75,00,65,00,00,00\n"
3022  "\"Wine43e\"=hex(0):56,00,61,00,6c,00\\\n"
3023  " 75,00,65,00,00,00\n"
3024  "\"Wine43f\"=hex(0):56,00,61,00,6c,00,7\\\n"
3025  "5,00,65,00,00,00\n"
3026  "\"Wine43g\"=hex(0):56,00,61,00,6c,00,7\\\n"
3027  " 5,00,65,00,00,00\n"
3028  "\"Wine43h\"=hex(0):56,00,61,00,\\;comment\n"
3029  " 6c,00,75,00,\\\n"
3030  " 65,00,00,00\n"
3031  "\"Wine43i\"=hex(0):56,00,61,00,\\;comment\n"
3032  " 6c,00,75,00,\n"
3033  " 65,00,00,00\n"
3034  "\"Wine43j\"=hex(0):56,00,61,00,\\;comment\n"
3035  " 6c,00,75,00,;comment\n"
3036  " 65,00,00,00\n"
3037  "\"Wine43k\"=hex(0):56,00,61,00,\\;comment\n"
3038  " 6c,00,75,00,\\#comment\n"
3039  " 65,00,00,00\n\n", &r);
3040  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3041  verify_reg(hkey, "Wine43a", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
3042  verify_reg(hkey, "Wine43b", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
3043  verify_reg_nonexist(hkey, "Wine43c");
3044  verify_reg_nonexist(hkey, "Wine43d");
3045  verify_reg_nonexist(hkey, "Wine43e");
3046  verify_reg_nonexist(hkey, "Wine43f");
3047  verify_reg_nonexist(hkey, "Wine43g");
3048  verify_reg(hkey, "Wine43h", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
3049  verify_reg(hkey, "Wine43i", REG_NONE, "V\0a\0l\0u", 8, 0);
3050  verify_reg(hkey, "Wine43j", REG_NONE, "V\0a\0l\0u", 8, 0);
3051  verify_reg_nonexist(hkey, "Wine43k");
3052 
3053  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3054  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
3055  "\"Wine44a\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
3056  "\"Wine44b\"=hex(2):25,00,50,00,41,00,\\\n"
3057  " 54,00,48,00,25,00,00,00\n"
3058  "\"Wine44c\"=hex(2):25,00,50,00,41,00\\\n"
3059  ",54,00,48,00,25,00,00,00\n"
3060  "\"Wine44d\"=hex(2):25,00,50,00,41,00\\\n"
3061  " ,54,00,48,00,25,00,00,00\n"
3062  "\"Wine44e\"=hex(2):25,00,50,00,41,00\\\n"
3063  " 54,00,48,00,25,00,00,00\n"
3064  "\"Wine44f\"=hex(2):25,00,50,00,4\\\n"
3065  "1,00,54,00,48,00,25,00,00,00\n"
3066  "\"Wine44g\"=hex(2):25,00,50,00,4\\\n"
3067  " 1,00,54,00,48,00,25,00,00,00\n"
3068  "\"Wine44h\"=hex(2):25,00,50,00,41,00,\\;comment\n"
3069  " 54,00,48,00,\\\n"
3070  " 25,00,00,00\n"
3071  "\"Wine44i\"=hex(2):25,00,50,00,41,00,\\;comment\n"
3072  " 54,00,48,00\n"
3073  " 25,00,00,00\n"
3074  "\"Wine44j\"=hex(2):25,00,50,00,41,00,\\;comment\n"
3075  " 54,00,48,00;comment\n"
3076  " 25,00,00,00\n"
3077  "\"Wine44k\"=hex(2):25,00,50,00,41,00,\\;comment\n"
3078  " 54,00,48,00,\\#comment\n"
3079  " 25,00,00,00\n\n", &r);
3080  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3081  verify_reg(hkey, "Wine44a", REG_EXPAND_SZ, "%PATH%", 7, 0);
3082  verify_reg(hkey, "Wine44b", REG_EXPAND_SZ, "%PATH%", 7, 0);
3083  verify_reg_nonexist(hkey, "Wine44c");
3084  verify_reg_nonexist(hkey, "Wine44d");
3085  verify_reg_nonexist(hkey, "Wine44e");
3086  verify_reg_nonexist(hkey, "Wine44f");
3087  verify_reg_nonexist(hkey, "Wine44g");
3088  verify_reg(hkey, "Wine44h", REG_EXPAND_SZ, "%PATH%", 7, 0);
3089  /* Wine44i */
3090  size = sizeof(buffer);
3091  err = RegQueryValueExA(hkey, "Wine44i", NULL, &type, (BYTE *)&buffer, &size);
3092  ok(err == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", err);
3093  ok(type == REG_EXPAND_SZ, "got wrong type %u, expected %u\n", type, REG_EXPAND_SZ);
3094  ok(size == 6 || broken(size == 5) /* WinXP */, "got wrong size %u, expected 6\n", size);
3095  ok(memcmp(buffer, "%PATH", size) == 0, "got wrong data\n");
3096  /* Wine44j */
3097  size = sizeof(buffer);
3098  memset(buffer, '-', size);
3099  err = RegQueryValueExA(hkey, "Wine44j", NULL, &type, (BYTE *)&buffer, &size);
3100  ok(err == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", err);
3101  ok(type == REG_EXPAND_SZ, "got wrong type %u, expected %u\n", type, REG_EXPAND_SZ);
3102  ok(size == 6 || broken(size == 5) /* WinXP */, "got wrong size %u, expected 6\n", size);
3103  ok(memcmp(buffer, "%PATH", size) == 0, "got wrong data\n");
3104  /* Wine44k */
3105  verify_reg_nonexist(hkey, "Wine44k");
3106 
3107  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3108  "[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
3109  "\"Wine45a\"=hex:11,22,33,44,55,66,77,88\n"
3110  "\"Wine45b\"=hex:11,22,33,44,\\\n"
3111  " 55,66,77,88\n"
3112  "\"Wine45c\"=hex:11,22,33,44\\\n"
3113  ",55,66,77,88\n"
3114  "\"Wine45d\"=hex:11,22,33,44\\\n"
3115  " ,55,66,77,88\n"
3116  "\"Wine45e\"=hex:11,22,33,44\\\n"
3117  " 55,66,77,88\n"
3118  "\"Wine45f\"=hex:11,22,33,4\\\n"
3119  "4,55,66,77,88\n"
3120  "\"Wine45g\"=hex:11,22,33,4\\\n"
3121  " 4,55,66,77,88\n"
3122  "\"Wine45h\"=hex:11,22,33,44,\\;comment\n"
3123  " 55,66,\\\n"
3124  " 77,88\n"
3125  "\"Wine45i\"=hex:11,22,33,44,\\;comment\n"
3126  " 55,66,\n"
3127  " 77,88\n"
3128  "\"Wine45j\"=hex:11,22,33,44,\\;comment\n"
3129  " 55,66,;comment\n"
3130  " 77,88\n"
3131  "\"Wine45k\"=hex:11,22,33,\\;comment\n"
3132  " 44,55,66,\\#comment\n"
3133  " 77,88\n\n", &r);
3134  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3135  hex[0] = 0x11; hex[1] = 0x22; hex[2] = 0x33; hex[3] = 0x44;
3136  hex[4] = 0x55; hex[5] = 0x66; hex[6] = 0x77; hex[7] = 0x88;
3137  verify_reg(hkey, "Wine45a", REG_BINARY, hex, sizeof(hex), 0);
3138  verify_reg(hkey, "Wine45b", REG_BINARY, hex, sizeof(hex), 0);
3139  verify_reg_nonexist(hkey, "Wine45c");
3140  verify_reg_nonexist(hkey, "Wine45d");
3141  verify_reg_nonexist(hkey, "Wine45e");
3142  verify_reg_nonexist(hkey, "Wine45f");
3143  verify_reg_nonexist(hkey, "Wine45g");
3144  verify_reg(hkey, "Wine45h", REG_BINARY, hex, sizeof(hex), 0);
3145  verify_reg(hkey, "Wine45i", REG_BINARY, hex, 6, 0);
3146  verify_reg(hkey, "Wine45j", REG_BINARY, hex, 6, 0);
3147  verify_reg_nonexist(hkey, "Wine45k");
3148 
3149  /* Test import with subkeys */
3150  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3151  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey\"1]\n"
3152  "\"Wine\\\\31\"=\"Test value\"\n\n", &r);
3153  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3154  open_key(hkey, "Subkey\"1", 0, &subkey);
3155  verify_reg(subkey, "Wine\\31", REG_SZ, "Test value", 11, 0);
3156  err = RegCloseKey(subkey);
3157  ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
3158  delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey\"1");
3159 
3160  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3161  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey/2]\n"
3162  "\"123/\\\"4;'5\"=\"Random value name\"\n\n", &r);
3163  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3164  open_key(hkey, "Subkey/2", 0, &subkey);
3165  verify_reg(subkey, "123/\"4;'5", REG_SZ, "Random value name", 18, 0);
3166  err = RegCloseKey(subkey);
3167  ok(err == ERROR_SUCCESS, "got %d, expected 0\n", err);
3168  delete_key(HKEY_CURRENT_USER, KEY_BASE "\\Subkey/2");
3169 
3170  /* Test key creation */
3171  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3172  "HKEY_CURRENT_USER\\" KEY_BASE "\\No_Opening_Bracket]\n", &r);
3173  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3174  verify_key_nonexist(hkey, "No_Opening_Bracket");
3175 
3176  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3177  "[HKEY_CURRENT_USER\\" KEY_BASE "\\No_Closing_Bracket\n", &r);
3178  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3179  verify_key_nonexist(hkey, "No_Closing_Bracket");
3180 
3181  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3182  "[ HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1a]\n", &r);
3183  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3184  verify_key_nonexist(hkey, "Subkey1a");
3185 
3186  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3187  "[\tHKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1b]\n", &r);
3188  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3189  verify_key_nonexist(hkey, "Subkey1b");
3190 
3191  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3192  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1c ]\n", &r);
3193  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3194  verify_key(hkey, "Subkey1c ");
3195  delete_key(hkey, "Subkey1c ");
3196 
3197  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3198  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1d\t]\n", &r);
3199  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3200  verify_key(hkey, "Subkey1d\t");
3201  delete_key(hkey, "Subkey1d\t");
3202 
3203  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3204  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1e\\]\n"
3205  "\"Wine\"=\"Test value\"\n\n", &r);
3206  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3207  verify_key(hkey, "Subkey1e\\");
3208  verify_key(hkey, "Subkey1e");
3209  open_key(hkey, "Subkey1e", 0, &subkey);
3210  verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
3211  RegCloseKey(subkey);
3212  delete_key(hkey, "Subkey1e");
3213 
3214  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3215  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1f\\\\]\n"
3216  "\"Wine\"=\"Test value\"\n\n", &r);
3217  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3218  verify_key(hkey, "Subkey1f\\\\");
3219  verify_key(hkey, "Subkey1f\\");
3220  verify_key(hkey, "Subkey1f");
3221  open_key(hkey, "Subkey1f\\\\", 0, &subkey);
3222  verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
3223  RegCloseKey(subkey);
3224  delete_key(hkey, "Subkey1f\\\\");
3225 
3226  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3227  "[HKEY_CURRENT_USER\\" KEY_BASE "\\Subkey1g\\\\\\\\]\n"
3228  "\"Wine\"=\"Test value\"\n\n", &r);
3229  ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
3230  verify_key(hkey, "Subkey1g\\\\\\\\");
3231  verify_key(hkey, "Subkey1g\\\\");
3232  verify_key(hkey, "Subkey1g\\");
3233  verify_key(hkey, "Subkey1g");
3234  open_key(hkey, "Subkey1g\\\\", 0, &subkey);
3235  verify_reg(subkey, "Wine", REG_SZ, "Test value", 11, 0);
3236  RegCloseKey(subkey);
3237  delete_key(hkey, "Subkey1g\\\\");
3238 
3239  /* Test key deletion. We start by creating some registry keys. */
3240  test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
3241  &q