Commit 04d52eb8 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

reg: Support use of registry views in the 'copy' operation.

parent 99b59158
...@@ -77,7 +77,7 @@ static enum operation ask_overwrite_value(WCHAR *path, WCHAR *value) ...@@ -77,7 +77,7 @@ static enum operation ask_overwrite_value(WCHAR *path, WCHAR *value)
} }
} }
static int run_copy(struct key *src, struct key *dest, BOOL recurse, BOOL force) static int run_copy(struct key *src, struct key *dest, REGSAM sam, BOOL recurse, BOOL force)
{ {
LONG rc; LONG rc;
DWORD max_subkey_len; DWORD max_subkey_len;
...@@ -87,14 +87,14 @@ static int run_copy(struct key *src, struct key *dest, BOOL recurse, BOOL force) ...@@ -87,14 +87,14 @@ static int run_copy(struct key *src, struct key *dest, BOOL recurse, BOOL force)
WCHAR *name = NULL; WCHAR *name = NULL;
BYTE *data = NULL; BYTE *data = NULL;
if ((rc = RegOpenKeyExW(src->root, src->subkey, 0, KEY_READ, &src->hkey))) if ((rc = RegOpenKeyExW(src->root, src->subkey, 0, KEY_READ|sam, &src->hkey)))
{ {
output_error(rc); output_error(rc);
return 1; return 1;
} }
if ((rc = RegCreateKeyExW(dest->root, dest->subkey, 0, NULL, REG_OPTION_NON_VOLATILE, if ((rc = RegCreateKeyExW(dest->root, dest->subkey, 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_READ|KEY_WRITE, NULL, &dest->hkey, &dispos))) KEY_READ|KEY_WRITE|sam, NULL, &dest->hkey, &dispos)))
{ {
RegCloseKey(src->hkey); RegCloseKey(src->hkey);
output_error(rc); output_error(rc);
...@@ -173,7 +173,7 @@ static int run_copy(struct key *src, struct key *dest, BOOL recurse, BOOL force) ...@@ -173,7 +173,7 @@ static int run_copy(struct key *src, struct key *dest, BOOL recurse, BOOL force)
swprintf(subkey_src.path, path_len, L"%s\\%s", src->path, name); swprintf(subkey_src.path, path_len, L"%s\\%s", src->path, name);
rc = run_copy(&subkey_src, &subkey_dest, TRUE, force); rc = run_copy(&subkey_src, &subkey_dest, sam, TRUE, force);
free(subkey_src.path); free(subkey_src.path);
...@@ -194,6 +194,7 @@ int reg_copy(int argc, WCHAR *argvW[]) ...@@ -194,6 +194,7 @@ int reg_copy(int argc, WCHAR *argvW[])
{ {
struct key src, dest; struct key src, dest;
BOOL recurse = FALSE, force = FALSE; BOOL recurse = FALSE, force = FALSE;
REGSAM sam = 0;
int i; int i;
if (argc == 3) if (argc == 3)
...@@ -214,8 +215,18 @@ int reg_copy(int argc, WCHAR *argvW[]) ...@@ -214,8 +215,18 @@ int reg_copy(int argc, WCHAR *argvW[])
str = &argvW[i][1]; str = &argvW[i][1];
if (!lstrcmpiW(str, L"reg:32") || !lstrcmpiW(str, L"reg:64")) 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;
...@@ -234,6 +245,9 @@ int reg_copy(int argc, WCHAR *argvW[]) ...@@ -234,6 +245,9 @@ int reg_copy(int argc, WCHAR *argvW[])
} }
} }
if (sam == (KEY_WOW64_32KEY|KEY_WOW64_64KEY))
goto invalid;
if (src.root == dest.root && !lstrcmpiW(src.subkey, dest.subkey)) if (src.root == dest.root && !lstrcmpiW(src.subkey, dest.subkey))
{ {
output_message(STRING_COPY_SRC_DEST_SAME); output_message(STRING_COPY_SRC_DEST_SAME);
...@@ -242,7 +256,7 @@ int reg_copy(int argc, WCHAR *argvW[]) ...@@ -242,7 +256,7 @@ int reg_copy(int argc, WCHAR *argvW[])
src.path = src.subkey; src.path = src.subkey;
return run_copy(&src, &dest, recurse, force); return run_copy(&src, &dest, sam, recurse, force);
invalid: invalid:
output_message(STRING_INVALID_SYNTAX); output_message(STRING_INVALID_SYNTAX);
......
...@@ -666,11 +666,11 @@ static void test_registry_view_win64(void) ...@@ -666,11 +666,11 @@ static void test_registry_view_win64(void)
verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /reg:32", &r); run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /reg:32", &r);
todo_wine 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);
run_reg_exe("reg export HKLM\\" KEY_BASE " file.reg /y /reg:32", &r); run_reg_exe("reg export HKLM\\" KEY_BASE " file.reg /y /reg:32", &r);
todo_wine 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 ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n"); ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n");
run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /reg:64", &r); run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /reg:64", &r);
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);
...@@ -691,7 +691,7 @@ static void test_registry_view_win64(void) ...@@ -691,7 +691,7 @@ static void test_registry_view_win64(void)
ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n"); ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n");
run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /reg:32", &r); run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /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);
delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_64KEY); delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_64KEY);
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
...@@ -724,7 +724,7 @@ static void test_registry_view_wow64(void) ...@@ -724,7 +724,7 @@ static void test_registry_view_wow64(void)
ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n"); ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n");
run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /reg:64", &r); run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /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);
delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_32KEY); delete_tree(HKEY_LOCAL_MACHINE, COPY_SRC, KEY_WOW64_32KEY);
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
...@@ -735,11 +735,11 @@ static void test_registry_view_wow64(void) ...@@ -735,11 +735,11 @@ static void test_registry_view_wow64(void)
verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY); verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /reg:64", &r); run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /reg:64", &r);
todo_wine 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);
run_reg_exe("reg export HKLM\\" KEY_BASE " file.reg /y /reg:64", &r); run_reg_exe("reg export HKLM\\" KEY_BASE " file.reg /y /reg:64", &r);
todo_wine 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 ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n"); ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n");
run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /reg:32", &r); run_reg_exe("reg copy HKLM\\" COPY_SRC " HKLM\\" KEY_BASE " /s /f /reg:32", &r);
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);
......
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