reg: Support use of registry views in the 'query' operation.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
48c7386872
commit
8eef4a8735
|
@ -140,6 +140,7 @@ static void output_value(const WCHAR *value_name, DWORD type, BYTE *data, DWORD
|
|||
}
|
||||
|
||||
static unsigned int num_values_found = 0;
|
||||
static REGSAM sam = 0;
|
||||
|
||||
static int query_value(HKEY hkey, WCHAR *value_name, WCHAR *path, BOOL recurse)
|
||||
{
|
||||
|
@ -203,7 +204,7 @@ static int query_value(HKEY hkey, WCHAR *value_name, WCHAR *path, BOOL recurse)
|
|||
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))
|
||||
{
|
||||
query_value(subkey, value_name, subkey_path, recurse);
|
||||
RegCloseKey(subkey);
|
||||
|
@ -290,7 +291,7 @@ static int query_all(HKEY hkey, WCHAR *path, BOOL recurse, BOOL recursing)
|
|||
if (recurse)
|
||||
{
|
||||
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))
|
||||
{
|
||||
query_all(subkey, subkey_path, recurse, TRUE);
|
||||
RegCloseKey(subkey);
|
||||
|
@ -308,12 +309,12 @@ static int query_all(HKEY hkey, WCHAR *path, BOOL recurse, BOOL recursing)
|
|||
}
|
||||
|
||||
static int run_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
|
||||
BOOL value_empty, BOOL recurse)
|
||||
BOOL value_empty, BOOL recurse)
|
||||
{
|
||||
HKEY hkey;
|
||||
int ret;
|
||||
|
||||
if (RegOpenKeyExW(root, path, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
|
||||
if (RegOpenKeyExW(root, path, 0, KEY_READ|sam, &hkey))
|
||||
{
|
||||
output_message(STRING_KEY_NONEXIST);
|
||||
return 1;
|
||||
|
@ -360,8 +361,18 @@ int reg_query(int argc, WCHAR *argvW[])
|
|||
value_empty = TRUE;
|
||||
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;
|
||||
}
|
||||
else if (!str[0] || str[1])
|
||||
goto invalid;
|
||||
|
||||
|
@ -383,6 +394,9 @@ int reg_query(int argc, WCHAR *argvW[])
|
|||
if (value_name && value_empty)
|
||||
goto invalid;
|
||||
|
||||
if (sam == (KEY_WOW64_32KEY|KEY_WOW64_64KEY))
|
||||
goto invalid;
|
||||
|
||||
key_name = get_long_key(root, path);
|
||||
|
||||
return run_query(root, path, key_name, value_name, value_empty, recurse);
|
||||
|
|
|
@ -414,16 +414,16 @@ static void test_registry_view_win64(void)
|
|||
create_test_key(KEY_WOW64_32KEY);
|
||||
|
||||
read_reg_output("reg query HKLM\\" KEY_BASE " /reg:32", buf, sizeof(buf), &r);
|
||||
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9a, FALSE, TODO_REG_COMPARE);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9a, FALSE, 0);
|
||||
|
||||
read_reg_output("reg query HKLM\\" KEY_BASE " /s /reg:32", buf, sizeof(buf), &r);
|
||||
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9b, FALSE, TODO_REG_COMPARE);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9b, FALSE, 0);
|
||||
|
||||
read_reg_output("reg query HKLM\\" KEY_BASE " /v Wine /s /reg:32", buf, sizeof(buf), &r);
|
||||
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9c, TRUE, TODO_REG_COMPARE);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9c, TRUE, 0);
|
||||
|
||||
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_32KEY);
|
||||
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
|
||||
|
@ -480,16 +480,16 @@ static void test_registry_view_wow64(void)
|
|||
create_test_key(KEY_WOW64_64KEY);
|
||||
|
||||
read_reg_output("reg query HKLM\\" KEY_BASE " /reg:64", buf, sizeof(buf), &r);
|
||||
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9a, FALSE, TODO_REG_COMPARE);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9a, FALSE, 0);
|
||||
|
||||
read_reg_output("reg query HKLM\\" KEY_BASE " /s /reg:64", buf, sizeof(buf), &r);
|
||||
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9b, FALSE, TODO_REG_COMPARE);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9b, FALSE, 0);
|
||||
|
||||
read_reg_output("reg query HKLM\\" KEY_BASE " /v Wine /s /reg:64", buf, sizeof(buf), &r);
|
||||
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9c, TRUE, TODO_REG_COMPARE);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
compare_query(buf, test9c, TRUE, 0);
|
||||
|
||||
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue