advapi32: Allow opening HKEY_CLASSES_ROOT subkeys with backslash prefix on NT.

This commit is contained in:
Lei Zhang 2008-11-21 17:03:51 -08:00 committed by Alexandre Julliard
parent a76d38d38e
commit aacb511da1
2 changed files with 15 additions and 0 deletions

View File

@ -306,6 +306,9 @@ LSTATUS WINAPI RegOpenKeyExW( HKEY hkey, LPCWSTR name, DWORD reserved, REGSAM ac
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
/* NT+ allows beginning backslash for HKEY_CLASSES_ROOT */
if (hkey == HKEY_CLASSES_ROOT && name && *name == '\\') name++;
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
attr.Length = sizeof(attr);
@ -346,6 +349,11 @@ LSTATUS WINAPI RegOpenKeyExA( HKEY hkey, LPCSTR name, DWORD reserved, REGSAM acc
NTSTATUS status;
if (!is_version_nt()) access = KEY_ALL_ACCESS; /* Win95 ignores the access mask */
else
{
/* NT+ allows beginning backslash for HKEY_CLASSES_ROOT */
if (hkey == HKEY_CLASSES_ROOT && name && *name == '\\') name++;
}
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;

View File

@ -961,6 +961,13 @@ static void test_reg_open_key(void)
ret == ERROR_FILE_NOT_FOUND /* Win9x,ME */
, "expected ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret);
hkResult = NULL;
ret = RegOpenKeyExA(HKEY_CLASSES_ROOT, "\\clsid", 0, KEY_QUERY_VALUE, &hkResult);
ok(ret == ERROR_SUCCESS || /* NT/2k/XP */
ret == ERROR_FILE_NOT_FOUND /* Win9x,ME */
, "expected ERROR_SUCCESS or ERROR_FILE_NOT_FOUND, got %d\n", ret);
RegCloseKey(hkResult);
/* WOW64 flags */
hkResult = NULL;
ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software", 0, KEY_READ|KEY_WOW64_32KEY, &hkResult);