ReactOS  0.4.14-dev-608-gd495a4f
version.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for version.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

DWORD WINAPI GetVersion (VOID)
 
BOOL WINAPI GetVersionExW (IN LPOSVERSIONINFOW lpVersionInformation)
 
BOOL WINAPI GetVersionExA (IN LPOSVERSIONINFOA lpVersionInformation)
 
BOOL WINAPI VerifyVersionInfoW (IN LPOSVERSIONINFOEXW lpVersionInformation, IN DWORD dwTypeMask, IN DWORDLONG dwlConditionMask)
 
BOOL WINAPI VerifyVersionInfoA (IN LPOSVERSIONINFOEXA lpVersionInformation, IN DWORD dwTypeMask, IN DWORDLONG dwlConditionMask)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file version.c.

Function Documentation

◆ GetVersion()

DWORD WINAPI GetVersion ( VOID  )

Definition at line 22 of file version.c.

23 {
24  PPEB Peb = NtCurrentPeb();
25 
26  return (DWORD)( ((Peb->OSPlatformId ^ 2) << 30) |
27  (Peb->OSBuildNumber << 16) |
28  (Peb->OSMinorVersion << 8 ) |
30 }
PPEB Peb
Definition: dllmain.c:27
ULONG OSPlatformId
Definition: ntddk_ex.h:303
unsigned long DWORD
Definition: ntddk_ex.h:95
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

Referenced by _LocalGetPrinterLevel0(), AfdCreateSocket(), CheckCdrwFilter(), ConvertStringSecurityDescriptorToSecurityDescriptorW(), ConvertStringSidToSidA(), ConvertStringSidToSidW(), CreateAllAccessSecurityAttributes(), dde_connect(), DECLARE_INTERFACE_(), DllMain(), get_host_os_flag(), get_window_region(), GetFileVersionInfoSizeExW(), InitTreeViewItems(), IPropertyStorage_fnWriteMultiple(), is_version_nt(), LoadCardBitmaps(), MDIMainFrame::MDIMainFrame(), MsiGetMode(), OaBuildVersion(), path_to_pidl(), RichEditWndProcW(), SHCreateWorkerWindowW(), SHELL_OsIsUnicode(), START_TEST(), test_button_messages(), test_CopyImage_Bitmap(), test_CopyImage_Check(), test_enum_value(), test_enumdisplaydevices_adapter(), test_GetDiskFreeSpaceA(), test_GetRandomRgn(), test_GetTempPathW(), test_reg_create_key(), test_SHSimpleIDListFromPath(), testCtrlHandler(), VerifyPassword(), and VfdIsValidPlatform().

◆ GetVersionExA()

BOOL WINAPI GetVersionExA ( IN LPOSVERSIONINFOA  lpVersionInformation)

Definition at line 69 of file version.c.

70 {
71  OSVERSIONINFOEXW VersionInformation;
72  LPOSVERSIONINFOEXA lpVersionInformationEx;
73  UNICODE_STRING CsdVersionW;
75  ANSI_STRING CsdVersionA;
76 
77  if ((lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA)) &&
78  (lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXA)))
79  {
81  return FALSE;
82  }
83 
84  VersionInformation.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
85 
86  if (!GetVersionExW((LPOSVERSIONINFOW)&VersionInformation)) return FALSE;
87 
88  /* Copy back fields that match both supported structures */
89  lpVersionInformation->dwMajorVersion = VersionInformation.dwMajorVersion;
90  lpVersionInformation->dwMinorVersion = VersionInformation.dwMinorVersion;
91  lpVersionInformation->dwBuildNumber = VersionInformation.dwBuildNumber;
92  lpVersionInformation->dwPlatformId = VersionInformation.dwPlatformId;
93 
94  if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))
95  {
96  lpVersionInformationEx = (PVOID)lpVersionInformation;
97  lpVersionInformationEx->wServicePackMajor = VersionInformation.wServicePackMajor;
98  lpVersionInformationEx->wServicePackMinor = VersionInformation.wServicePackMinor;
99  lpVersionInformationEx->wSuiteMask = VersionInformation.wSuiteMask;
100  lpVersionInformationEx->wProductType = VersionInformation.wProductType;
101  lpVersionInformationEx->wReserved = VersionInformation.wReserved;
102  }
103 
104  /* Convert the CSD string */
105  RtlInitEmptyAnsiString(&CsdVersionA,
106  lpVersionInformation->szCSDVersion,
107  sizeof(lpVersionInformation->szCSDVersion));
108  RtlInitUnicodeString(&CsdVersionW, VersionInformation.szCSDVersion);
109  Status = RtlUnicodeStringToAnsiString(&CsdVersionA, &CsdVersionW, FALSE);
110  return (NT_SUCCESS(Status));
111 }
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:265
USHORT wSuiteMask
Definition: rtltypes.h:259
LONG NTSTATUS
Definition: precomp.h:26
WCHAR szCSDVersion[128]
Definition: rtltypes.h:247
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
USHORT wServicePackMinor
Definition: rtltypes.h:258
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
void * PVOID
Definition: retypes.h:9
ULONG dwMajorVersion
Definition: rtltypes.h:243
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:417
ULONG dwBuildNumber
Definition: rtltypes.h:245
USHORT wServicePackMajor
Definition: rtltypes.h:257
struct _OSVERSIONINFOEXW OSVERSIONINFOEXW
ULONG dwPlatformId
Definition: rtltypes.h:246
Status
Definition: gdiplustypes.h:24
ULONG dwMinorVersion
Definition: rtltypes.h:244
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
UCHAR wProductType
Definition: rtltypes.h:260
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by acmGetVersion(), ImmGetVirtualKey(), IsOS(), IsWindowsXPorLaterCompatible(), START_TEST(), test_GetVersionEx(), test_initvar(), test_VerifyVersionInfo(), and verify_shima_imp().

