svn maintenance
[reactos.git] / reactos / ntoskrnl / rtl / misc.c
1 /* $Id:$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/rtl/misc.c
6 * PURPOSE: Various functions
7 *
8 * PROGRAMMERS: Hartmut Birr
9 */
10
11 /* INCLUDES *****************************************************************/
12
13 #include <ntoskrnl.h>
14 #define NDEBUG
15 #include <internal/debug.h>
16
17 /* GLOBALS *******************************************************************/
18
19 extern ULONG NtGlobalFlag;
20 extern ULONG NtMajorVersion;
21 extern ULONG NtMinorVersion;
22 extern ULONG NtOSCSDVersion;
23
24 /* header hell made me do this...sorry */
25 typedef struct _OSVERSIONINFOW {
26 DWORD dwOSVersionInfoSize;
27 DWORD dwMajorVersion;
28 DWORD dwMinorVersion;
29 DWORD dwBuildNumber;
30 DWORD dwPlatformId;
31 WCHAR szCSDVersion[ 128 ];
32 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
33
34 typedef struct _OSVERSIONINFOEXW {
35 DWORD dwOSVersionInfoSize;
36 DWORD dwMajorVersion;
37 DWORD dwMinorVersion;
38 DWORD dwBuildNumber;
39 DWORD dwPlatformId;
40 WCHAR szCSDVersion[ 128 ];
41 WORD wServicePackMajor;
42 WORD wServicePackMinor;
43 WORD wSuiteMask;
44 BYTE wProductType;
45 BYTE wReserved;
46 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
47
48 #ifndef VER_PLATFORM_WIN32_NT
49 #define VER_PLATFORM_WIN32_NT (2)
50 #endif
51
52 /* FUNCTIONS *****************************************************************/
53
54 /*
55 * @implemented
56 */
57 ULONG
58 STDCALL
59 RtlGetNtGlobalFlags(VOID)
60 {
61 return(NtGlobalFlag);
62 }
63
64
65 /*
66 * @implemented
67 */
68 NTSTATUS STDCALL
69 RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
70 {
71 if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
72 lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
73 {
74 lpVersionInformation->dwMajorVersion = NtMajorVersion;
75 lpVersionInformation->dwMinorVersion = NtMinorVersion;
76 lpVersionInformation->dwBuildNumber = NtBuildNumber;
77 lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
78 if(((NtOSCSDVersion >> 8) & 0xFF) != 0)
79 {
80 int i = _snwprintf(lpVersionInformation->szCSDVersion,
81 (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1,
82 L"Service Pack %d",
83 ((NtOSCSDVersion >> 8) & 0xFF));
84 lpVersionInformation->szCSDVersion[i] = L'\0';
85 }
86 else
87 {
88 RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
89 }
90 if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
91 {
92 RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)lpVersionInformation;
93 InfoEx->wServicePackMajor = (NtOSCSDVersion >> 8) & 0xFF;
94 InfoEx->wServicePackMinor = NtOSCSDVersion & 0xFF;
95 InfoEx->wSuiteMask = SharedUserData->SuiteMask;
96 InfoEx->wProductType = SharedUserData->NtProductType;
97 }
98
99 return STATUS_SUCCESS;
100 }
101
102 return STATUS_INVALID_PARAMETER;
103 }
104