Sync trunk.
[reactos.git] / dll / ntdll / rtl / version.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/ntdll/rtl/process.c
5 * PURPOSE: Process functions
6 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
7 * UPDATE HISTORY:
8 * Created 01/11/98
9 */
10
11 /* INCLUDES ****************************************************************/
12
13 #include <ntdll.h>
14 #define NDEBUG
15 #include <debug.h>
16
17 /* FUNCTIONS ****************************************************************/
18
19 /**********************************************************************
20 * NAME EXPORTED
21 * RtlGetNtProductType
22 *
23 * DESCRIPTION
24 * Retrieves the OS product type.
25 *
26 * ARGUMENTS
27 * ProductType Pointer to the product type variable.
28 *
29 * RETURN VALUE
30 * TRUE if successful, otherwise FALSE
31 *
32 * NOTE
33 * ProductType can be one of the following values:
34 * 1 Workstation (Winnt)
35 * 2 Server (Lanmannt)
36 * 3 Advanced Server (Servernt)
37 *
38 * REVISIONS
39 * 2000-08-10 ekohl
40 *
41 * @implemented
42 */
43
44 BOOLEAN NTAPI
45 RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
46 {
47 *ProductType = SharedUserData->NtProductType;
48 return(TRUE);
49 }
50
51 /**********************************************************************
52 * NAME EXPORTED
53 * RtlGetNtVersionNumbers
54 *
55 * DESCRIPTION
56 * Get the version numbers of the run time library.
57 *
58 * ARGUMENTS
59 * major [OUT] Destination for the Major version
60 * minor [OUT] Destination for the Minor version
61 * build [OUT] Destination for the Build version
62 *
63 * RETURN VALUE
64 * Nothing.
65 *
66 * NOTE
67 * Introduced in Windows XP (NT5.1)
68 *
69 * @implemented
70 */
71
72 void NTAPI
73 RtlGetNtVersionNumbers(LPDWORD major, LPDWORD minor, LPDWORD build)
74 {
75 PPEB pPeb = NtCurrentPeb();
76
77 if (major)
78 {
79 /* msvcrt.dll as released with XP Home fails in DLLMain() if the
80 * major version is not 5. So, we should never set a version < 5 ...
81 * This makes sense since this call didn't exist before XP anyway.
82 */
83 *major = pPeb->OSMajorVersion < 5 ? 5 : pPeb->OSMajorVersion;
84 }
85
86 if (minor)
87 {
88 if (pPeb->OSMinorVersion <= 5)
89 *minor = pPeb->OSMinorVersion < 1 ? 1 : pPeb->OSMinorVersion;
90 else
91 *minor = pPeb->OSMinorVersion;
92 }
93
94 if (build)
95 {
96 /* FIXME: Does anybody know the real formula? */
97 *build = (0xF0000000 | pPeb->OSBuildNumber);
98 }
99 }
100
101 /*
102 * @implemented
103 */
104 NTSTATUS NTAPI
105 RtlGetVersion(RTL_OSVERSIONINFOW *Info)
106 {
107 LONG i, MaxLength;
108
109 if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
110 Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
111 {
112 PPEB Peb = NtCurrentPeb();
113
114 Info->dwMajorVersion = Peb->OSMajorVersion;
115 Info->dwMinorVersion = Peb->OSMinorVersion;
116 Info->dwBuildNumber = Peb->OSBuildNumber;
117 Info->dwPlatformId = Peb->OSPlatformId;
118 RtlZeroMemory(Info->szCSDVersion, sizeof(Info->szCSDVersion));
119 if(((Peb->OSCSDVersion >> 8) & 0xFF) != 0)
120 {
121 MaxLength = (sizeof(Info->szCSDVersion) / sizeof(Info->szCSDVersion[0])) - 1;
122 i = _snwprintf(Info->szCSDVersion,
123 MaxLength,
124 L"Service Pack %d",
125 ((Peb->OSCSDVersion >> 8) & 0xFF));
126 if (i < 0)
127 {
128 /* null-terminate if it was overflowed */
129 Info->szCSDVersion[MaxLength] = L'\0';
130 }
131 }
132 if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
133 {
134 RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)Info;
135 InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
136 InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
137 InfoEx->wSuiteMask = SharedUserData->SuiteMask;
138 InfoEx->wProductType = SharedUserData->NtProductType;
139 }
140
141 return STATUS_SUCCESS;
142 }
143
144 return STATUS_INVALID_PARAMETER;
145 }
146
147 /* EOF */