Commit 8eef4a87 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

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

parent 48c73868
...@@ -140,6 +140,7 @@ static void output_value(const WCHAR *value_name, DWORD type, BYTE *data, DWORD ...@@ -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 unsigned int num_values_found = 0;
static REGSAM sam = 0;
static int query_value(HKEY hkey, WCHAR *value_name, WCHAR *path, BOOL recurse) 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) ...@@ -203,7 +204,7 @@ static int query_value(HKEY hkey, WCHAR *value_name, WCHAR *path, BOOL recurse)
if (rc == ERROR_SUCCESS) if (rc == ERROR_SUCCESS)
{ {
subkey_path = build_subkey_path(path, path_len, subkey_name, subkey_len); 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); query_value(subkey, value_name, subkey_path, recurse);
RegCloseKey(subkey); RegCloseKey(subkey);
...@@ -290,7 +291,7 @@ static int query_all(HKEY hkey, WCHAR *path, BOOL recurse, BOOL recursing) ...@@ -290,7 +291,7 @@ static int query_all(HKEY hkey, WCHAR *path, BOOL recurse, BOOL recursing)
if (recurse) if (recurse)
{ {
subkey_path = build_subkey_path(path, path_len, subkey_name, subkey_len); 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); query_all(subkey, subkey_path, recurse, TRUE);
RegCloseKey(subkey); RegCloseKey(subkey);
...@@ -308,12 +309,12 @@ static int query_all(HKEY hkey, WCHAR *path, BOOL recurse, BOOL recursing) ...@@ -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, 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; HKEY hkey;
int ret; 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); output_message(STRING_KEY_NONEXIST);
return 1; return 1;
...@@ -360,8 +361,18 @@ int reg_query(int argc, WCHAR *argvW[]) ...@@ -360,8 +361,18 @@ int reg_query(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;
...@@ -383,6 +394,9 @@ int reg_query(int argc, WCHAR *argvW[]) ...@@ -383,6 +394,9 @@ int reg_query(int argc, WCHAR *argvW[])
if (value_name && value_empty) if (value_name && value_empty)
goto invalid; goto invalid;
if (sam == (KEY_WOW64_32KEY|KEY_WOW64_64KEY))
goto invalid;
key_name = get_long_key(root, path); key_name = get_long_key(root, path);
return run_query(root, path, key_name, value_name, value_empty, recurse); return run_query(root, path, key_name, value_name, value_empty, recurse);
......
...@@ -414,16 +414,16 @@ static void test_registry_view_win64(void) ...@@ -414,16 +414,16 @@ static void test_registry_view_win64(void)
create_test_key(KEY_WOW64_32KEY); create_test_key(KEY_WOW64_32KEY);
read_reg_output("reg query HKLM\\" KEY_BASE " /reg:32", buf, sizeof(buf), &r); 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); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
compare_query(buf, test9a, FALSE, TODO_REG_COMPARE); compare_query(buf, test9a, FALSE, 0);
read_reg_output("reg query HKLM\\" KEY_BASE " /s /reg:32", buf, sizeof(buf), &r); 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); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
compare_query(buf, test9b, FALSE, TODO_REG_COMPARE); compare_query(buf, test9b, FALSE, 0);
read_reg_output("reg query HKLM\\" KEY_BASE " /v Wine /s /reg:32", buf, sizeof(buf), &r); 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); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
compare_query(buf, test9c, TRUE, TODO_REG_COMPARE); 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_32KEY);
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
...@@ -480,16 +480,16 @@ static void test_registry_view_wow64(void) ...@@ -480,16 +480,16 @@ static void test_registry_view_wow64(void)
create_test_key(KEY_WOW64_64KEY); create_test_key(KEY_WOW64_64KEY);
read_reg_output("reg query HKLM\\" KEY_BASE " /reg:64", buf, sizeof(buf), &r); 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); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
compare_query(buf, test9a, FALSE, TODO_REG_COMPARE); compare_query(buf, test9a, FALSE, 0);
read_reg_output("reg query HKLM\\" KEY_BASE " /s /reg:64", buf, sizeof(buf), &r); 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); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
compare_query(buf, test9b, FALSE, TODO_REG_COMPARE); compare_query(buf, test9b, FALSE, 0);
read_reg_output("reg query HKLM\\" KEY_BASE " /v Wine /s /reg:64", buf, sizeof(buf), &r); 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); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
compare_query(buf, test9c, TRUE, TODO_REG_COMPARE); compare_query(buf, test9c, TRUE, 0);
delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY); delete_tree(HKEY_LOCAL_MACHINE, KEY_BASE, KEY_WOW64_64KEY);
} }
......
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