ReactOS  0.4.15-dev-3451-gf606fec
version.c File Reference
#include "wine/test.h"
#include "winbase.h"
#include "winternl.h"
Include dependency graph for version.c:

Go to the source code of this file.

Macros

#define GET_PROC(func)   p##func = (void *)GetProcAddress(hmod, #func);
 

Functions

static BOOL (WINAPI *pGetProductInfo)(DWORD
 
static DWORD *static NTSTATUS (WINAPI *pRtlGetVersion)(RTL_OSVERSIONINFOEXW *)
 
static void init_function_pointers (void)
 
static void test_GetProductInfo (void)
 
static void test_GetVersionEx (void)
 
static void test_VerifyVersionInfo (void)
 
 START_TEST (version)
 

Variables

static DWORD
 

Macro Definition Documentation

◆ GET_PROC

#define GET_PROC (   func)    p##func = (void *)GetProcAddress(hmod, #func);

Definition at line 28 of file version.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pGetProductInfo)
static

◆ init_function_pointers()

static void init_function_pointers ( void  )
static

Definition at line 31 of file version.c.

32 {
33  HMODULE hmod;
34 
35  hmod = GetModuleHandleA("kernel32.dll");
36 
37  GET_PROC(GetProductInfo);
38 
39  hmod = GetModuleHandleA("ntdll.dll");
40 
42 }
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define GET_PROC(func)
Definition: version.c:28

Referenced by START_TEST().

◆ NTSTATUS()

static DWORD* static NTSTATUS ( WINAPI pRtlGetVersion)
static

◆ START_TEST()

START_TEST ( version  )

Definition at line 697 of file version.c.

698 {
700 
704 }
static void init_function_pointers(void)
Definition: version.c:31
static void test_GetVersionEx(void)
Definition: version.c:100
static void test_VerifyVersionInfo(void)
Definition: version.c:155
static void test_GetProductInfo(void)
Definition: version.c:44

◆ test_GetProductInfo()

static void test_GetProductInfo ( void  )
static

Definition at line 44 of file version.c.

45 {
46  DWORD product;
47  DWORD res;
48  DWORD table[] = {9,8,7,6,
49  7,0,0,0,
50  6,2,0,0,
51  6,1,2,0,
52  6,1,1,0,
53  6,1,0,2,
54  6,1,0,0,
55  6,0,3,0,
56  6,0,2,0,
57  6,0,1,5,
58  6,0,1,0,
59  6,0,0,0,
60  5,3,0,0,
61  5,2,0,0,
62  5,1,0,0,
63  5,0,0,0,
64  0};
65 
66  DWORD *entry = table;
67 
68  if (!pGetProductInfo)
69  {
70  /* Not present before Vista */
71  win_skip("GetProductInfo() not available\n");
72  return;
73  }
74 
75  while (*entry)
76  {
77  /* SetLastError() / GetLastError(): value is untouched */
78  product = 0xdeadbeef;
79  SetLastError(0xdeadbeef);
80  res = pGetProductInfo(entry[0], entry[1], entry[2], entry[3], &product);
81 
82  if (entry[0] >= 6)
83  ok(res && (product > PRODUCT_UNDEFINED) && (product <= PRODUCT_ENTERPRISE_S_N_EVALUATION),
84  "got %d and 0x%x (expected TRUE and a valid PRODUCT_* value)\n", res, product);
85  else
86  ok(!res && !product && (GetLastError() == 0xdeadbeef),
87  "got %d and 0x%x with 0x%x (expected FALSE and PRODUCT_UNDEFINED with LastError untouched)\n",
88  res, product, GetLastError());
89 
90  entry+= 4;
91  }
92 
93  /* NULL pointer is not a problem */
94  SetLastError(0xdeadbeef);
95  res = pGetProductInfo(6, 1, 0, 0, NULL);
96  ok( (!res) && (GetLastError() == 0xdeadbeef),
97  "got %d with 0x%x (expected FALSE with LastError untouched\n", res, GetLastError());
98 }
#define PRODUCT_ENTERPRISE_S_N_EVALUATION
#define PRODUCT_UNDEFINED
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
uint32_t entry
Definition: isohybrid.c:63
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
#define win_skip
Definition: test.h:151

Referenced by START_TEST().

◆ test_GetVersionEx()

static void test_GetVersionEx ( void  )
static

Definition at line 100 of file version.c.

