Commit 0c71a987 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

reg: Support use of registry views in the 'import' command.

parent c2ea032a
......@@ -83,6 +83,7 @@ struct parser
WCHAR two_wchars[2]; /* first two characters from the encoding check */
BOOL is_unicode; /* parsing Unicode or ASCII data */
short int reg_version; /* registry file version */
REGSAM sam; /* 32-bit or 64-bit registry view (if set) */
HKEY hkey; /* current registry key */
WCHAR *key_name; /* current key name */
WCHAR *value_name; /* value name */
......@@ -373,7 +374,7 @@ static LONG open_key(struct parser *parser, WCHAR *path)
return ERROR_INVALID_PARAMETER;
res = RegCreateKeyExW(key_class, key_path, 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &parser->hkey, NULL);
KEY_ALL_ACCESS|parser->sam, NULL, &parser->hkey, NULL);
if (res == ERROR_SUCCESS)
{
......@@ -980,6 +981,8 @@ int reg_import(int argc, WCHAR *argvW[])
if (argc > 4) goto invalid;
parser.sam = 0;
if (argc == 4)
{
WCHAR *str = argvW[3];
......@@ -989,7 +992,11 @@ int reg_import(int argc, WCHAR *argvW[])
str++;
if (lstrcmpiW(str, L"reg:32") && lstrcmpiW(str, L"reg:64"))
if (!lstrcmpiW(str, L"reg:32"))
parser.sam = KEY_WOW64_32KEY;
else if (!lstrcmpiW(str, L"reg:64"))
parser.sam = KEY_WOW64_64KEY;
else
goto invalid;
}
......
......@@ -3728,20 +3728,20 @@ static void test_registry_view_win64(void)
run_reg_exe("reg import reg5.reg /reg:32", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY, &hkey);
todo_wine verify_reg(hkey, "Wine1", REG_DWORD, &dword, sizeof(dword), 0);
todo_wine verify_reg(hkey, "Wine2", REG_SZ, "Test Value", 11, 0);
todo_wine verify_reg(hkey, "Wine3", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
todo_wine verify_reg(hkey, "", REG_SZ, "Test", 5, 0);
todo_wine verify_reg(hkey, "Wine4", REG_EXPAND_SZ, "%PATH%", 7, 0);
open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY, &hkey);
verify_reg(hkey, "Wine1", REG_DWORD, &dword, sizeof(dword), 0);
verify_reg(hkey, "Wine2", REG_SZ, "Test Value", 11, 0);
verify_reg(hkey, "Wine3", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
verify_reg(hkey, "", REG_SZ, "Test", 5, 0);
verify_reg(hkey, "Wine4", REG_EXPAND_SZ, "%PATH%", 7, 0);
todo_wine open_key(hkey, "subkey", KEY_WOW64_32KEY, &subkey);
todo_wine verify_reg(subkey, "Empty string", REG_SZ, "", 1, 0);
todo_wine verify_reg(subkey, NULL, REG_SZ, "Default registry value", 23, 0);
todo_wine close_key(subkey);
todo_wine close_key(hkey);
open_key(hkey, "subkey", KEY_WOW64_32KEY, &subkey);
verify_reg(subkey, "Empty string", REG_SZ, "", 1, 0);
verify_reg(subkey, NULL, REG_SZ, "Default registry value", 23, 0);
close_key(subkey);
close_key(hkey);
todo_wine verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
......@@ -3819,20 +3819,20 @@ static void test_registry_view_wow64(void)
run_reg_exe("reg import reg5.reg /reg:64", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey);
todo_wine verify_reg(hkey, "Wine1", REG_DWORD, &dword, sizeof(dword), 0);
todo_wine verify_reg(hkey, "Wine2", REG_SZ, "Test Value", 11, 0);
todo_wine verify_reg(hkey, "Wine3", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
todo_wine verify_reg(hkey, "", REG_SZ, "Test", 5, 0);
todo_wine verify_reg(hkey, "Wine4", REG_EXPAND_SZ, "%PATH%", 7, 0);
open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey);
verify_reg(hkey, "Wine1", REG_DWORD, &dword, sizeof(dword), 0);
verify_reg(hkey, "Wine2", REG_SZ, "Test Value", 11, 0);
verify_reg(hkey, "Wine3", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
verify_reg(hkey, "", REG_SZ, "Test", 5, 0);
verify_reg(hkey, "Wine4", REG_EXPAND_SZ, "%PATH%", 7, 0);
todo_wine open_key(hkey, "subkey", KEY_WOW64_64KEY, &subkey);
todo_wine verify_reg(subkey, "Empty string", REG_SZ, "", 1, 0);
todo_wine verify_reg(subkey, NULL, REG_SZ, "Default registry value", 23, 0);
todo_wine close_key(subkey);
todo_wine close_key(hkey);
open_key(hkey, "subkey", KEY_WOW64_64KEY, &subkey);
verify_reg(subkey, "Empty string", REG_SZ, "", 1, 0);
verify_reg(subkey, NULL, REG_SZ, "Default registry value", 23, 0);
close_key(subkey);
close_key(hkey);
todo_wine verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment