[PSDK]
[reactos.git] / reactos / dll / win32 / advapi32 / reg / reg.c
index 8e9c3f0..86e14b8 100644 (file)
@@ -425,11 +425,16 @@ RegCloseKey(HKEY hKey)
     NTSTATUS Status;
 
     /* don't close null handle or a pseudo handle */
-    if ((!hKey) || (((ULONG_PTR)hKey & 0xF0000000) == 0x80000000))
+    if (!hKey)
     {
         return ERROR_INVALID_HANDLE;
     }
 
+    if (((ULONG_PTR)hKey & 0xF0000000) == 0x80000000)
+    {
+        return ERROR_SUCCESS;
+    }
+
     Status = NtClose(hKey);
     if (!NT_SUCCESS(Status))
     {
@@ -2632,7 +2637,7 @@ RegEnumKeyExW(
         {
             if (KeyInfo->Basic.NameLength > NameLength)
             {
-                ErrorCode = ERROR_BUFFER_OVERFLOW;
+                ErrorCode = ERROR_MORE_DATA;
             }
             else
             {
@@ -2648,7 +2653,7 @@ RegEnumKeyExW(
             if (KeyInfo->Node.NameLength > NameLength ||
                 KeyInfo->Node.ClassLength > ClassLength)
             {
-                ErrorCode = ERROR_BUFFER_OVERFLOW;
+                ErrorCode = ERROR_MORE_DATA;
             }
             else
             {
@@ -3604,6 +3609,11 @@ RegQueryInfoKeyA(HKEY hKey,
     NTSTATUS Status;
     DWORD cClass = 0;
 
+    if ((lpClass) && (!lpcClass))
+    {
+        return ERROR_INVALID_PARAMETER;
+    }
+
     RtlInitUnicodeString(&UnicodeString,
                          NULL);
     if (lpClass != NULL)
@@ -3640,7 +3650,7 @@ RegQueryInfoKeyA(HKEY hKey,
                                               FALSE);
         ErrorCode = RtlNtStatusToDosError(Status);
         cClass = AnsiString.Length;
-        lpClass[*lpcClass - 1] = 0;
+        lpClass[cClass] = ANSI_NULL;
     }
 
     if (lpcClass != NULL)
@@ -3776,10 +3786,9 @@ RegQueryInfoKeyW(HKEY hKey,
                                        NULL,
                                        0,
                                        lpcbSecurityDescriptor);
-        if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_TOO_SMALL)
+        if (Status != STATUS_BUFFER_TOO_SMALL)
         {
-            ErrorCode = RtlNtStatusToDosError(Status);
-            goto Cleanup;
+            *lpcbSecurityDescriptor = 0;
         }
     }
 
@@ -3789,7 +3798,6 @@ RegQueryInfoKeyW(HKEY hKey,
         lpftLastWriteTime->dwHighDateTime = FullInfo->LastWriteTime.u.HighPart;
     }
 
-    ErrorCode = ERROR_SUCCESS;
     if (lpClass != NULL)
     {
         if (*lpcClass == 0)
@@ -3847,7 +3855,7 @@ RegQueryMultipleValuesA(HKEY hKey,
     LONG ErrorCode;
 
     if (maxBytes >= (1024*1024))
-        return ERROR_TRANSFER_TOO_LONG;
+        return ERROR_MORE_DATA;
 
     *ldwTotsize = 0;
 
@@ -3911,7 +3919,7 @@ RegQueryMultipleValuesW(HKEY hKey,
     LONG ErrorCode;
 
     if (maxBytes >= (1024*1024))
-        return ERROR_TRANSFER_TOO_LONG;
+        return ERROR_MORE_DATA;
 
     *ldwTotsize = 0;