◆ GetVersionExW()

BOOL WINAPI GetVersionExW ( IN LPOSVERSIONINFOW  lpVersionInformation)

Definition at line 37 of file version.c.

38 {
40  LPOSVERSIONINFOEXW lpVersionInformationEx;
41 
42  if ((lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW)) &&
43  (lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW)))
44  {
46  return FALSE;
47  }
48 
49  Status = RtlGetVersion((PRTL_OSVERSIONINFOW)lpVersionInformation);
50  if (Status == STATUS_SUCCESS)
51  {
52  if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
53  {
54  lpVersionInformationEx = (PVOID)lpVersionInformation;
55  lpVersionInformationEx->wReserved = 0;
56  }
57 
58  return TRUE;
59  }
60 
61  return FALSE;
62 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
LONG NTSTATUS
Definition: precomp.h:26
void * PVOID
Definition: retypes.h:9
#define SetLastError(x)
Definition: compat.h:417
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by _LocalGetPrintServerHandleData(), AllSysInfo(), build_systeminfo_tree(), DllMain(), dump_system_info(), ensure_useragent(), FILEDLG95_InitControls(), fill_operatingsystem(), get_app_version(), CConfiguration::GetSystemInformation(), GetVersionExA(), init_driver_info(), InitOsVersion(), IsPreVistaOSVersion(), IsWindowsOS(), NetrServerGetInfo(), NetWkstaGetInfo(), PrintOSVersion(), ReportProductInfoEvent(), set_installer_properties(), test_assoc_perceived(), and verify_shimw_imp().

◆ VerifyVersionInfoA()

BOOL WINAPI VerifyVersionInfoA ( IN LPOSVERSIONINFOEXA  lpVersionInformation,
IN DWORD  dwTypeMask,
IN DWORDLONG  dwlConditionMask 
)

Definition at line 161 of file version.c.

