2 * Unit test suite for version functions
4 * Copyright 2006 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
26 static BOOL (WINAPI
* pGetProductInfo
)(DWORD
, DWORD
, DWORD
, DWORD
, DWORD
*);
27 static UINT (WINAPI
* pGetSystemFirmwareTable
)(DWORD
, DWORD
, void *, DWORD
);
28 static LONG (WINAPI
* pPackageIdFromFullName
)(const WCHAR
*, UINT32
, UINT32
*, BYTE
*);
29 static NTSTATUS (WINAPI
* pNtQuerySystemInformation
)(SYSTEM_INFORMATION_CLASS
, void *, ULONG
, ULONG
*);
30 static NTSTATUS (WINAPI
* pRtlGetVersion
)(RTL_OSVERSIONINFOEXW
*);
32 #define GET_PROC(func) \
33 p##func = (void *)GetProcAddress(hmod, #func);
35 /* Firmware table providers */
36 #define ACPI 0x41435049
37 #define FIRM 0x4649524D
38 #define RSMB 0x52534D42
40 static void init_function_pointers(void)
44 hmod
= GetModuleHandleA("kernel32.dll");
46 GET_PROC(GetProductInfo
);
47 GET_PROC(GetSystemFirmwareTable
);
48 GET_PROC(PackageIdFromFullName
);
50 hmod
= GetModuleHandleA("ntdll.dll");
52 GET_PROC(NtQuerySystemInformation
);
53 GET_PROC(RtlGetVersion
);
56 static void test_GetProductInfo(void)
60 DWORD table
[] = {9,8,7,6,
82 /* Not present before Vista */
83 win_skip("GetProductInfo() not available\n");
89 /* SetLastError() / GetLastError(): value is untouched */
91 SetLastError(0xdeadbeef);
92 res
= pGetProductInfo(entry
[0], entry
[1], entry
[2], entry
[3], &product
);
95 ok(res
&& (product
> PRODUCT_UNDEFINED
) && (product
<= PRODUCT_ENTERPRISE_S_N_EVALUATION
),
96 "got %d and 0x%x (expected TRUE and a valid PRODUCT_* value)\n", res
, product
);
98 ok(!res
&& !product
&& (GetLastError() == 0xdeadbeef),
99 "got %d and 0x%x with 0x%x (expected FALSE and PRODUCT_UNDEFINED with LastError untouched)\n",
100 res
, product
, GetLastError());
105 /* NULL pointer is not a problem */
106 SetLastError(0xdeadbeef);
107 res
= pGetProductInfo(6, 1, 0, 0, NULL
);
108 ok( (!res
) && (GetLastError() == 0xdeadbeef),
109 "got %d with 0x%x (expected FALSE with LastError untouched\n", res
, GetLastError());
112 static void test_GetVersionEx(void)
114 OSVERSIONINFOA infoA
;
115 OSVERSIONINFOEXA infoExA
;
120 /* Silently crashes on XP */
124 SetLastError(0xdeadbeef);
125 memset(&infoA
,0,sizeof infoA
);
126 ret
= GetVersionExA(&infoA
);
127 ok(!ret
, "Expected GetVersionExA to fail\n");
128 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
||
129 GetLastError() == 0xdeadbeef /* Win9x */,
130 "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
133 SetLastError(0xdeadbeef);
134 infoA
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOA
) / 2;
135 ret
= GetVersionExA(&infoA
);
136 ok(!ret
, "Expected GetVersionExA to fail\n");
137 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
||
138 GetLastError() == 0xdeadbeef /* Win9x */,
139 "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
142 SetLastError(0xdeadbeef);
143 infoA
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOA
) * 2;
144 ret
= GetVersionExA(&infoA
);
145 ok(!ret
, "Expected GetVersionExA to fail\n");
146 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
||
147 GetLastError() == 0xdeadbeef /* Win9x */,
148 "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
151 SetLastError(0xdeadbeef);
152 infoA
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOA
);
153 ret
= GetVersionExA(&infoA
);
154 ok(ret
, "Expected GetVersionExA to succeed\n");
155 ok(GetLastError() == 0xdeadbeef,
156 "Expected 0xdeadbeef, got %d\n", GetLastError());
158 SetLastError(0xdeadbeef);
159 infoExA
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXA
);
160 ret
= GetVersionExA((OSVERSIONINFOA
*)&infoExA
);
161 ok(ret
, "GetVersionExA failed.\n");
163 if (!infoExA
.wServicePackMajor
&& !infoExA
.wServicePackMinor
)
164 ok(!infoExA
.szCSDVersion
[0], "got '%s'\n", infoExA
.szCSDVersion
);
167 static void test_VerifyVersionInfo(void)
172 SRCVERSION_CURRENT
= 1,
173 SRCVERSION_INC_MINOR
= 2,
174 SRCVERSION_INC_SP_MINOR
= 3,
175 SRCVERSION_INC_SP_MAJOR
= 4,
176 SRCVERSION_DEC_SP_MAJOR
= 5,
177 SRCVERSION_DEC_MAJOR
= 6,
178 SRCVERSION_INC_BUILD
= 7,
179 SRCVERSION_REQUIRES_SP
= 0x1000,
182 struct verify_version_test
184 DWORD verifymask
; /* Type mask for VerifyVersionInfo() */
185 DWORD srcinfo
; /* The way current version info is modified. */
186 DWORD err
; /* Error code on failure, 0 on success. */
196 } verify_version_tests
[] =
199 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
200 SRCVERSION_INC_MINOR
,
203 VER_MAJORVERSION
, VER_EQUAL
,
204 VER_MINORVERSION
, VER_LESS
,
207 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
208 SRCVERSION_INC_MINOR
,
209 ERROR_OLD_WIN_VERSION
,
211 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
212 VER_MINORVERSION
, VER_LESS
,
215 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
219 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
220 VER_MINORVERSION
, VER_LESS
,
223 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
227 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
228 VER_MINORVERSION
, VER_AND
,
231 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
232 SRCVERSION_INC_MINOR
,
235 VER_MAJORVERSION
, VER_LESS_EQUAL
,
236 VER_MINORVERSION
, VER_LESS
,
239 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
240 SRCVERSION_INC_MINOR
,
241 ERROR_OLD_WIN_VERSION
,
243 VER_MAJORVERSION
, VER_AND
,
244 VER_MINORVERSION
, VER_LESS
,
247 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
248 SRCVERSION_INC_MINOR
,
249 ERROR_OLD_WIN_VERSION
,
251 VER_MAJORVERSION
, VER_OR
,
252 VER_MINORVERSION
, VER_LESS
,
255 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
256 SRCVERSION_INC_SP_MINOR
,
257 ERROR_OLD_WIN_VERSION
,
259 VER_MINORVERSION
, VER_EQUAL
,
260 VER_SERVICEPACKMINOR
, VER_LESS
,
263 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
264 SRCVERSION_INC_SP_MINOR
,
265 ERROR_OLD_WIN_VERSION
,
267 VER_MAJORVERSION
, VER_EQUAL
,
268 VER_SERVICEPACKMINOR
, VER_LESS
,
271 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
272 SRCVERSION_INC_SP_MAJOR
,
273 ERROR_OLD_WIN_VERSION
,
275 VER_MAJORVERSION
, VER_EQUAL
,
276 VER_SERVICEPACKMAJOR
, VER_EQUAL
,
279 VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
280 SRCVERSION_INC_SP_MINOR
,
283 VER_SERVICEPACKMAJOR
, VER_EQUAL
,
284 VER_SERVICEPACKMINOR
, VER_LESS
,
287 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
288 SRCVERSION_INC_SP_MINOR
,
289 ERROR_OLD_WIN_VERSION
,
291 VER_SERVICEPACKMAJOR
, VER_EQUAL
,
292 VER_SERVICEPACKMINOR
, VER_LESS
,
295 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
296 SRCVERSION_INC_SP_MINOR
,
299 VER_MINORVERSION
, VER_EQUAL
,
300 VER_SERVICEPACKMAJOR
, VER_EQUAL
,
301 VER_SERVICEPACKMINOR
, VER_LESS
,
304 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
305 SRCVERSION_INC_SP_MINOR
,
306 ERROR_OLD_WIN_VERSION
,
308 VER_MINORVERSION
, VER_EQUAL
,
309 VER_SERVICEPACKMAJOR
, VER_EQUAL
,
310 VER_SERVICEPACKMINOR
, VER_LESS
,
313 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
314 SRCVERSION_INC_SP_MINOR
,
317 VER_MAJORVERSION
, VER_EQUAL
,
318 VER_MINORVERSION
, VER_EQUAL
,
319 VER_SERVICEPACKMAJOR
, VER_EQUAL
,
320 VER_SERVICEPACKMINOR
, VER_LESS
,
323 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
324 SRCVERSION_INC_SP_MINOR
,
325 ERROR_OLD_WIN_VERSION
,
327 VER_MAJORVERSION
, VER_EQUAL
,
328 VER_MINORVERSION
, VER_GREATER_EQUAL
,
329 VER_SERVICEPACKMAJOR
, VER_EQUAL
,
330 VER_SERVICEPACKMINOR
, VER_LESS
,
333 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
334 SRCVERSION_INC_SP_MAJOR
,
337 VER_MAJORVERSION
, VER_LESS_EQUAL
,
338 VER_SERVICEPACKMAJOR
, VER_GREATER
,
341 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
342 SRCVERSION_INC_SP_MAJOR
,
343 ERROR_OLD_WIN_VERSION
,
345 VER_MAJORVERSION
, VER_EQUAL
,
346 VER_SERVICEPACKMAJOR
, VER_LESS
,
349 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
350 SRCVERSION_INC_SP_MAJOR
,
351 ERROR_OLD_WIN_VERSION
,
353 VER_MINORVERSION
, VER_EQUAL
,
354 VER_SERVICEPACKMAJOR
, VER_LESS
,
357 VER_MAJORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
358 SRCVERSION_INC_SP_MAJOR
,
361 VER_MAJORVERSION
, VER_EQUAL
,
362 VER_SERVICEPACKMAJOR
, VER_LESS
,
365 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
366 SRCVERSION_INC_SP_MAJOR
,
367 ERROR_OLD_WIN_VERSION
,
369 VER_MAJORVERSION
, VER_EQUAL
,
370 VER_SERVICEPACKMAJOR
, VER_LESS
,
373 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
374 SRCVERSION_INC_SP_MAJOR
,
377 VER_MAJORVERSION
, VER_EQUAL
,
378 VER_MINORVERSION
, VER_EQUAL
,
379 VER_SERVICEPACKMAJOR
, VER_LESS
,
382 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
383 SRCVERSION_INC_SP_MAJOR
,
384 ERROR_OLD_WIN_VERSION
,
386 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
387 VER_SERVICEPACKMAJOR
, VER_LESS
,
390 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
391 SRCVERSION_DEC_MAJOR
,
394 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
395 VER_SERVICEPACKMAJOR
, VER_LESS
,
398 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
402 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
403 VER_SERVICEPACKMAJOR
, VER_LESS
,
406 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
407 SRCVERSION_INC_SP_MAJOR
,
408 ERROR_OLD_WIN_VERSION
,
410 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
411 VER_MINORVERSION
, VER_EQUAL
,
412 VER_SERVICEPACKMAJOR
, VER_LESS
,
415 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
416 SRCVERSION_INC_SP_MAJOR
,
417 ERROR_OLD_WIN_VERSION
,
419 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
420 VER_MINORVERSION
, VER_GREATER_EQUAL
,
421 VER_SERVICEPACKMAJOR
, VER_LESS_EQUAL
,
424 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
425 SRCVERSION_INC_SP_MAJOR
,
426 ERROR_OLD_WIN_VERSION
,
428 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
429 VER_SERVICEPACKMAJOR
, VER_AND
,
432 VER_MAJORVERSION
| VER_MINORVERSION
,
436 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
439 VER_MAJORVERSION
| VER_MINORVERSION
| VER_BUILDNUMBER
,
441 ERROR_OLD_WIN_VERSION
,
443 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
450 VER_SUITENAME
, VER_AND
,
457 VER_SUITENAME
, VER_OR
,
460 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
461 SRCVERSION_INC_SP_MINOR
,
462 ERROR_OLD_WIN_VERSION
,
464 VER_MINORVERSION
, VER_GREATER_EQUAL
,
467 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
468 SRCVERSION_INC_SP_MAJOR
,
471 VER_MINORVERSION
, VER_LESS
,
474 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
475 SRCVERSION_INC_SP_MAJOR
,
478 VER_MINORVERSION
, VER_LESS_EQUAL
,
481 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
482 SRCVERSION_INC_SP_MAJOR
,
483 ERROR_OLD_WIN_VERSION
,
485 VER_MINORVERSION
, VER_EQUAL
,
488 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
489 SRCVERSION_INC_SP_MAJOR
,
490 ERROR_OLD_WIN_VERSION
,
492 VER_MINORVERSION
, VER_GREATER_EQUAL
,
495 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
496 SRCVERSION_INC_MINOR
,
497 ERROR_OLD_WIN_VERSION
,
499 VER_MINORVERSION
, VER_GREATER_EQUAL
,
502 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
503 SRCVERSION_INC_MINOR
,
504 ERROR_OLD_WIN_VERSION
,
506 VER_MINORVERSION
, VER_GREATER_EQUAL
,
509 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
513 VER_MINORVERSION
, VER_GREATER_EQUAL
,
516 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
517 SRCVERSION_INC_BUILD
,
518 ERROR_OLD_WIN_VERSION
,
520 VER_MINORVERSION
, VER_GREATER_EQUAL
,
523 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
524 SRCVERSION_INC_BUILD
,
527 VER_MINORVERSION
, VER_GREATER_EQUAL
,
530 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
531 SRCVERSION_DEC_SP_MAJOR
| SRCVERSION_REQUIRES_SP
,
534 VER_MINORVERSION
, VER_GREATER
,
537 VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
538 SRCVERSION_DEC_SP_MAJOR
| SRCVERSION_REQUIRES_SP
,
541 VER_MINORVERSION
, VER_GREATER_EQUAL
,
544 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
545 SRCVERSION_DEC_SP_MAJOR
| SRCVERSION_REQUIRES_SP
,
546 ERROR_OLD_WIN_VERSION
,
548 VER_MAJORVERSION
, VER_EQUAL
,
549 VER_SERVICEPACKMAJOR
, VER_GREATER
,
552 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
553 SRCVERSION_DEC_SP_MAJOR
| SRCVERSION_REQUIRES_SP
,
556 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
557 VER_MINORVERSION
, VER_EQUAL
,
558 VER_SERVICEPACKMAJOR
, VER_GREATER
,
561 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
562 SRCVERSION_DEC_SP_MAJOR
| SRCVERSION_REQUIRES_SP
,
565 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
566 VER_MINORVERSION
, VER_LESS_EQUAL
,
567 VER_SERVICEPACKMAJOR
, VER_GREATER
,
570 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
571 SRCVERSION_DEC_SP_MAJOR
| SRCVERSION_REQUIRES_SP
,
574 VER_MAJORVERSION
, VER_GREATER_EQUAL
,
575 VER_MINORVERSION
, VER_AND
,
576 VER_SERVICEPACKMAJOR
, VER_GREATER
,
579 VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
580 SRCVERSION_DEC_SP_MAJOR
| SRCVERSION_REQUIRES_SP
,
581 ERROR_OLD_WIN_VERSION
,
583 VER_SERVICEPACKMAJOR
, VER_GREATER
,
584 VER_SERVICEPACKMINOR
, VER_EQUAL
,
588 OSVERSIONINFOEXA info
;
593 /* Before we start doing some tests we should check what the version of
594 * the ServicePack is. Tests on a box with no ServicePack will fail otherwise.
596 info
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXA
);
597 GetVersionExA((OSVERSIONINFOA
*)&info
);
598 servicepack
= info
.wServicePackMajor
;
599 if (servicepack
== 0)
600 skip("There is no ServicePack on this system. Some tests will be skipped.\n");
602 /* Win8.1+ returns Win8 version in GetVersionEx when there's no app manifest targeting 8.1 */
603 if (info
.dwMajorVersion
== 6 && info
.dwMinorVersion
== 2)
605 RTL_OSVERSIONINFOEXW rtlinfo
;
606 rtlinfo
.dwOSVersionInfoSize
= sizeof(RTL_OSVERSIONINFOEXW
);
607 ok(!pRtlGetVersion(&rtlinfo
), "RtlGetVersion failed\n");
609 if (rtlinfo
.dwMajorVersion
!= 6 || rtlinfo
.dwMinorVersion
!= 2)
611 skip("GetVersionEx and VerifyVersionInfo are faking values\n");
616 for (i
= 0; i
< ARRAY_SIZE(verify_version_tests
); i
++)
618 struct verify_version_test
*test
= &verify_version_tests
[i
];
619 DWORD srcinfo
= test
->srcinfo
;
622 if (servicepack
== 0 && srcinfo
& SRCVERSION_REQUIRES_SP
)
624 srcinfo
&= ~SRCVERSION_REQUIRES_SP
;
626 info
.dwOSVersionInfoSize
= sizeof(info
);
627 GetVersionExA((OSVERSIONINFOA
*)&info
);
631 case SRCVERSION_ZERO
:
632 memset(&info
, 0, sizeof(info
));
634 case SRCVERSION_INC_MINOR
:
635 info
.dwMinorVersion
++;
637 case SRCVERSION_INC_SP_MINOR
:
638 info
.wServicePackMinor
++;
640 case SRCVERSION_INC_SP_MAJOR
:
641 info
.wServicePackMajor
++;
643 case SRCVERSION_DEC_SP_MAJOR
:
644 info
.wServicePackMajor
--;
646 case SRCVERSION_DEC_MAJOR
:
647 info
.dwMajorVersion
--;
649 case SRCVERSION_INC_BUILD
:
650 info
.dwBuildNumber
++;
656 mask
= VerSetConditionMask(0, test
->typemask1
, test
->condition1
);
658 mask
= VerSetConditionMask(mask
, test
->typemask2
, test
->condition2
);
660 mask
= VerSetConditionMask(mask
, test
->typemask3
, test
->condition3
);
662 mask
= VerSetConditionMask(mask
, test
->typemask4
, test
->condition4
);
664 SetLastError(0xdeadbeef);
665 ret
= VerifyVersionInfoA(&info
, test
->verifymask
, mask
);
666 ok(test
->err
? !ret
: ret
, "%u: unexpected return value %d.\n", i
, ret
);
668 ok(GetLastError() == test
->err
, "%u: unexpected error code %d, expected %d.\n", i
, GetLastError(), test
->err
);
671 /* test handling of version numbers */
672 /* v3.10 is always less than v4.x even
673 * if the minor version is tested */
674 info
.dwMajorVersion
= 3;
675 info
.dwMinorVersion
= 10;
676 ret
= VerifyVersionInfoA(&info
, VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
677 VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
),
678 VER_MAJORVERSION
, VER_GREATER_EQUAL
));
679 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
681 info
.dwMinorVersion
= 0;
682 info
.wServicePackMajor
= 10;
683 ret
= VerifyVersionInfoA(&info
, VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
684 VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
),
685 VER_MAJORVERSION
, VER_GREATER_EQUAL
));
686 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
688 info
.wServicePackMajor
= 0;
689 info
.wServicePackMinor
= 10;
690 ret
= VerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
691 VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
),
692 VER_MAJORVERSION
, VER_GREATER_EQUAL
));
693 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
695 /* test bad dwOSVersionInfoSize */
696 info
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXA
);
697 GetVersionExA((OSVERSIONINFOA
*)&info
);
698 info
.dwOSVersionInfoSize
= 0;
699 ret
= VerifyVersionInfoA(&info
, VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
700 VerSetConditionMask(0, VER_MAJORVERSION
, VER_GREATER_EQUAL
));
701 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
704 static void test_GetSystemFirmwareTable(void)
706 static const ULONG min_sfti_len
= FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION
, TableBuffer
);
709 SYSTEM_FIRMWARE_TABLE_INFORMATION
*sfti
;
712 if (!pGetSystemFirmwareTable
)
714 win_skip("GetSystemFirmwareTable not available\n");
718 sfti
= HeapAlloc(GetProcessHeap(), 0, min_sfti_len
);
719 ok(!!sfti
, "Failed to allocate memory\n");
720 sfti
->ProviderSignature
= RSMB
;
721 sfti
->Action
= SystemFirmwareTable_Get
;
723 pNtQuerySystemInformation(SystemFirmwareTableInformation
, sfti
, min_sfti_len
, &expected_len
);
724 if (expected_len
== 0) /* xp, 2003 */
726 win_skip("SystemFirmwareTableInformation is not available\n");
727 HeapFree(GetProcessHeap(), 0, sfti
);
730 sfti
= HeapReAlloc(GetProcessHeap(), 0, sfti
, expected_len
);
731 ok(!!sfti
, "Failed to allocate memory\n");
732 pNtQuerySystemInformation(SystemFirmwareTableInformation
, sfti
, expected_len
, &expected_len
);
734 expected_len
-= min_sfti_len
;
735 len
= pGetSystemFirmwareTable(RSMB
, 0, NULL
, 0);
736 ok(len
== expected_len
, "Expected length %u, got %u\n", expected_len
, len
);
738 smbios_table
= HeapAlloc(GetProcessHeap(), 0, expected_len
);
739 len
= pGetSystemFirmwareTable(RSMB
, 0, smbios_table
, expected_len
);
740 ok(len
== expected_len
, "Expected length %u, got %u\n", expected_len
, len
);
741 ok(len
== 0 || !memcmp(smbios_table
, sfti
->TableBuffer
, 6),
742 "Expected prologue %02x %02x %02x %02x %02x %02x, got %02x %02x %02x %02x %02x %02x\n",
743 sfti
->TableBuffer
[0], sfti
->TableBuffer
[1], sfti
->TableBuffer
[2],
744 sfti
->TableBuffer
[3], sfti
->TableBuffer
[4], sfti
->TableBuffer
[5],
745 smbios_table
[0], smbios_table
[1], smbios_table
[2],
746 smbios_table
[3], smbios_table
[4], smbios_table
[5]);
748 HeapFree(GetProcessHeap(), 0, sfti
);
749 HeapFree(GetProcessHeap(), 0, smbios_table
);
760 {PROCESSOR_ARCHITECTURE_INTEL
, L
"X86"},
761 {PROCESSOR_ARCHITECTURE_ARM
, L
"Arm"},
762 {PROCESSOR_ARCHITECTURE_AMD64
, L
"X64"},
763 {PROCESSOR_ARCHITECTURE_NEUTRAL
, L
"Neutral"},
764 {PROCESSOR_ARCHITECTURE_ARM64
, L
"Arm64", TRUE
/* Before Win10. */},
765 {PROCESSOR_ARCHITECTURE_UNKNOWN
, L
"Unknown", TRUE
/* Before Win10 1709. */},
768 static const WCHAR
*arch_string_from_code(UINT32 arch
)
772 for (i
= 0; i
< ARRAY_SIZE(arch_data
); ++i
)
773 if (arch_data
[i
].code
== arch
)
774 return arch_data
[i
].name
;
779 static unsigned int get_package_str_size(const WCHAR
*str
)
781 return str
? (lstrlenW(str
) + 1) * sizeof(*str
) : 0;
784 static unsigned int get_package_id_size(const PACKAGE_ID
*id
)
786 return sizeof(*id
) + get_package_str_size(id
->name
)
787 + get_package_str_size(id
->resourceId
) + 14 * sizeof(WCHAR
);
790 static void packagefullname_from_packageid(WCHAR
*buffer
, size_t count
, const PACKAGE_ID
*id
)
792 swprintf(buffer
, count
, L
"%s_%u.%u.%u.%u_%s_%s_%s", id
->name
, id
->version
.Major
,
793 id
->version
.Minor
, id
->version
.Build
, id
->version
.Revision
,
794 arch_string_from_code(id
->processorArchitecture
), id
->resourceId
,
798 static void test_PackageIdFromFullName(void)
800 static const PACKAGE_ID test_package_id
=
802 0, PROCESSOR_ARCHITECTURE_INTEL
,
803 {{.Major
= 1, .Minor
= 2, .Build
= 3, .Revision
= 4}},
804 (WCHAR
*)L
"TestPackage", NULL
,
805 (WCHAR
*)L
"TestResourceId", (WCHAR
*)L
"0abcdefghjkme"
807 UINT32 size
, expected_size
;
815 if (!pPackageIdFromFullName
)
817 win_skip("PackageIdFromFullName not available.\n");
821 packagefullname_from_packageid(fullname
, ARRAY_SIZE(fullname
), &test_package_id
);
823 id
= (PACKAGE_ID
*)id_buffer
;
825 memset(id_buffer
, 0xcc, sizeof(id_buffer
));
826 expected_size
= get_package_id_size(&test_package_id
);
827 size
= sizeof(id_buffer
);
828 ret
= pPackageIdFromFullName(fullname
, 0, &size
, id_buffer
);
829 ok(ret
== ERROR_SUCCESS
, "Got unexpected ret %u.\n", ret
);
830 ok(size
== expected_size
, "Got unexpected length %u, expected %u.\n", size
, expected_size
);
831 ok(!lstrcmpW(id
->name
, test_package_id
.name
), "Got unexpected name %s.\n", debugstr_w(id
->name
));
832 ok(!lstrcmpW(id
->resourceId
, test_package_id
.resourceId
), "Got unexpected resourceId %s.\n",
833 debugstr_w(id
->resourceId
));
834 ok(!lstrcmpW(id
->publisherId
, test_package_id
.publisherId
), "Got unexpected publisherId %s.\n",
835 debugstr_w(id
->publisherId
));
836 ok(!id
->publisher
, "Got unexpected publisher %s.\n", debugstr_w(id
->publisher
));
837 ok(id
->processorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
, "Got unexpected processorArchitecture %u.\n",
838 id
->processorArchitecture
);
839 ok(id
->version
.Version
== 0x0001000200030004, "Got unexpected Version %s.\n",
840 wine_dbgstr_longlong(id
->version
.Version
));
841 ok((BYTE
*)id
->name
== id_buffer
+ sizeof(*id
), "Got unexpected name %p, buffer %p.\n", id
->name
, id_buffer
);
842 ok((BYTE
*)id
->resourceId
== (BYTE
*)id
->name
+ (lstrlenW(id
->name
) + 1) * 2,
843 "Got unexpected resourceId %p, buffer %p.\n", id
->resourceId
, id_buffer
);
844 ok((BYTE
*)id
->publisherId
== (BYTE
*)id
->resourceId
+ (lstrlenW(id
->resourceId
) + 1) * 2,
845 "Got unexpected publisherId %p, buffer %p.\n", id
->resourceId
, id_buffer
);
847 ret
= pPackageIdFromFullName(fullname
, 0, NULL
, id_buffer
);
848 ok(ret
== ERROR_INVALID_PARAMETER
, "Got unexpected ret %d.\n", ret
);
850 size
= sizeof(id_buffer
);
851 ret
= pPackageIdFromFullName(NULL
, 0, &size
, id_buffer
);
852 ok(ret
== ERROR_INVALID_PARAMETER
, "Got unexpected ret %d.\n", ret
);
853 ok(size
== sizeof(id_buffer
), "Got unexpected size %u.\n", size
);
855 size
= sizeof(id_buffer
);
856 ret
= pPackageIdFromFullName(fullname
, 0, &size
, NULL
);
857 ok(ret
== ERROR_INVALID_PARAMETER
, "Got unexpected ret %d.\n", ret
);
858 ok(size
== sizeof(id_buffer
), "Got unexpected size %u.\n", size
);
860 size
= expected_size
- 1;
861 ret
= pPackageIdFromFullName(fullname
, 0, &size
, NULL
);
862 ok(ret
== ERROR_INVALID_PARAMETER
, "Got unexpected ret %d.\n", ret
);
863 ok(size
== expected_size
- 1, "Got unexpected size %u.\n", size
);
865 size
= expected_size
- 1;
866 ret
= pPackageIdFromFullName(fullname
, 0, &size
, id_buffer
);
867 ok(ret
== ERROR_INSUFFICIENT_BUFFER
, "Got unexpected ret %d.\n", ret
);
868 ok(size
== expected_size
, "Got unexpected size %u.\n", size
);
871 ret
= pPackageIdFromFullName(fullname
, 0, &size
, NULL
);
872 ok(ret
== ERROR_INSUFFICIENT_BUFFER
, "Got unexpected ret %d.\n", ret
);
873 ok(size
== expected_size
, "Got unexpected size %u.\n", size
);
875 for (i
= 0; i
< ARRAY_SIZE(arch_data
); ++i
)
877 test_id
= test_package_id
;
878 test_id
.processorArchitecture
= arch_data
[i
].code
;
879 packagefullname_from_packageid(fullname
, ARRAY_SIZE(fullname
), &test_id
);
880 size
= expected_size
;
881 ret
= pPackageIdFromFullName(fullname
, 0, &size
, id_buffer
);
882 ok(ret
== ERROR_SUCCESS
|| broken(arch_data
[i
].broken
&& ret
== ERROR_INVALID_PARAMETER
),
883 "Got unexpected ret %u.\n", ret
);
884 if (ret
!= ERROR_SUCCESS
)
886 ok(size
== expected_size
, "Got unexpected length %u, expected %u.\n", size
, expected_size
);
887 ok(id
->processorArchitecture
== arch_data
[i
].code
, "Got unexpected processorArchitecture %u, arch %S.\n",
888 id
->processorArchitecture
, arch_data
[i
].name
);
891 size
= sizeof(id_buffer
);
892 ret
= pPackageIdFromFullName(L
"TestPackage_1.2.3.4_X86_TestResourceId_0abcdefghjkme", 0, &size
, id_buffer
);
893 ok(ret
== ERROR_SUCCESS
, "Got unexpected ret %u.\n", ret
);
895 size
= sizeof(id_buffer
);
896 ret
= pPackageIdFromFullName(L
"TestPackage_1.2.3.4_X86_TestResourceId_abcdefghjkme", 0, &size
, id_buffer
);
897 ok(ret
== ERROR_INVALID_PARAMETER
, "Got unexpected ret %u.\n", ret
);
899 size
= sizeof(id_buffer
);
900 ret
= pPackageIdFromFullName(L
"TestPackage_1.2.3.4_X86_TestResourceId_0abcdefghjkmee", 0, &size
, id_buffer
);
901 ok(ret
== ERROR_INVALID_PARAMETER
, "Got unexpected ret %u.\n", ret
);
903 size
= sizeof(id_buffer
);
904 ret
= pPackageIdFromFullName(L
"TestPackage_1.2.3_X86_TestResourceId_0abcdefghjkme", 0, &size
, id_buffer
);
905 ok(ret
== ERROR_INVALID_PARAMETER
, "Got unexpected ret %u.\n", ret
);
907 size
= sizeof(id_buffer
);
908 ret
= pPackageIdFromFullName(L
"TestPackage_1.2.3.4_X86_TestResourceId_0abcdefghjkme_", 0, &size
, id_buffer
);
909 ok(ret
== ERROR_INVALID_PARAMETER
, "Got unexpected ret %u.\n", ret
);
911 size
= sizeof(id_buffer
);
912 ret
= pPackageIdFromFullName(L
"TestPackage_1.2.3.4_X86__0abcdefghjkme", 0, &size
, id_buffer
);
913 ok(ret
== ERROR_SUCCESS
, "Got unexpected ret %u.\n", ret
);
914 ok(!lstrcmpW(id
->resourceId
, L
""), "Got unexpected resourceId %s.\n", debugstr_w(id
->resourceId
));
916 size
= sizeof(id_buffer
);
917 ret
= pPackageIdFromFullName(L
"TestPackage_1.2.3.4_X86_0abcdefghjkme", 0, &size
, id_buffer
);
918 ok(ret
== ERROR_INVALID_PARAMETER
, "Got unexpected ret %u.\n", ret
);
923 init_function_pointers();
925 test_GetProductInfo();
927 test_VerifyVersionInfo();
928 test_GetSystemFirmwareTable();
929 test_PackageIdFromFullName();