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