Author: mjansen
Date: Sat Nov  5 17:46:30 2016
New Revision: 73143

URL: http://svn.reactos.org/svn/reactos?rev=73143&view=rev
Log:
[ADVAPI32] Set REG_NONE type in RegQueryValueExW with certain failure cases. 
Patch by Victor Martinez Calvo. CORE-9666 #resolve #comment Thanks!

Modified:
    trunk/reactos/dll/win32/advapi32/reg/reg.c

Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg.c?rev=73143&r1=73142&r2=73143&view=diff
==============================================================================
--- trunk/reactos/dll/win32/advapi32/reg/reg.c  [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/reg/reg.c  [iso-8859-1] Sat Nov  5 
17:46:30 2016
@@ -4135,19 +4135,25 @@
 
     RtlInitUnicodeString( &name_str, name );
 
-    if (data) total_size = min( sizeof(buffer), *count + info_size );
+    if (data)
+        total_size = min( sizeof(buffer), *count + info_size );
     else
-    {
         total_size = info_size;
-        if (count) *count = 0;
-    }
-
-    /* this matches Win9x behaviour - NT sets *type to a random value */
-    if (type) *type = REG_NONE;
+
 
     status = NtQueryValueKey( hkey, &name_str, KeyValuePartialInformation,
                               buffer, total_size, &total_size );
-    if (!NT_SUCCESS(status) && status != STATUS_BUFFER_OVERFLOW) goto done;
+
+    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))
+        {
+            if (type) *type = REG_NONE;
+            if (count) *count = 0;
+        }
+        goto done;
+    }
 
     if (data)
     {


Reply via email to