101 {
103  OSVERSIONINFOEXA infoExA;
104  BOOL ret;
105 
106  if (0)
107  {
108  /* Silently crashes on XP */
110  }
111 
112  SetLastError(0xdeadbeef);
113  memset(&infoA,0,sizeof infoA);
114  ret = GetVersionExA(&infoA);
115  ok(!ret, "Expected GetVersionExA to fail\n");
117  GetLastError() == 0xdeadbeef /* Win9x */,
118  "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
119  GetLastError());
120 
121  SetLastError(0xdeadbeef);
122  infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA) / 2;
123  ret = GetVersionExA(&infoA);
124  ok(!ret, "Expected GetVersionExA to fail\n");
126  GetLastError() == 0xdeadbeef /* Win9x */,
127  "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
128  GetLastError());
129 
130  SetLastError(0xdeadbeef);
131  infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA) * 2;
132  ret = GetVersionExA(&infoA);
133  ok(!ret, "Expected GetVersionExA to fail\n");
135  GetLastError() == 0xdeadbeef /* Win9x */,
136  "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
137  GetLastError());
138 
139  SetLastError(0xdeadbeef);
140  infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
141  ret = GetVersionExA(&infoA);
142  ok(ret, "Expected GetVersionExA to succeed\n");
143  ok(GetLastError() == 0xdeadbeef,
144  "Expected 0xdeadbeef, got %d\n", GetLastError());
145 
146  SetLastError(0xdeadbeef);
147  infoExA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
148  ret = GetVersionExA((OSVERSIONINFOA *)&infoExA);
149  ok(ret, "GetVersionExA failed.\n");
150 
151  if (!infoExA.wServicePackMajor && !infoExA.wServicePackMinor)
152  ok(!infoExA.szCSDVersion[0], "got '%s'\n", infoExA.szCSDVersion);
153 }
static const SecPkgInfoA infoA
Definition: kerberos.c:302
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
unsigned int BOOL
Definition: ntddk_ex.h:94
USHORT wServicePackMinor
Definition: rtltypes.h:262
BOOL WINAPI GetVersionExA(IN LPOSVERSIONINFOA lpVersionInformation)
Definition: version.c:69
struct _OSVERSIONINFOEXA OSVERSIONINFOEXA
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:255
#define SetLastError(x)
Definition: compat.h:611
int ret
USHORT wServicePackMajor
Definition: rtltypes.h:261
CHAR szCSDVersion[128]
Definition: rtltypes.h:260
struct _OSVERSIONINFOA OSVERSIONINFOA
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define memset(x, y, z)
Definition: compat.h:39
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_VerifyVersionInfo()

static void test_VerifyVersionInfo ( void  )
static

Definition at line 155 of file version.c.

