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)
11 /* INCLUDES *******************************************************************/
18 /* FUNCTIONS ******************************************************************/
20 /* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
22 SetRosSpecificInfo(IN OUT PRTL_OSVERSIONINFOEXW VersionInformation
)
24 CHAR Buffer
[sizeof(KEY_VALUE_PARTIAL_INFORMATION
) + sizeof(ULONG
)];
25 PKEY_VALUE_PARTIAL_INFORMATION kvpInfo
= (PVOID
)Buffer
;
26 OBJECT_ATTRIBUTES ObjectAttributes
;
27 ULONG ReportAsWorkstation
= 0;
31 UNICODE_STRING KeyName
= RTL_CONSTANT_STRING(L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ReactOS\\Settings\\Version");
32 UNICODE_STRING ValName
= RTL_CONSTANT_STRING(L
"ReportAsWorkstation");
34 InitializeObjectAttributes(&ObjectAttributes
,
36 OBJ_OPENIF
| OBJ_CASE_INSENSITIVE
,
40 /* Don't change anything if the key doesn't exist */
41 Status
= NtOpenKey(&hKey
, KEY_READ
, &ObjectAttributes
);
42 if (NT_SUCCESS(Status
))
44 /* Get the value from the registry and make sure it's a 32-bit value */
45 Status
= NtQueryValueKey(hKey
,
47 KeyValuePartialInformation
,
51 if (NT_SUCCESS(Status
) &&
52 (kvpInfo
->Type
== REG_DWORD
) &&
53 (kvpInfo
->DataLength
== sizeof(ULONG
)))
55 /* Is the value set? */
56 ReportAsWorkstation
= *(PULONG
)kvpInfo
->Data
;
57 if ((VersionInformation
->wProductType
== VER_NT_SERVER
) &&
58 (ReportAsWorkstation
!= 0))
60 /* It is, modify the product type to report a workstation */
61 VersionInformation
->wProductType
= VER_NT_WORKSTATION
;
62 DPRINT1("We modified the reported OS from NtProductServer to NtProductWinNt\n");
66 /* Close the handle */
71 /**********************************************************************
76 * Retrieves the OS product type.
79 * ProductType Pointer to the product type variable.
82 * TRUE if successful, otherwise FALSE
85 * ProductType can be one of the following values:
86 * 1 Workstation (WinNT)
88 * 3 Advanced Server (ServerNT)
96 RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType
)
98 *ProductType
= SharedUserData
->NtProductType
;
102 /**********************************************************************
104 * RtlGetNtVersionNumbers
107 * Get the version numbers of the run time library.
110 * pdwMajorVersion [OUT] Destination for the Major version
111 * pdwMinorVersion [OUT] Destination for the Minor version
112 * pdwBuildNumber [OUT] Destination for the Build version
118 * - Introduced in Windows XP (NT 5.1)
119 * - Since this call didn't exist before XP, we report at least the version
120 * 5.1. This fixes the loading of msvcrt.dll as released with XP Home,
121 * which fails in DLLMain() if the major version isn't 5.
126 RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion
,
127 OUT LPDWORD pdwMinorVersion
,
128 OUT LPDWORD pdwBuildNumber
)
130 PPEB pPeb
= NtCurrentPeb();
134 *pdwMajorVersion
= pPeb
->OSMajorVersion
< 5 ? 5 : pPeb
->OSMajorVersion
;
139 if ( (pPeb
->OSMajorVersion
< 5) ||
140 ((pPeb
->OSMajorVersion
== 5) && (pPeb
->OSMinorVersion
< 1)) )
141 *pdwMinorVersion
= 1;
143 *pdwMinorVersion
= pPeb
->OSMinorVersion
;
148 /* Windows really does this! */
149 *pdwBuildNumber
= (0xF0000000 | pPeb
->OSBuildNumber
);
155 * @note User-mode version of RtlGetVersion in ntoskrnl/rtl/misc.c
158 RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation
)
162 if (lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOW
) ||
163 lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
))
165 PPEB Peb
= NtCurrentPeb();
167 lpVersionInformation
->dwMajorVersion
= Peb
->OSMajorVersion
;
168 lpVersionInformation
->dwMinorVersion
= Peb
->OSMinorVersion
;
169 lpVersionInformation
->dwBuildNumber
= Peb
->OSBuildNumber
;
170 lpVersionInformation
->dwPlatformId
= Peb
->OSPlatformId
;
171 RtlZeroMemory(lpVersionInformation
->szCSDVersion
, sizeof(lpVersionInformation
->szCSDVersion
));
173 if(((Peb
->OSCSDVersion
>> 8) & 0xFF) != 0)
175 MaxLength
= (sizeof(lpVersionInformation
->szCSDVersion
) / sizeof(lpVersionInformation
->szCSDVersion
[0])) - 1;
176 i
= _snwprintf(lpVersionInformation
->szCSDVersion
,
179 ((Peb
->OSCSDVersion
>> 8) & 0xFF));
182 /* Null-terminate if it was overflowed */
183 lpVersionInformation
->szCSDVersion
[MaxLength
] = L
'\0';
187 if (lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
))
189 PRTL_OSVERSIONINFOEXW InfoEx
= (PRTL_OSVERSIONINFOEXW
)lpVersionInformation
;
190 InfoEx
->wServicePackMajor
= (Peb
->OSCSDVersion
>> 8) & 0xFF;
191 InfoEx
->wServicePackMinor
= Peb
->OSCSDVersion
& 0xFF;
192 InfoEx
->wSuiteMask
= SharedUserData
->SuiteMask
& 0xFFFF;
193 InfoEx
->wProductType
= SharedUserData
->NtProductType
;
194 InfoEx
->wReserved
= 0;
196 /* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
197 SetRosSpecificInfo(InfoEx
);
200 return STATUS_SUCCESS
;
203 return STATUS_INVALID_PARAMETER
;