[NTOSKRNL][NTDLL][RTL][KERNEL32]
[reactos.git] / reactos / 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 * pdwMajorVersion [OUT] Destination for the Major version
60 * pdwMinorVersion [OUT] Destination for the Minor version
61 * pdwBuildNumber [OUT] Destination for the Build version
62 *
63 * RETURN VALUE
64 * Nothing.
65 *
66 * NOTES
67 * - Introduced in Windows XP (NT 5.1)
68 * - Since this call didn't exist before XP, we report at least the version
69 * 5.1. This fixes the loading of msvcrt.dll as released with XP Home,
70 * which fails in DLLMain() if the major version isn't 5.
71 *
72 * @implemented
73 */
74
75 VOID NTAPI
76 RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion,
77 OUT LPDWORD pdwMinorVersion,
78 OUT LPDWORD pdwBuildNumber)
79 {
80 PPEB pPeb = NtCurrentPeb();
81
82 if (pdwMajorVersion)
83 {
84 *pdwMajorVersion = pPeb->OSMajorVersion < 5 ? 5 : pPeb->OSMajorVersion;
85 }
86
87 if (pdwMinorVersion)
88 {
89 if ( (pPeb->OSMajorVersion < 5) ||
90 ((pPeb->OSMajorVersion == 5) && (pPeb->OSMinorVersion < 1)) )
91 *pdwMinorVersion = 1;
92 else
93 *pdwMinorVersion = pPeb->OSMinorVersion;
94 }
95
96 if (pdwBuildNumber)
97 {
98 /* Windows really does this! */
99 *pdwBuildNumber = (0xF0000000 | pPeb->OSBuildNumber);
100 }
101 }
102
103 /*
104 * @implemented
105 */
106 NTSTATUS NTAPI
107 RtlGetVersion(RTL_OSVERSIONINFOW *Info)
108 {
109 LONG i, MaxLength;
110
111 if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
112 Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
113 {
114 PPEB Peb = NtCurrentPeb();
115
116 Info->dwMajorVersion = Peb->OSMajorVersion;
117 Info->dwMinorVersion = Peb->OSMinorVersion;
118 Info->dwBuildNumber = Peb->OSBuildNumber;
119 Info->dwPlatformId = Peb->OSPlatformId;
120 RtlZeroMemory(Info->szCSDVersion, sizeof(Info->szCSDVersion));
121 if(((Peb->OSCSDVersion >> 8) & 0xFF) != 0)
122 {
123 MaxLength = (sizeof(Info->szCSDVersion) / sizeof(Info->szCSDVersion[0])) - 1;
124 i = _snwprintf(Info->szCSDVersion,
125 MaxLength,
126 L"Service Pack %d",
127 ((Peb->OSCSDVersion >> 8) & 0xFF));
128 if (i < 0)
129 {
130 /* null-terminate if it was overflowed */
131 Info->szCSDVersion[MaxLength] = L'\0';
132 }
133 }
134 if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
135 {
136 RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)Info;
137 InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
138 InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
139 InfoEx->wSuiteMask = SharedUserData->SuiteMask & 0xFFFF;
140 InfoEx->wProductType = SharedUserData->NtProductType;
141 }
142
143 return STATUS_SUCCESS;
144 }
145
146 return STATUS_INVALID_PARAMETER;
147 }
148
149 /* EOF */