advapi32: RegCreateKeyEx fix.

On Win9x,ME RegCreateKeyEx ignores the backslash character if the
subkey begins with one. With a regression test.
This commit is contained in:
Rein Klazes 2005-12-08 13:49:02 +01:00 committed by Alexandre Julliard
parent b86efe5d11
commit 62b69d6486
2 changed files with 20 additions and 1 deletions

View File

@ -206,7 +206,11 @@ DWORD WINAPI RegCreateKeyExA( HKEY hkey, LPCSTR name, DWORD reserved, LPSTR clas
NTSTATUS status;
if (reserved) return ERROR_INVALID_PARAMETER;
if (!is_version_nt()) access = KEY_ALL_ACCESS; /* Win95 ignores the access mask */
if (!is_version_nt())
{
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;

View File

@ -476,6 +476,12 @@ static void test_reg_open_key(void)
/* send in NULL hkResult */
ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", NULL);
ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", ret);
/* beginning backslash character */
ret = RegOpenKeyA(HKEY_CURRENT_USER, "\\Software\\Wine\\Test", &hkResult);
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 %ld\n", ret);
}
static void test_reg_create_key(void)
@ -492,6 +498,15 @@ static void test_reg_create_key(void)
/* clean up */
RegDeleteKey(hkey2, NULL);
RegDeleteKey(hkey1, NULL);
/* beginning backslash character */
ret = RegCreateKeyExA(hkey_main, "\\Subkey3", 0, NULL, 0, KEY_NOTIFY, NULL, &hkey1, NULL);
if (!(GetVersion() & 0x80000000))
ok(ret == ERROR_BAD_PATHNAME, "expected ERROR_BAD_PATHNAME, got %ld\n", ret);
else {
ok(!ret, "RegCreateKeyExA failed with error %ld\n", ret);
RegDeleteKey(hkey1, NULL);
}
}
static void test_reg_close_key(void)