Synchronize with trunk revision 59781.
[reactos.git] / ntoskrnl / rtl / misc.c
index 01665c5..1b88549 100644 (file)
@@ -29,51 +29,37 @@ ULONG
 NTAPI
 RtlGetNtGlobalFlags(VOID)
 {
-       return(NtGlobalFlag);
+    return NtGlobalFlag;
 }
 
-
 /*
-* @implemented
-*/
-NTSTATUS NTAPI
+ * @implemented
+ */
+NTSTATUS 
+NTAPI
 RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
 {
-   LONG i;
-   ULONG MaxLength;
-   if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
-       lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
-   {
-      lpVersionInformation->dwMajorVersion = NtMajorVersion;
-      lpVersionInformation->dwMinorVersion = NtMinorVersion;
-      lpVersionInformation->dwBuildNumber = NtBuildNumber;
-      lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
-      RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
-      if(((CmNtCSDVersion >> 8) & 0xFF) != 0)
-      {
-        MaxLength = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1;
-        i = _snwprintf(lpVersionInformation->szCSDVersion,
-                       MaxLength,
-                       L"Service Pack %d",
-                       ((CmNtCSDVersion >> 8) & 0xFF));
-        if (i < 0)
-        {
-           /* null-terminate if it was overflowed */
-           lpVersionInformation->szCSDVersion[MaxLength] = L'\0';
-        }
-      }
-      if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
-      {
-         RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)lpVersionInformation;
-         InfoEx->wServicePackMajor = (USHORT)(CmNtCSDVersion >> 8) & 0xFF;
-         InfoEx->wServicePackMinor = (USHORT)(CmNtCSDVersion & 0xFF);
-         InfoEx->wSuiteMask = (USHORT)SharedUserData->SuiteMask;
-         InfoEx->wProductType = SharedUserData->NtProductType;
-      }
+    PAGED_CODE();
+
+    /* Return the basics */
+    lpVersionInformation->dwMajorVersion = NtMajorVersion;
+    lpVersionInformation->dwMinorVersion = NtMinorVersion;
+    lpVersionInformation->dwBuildNumber = NtBuildNumber & 0x3FFF;
+    lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
 
-      return STATUS_SUCCESS;
-   }
+    /* Check if this is the extended version */
+    if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
+    {
+        PRTL_OSVERSIONINFOEXW InfoEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation;
+        InfoEx->wServicePackMajor = (USHORT)(CmNtCSDVersion >> 8) & 0xFF;
+        InfoEx->wServicePackMinor = (USHORT)(CmNtCSDVersion & 0xFF);
+        InfoEx->wSuiteMask = (USHORT)(SharedUserData->SuiteMask & 0xFFFF);
+        InfoEx->wProductType = SharedUserData->NtProductType;
+        InfoEx->wReserved = 0;
+    }
 
-   return STATUS_INVALID_PARAMETER;
+    /* Always succeed */
+    return STATUS_SUCCESS;
 }
 
+/* EOF */