ReactOS  0.4.14-dev-55-g2da92ac
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 (PNT_PRODUCT_TYPE ProductType)
 
VOID NTAPI RtlGetNtVersionNumbers (OUT PULONG pMajorVersion, OUT PULONG pMinorVersion, OUT PULONG pBuildNumber)
 
NTSTATUS NTAPI RtlGetVersion (IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file version.c.

Function Documentation

◆ RtlGetNtProductType()

BOOLEAN NTAPI RtlGetNtProductType ( PNT_PRODUCT_TYPE  ProductType)

Definition at line 96 of file version.c.

97 {
98  *ProductType = SharedUserData->NtProductType;
99  return TRUE;
100 }
#define TRUE
Definition: types.h:120
#define SharedUserData

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

◆ RtlGetNtVersionNumbers()

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

Definition at line 126 of file version.c.

129 {
130  PPEB pPeb = NtCurrentPeb();
131 
132  if (pMajorVersion)
133  {
134  *pMajorVersion = pPeb->OSMajorVersion < 5 ? 5 : pPeb->OSMajorVersion;
135  }
136 
137  if (pMinorVersion)
138  {
139  if ( (pPeb->OSMajorVersion < 5) ||
140  ((pPeb->OSMajorVersion == 5) && (pPeb->OSMinorVersion < 1)) )
141  *pMinorVersion = 1;
142  else
143  *pMinorVersion = pPeb->OSMinorVersion;
144  }
145 
146  if (pBuildNumber)
147  {
148  /* Windows really does this! */
149  *pBuildNumber = (0xF0000000 | pPeb->OSBuildNumber);
150  }
151 }
ULONG OSBuildNumber
Definition: ntddk_ex.h:302
ULONG OSMinorVersion
Definition: ntddk_ex.h:301
#define NtCurrentPeb()
Definition: FLS.c:20
ULONG OSMajorVersion
Definition: ntddk_ex.h:300

◆ RtlGetVersion()

NTSTATUS NTAPI RtlGetVersion ( IN OUT PRTL_OSVERSIONINFOW  lpVersionInformation)

Definition at line 158 of file version.c.

159 {
160  SIZE_T Length;
161  PPEB Peb = NtCurrentPeb();
162 
163  if (lpVersionInformation->dwOSVersionInfoSize != sizeof(RTL_OSVERSIONINFOW) &&
164  lpVersionInformation->dwOSVersionInfoSize != sizeof(RTL_OSVERSIONINFOEXW))
165  {
167  }
168 
169  lpVersionInformation->dwMajorVersion = Peb->OSMajorVersion;
170  lpVersionInformation->dwMinorVersion = Peb->OSMinorVersion;
171  lpVersionInformation->dwBuildNumber = Peb->OSBuildNumber;
172  lpVersionInformation->dwPlatformId = Peb->OSPlatformId;
173  RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
174 
175  /* If we have a CSD version string, initialized by Application Compatibility... */
177  {
178  /* ... copy it... */
179  Length = min(wcslen(Peb->CSDVersion.Buffer), ARRAYSIZE(lpVersionInformation->szCSDVersion) - 1);
180  wcsncpy(lpVersionInformation->szCSDVersion, Peb->CSDVersion.Buffer, Length);
181  }
182  else
183  {
184  /* ... otherwise we just null-terminate it */
185  Length = 0;
186  }
187 
188  /* Always null-terminate the user CSD version string */
189  lpVersionInformation->szCSDVersion[Length] = UNICODE_NULL;
190 
191  if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
192  {
193  PRTL_OSVERSIONINFOEXW InfoEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation;
194  InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
195  InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
196  InfoEx->wSuiteMask = SharedUserData->SuiteMask & 0xFFFF;
197  InfoEx->wProductType = SharedUserData->NtProductType;
198  InfoEx->wReserved = 0;
199 
200  /* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
201  SetRosSpecificInfo(InfoEx);
202  }
203 
204  return STATUS_SUCCESS;
205 }
UCHAR wProductType
Definition: rtltypes.h:274
PPEB Peb
Definition: dllmain.c:27
ULONG OSPlatformId
Definition: ntddk_ex.h:303
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
USHORT wSuiteMask
Definition: rtltypes.h:273
#define UNICODE_NULL
static VOID NTAPI SetRosSpecificInfo(IN OUT PRTL_OSVERSIONINFOEXW VersionInformation)
Definition: version.c:22
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define SharedUserData
ULONG OSBuildNumber
Definition: ntddk_ex.h:302
ULONG_PTR SIZE_T
Definition: typedefs.h:78
ULONG OSMinorVersion
Definition: ntddk_ex.h:301
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define NtCurrentPeb()
Definition: FLS.c:20
USHORT wServicePackMajor
Definition: rtltypes.h:271
struct _OSVERSIONINFOEXW * PRTL_OSVERSIONINFOEXW
#define min(a, b)
Definition: monoChain.cc:55
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
UNICODE_STRING CSDVersion
Definition: winternl.h:353
ULONG OSMajorVersion
Definition: ntddk_ex.h:300
return STATUS_SUCCESS
Definition: btrfs.c:2966
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
USHORT wServicePackMinor
Definition: rtltypes.h:272

Referenced by _tmain(), GetSystemVersionString(), GetVersionExW(), init_function_pointers(), InitializeMachineInformation(), RtlVerifyVersionInfo(), run_open_osfhandle(), START_TEST(), TestEntry(), and VideoPortGetVersion().

◆ SetRosSpecificInfo()

static VOID NTAPI SetRosSpecificInfo ( IN OUT PRTL_OSVERSIONINFOEXW  VersionInformation)
static

Definition at line 22 of file version.c.

23 {
27  ULONG ReportAsWorkstation = 0;
28  HANDLE hKey;
29  ULONG Length;
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");
33 
35  &KeyName,
37  NULL,
38  NULL);
39 
40  /* Don't change anything if the key doesn't exist */
42  if (NT_SUCCESS(Status))
43  {
44  /* Get the value from the registry and make sure it's a 32-bit value */
45  Status = NtQueryValueKey(hKey,
46  &ValName,
48  kvpInfo,
49  sizeof(Buffer),
50  &Length);
51  if (NT_SUCCESS(Status) &&
52  (kvpInfo->Type == REG_DWORD) &&
53  (kvpInfo->DataLength == sizeof(ULONG)))
54  {
55  /* Is the value set? */
56  ReportAsWorkstation = *(PULONG)kvpInfo->Data;
57  if ((VersionInformation->wProductType == VER_NT_SERVER) &&
58  (ReportAsWorkstation != 0))
59  {
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");
63  }
64  }
65 
66  /* Close the handle */
67  NtClose(hKey);
68  }
69 }
#define VER_NT_WORKSTATION
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define KEY_READ
Definition: nt_native.h:1023
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_OPENIF
Definition: winternl.h:229
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
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)
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
unsigned int * PULONG
Definition: retypes.h:1
#define DPRINT1
Definition: precomp.h:8
#define VER_NT_SERVER
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_DWORD
Definition: sdbapi.c:596
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by RtlGetVersion().