ReactOS 0.4.16-dev-980-g00983aa
version.c File Reference
#include <ntdll.h>
#include <debug.h>
Include dependency graph for version.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static VOID NTAPI SetRosSpecificInfo (IN OUT PRTL_OSVERSIONINFOEXW VersionInformation)
 
BOOLEAN NTAPI RtlGetNtProductType (_Out_ PNT_PRODUCT_TYPE ProductType)
 
VOID NTAPI RtlGetNtVersionNumbers (OUT PULONG pMajorVersion, OUT PULONG pMinorVersion, OUT PULONG pBuildNumber)
 
NTSTATUS NTAPI RtlGetVersion (IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
 

Variables

static signed char g_ReportProductType = 0
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file version.c.

Function Documentation

◆ RtlGetNtProductType()

BOOLEAN NTAPI RtlGetNtProductType ( _Out_ PNT_PRODUCT_TYPE  ProductType)

Definition at line 105 of file version.c.

106{
107 *ProductType = SharedUserData->NtProductType;
108
109 if (g_ReportProductType == 0)
110 {
111 /* Initialize cached value */
113 ovi.dwOSVersionInfoSize = sizeof(ovi);
114 ovi.wProductType = *ProductType;
115 SetRosSpecificInfo(&ovi);
116 }
117
118 if (g_ReportProductType > 0)
119 {
120 *ProductType = g_ReportProductType;
121 DPRINT("Overriding RtlGetNtProductType to return %d\n", *ProductType);
122 }
123 return TRUE;
124}
#define TRUE
Definition: types.h:120
static signed char g_ReportProductType
Definition: version.c:20
static VOID NTAPI SetRosSpecificInfo(IN OUT PRTL_OSVERSIONINFOEXW VersionInformation)
Definition: version.c:24
#define SharedUserData
#define DPRINT
Definition: sndvol32.h:73
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:269
UCHAR wProductType
Definition: rtltypes.h:278

Referenced by cmdAccounts(), LsapInitLsa(), NewCtxInit(), SamIInitialize(), and START_TEST().

◆ RtlGetNtVersionNumbers()

VOID NTAPI RtlGetNtVersionNumbers ( OUT PULONG  pMajorVersion,
OUT PULONG  pMinorVersion,
OUT PULONG  pBuildNumber 
)

Definition at line 150 of file version.c.

153{
154 PPEB pPeb = NtCurrentPeb();
155
156 if (pMajorVersion)
157 {
158 *pMajorVersion = pPeb->OSMajorVersion < 5 ? 5 : pPeb->OSMajorVersion;
159 }
160
161 if (pMinorVersion)
162 {
163 if ( (pPeb->OSMajorVersion < 5) ||
164 ((pPeb->OSMajorVersion == 5) && (pPeb->OSMinorVersion < 1)) )
165 *pMinorVersion = 1;
166 else
167 *pMinorVersion = pPeb->OSMinorVersion;
168 }
169
170 if (pBuildNumber)
171 {
172 /* Windows really does this! */
173 *pBuildNumber = (0xF0000000 | pPeb->OSBuildNumber);
174 }
175}
#define NtCurrentPeb()
Definition: FLS.c:22
ULONG OSMinorVersion
Definition: ntddk_ex.h:301
ULONG OSMajorVersion
Definition: ntddk_ex.h:300
ULONG OSBuildNumber
Definition: ntddk_ex.h:302

◆ RtlGetVersion()

NTSTATUS NTAPI RtlGetVersion ( IN OUT PRTL_OSVERSIONINFOW  lpVersionInformation)

Definition at line 182 of file version.c.

183{
186
187 if (lpVersionInformation->dwOSVersionInfoSize != sizeof(RTL_OSVERSIONINFOW) &&
188 lpVersionInformation->dwOSVersionInfoSize != sizeof(RTL_OSVERSIONINFOEXW))
189 {
191 }
192
193 lpVersionInformation->dwMajorVersion = Peb->OSMajorVersion;
194 lpVersionInformation->dwMinorVersion = Peb->OSMinorVersion;
195 lpVersionInformation->dwBuildNumber = Peb->OSBuildNumber;
196 lpVersionInformation->dwPlatformId = Peb->OSPlatformId;
197 RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
198
199 /* If we have a CSD version string, initialized by Application Compatibility... */
201 {
202 /* ... copy it... */
203 Length = min(wcslen(Peb->CSDVersion.Buffer), ARRAYSIZE(lpVersionInformation->szCSDVersion) - 1);
204 wcsncpy(lpVersionInformation->szCSDVersion, Peb->CSDVersion.Buffer, Length);
205 }
206 else
207 {
208 /* ... otherwise we just null-terminate it */
209 Length = 0;
210 }
211
212 /* Always null-terminate the user CSD version string */
213 lpVersionInformation->szCSDVersion[Length] = UNICODE_NULL;
214
215 if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
216 {
217 PRTL_OSVERSIONINFOEXW InfoEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation;
218 InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
219 InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
220 InfoEx->wSuiteMask = SharedUserData->SuiteMask & 0xFFFF;
221 InfoEx->wProductType = SharedUserData->NtProductType;
222 InfoEx->wReserved = 0;
223
224 /* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
225 SetRosSpecificInfo(InfoEx);
226 }
227
228 return STATUS_SUCCESS;
229}
wcsncpy
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
PPEB Peb
Definition: dllmain.c:27
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define min(a, b)
Definition: monoChain.cc:55
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_SUCCESS
Definition: shellext.h:65
USHORT wServicePackMinor
Definition: rtltypes.h:276
USHORT wSuiteMask
Definition: rtltypes.h:277
USHORT wServicePackMajor
Definition: rtltypes.h:275
UNICODE_STRING CSDVersion
Definition: winternl.h:353
ULONG OSPlatformId
Definition: ntddk_ex.h:303
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _OSVERSIONINFOEXW * PRTL_OSVERSIONINFOEXW

Referenced by _Function_class_(), _tmain(), AuxKlibInitialize(), DwmIsCompositionEnabled(), GetNtDdiVersion(), GetSystemVersionString(), GetVersionExW(), init_function_pointers(), InitializeMachineInformation(), InitializeTransferPackets(), RtlVerifyVersionInfo(), run_open_osfhandle(), set_installer_properties(), START_TEST(), TestEntry(), and VideoPortGetVersion().

◆ SetRosSpecificInfo()

static VOID NTAPI SetRosSpecificInfo ( IN OUT PRTL_OSVERSIONINFOEXW  VersionInformation)
static

Definition at line 24 of file version.c.

25{
32 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ReactOS\\Settings\\Version");
33 UNICODE_STRING ValName = RTL_CONSTANT_STRING(L"ReportAsWorkstation");
34
36 &KeyName,
38 NULL,
39 NULL);
40
41 /* Don't change anything if the key doesn't exist */
43 if (NT_SUCCESS(Status))
44 {
45 /* Get the value from the registry and make sure it's a 32-bit value */
47 &ValName,
49 kvpInfo,
50 sizeof(Buffer),
51 &Length);
52 if (NT_SUCCESS(Status) &&
53 (kvpInfo->Type == REG_DWORD) &&
54 (kvpInfo->DataLength == sizeof(ULONG)))
55 {
56 ULONG IsWorkstation = SharedUserData->NtProductType == NtProductWinNt;
57 ULONG ReportAsWorkstation = (*(PULONG)kvpInfo->Data) != 0;
58 if (IsWorkstation != ReportAsWorkstation)
59 {
60 g_ReportProductType = ReportAsWorkstation ? NtProductWinNt : NtProductServer;
61 }
62 }
63
64 /* Close the handle */
66 }
67
68 if (g_ReportProductType > 0)
69 {
70 VersionInformation->wProductType = g_ReportProductType;
71 DPRINT("We modified the reported OS product type from %d to %d\n",
72 SharedUserData->NtProductType, VersionInformation->wProductType);
73 }
74 else
75 {
77 }
78}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
@ NtProductWinNt
Definition: shellpath.c:64
@ NtProductServer
Definition: shellpath.c:66
FxAutoRegKey hKey
Status
Definition: gdiplustypes.h:25
#define OBJ_OPENIF
Definition: winternl.h:229
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
@ KeyValuePartialInformation
Definition: nt_native.h:1182
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define L(x)
Definition: ntvdm.h:50
#define REG_DWORD
Definition: sdbapi.c:596
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
char CHAR
Definition: xmlstorage.h:175

Referenced by RtlGetNtProductType(), and RtlGetVersion().

Variable Documentation

◆ g_ReportProductType

signed char g_ReportProductType = 0
static

Definition at line 20 of file version.c.

Referenced by RtlGetNtProductType(), and SetRosSpecificInfo().