Synchronize up to trunk's revision r57689.
[reactos.git] / ntoskrnl / rtl / misc.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/rtl/misc.c
5 * PURPOSE: Various functions
6 *
7 * PROGRAMMERS:
8 */
9
10 /* INCLUDES *****************************************************************/
11
12 #include <ntoskrnl.h>
13 #define NDEBUG
14 #include <debug.h>
15
16 /* GLOBALS *******************************************************************/
17
18 extern ULONG NtGlobalFlag;
19 extern ULONG NtMajorVersion;
20 extern ULONG NtMinorVersion;
21 extern ULONG NtOSCSDVersion;
22
23 /* FUNCTIONS *****************************************************************/
24
25 /*
26 * @implemented
27 */
28 ULONG
29 NTAPI
30 RtlGetNtGlobalFlags(VOID)
31 {
32 return NtGlobalFlag;
33 }
34
35 /*
36 * @implemented
37 */
38 NTSTATUS NTAPI
39 RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
40 {
41 LONG i;
42 ULONG MaxLength;
43
44 if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
45 lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
46 {
47 lpVersionInformation->dwMajorVersion = NtMajorVersion;
48 lpVersionInformation->dwMinorVersion = NtMinorVersion;
49 lpVersionInformation->dwBuildNumber = NtBuildNumber;
50 lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
51 RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
52
53 if(((CmNtCSDVersion >> 8) & 0xFF) != 0)
54 {
55 MaxLength = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1;
56 i = _snwprintf(lpVersionInformation->szCSDVersion,
57 MaxLength,
58 L"Service Pack %d",
59 ((CmNtCSDVersion >> 8) & 0xFF));
60 if (i < 0)
61 {
62 /* Null-terminate if it was overflowed */
63 lpVersionInformation->szCSDVersion[MaxLength] = L'\0';
64 }
65 }
66
67 if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
68 {
69 PRTL_OSVERSIONINFOEXW InfoEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation;
70 InfoEx->wServicePackMajor = (USHORT)(CmNtCSDVersion >> 8) & 0xFF;
71 InfoEx->wServicePackMinor = (USHORT)(CmNtCSDVersion & 0xFF);
72 InfoEx->wSuiteMask = (USHORT)(SharedUserData->SuiteMask & 0xFFFF);
73 InfoEx->wProductType = SharedUserData->NtProductType;
74 InfoEx->wReserved = 0;
75 }
76
77 return STATUS_SUCCESS;
78 }
79
80 return STATUS_INVALID_PARAMETER;
81 }
82
83 /* EOF */