From daafda22f840edc9a584abc7925f9ee17ef18228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Zalewski?= Date: Thu, 24 Jul 2008 12:19:17 +0200 Subject: [PATCH] advapi32: Remove access checks from advapi32 (makes KEY_WOW64_* work). --- dlls/advapi32/registry.c | 5 ----- dlls/advapi32/tests/registry.c | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c index 55607c2a841..4c97ed1338c 100644 --- a/dlls/advapi32/registry.c +++ b/dlls/advapi32/registry.c @@ -44,9 +44,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(reg); -/* allowed bits for access mask */ -#define KEY_ACCESS_MASK (KEY_ALL_ACCESS | MAXIMUM_ALLOWED) - #define HKEY_SPECIAL_ROOT_FIRST HKEY_CLASSES_ROOT #define HKEY_SPECIAL_ROOT_LAST HKEY_DYN_DATA #define NB_SPECIAL_ROOT_KEYS ((UINT)HKEY_SPECIAL_ROOT_LAST - (UINT)HKEY_SPECIAL_ROOT_FIRST + 1) @@ -188,7 +185,6 @@ LSTATUS WINAPI RegCreateKeyExW( HKEY hkey, LPCWSTR name, DWORD reserved, LPWSTR UNICODE_STRING nameW, classW; if (reserved) return ERROR_INVALID_PARAMETER; - if (!(access & KEY_ACCESS_MASK) || (access & ~KEY_ACCESS_MASK)) return ERROR_ACCESS_DENIED; if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE; attr.Length = sizeof(attr); @@ -243,7 +239,6 @@ LSTATUS WINAPI RegCreateKeyExA( HKEY hkey, LPCSTR name, DWORD reserved, LPSTR cl access = KEY_ALL_ACCESS; /* Win95 ignores the access mask */ if (name && *name == '\\') name++; /* win9x,ME ignores one (and only one) beginning backslash */ } - else if (!(access & KEY_ACCESS_MASK) || (access & ~KEY_ACCESS_MASK)) return ERROR_ACCESS_DENIED; if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE; attr.Length = sizeof(attr); diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index 9d5d4c2bc06..ac0cd083d23 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -949,6 +949,17 @@ static void test_reg_open_key(void) ok(ret == ERROR_BAD_PATHNAME || /* NT/2k/XP */ ret == ERROR_FILE_NOT_FOUND /* Win9x,ME */ , "expected ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret); + + /* WOW64 flags */ + hkResult = NULL; + ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software", 0, KEY_READ|KEY_WOW64_32KEY, &hkResult); + ok(ret == ERROR_SUCCESS && hkResult != NULL, "RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret); + RegCloseKey(hkResult); + + hkResult = NULL; + ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software", 0, KEY_READ|KEY_WOW64_64KEY, &hkResult); + ok(ret == ERROR_SUCCESS && hkResult != NULL, "RegOpenKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret); + RegCloseKey(hkResult); } static void test_reg_create_key(void) @@ -974,6 +985,17 @@ static void test_reg_create_key(void) ok(!ret, "RegCreateKeyExA failed with error %d\n", ret); RegDeleteKey(hkey1, NULL); } + + /* WOW64 flags - open an existing key */ + hkey1 = NULL; + ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0, KEY_READ|KEY_WOW64_32KEY, NULL, &hkey1, NULL); + ok(ret == ERROR_SUCCESS && hkey1 != NULL, "RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret); + RegCloseKey(hkey1); + + hkey1 = NULL; + ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0, KEY_READ|KEY_WOW64_32KEY, NULL, &hkey1, NULL); + ok(ret == ERROR_SUCCESS && hkey1 != NULL, "RegOpenKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret); + RegCloseKey(hkey1); } static void test_reg_close_key(void)