Commit fcf79426 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

reg: Support use of registry views when exporting registry data.

parent 0b5ba1d0
......@@ -225,7 +225,7 @@ static void export_key_name(HANDLE hFile, WCHAR *name)
free(buf);
}
static int export_registry_data(HANDLE hFile, HKEY hkey, WCHAR *path)
static int export_registry_data(HANDLE hFile, HKEY hkey, WCHAR *path, REGSAM sam)
{
LONG rc;
DWORD max_value_len = 256, value_len;
......@@ -284,9 +284,9 @@ static int export_registry_data(HANDLE hFile, HKEY hkey, WCHAR *path)
if (rc == ERROR_SUCCESS)
{
subkey_path = build_subkey_path(path, path_len, subkey_name, subkey_len);
if (!RegOpenKeyExW(hkey, subkey_name, 0, KEY_READ, &subkey))
if (!RegOpenKeyExW(hkey, subkey_name, 0, KEY_READ|sam, &subkey))
{
export_registry_data(hFile, subkey, subkey_path);
export_registry_data(hFile, subkey, subkey_path, sam);
RegCloseKey(subkey);
}
free(subkey_path);
......@@ -349,6 +349,7 @@ int reg_export(int argc, WCHAR *argvW[])
HKEY root, hkey;
WCHAR *path, *key_name;
BOOL overwrite_file = FALSE;
REGSAM sam = 0;
HANDLE hFile;
int i, ret;
......@@ -368,13 +369,26 @@ int reg_export(int argc, WCHAR *argvW[])
if (is_char(*str, 'y') && !str[1])
overwrite_file = TRUE;
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;
}
else
goto invalid;
}
if (RegOpenKeyExW(root, path, 0, KEY_READ, &hkey))
if (sam == (KEY_WOW64_32KEY|KEY_WOW64_64KEY))
goto invalid;
if (RegOpenKeyExW(root, path, 0, KEY_READ|sam, &hkey))
{
output_message(STRING_KEY_NONEXIST);
return 1;
......@@ -384,7 +398,7 @@ int reg_export(int argc, WCHAR *argvW[])
hFile = get_file_handle(argvW[3], overwrite_file);
export_file_header(hFile);
ret = export_registry_data(hFile, hkey, key_name);
ret = export_registry_data(hFile, hkey, key_name, sam);
export_newline(hFile);
CloseHandle(hFile);
......
......@@ -528,8 +528,8 @@ static void test_registry_view_win64(void)
verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
run_reg_exe("reg export HKEY_LOCAL_MACHINE\\" KEY_BASE " file.reg /y /reg:32", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine ok(compare_export("file.reg", registry_view_test, TODO_REG_COMPARE), "compare_export() failed\n");
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n");
run_reg_exe("reg export HKEY_LOCAL_MACHINE\\" KEY_BASE " file.reg /y /reg:64", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
......@@ -546,7 +546,7 @@ static void test_registry_view_win64(void)
ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n");
run_reg_exe("reg export HKEY_LOCAL_MACHINE\\" KEY_BASE " file.reg /y /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, KEY_BASE, KEY_WOW64_64KEY);
}
......@@ -571,7 +571,7 @@ static void test_registry_view_wow64(void)
ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n");
run_reg_exe("reg export HKEY_LOCAL_MACHINE\\" KEY_BASE " file.reg /y /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, KEY_BASE, KEY_WOW64_32KEY);
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
......@@ -581,7 +581,7 @@ static void test_registry_view_wow64(void)
verify_key_nonexist(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
run_reg_exe("reg export HKEY_LOCAL_MACHINE\\" 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);
ok(compare_export("file.reg", registry_view_test, 0), "compare_export() failed\n");
run_reg_exe("reg export HKEY_LOCAL_MACHINE\\" KEY_BASE " file.reg /y /reg:32", &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