Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/advapi32/registry.c | 2 ++ dlls/advapi32/tests/registry.c | 6 ++++++ 2 files changed, 8 insertions(+)
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c index 0a8ccfbf20..4b33ade88c 100644 --- a/dlls/advapi32/registry.c +++ b/dlls/advapi32/registry.c @@ -313,6 +313,8 @@ static inline HKEY get_special_root_hkey( HKEY hkey, REGSAM access ) { HKEY ret = hkey;
+ if (hkey == INVALID_HANDLE_VALUE) return 0; + if ((HandleToUlong(hkey) >= HandleToUlong(HKEY_SPECIAL_ROOT_FIRST)) && (HandleToUlong(hkey) <= HandleToUlong(HKEY_SPECIAL_ROOT_LAST))) { diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index ed14ae92b4..dae535253e 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -1309,6 +1309,9 @@ static void test_reg_create_key(void) ret = RegCreateKeyExA(INVALID_HANDLE_VALUE, (const char *)0xdeadbeef, 0, NULL, 0, 0, NULL, NULL, NULL); ok(ret == ERROR_BADKEY, "RegCreateKeyExA returned %d\n", ret);
+ ret = RegCreateKeyExA(INVALID_HANDLE_VALUE, (const char *)0xdeadbeef, 0, NULL, 0, 0, NULL, (HKEY *)0xdeadbeef, NULL); + ok(ret == ERROR_INVALID_HANDLE, "RegCreateKeyExA returned %d\n", ret); + ret = RegCreateKeyExW(INVALID_HANDLE_VALUE, NULL, 1, NULL, 0, 0, NULL, NULL, NULL); ok(ret == ERROR_INVALID_PARAMETER, "RegCreateKeyExA returned %d\n", ret);
@@ -1321,6 +1324,9 @@ static void test_reg_create_key(void) ret = RegCreateKeyExW(INVALID_HANDLE_VALUE, (const WCHAR *)0xdeadbeef, 0, NULL, 0, 0, NULL, NULL, NULL); ok(ret == ERROR_BADKEY, "RegCreateKeyExA returned %d\n", ret);
+ ret = RegCreateKeyExW(INVALID_HANDLE_VALUE, (const WCHAR *)0xdeadbeef, 0, NULL, 0, 0, NULL, (HKEY *)0xdeadbeef, NULL); + ok(ret == ERROR_INVALID_HANDLE, "RegCreateKeyExA returned %d\n", ret); + ret = RegCreateKeyExA(hkey_main, "Subkey1", 0, NULL, 0, KEY_NOTIFY, NULL, &hkey1, NULL); ok(!ret, "RegCreateKeyExA failed with error %d\n", ret); /* should succeed: all versions of Windows ignore the access rights