Commit 304b80a9 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

reg: Support the use of registry views during the 'add' operation.

parent 15b18f48
...@@ -158,7 +158,7 @@ static BOOL get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, ...@@ -158,7 +158,7 @@ static BOOL get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator,
return TRUE; return TRUE;
} }
static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, static int run_add(HKEY root, WCHAR *path, REGSAM sam, WCHAR *value_name, BOOL value_empty,
WCHAR *type, WCHAR separator, WCHAR *data, BOOL force) WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
{ {
HKEY hkey; HKEY hkey;
...@@ -167,7 +167,7 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, ...@@ -167,7 +167,7 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
LONG rc; LONG rc;
if (RegCreateKeyExW(root, path, 0, NULL, REG_OPTION_NON_VOLATILE, if (RegCreateKeyExW(root, path, 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_READ|KEY_WRITE, NULL, &hkey, &dispos)) KEY_READ|KEY_WRITE|sam, NULL, &hkey, &dispos))
{ {
output_message(STRING_ACCESS_DENIED); output_message(STRING_ACCESS_DENIED);
return 1; return 1;
...@@ -229,6 +229,7 @@ int reg_add(int argc, WCHAR *argvW[]) ...@@ -229,6 +229,7 @@ int reg_add(int argc, WCHAR *argvW[])
HKEY root; HKEY root;
WCHAR *path, *value_name = NULL, *type = NULL, *data = NULL, separator = '\0'; WCHAR *path, *value_name = NULL, *type = NULL, *data = NULL, separator = '\0';
BOOL value_empty = FALSE, force = FALSE; BOOL value_empty = FALSE, force = FALSE;
REGSAM sam = 0;
int i; int i;
if (!parse_registry_key(argvW[2], &root, &path)) if (!parse_registry_key(argvW[2], &root, &path))
...@@ -249,8 +250,18 @@ int reg_add(int argc, WCHAR *argvW[]) ...@@ -249,8 +250,18 @@ int reg_add(int argc, WCHAR *argvW[])
value_empty = TRUE; value_empty = TRUE;
continue; continue;
} }
else if (!lstrcmpiW(str, L"reg:32") || !lstrcmpiW(str, L"reg:64")) else if (!lstrcmpiW(str, L"reg:32"))
{
if (sam & KEY_WOW64_32KEY) goto invalid;
sam |= KEY_WOW64_32KEY;
continue;
}
else if (!lstrcmpiW(str, L"reg:64"))
{
if (sam & KEY_WOW64_64KEY) goto invalid;
sam |= KEY_WOW64_64KEY;
continue; continue;
}
else if (!str[0] || str[1]) else if (!str[0] || str[1])
goto invalid; goto invalid;
...@@ -286,7 +297,10 @@ int reg_add(int argc, WCHAR *argvW[]) ...@@ -286,7 +297,10 @@ int reg_add(int argc, WCHAR *argvW[])
if (value_name && value_empty) if (value_name && value_empty)
goto invalid; goto invalid;
return run_add(root, path, value_name, value_empty, type, separator, data, force); if (sam == (KEY_WOW64_32KEY|KEY_WOW64_64KEY))
goto invalid;
return run_add(root, path, sam, value_name, value_empty, type, separator, data, force);
invalid: invalid:
output_message(STRING_INVALID_SYNTAX); output_message(STRING_INVALID_SYNTAX);
......
...@@ -277,13 +277,13 @@ static void test_command_syntax(void) ...@@ -277,13 +277,13 @@ static void test_command_syntax(void)
/* Test registry view */ /* Test registry view */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v abc /d 123 /f /reg:32 /reg:32", &r); run_reg_exe("reg add HKCU\\" KEY_BASE " /v abc /d 123 /f /reg:32 /reg:32", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v abc /d 123 /f /reg:32 /reg:64", &r); run_reg_exe("reg add HKCU\\" KEY_BASE " /v abc /d 123 /f /reg:32 /reg:64", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v abc /d 123 /f /reg:64 /reg:64", &r); run_reg_exe("reg add HKCU\\" KEY_BASE " /v abc /d 123 /f /reg:64 /reg:64", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r); ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
} }
static void test_key_formats(void) static void test_key_formats(void)
...@@ -914,12 +914,12 @@ static void test_registry_view_win64(void) ...@@ -914,12 +914,12 @@ static void test_registry_view_win64(void)
run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine32 /d Test /f /reg:32", &r); run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine32 /d Test /f /reg:32", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", 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); open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY, &hkey);
todo_wine verify_reg(hkey, "Wine32", REG_SZ, "Test", 5, 0); verify_reg(hkey, "Wine32", REG_SZ, "Test", 5, 0);
todo_wine close_key(hkey); close_key(hkey);
todo_wine delete_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); delete_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
todo_wine verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
/* Try adding to the 64-bit registry view (64-bit Windows) */ /* Try adding to the 64-bit registry view (64-bit Windows) */
run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine64 /d Test /f /reg:64", &r); run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine64 /d Test /f /reg:64", &r);
...@@ -958,16 +958,16 @@ static void test_registry_view_wow64(void) ...@@ -958,16 +958,16 @@ static void test_registry_view_wow64(void)
run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine64 /d Test /f /reg:64", &r); run_reg_exe("reg add HKLM\\" KEY_BASE " /v Wine64 /d Test /f /reg:64", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", 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); open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey);
todo_wine verify_reg(hkey, "Wine64", REG_SZ, "Test", 5, 0); verify_reg(hkey, "Wine64", REG_SZ, "Test", 5, 0);
todo_wine close_key(hkey); close_key(hkey);
todo_wine open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey); open_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY, &hkey);
todo_wine verify_reg(hkey, "Wine64", REG_SZ, "Test", 5, 0); verify_reg(hkey, "Wine64", REG_SZ, "Test", 5, 0);
todo_wine close_key(hkey); close_key(hkey);
todo_wine delete_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); delete_key(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
todo_wine verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
} }
START_TEST(add) START_TEST(add)
......
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