156 {
157  enum srcversion_mode
158  {
159  SRCVERSION_ZERO = 0,
160  SRCVERSION_CURRENT = 1,
161  SRCVERSION_INC_MINOR = 2,
162  SRCVERSION_INC_SP_MINOR = 3,
163  SRCVERSION_INC_SP_MAJOR = 4,
164  SRCVERSION_DEC_SP_MAJOR = 5,
165  SRCVERSION_DEC_MAJOR = 6,
166  SRCVERSION_INC_BUILD = 7,
167  SRCVERSION_REQUIRES_SP = 0x1000,
168  };
169 
170  struct verify_version_test
171  {
172  DWORD verifymask; /* Type mask for VerifyVersionInfo() */
173  DWORD srcinfo; /* The way current version info is modified. */
174  DWORD err; /* Error code on failure, 0 on success. */
175 
176  DWORD typemask1;
177  DWORD condition1;
178  DWORD typemask2;
179  DWORD condition2;
180  DWORD typemask3;
181  DWORD condition3;
182  DWORD typemask4;
183  DWORD condition4;
184 
185  BOOL todo;
186  } verify_version_tests[] =
187  {
188  {
190  SRCVERSION_INC_MINOR,
191  0,
192 
195  },
196  {
198  SRCVERSION_INC_MINOR,
200 
203  },
204  {
206  SRCVERSION_CURRENT,
207  0,
208 
211  },
212  {
214  SRCVERSION_CURRENT,
215  0,
216 
219  },
220  {
222  SRCVERSION_INC_MINOR,
223  0,
224 
227  },
228  {
230  SRCVERSION_INC_MINOR,
232 
235  },
236  {
238  SRCVERSION_INC_MINOR,
240 
243  },
244  {
246  SRCVERSION_INC_SP_MINOR,
248 
251  },
252  {
254  SRCVERSION_INC_SP_MINOR,
256 
259  },
260  {
262  SRCVERSION_INC_SP_MAJOR,
264 
267  },
268  {
270  SRCVERSION_INC_SP_MINOR,
271  0,
272 
275  },
276  {
278  SRCVERSION_INC_SP_MINOR,
280 
283  },
284  {
286  SRCVERSION_INC_SP_MINOR,
287  0,
288 
292  },
293  {
295  SRCVERSION_INC_SP_MINOR,
297 
301  },
302  {
304  SRCVERSION_INC_SP_MINOR,
305  0,
306 
311  },
312  {
314  SRCVERSION_INC_SP_MINOR,
316 
321  },
322  {
324  SRCVERSION_INC_SP_MAJOR,
325  0,
326 
329  },
330  {
332  SRCVERSION_INC_SP_MAJOR,
334 
337  },
338  {
340  SRCVERSION_INC_SP_MAJOR,
342 
345  },
346  {
348  SRCVERSION_INC_SP_MAJOR,
349  0,
350 
353  },
354  {
356  SRCVERSION_INC_SP_MAJOR,
358 
361  },
362  {
364  SRCVERSION_INC_SP_MAJOR,
365  0,
366 
370  },
371  {
373  SRCVERSION_INC_SP_MAJOR,
375 
378  },
379  {
381  SRCVERSION_DEC_MAJOR,
382  0,
383 
386  },
387  {
389  SRCVERSION_CURRENT,
390  0,
391 
394  },
395  {
397  SRCVERSION_INC_SP_MAJOR,
399 
403  },
404  {
406  SRCVERSION_INC_SP_MAJOR,
408 
412  },
413  {
415  SRCVERSION_INC_SP_MAJOR,
417 
420  },
421  {
423  SRCVERSION_ZERO,
424  0,
425 
427  },
428  {
430  SRCVERSION_ZERO,
432 
434  },
435  {
437  SRCVERSION_ZERO,
438  0,
439 
441  },
442  {
444  SRCVERSION_ZERO,
445  0,
446 
448  },
449  {
451  SRCVERSION_INC_SP_MINOR,
453 
455  },
456  {
458  SRCVERSION_INC_SP_MAJOR,
459  0,
460 
462  },
463  {
465  SRCVERSION_INC_SP_MAJOR,
466  0,
467 
469  },
470  {
472  SRCVERSION_INC_SP_MAJOR,
474 
476  },
477  {
479  SRCVERSION_INC_SP_MAJOR,
481 
483  },
484  {
486  SRCVERSION_INC_MINOR,
488 
490  },
491  {
493  SRCVERSION_INC_MINOR,
495 
497  },
498  {
500  SRCVERSION_CURRENT,
501  0,
502 
504  },
505  {
507  SRCVERSION_INC_BUILD,
509 
511  },
512  {
514  SRCVERSION_INC_BUILD,
515  0,
516 
518  },
519  {
521  SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
522  0,
523 
525  },
526  {
528  SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
529  0,
530 
532  },
533  {
535  SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
537 
540  },
541  {
543  SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
544  0,
545 
549  },
550  {
552  SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
553  0,
554 
558  },
559  {
561  SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
562  0,
563 
567  },
568  {
570  SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
572 
575  },
576  };
577 
579  DWORD servicepack;
580  unsigned int i;
581  BOOL ret;
582 
583  /* Before we start doing some tests we should check what the version of
584  * the ServicePack is. Tests on a box with no ServicePack will fail otherwise.
585  */
586  info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
588  servicepack = info.wServicePackMajor;
589  if (servicepack == 0)
590  skip("There is no ServicePack on this system. Some tests will be skipped.\n");
591 
592  /* Win8.1+ returns Win8 version in GetVersionEx when there's no app manifest targeting 8.1 */
593  if (info.dwMajorVersion == 6 && info.dwMinorVersion == 2)
594  {
595  RTL_OSVERSIONINFOEXW rtlinfo;
596  rtlinfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
597  ok(!pRtlGetVersion(&rtlinfo), "RtlGetVersion failed\n");
598 
599  if (rtlinfo.dwMajorVersion != 6 || rtlinfo.dwMinorVersion != 2)
600  {
601  win_skip("GetVersionEx and VerifyVersionInfo are faking values\n");
602  return;
603  }
604  }
605 
606  for (i = 0; i < sizeof(verify_version_tests)/sizeof(verify_version_tests[0]); i++)
607  {
608  struct verify_version_test *test = &verify_version_tests[i];
609  DWORD srcinfo = test->srcinfo;
610  ULONGLONG mask;
611 
612  if (servicepack == 0 && srcinfo & SRCVERSION_REQUIRES_SP)
613  continue;
614  srcinfo &= ~SRCVERSION_REQUIRES_SP;
615 
616  info.dwOSVersionInfoSize = sizeof(info);
618 
619  switch (srcinfo)
620  {
621  case SRCVERSION_ZERO:
622  memset(&info, 0, sizeof(info));
623  break;
624  case SRCVERSION_INC_MINOR:
625  info.dwMinorVersion++;
626  break;
627  case SRCVERSION_INC_SP_MINOR:
628  info.wServicePackMinor++;
629  break;
630  case SRCVERSION_INC_SP_MAJOR:
631  info.wServicePackMajor++;
632  break;
633  case SRCVERSION_DEC_SP_MAJOR:
634  info.wServicePackMajor--;
635  break;
636  case SRCVERSION_DEC_MAJOR:
637  info.dwMajorVersion--;
638  break;
639  case SRCVERSION_INC_BUILD:
640  info.dwBuildNumber++;
641  break;
642  default:
643  ;
644  }
645 
646  mask = VerSetConditionMask(0, test->typemask1, test->condition1);
647  if (test->typemask2)
648  mask = VerSetConditionMask(mask, test->typemask2, test->condition2);
649  if (test->typemask3)
650  mask = VerSetConditionMask(mask, test->typemask3, test->condition3);
651  if (test->typemask4)
652  mask = VerSetConditionMask(mask, test->typemask4, test->condition4);
653 
654  SetLastError(0xdeadbeef);
655  ret = VerifyVersionInfoA(&info, test->verifymask, mask);
656  todo_wine_if(test->todo)
657  {
658  ok(test->err ? !ret : ret, "%u: unexpected return value %d.\n", i, ret);
659  if (!ret)
660  ok(GetLastError() == test->err, "%u: unexpected error code %d, expected %d.\n", i, GetLastError(), test->err);
661  }
662  }
663 
664  /* test handling of version numbers */
665  /* v3.10 is always less than v4.x even
666  * if the minor version is tested */
667  info.dwMajorVersion = 3;
668  info.dwMinorVersion = 10;
672  ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
673 
674  info.dwMinorVersion = 0;
675  info.wServicePackMajor = 10;
679  ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
680 
681  info.wServicePackMajor = 0;
682  info.wServicePackMinor = 10;
686  ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
687 
688  /* test bad dwOSVersionInfoSize */
689  info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
691  info.dwOSVersionInfoSize = 0;
694  ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
695 }
#define VER_MINORVERSION
Definition: rtltypes.h:226
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:269
#define VER_SUITENAME
Definition: rtltypes.h:232
#define VER_AND
Definition: rtltypes.h:242
ULONGLONG NTAPI VerSetConditionMask(IN ULONGLONG ConditionMask, IN ULONG TypeMask, IN UCHAR Condition)
Definition: version.c:262
#define VER_BUILDNUMBER
Definition: rtltypes.h:228
ULONG dwMinorVersion
Definition: rtltypes.h:271
BOOL todo
Definition: filedlg.c:313
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define test
Definition: rosglue.h:37
BOOL WINAPI VerifyVersionInfoA(IN LPOSVERSIONINFOEXA lpVersionInformation, IN DWORD dwTypeMask, IN DWORDLONG dwlConditionMask)
Definition: version.c:161
ULONG dwMajorVersion
Definition: rtltypes.h:270
GLenum GLint GLuint mask
Definition: glext.h:6028
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _OSVERSIONINFOEXW RTL_OSVERSIONINFOEXW
#define VER_LESS_EQUAL
Definition: rtltypes.h:241
BOOL WINAPI GetVersionExA(IN LPOSVERSIONINFOA lpVersionInformation)
Definition: version.c:69
struct _OSVERSIONINFOEXA OSVERSIONINFOEXA
#define VER_OR
Definition: rtltypes.h:243
#define todo_wine_if(is_todo)
Definition: test.h:165
#define VER_EQUAL
Definition: rtltypes.h:237
uint64_t ULONGLONG
Definition: typedefs.h:67
#define VER_MAJORVERSION
Definition: rtltypes.h:227
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
struct _test_info info[]
Definition: SetCursorPos.c:19
int ret
#define VER_SERVICEPACKMAJOR
Definition: rtltypes.h:231
#define err(...)
#define VER_GREATER
Definition: rtltypes.h:238
#define VER_GREATER_EQUAL
Definition: rtltypes.h:239
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ok(value,...)
Definition: atltest.h:57
#define VER_SERVICEPACKMINOR
Definition: rtltypes.h:230
#define skip(...)
Definition: atltest.h:64
#define ERROR_OLD_WIN_VERSION
Definition: winerror.h:672
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:151
#define VER_LESS
Definition: rtltypes.h:240

Referenced by START_TEST().

Variable Documentation

◆ DWORD

Definition at line 25 of file version.c.