164 {
165  OSVERSIONINFOEXW viex;
166 
167  /* NOTE: szCSDVersion is ignored, we don't need to convert it to Unicode */
168  viex.dwOSVersionInfoSize = sizeof(viex);
169  viex.dwMajorVersion = lpVersionInformation->dwMajorVersion;
170  viex.dwMinorVersion = lpVersionInformation->dwMinorVersion;
171  viex.dwBuildNumber = lpVersionInformation->dwBuildNumber;
172  viex.dwPlatformId = lpVersionInformation->dwPlatformId;
173  viex.wServicePackMajor = lpVersionInformation->wServicePackMajor;
174  viex.wServicePackMinor = lpVersionInformation->wServicePackMinor;
175  viex.wSuiteMask = lpVersionInformation->wSuiteMask;
176  viex.wProductType = lpVersionInformation->wProductType;
177  viex.wReserved = lpVersionInformation->wReserved;
178  return VerifyVersionInfoW(&viex, dwTypeMask, dwlConditionMask);
179 }
ULONG dwBuildNumber
Definition: rtltypes.h:268
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:265
UCHAR wProductType
Definition: rtltypes.h:274
ULONG dwPlatformId
Definition: rtltypes.h:269
ULONG dwMinorVersion
Definition: rtltypes.h:267
USHORT wSuiteMask
Definition: rtltypes.h:273
ULONG dwMajorVersion
Definition: rtltypes.h:266
BOOL WINAPI VerifyVersionInfoW(IN LPOSVERSIONINFOEXW lpVersionInformation, IN DWORD dwTypeMask, IN DWORDLONG dwlConditionMask)
Definition: version.c:118
USHORT wServicePackMajor
Definition: rtltypes.h:271
USHORT wServicePackMinor
Definition: rtltypes.h:272

Referenced by test_VerifyVersionInfo().

◆ VerifyVersionInfoW()

BOOL WINAPI VerifyVersionInfoW ( IN LPOSVERSIONINFOEXW  lpVersionInformation,
IN DWORD  dwTypeMask,
IN DWORDLONG  dwlConditionMask 
)

Definition at line 118 of file version.c.

121 {
123 
124  Status = RtlVerifyVersionInfo((PRTL_OSVERSIONINFOEXW)lpVersionInformation,
125  dwTypeMask,
126  dwlConditionMask);
127  switch (Status)
128  {
131  return FALSE;
132 
134  if (lpVersionInformation)
135  {
136  DPRINT1("VerifyVersionInfo -- Version mismatch(%d.%d.%d:%d)\n",
137  (dwTypeMask & VER_MAJORVERSION) ? lpVersionInformation->dwMajorVersion : -1,
138  (dwTypeMask & VER_MINORVERSION) ? lpVersionInformation->dwMinorVersion : -1,
139  (dwTypeMask & VER_BUILDNUMBER) ? lpVersionInformation->dwBuildNumber : -1,
140  (dwTypeMask & VER_PLATFORMID) ? lpVersionInformation->dwPlatformId : -1);
141  }
142  else
143  {
144  DPRINT1("VerifyVersionInfo -- Version mismatch(NULL)\n");
145  }
147  return FALSE;
148 
149  default:
150  /* RtlVerifyVersionInfo shouldn't report any other failure code! */
152  return TRUE;
153  }
154 }
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:311
#define VER_MINORVERSION
Definition: rtltypes.h:226
#define TRUE
Definition: types.h:120
#define VER_BUILDNUMBER
Definition: rtltypes.h:228
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_BAD_ARGUMENTS
Definition: winerror.h:232
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define VER_PLATFORMID
Definition: rtltypes.h:229
#define VER_MAJORVERSION
Definition: rtltypes.h:227
#define SetLastError(x)
Definition: compat.h:417
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
#define ERROR_OLD_WIN_VERSION
Definition: winerror.h:672
NTSTATUS NTAPI RtlVerifyVersionInfo(IN PRTL_OSVERSIONINFOEXW VersionInfo, IN ULONG TypeMask, IN ULONGLONG ConditionMask)
Definition: version.c:55

Referenced by IsWindows8OrGreater(), IsWindowsServer(), VerifyVersionInfoA(), and winver_equal_or_newer().