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 *******************************************************************/
17 /* FUNCTIONS ******************************************************************/
19 /* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
21 SetRosSpecificInfo(IN OUT PRTL_OSVERSIONINFOEXW VersionInformation
)
23 CHAR Buffer
[sizeof(KEY_VALUE_PARTIAL_INFORMATION
) + sizeof(ULONG
)];
24 PKEY_VALUE_PARTIAL_INFORMATION kvpInfo
= (PVOID
)Buffer
;
25 OBJECT_ATTRIBUTES ObjectAttributes
;
26 ULONG ReportAsWorkstation
= 0;
30 UNICODE_STRING KeyName
= RTL_CONSTANT_STRING(L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ReactOS\\Settings\\Version");
31 UNICODE_STRING ValName
= RTL_CONSTANT_STRING(L
"ReportAsWorkstation");
33 InitializeObjectAttributes(&ObjectAttributes
,
35 OBJ_OPENIF
| OBJ_CASE_INSENSITIVE
,
39 /* Don't change anything if the key doesn't exist */
40 Status
= NtOpenKey(&hKey
, KEY_READ
, &ObjectAttributes
);
41 if (NT_SUCCESS(Status
))
43 /* Get the value from the registry and make sure it's a 32-bit value */
44 Status
= NtQueryValueKey(hKey
,
46 KeyValuePartialInformation
,
50 if (NT_SUCCESS(Status
) &&
51 (kvpInfo
->Type
== REG_DWORD
) &&
52 (kvpInfo
->DataLength
== sizeof(ULONG
)))
54 /* Is the value set? */
55 ReportAsWorkstation
= *(PULONG
)kvpInfo
->Data
;
56 if ((VersionInformation
->wProductType
== VER_NT_SERVER
) &&
57 (ReportAsWorkstation
!= 0))
59 /* It is, modify the product type to report a workstation */
60 VersionInformation
->wProductType
= VER_NT_WORKSTATION
;
61 DPRINT1("We modified the reported OS from NtProductServer to NtProductWinNt\n");
65 /* Close the handle */
70 /**********************************************************************
75 * Retrieves the OS product type.
78 * ProductType Pointer to the product type variable.
81 * TRUE if successful, otherwise FALSE
84 * ProductType can be one of the following values:
85 * 1 Workstation (WinNT)
87 * 3 Advanced Server (ServerNT)
95 RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType
)
97 *ProductType
= SharedUserData
->NtProductType
;
101 /**********************************************************************
103 * RtlGetNtVersionNumbers
106 * Get the version numbers of the run time library.
109 * pdwMajorVersion [OUT] Destination for the Major version
110 * pdwMinorVersion [OUT] Destination for the Minor version
111 * pdwBuildNumber [OUT] Destination for the Build version
117 * - Introduced in Windows XP (NT 5.1)
118 * - Since this call didn't exist before XP, we report at least the version
119 * 5.1. This fixes the loading of msvcrt.dll as released with XP Home,
120 * which fails in DLLMain() if the major version isn't 5.
125 RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion
,
126 OUT LPDWORD pdwMinorVersion
,
127 OUT LPDWORD pdwBuildNumber
)
129 PPEB pPeb
= NtCurrentPeb();
133 *pdwMajorVersion
= pPeb
->OSMajorVersion
< 5 ? 5 : pPeb
->OSMajorVersion
;
138 if ( (pPeb
->OSMajorVersion
< 5) ||
139 ((pPeb
->OSMajorVersion
== 5) && (pPeb
->OSMinorVersion
< 1)) )
140 *pdwMinorVersion
= 1;
142 *pdwMinorVersion
= pPeb
->OSMinorVersion
;
147 /* Windows really does this! */
148 *pdwBuildNumber
= (0xF0000000 | pPeb
->OSBuildNumber
);
154 * @note User-mode version of RtlGetVersion in ntoskrnl/rtl/misc.c
157 RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation
)
161 if (lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOW
) ||
162 lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
))
164 PPEB Peb
= NtCurrentPeb();
166 lpVersionInformation
->dwMajorVersion
= Peb
->OSMajorVersion
;
167 lpVersionInformation
->dwMinorVersion
= Peb
->OSMinorVersion
;
168 lpVersionInformation
->dwBuildNumber
= Peb
->OSBuildNumber
;
169 lpVersionInformation
->dwPlatformId
= Peb
->OSPlatformId
;
170 RtlZeroMemory(lpVersionInformation
->szCSDVersion
, sizeof(lpVersionInformation
->szCSDVersion
));
172 if(((Peb
->OSCSDVersion
>> 8) & 0xFF) != 0)
174 MaxLength
= (sizeof(lpVersionInformation
->szCSDVersion
) / sizeof(lpVersionInformation
->szCSDVersion
[0])) - 1;
175 i
= _snwprintf(lpVersionInformation
->szCSDVersion
,
178 ((Peb
->OSCSDVersion
>> 8) & 0xFF));
181 /* Null-terminate if it was overflowed */
182 lpVersionInformation
->szCSDVersion
[MaxLength
] = L
'\0';
186 if (lpVersionInformation
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
))
188 PRTL_OSVERSIONINFOEXW InfoEx
= (PRTL_OSVERSIONINFOEXW
)lpVersionInformation
;
189 InfoEx
->wServicePackMajor
= (Peb
->OSCSDVersion
>> 8) & 0xFF;
190 InfoEx
->wServicePackMinor
= Peb
->OSCSDVersion
& 0xFF;
191 InfoEx
->wSuiteMask
= SharedUserData
->SuiteMask
& 0xFFFF;
192 InfoEx
->wProductType
= SharedUserData
->NtProductType
;
193 InfoEx
->wReserved
= 0;
195 /* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
196 SetRosSpecificInfo(InfoEx
);
199 return STATUS_SUCCESS
;
202 return STATUS_INVALID_PARAMETER
;