Rein Klazes : advapi32: RegCreateKeyEx fix.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Dec 8 07:06:22 CST 2005
Module: wine
Branch: refs/heads/master
Commit: 62b69d64869600e5d81c611b5450386e9fcab586
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=62b69d64869600e5d81c611b5450386e9fcab586
Author: Rein Klazes <wijn at wanadoo.nl>
Date: Thu Dec 8 13:49:02 2005 +0100
advapi32: RegCreateKeyEx fix.
On Win9x,ME RegCreateKeyEx ignores the backslash character if the
subkey begins with one. With a regression test.
---
dlls/advapi32/registry.c | 6 +++++-
dlls/advapi32/tests/registry.c | 15 +++++++++++++++
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index 9399c1e..4cb6add 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -206,7 +206,11 @@ DWORD WINAPI RegCreateKeyExA( HKEY hkey,
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;
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 738de73..8014e14 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -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)
More information about the wine-cvs
mailing list