diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index 505e7fca9c5..04037722161 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -330,6 +330,22 @@ static void test_reg_open_key() ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", ret); } +static void test_reg_create_key() +{ + LONG ret; + HKEY hkey1, hkey2; + ret = RegCreateKeyExA(hkey_main, "Subkey1", 0, NULL, 0, KEY_NOTIFY, NULL, &hkey1, NULL); + ok(!ret, "RegCreateKeyExA failed with error %ld\n", ret); + /* should succeed: all versions of Windows ignore the access rights + * to the parent handle */ + ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, 0, KEY_SET_VALUE, NULL, &hkey2, NULL); + ok(!ret, "RegCreateKeyExA failed with error %ld\n", ret); + + /* clean up */ + RegDeleteKey(hkey2, NULL); + RegDeleteKey(hkey1, NULL); +} + static void test_reg_close_key() { DWORD ret = 0; @@ -435,6 +451,7 @@ START_TEST(registry) test_enum_value(); test_query_value_ex(); test_reg_open_key(); + test_reg_create_key(); test_reg_close_key(); test_reg_delete_key(); diff --git a/server/registry.c b/server/registry.c index 7546fa538e0..3ddeffa7263 100644 --- a/server/registry.c +++ b/server/registry.c @@ -1690,7 +1690,8 @@ DECL_HANDLER(create_key) if (access & MAXIMUM_ALLOWED) access = KEY_ALL_ACCESS; /* FIXME: needs general solution */ reply->hkey = 0; if (!(name = copy_req_path( req->namelen, !req->parent ))) return; - if ((parent = get_hkey_obj( req->parent, KEY_CREATE_SUB_KEY ))) + /* NOTE: no access rights are required from the parent handle to create a key */ + if ((parent = get_hkey_obj( req->parent, 0 ))) { int flags = (req->options & REG_OPTION_VOLATILE) ? KEY_VOLATILE : KEY_DIRTY;