[WINESYNC] reg: Support use of registry views when exporting registry data.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id fcf79426147adf0d9f1d80b0cf24d0b6abd8bf59 by Hugh McMaster <hugh.mcmaster@outlook.com>
This commit is contained in:
winesync 2022-01-17 18:47:38 +01:00 committed by Thomas Csovcsity
parent bac2e89b05
commit 35b9e2d380
3 changed files with 26 additions and 12 deletions

View file

@ -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);

View file

@ -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);

View file

@ -4,4 +4,4 @@ directories:
files:
programs/reg/resource.h: base/applications/cmdutils/reg/resource.h
tags:
wine: 0b5ba1d0be04f7c6bc0e53e9a28984cf2941b4bc
wine: fcf79426147adf0d9f1d80b0cf24d0b6abd8bf59