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