[ADVAPI32][ADVAPI32_APITEST] Fix incorrect parameter output uncovered by CORE-12333...
authorMark Jansen <mark.jansen@reactos.org>
Sun, 13 Nov 2016 18:11:14 +0000 (18:11 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Sun, 13 Nov 2016 18:11:14 +0000 (18:11 +0000)
svn path=/trunk/; revision=73228

reactos/dll/win32/advapi32/reg/reg.c
rostests/apitests/advapi32/RegQueryValueExW.c

index 043d74d..0b29d1d 100644 (file)
@@ -4147,11 +4147,17 @@ RegQueryValueExW(
     if (!NT_SUCCESS(status) && status != STATUS_BUFFER_OVERFLOW)
     {
         // NT: Valid handles with inexistant/null values or invalid (but not NULL) handles sets type to REG_NONE
-        if ((status == STATUS_OBJECT_NAME_NOT_FOUND) ||(status == STATUS_INVALID_HANDLE && hkey))
+        // On windows these conditions are likely to be side effects of the implementation...
+        if (status == STATUS_INVALID_HANDLE && hkey)
         {
             if (type) *type = REG_NONE;
             if (count) *count = 0;
         }
+        else if (status == STATUS_OBJECT_NAME_NOT_FOUND)
+        {
+            if (type) *type = REG_NONE;
+            if (data == NULL && count) *count = 0;
+        }
         goto done;
     }
 
index 7729d74..5e02eac 100644 (file)
@@ -303,6 +303,20 @@ START_TEST(RegQueryValueExW)
     ok(size == 46, "Expected size = 46, size is: %ld", size);
     ok(!wcscmp(data23, string22W), "Expected same string! data23: %S, string22W: %S", data23, string22W);
 
+    /* Ask for a var that doesnt exist. */
+    SetLastError(0xdeadbeef);
+    size = sizeof(data23);
+    memset(data23, 0, sizeof(data23));
+    type = 666;
+    ret = RegQueryValueExW(hkey_main, L"XXXXXYYYYYZZZZZZ", NULL, &type, (LPBYTE)data23, &size);
+    ok(ret == ERROR_FILE_NOT_FOUND, "RegQueryValueExW returned: %lx\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "RegQueryValueExW returned: %lx\n", GetLastError());
+    /* 2k3 leaves garbage */
+    ok(type == REG_NONE || broken(type != REG_NONE && type != 666), "Expected REG_NONE, Type is: %ld\n", type);
+    ok(size == 46, "Expected size = 46, size is: %ld", size);
+    ok(!wcscmp(data23,L""), "Expected same string! data23: %S, ''", data23);
+
+
     RegCloseKey(hkey_main);
     RegCloseKey(subkey);