Autosyncing with Wine HEAD
[reactos.git] / rostests / winetests / version / info.c
1 /*
2 * Copyright (C) 2004 Stefan Leichter
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #include <stdarg.h>
20 #include <stdio.h>
21 #include <assert.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "winver.h"
27 #include "wine/test.h"
28
29 #define MY_LAST_ERROR ((DWORD)-1)
30 #define EXPECT_BAD_PATH__NOT_FOUND \
31 ok( (ERROR_PATH_NOT_FOUND == GetLastError()) || \
32 (ERROR_RESOURCE_DATA_NOT_FOUND == GetLastError()) || \
33 (ERROR_FILE_NOT_FOUND == GetLastError()) || \
34 (ERROR_BAD_PATHNAME == GetLastError()), \
35 "Last error wrong! ERROR_RESOURCE_DATA_NOT_FOUND/ERROR_BAD_PATHNAME (98)/" \
36 "ERROR_PATH_NOT_FOUND (NT4)/ERROR_FILE_NOT_FOUND (2k3)" \
37 "expected, got %u\n", GetLastError());
38 #define EXPECT_INVALID__NOT_FOUND \
39 ok( (ERROR_PATH_NOT_FOUND == GetLastError()) || \
40 (ERROR_RESOURCE_DATA_NOT_FOUND == GetLastError()) || \
41 (ERROR_FILE_NOT_FOUND == GetLastError()) || \
42 (ERROR_INVALID_PARAMETER == GetLastError()), \
43 "Last error wrong! ERROR_RESOURCE_DATA_NOT_FOUND/ERROR_INVALID_PARAMETER (98)/" \
44 "ERROR_PATH_NOT_FOUND (NT4)/ERROR_FILE_NOT_FOUND (2k3)" \
45 "expected, got %u\n", GetLastError());
46
47 static void create_file(const CHAR *name)
48 {
49 HANDLE file;
50 DWORD written;
51
52 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
53 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
54 WriteFile(file, name, strlen(name), &written, NULL);
55 WriteFile(file, "\n", strlen("\n"), &written, NULL);
56 CloseHandle(file);
57 }
58
59 static void test_info_size(void)
60 { DWORD hdl, retval;
61 char mypath[MAX_PATH] = "";
62
63 SetLastError(MY_LAST_ERROR);
64 retval = GetFileVersionInfoSizeA( NULL, NULL);
65 ok( !retval,
66 "GetFileVersionInfoSizeA result wrong! 0L expected, got 0x%08x\n",
67 retval);
68 EXPECT_INVALID__NOT_FOUND;
69
70 hdl = 0x55555555;
71 SetLastError(MY_LAST_ERROR);
72 retval = GetFileVersionInfoSizeA( NULL, &hdl);
73 ok( !retval,
74 "GetFileVersionInfoSizeA result wrong! 0L expected, got 0x%08x\n",
75 retval);
76 EXPECT_INVALID__NOT_FOUND;
77 ok( hdl == 0L,
78 "Handle wrong! 0L expected, got 0x%08x\n", hdl);
79
80 SetLastError(MY_LAST_ERROR);
81 retval = GetFileVersionInfoSizeA( "", NULL);
82 ok( !retval,
83 "GetFileVersionInfoSizeA result wrong! 0L expected, got 0x%08x\n",
84 retval);
85 EXPECT_BAD_PATH__NOT_FOUND;
86
87 hdl = 0x55555555;
88 SetLastError(MY_LAST_ERROR);
89 retval = GetFileVersionInfoSizeA( "", &hdl);
90 ok( !retval,
91 "GetFileVersionInfoSizeA result wrong! 0L expected, got 0x%08x\n",
92 retval);
93 EXPECT_BAD_PATH__NOT_FOUND;
94 ok( hdl == 0L,
95 "Handle wrong! 0L expected, got 0x%08x\n", hdl);
96
97 SetLastError(MY_LAST_ERROR);
98 retval = GetFileVersionInfoSizeA( "kernel32.dll", NULL);
99 ok( retval,
100 "GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08x\n",
101 retval);
102 ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()),
103 "Last error wrong! NO_ERROR/0x%08x (NT4) expected, got %u\n",
104 MY_LAST_ERROR, GetLastError());
105
106 hdl = 0x55555555;
107 SetLastError(MY_LAST_ERROR);
108 retval = GetFileVersionInfoSizeA( "kernel32.dll", &hdl);
109 ok( retval,
110 "GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08x\n",
111 retval);
112 ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()),
113 "Last error wrong! NO_ERROR/0x%08x (NT4) expected, got %u\n",
114 MY_LAST_ERROR, GetLastError());
115 ok( hdl == 0L,
116 "Handle wrong! 0L expected, got 0x%08x\n", hdl);
117
118 SetLastError(MY_LAST_ERROR);
119 retval = GetFileVersionInfoSizeA( "notexist.dll", NULL);
120 ok( !retval,
121 "GetFileVersionInfoSizeA result wrong! 0L expected, got 0x%08x\n",
122 retval);
123 ok( (ERROR_FILE_NOT_FOUND == GetLastError()) ||
124 (ERROR_RESOURCE_DATA_NOT_FOUND == GetLastError()) ||
125 (MY_LAST_ERROR == GetLastError()),
126 "Last error wrong! ERROR_FILE_NOT_FOUND/ERROR_RESOURCE_DATA_NOT_FOUND "
127 "(XP)/0x%08x (NT4) expected, got %u\n", MY_LAST_ERROR, GetLastError());
128
129 /* test a currently loaded executable */
130 if(GetModuleFileNameA(NULL, mypath, MAX_PATH)) {
131 hdl = 0x55555555;
132 SetLastError(MY_LAST_ERROR);
133 retval = GetFileVersionInfoSizeA( mypath, &hdl);
134 ok( retval,
135 "GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08x\n",
136 retval);
137 ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()),
138 "Last error wrong! NO_ERROR/0x%08x (NT4) expected, got %u\n",
139 MY_LAST_ERROR, GetLastError());
140 ok( hdl == 0L,
141 "Handle wrong! 0L expected, got 0x%08x\n", hdl);
142 }
143 else
144 trace("skipping GetModuleFileNameA(NULL,..) failed\n");
145
146 /* test a not loaded executable */
147 if(GetSystemDirectoryA(mypath, MAX_PATH)) {
148 lstrcatA(mypath, "\\regsvr32.exe");
149
150 if(INVALID_FILE_ATTRIBUTES == GetFileAttributesA(mypath))
151 trace("GetFileAttributesA(%s) failed\n", mypath);
152 else {
153 hdl = 0x55555555;
154 SetLastError(MY_LAST_ERROR);
155 retval = GetFileVersionInfoSizeA( mypath, &hdl);
156 ok( retval,
157 "GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08x\n",
158 retval);
159 ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()),
160 "Last error wrong! NO_ERROR/0x%08x (NT4) expected, got %u\n",
161 MY_LAST_ERROR, GetLastError());
162 ok( hdl == 0L,
163 "Handle wrong! 0L expected, got 0x%08x\n", hdl);
164 }
165 }
166 else
167 trace("skipping GetModuleFileNameA(NULL,..) failed\n");
168
169 create_file("test.txt");
170
171 /* no version info */
172 SetLastError(0xdeadbeef);
173 hdl = 0xcafe;
174 retval = GetFileVersionInfoSizeA("test.txt", &hdl);
175 ok(retval == 0, "Expected 0, got %d\n", retval);
176 ok(hdl == 0, "Expected 0, got %d\n", hdl);
177 ok(GetLastError() == ERROR_RESOURCE_DATA_NOT_FOUND,
178 "Expected ERROR_RESOURCE_DATA_NOT_FOUND, got %d\n", GetLastError());
179
180 DeleteFileA("test.txt");
181 }
182
183 static void VersionDwordLong2String(DWORDLONG Version, LPSTR lpszVerString)
184 {
185 WORD a, b, c, d;
186
187 a = (WORD)(Version >> 48);
188 b = (WORD)((Version >> 32) & 0xffff);
189 c = (WORD)((Version >> 16) & 0xffff);
190 d = (WORD)(Version & 0xffff);
191
192 sprintf(lpszVerString, "%d.%d.%d.%d", a, b, c, d);
193
194 return;
195 }
196
197 static void test_info(void)
198 {
199 DWORD hdl, retval;
200 PVOID pVersionInfo = NULL;
201 BOOL boolret;
202 VS_FIXEDFILEINFO *pFixedVersionInfo;
203 UINT uiLength;
204 char VersionString[MAX_PATH];
205 static CHAR backslash[] = "\\";
206 DWORDLONG dwlVersion;
207
208 hdl = 0x55555555;
209 SetLastError(MY_LAST_ERROR);
210 retval = GetFileVersionInfoSizeA( "kernel32.dll", &hdl);
211 ok( retval,
212 "GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08x\n",
213 retval);
214 ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()),
215 "Last error wrong! NO_ERROR/0x%08x (NT4) expected, got %u\n",
216 MY_LAST_ERROR, GetLastError());
217 ok( hdl == 0L,
218 "Handle wrong! 0L expected, got 0x%08x\n", hdl);
219
220 if ( retval == 0 || hdl != 0)
221 return;
222
223 pVersionInfo = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, retval );
224 ok(pVersionInfo != 0, "HeapAlloc failed\n" );
225 if (pVersionInfo == 0)
226 return;
227
228 if (0)
229 {
230 /* this test crashes on WinNT4
231 */
232 boolret = GetFileVersionInfoA( "kernel32.dll", 0, retval, 0);
233 ok (!boolret, "GetFileVersionInfoA should have failed: GetLastError = %u\n", GetLastError());
234 ok ((GetLastError() == ERROR_INVALID_DATA) || (GetLastError() == ERROR_BAD_PATHNAME) ||
235 (GetLastError() == NO_ERROR),
236 "Last error wrong! ERROR_INVALID_DATA/ERROR_BAD_PATHNAME (ME)/"
237 "NO_ERROR (95) expected, got %u\n",
238 GetLastError());
239 }
240
241 boolret = GetFileVersionInfoA( "kernel32.dll", 0, retval, pVersionInfo );
242 ok (boolret, "GetFileVersionInfoA failed: GetLastError = %u\n", GetLastError());
243 if (!boolret)
244 goto cleanup;
245
246 boolret = VerQueryValueA( pVersionInfo, backslash, (LPVOID *)&pFixedVersionInfo, &uiLength );
247 ok (boolret, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
248 if (!boolret)
249 goto cleanup;
250
251 dwlVersion = (((DWORDLONG)pFixedVersionInfo->dwFileVersionMS) << 32) +
252 pFixedVersionInfo->dwFileVersionLS;
253
254 VersionDwordLong2String(dwlVersion, VersionString);
255
256 trace("kernel32.dll version: %s\n", VersionString);
257
258 if (0)
259 {
260 /* this test crashes on WinNT4
261 */
262 boolret = VerQueryValueA( pVersionInfo, backslash, (LPVOID *)&pFixedVersionInfo, 0);
263 ok (boolret, "VerQueryValue failed: GetLastError = %u\n", GetLastError());
264 }
265
266 cleanup:
267 HeapFree( GetProcessHeap(), 0, pVersionInfo);
268 }
269
270 static void test_32bit_win(void)
271 {
272 DWORD hdlA, retvalA;
273 DWORD hdlW, retvalW = 0;
274 BOOL retA,retW;
275 PVOID pVersionInfoA = NULL;
276 PVOID pVersionInfoW = NULL;
277 char *pBufA;
278 WCHAR *pBufW;
279 UINT uiLengthA, uiLengthW;
280 char mypathA[MAX_PATH];
281 WCHAR mypathW[MAX_PATH];
282 char rootA[] = "\\";
283 WCHAR rootW[] = { '\\', 0 };
284 char varfileinfoA[] = "\\VarFileInfo\\Translation";
285 WCHAR varfileinfoW[] = { '\\','V','a','r','F','i','l','e','I','n','f','o',
286 '\\','T','r','a','n','s','l','a','t','i','o','n', 0 };
287 char WineVarFileInfoA[] = { 0x09, 0x04, 0xE4, 0x04 };
288 char FileDescriptionA[] = "\\StringFileInfo\\040904E4\\FileDescription";
289 WCHAR FileDescriptionW[] = { '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
290 '\\','0','4','0','9','0','4','E','4',
291 '\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n', 0 };
292 char WineFileDescriptionA[] = "FileDescription";
293 WCHAR WineFileDescriptionW[] = { 'F','i','l','e','D','e','s','c','r','i','p','t','i','o','n', 0 };
294 BOOL is_unicode_enabled = TRUE;
295
296 /* A copy from dlls/version/info.c */
297 typedef struct
298 {
299 WORD wLength;
300 WORD wValueLength;
301 WORD wType;
302 WCHAR szKey[1];
303 #if 0 /* variable length structure */
304 /* DWORD aligned */
305 BYTE Value[];
306 /* DWORD aligned */
307 VS_VERSION_INFO_STRUCT32 Children[];
308 #endif
309 } VS_VERSION_INFO_STRUCT32;
310
311 /* If we call GetFileVersionInfoA on a system that supports Unicode, NT/W2K/XP/W2K3 (by default) and Wine,
312 * the versioninfo will contain Unicode strings.
313 * Part of the test is to call both the A and W versions, which should have the same Version Information
314 * for some requests, on systems that support both calls.
315 */
316
317 /* First get the versioninfo via the W versions */
318 SetLastError(0xdeadbeef);
319 GetModuleFileNameW(NULL, mypathW, MAX_PATH);
320 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
321 {
322 trace("GetModuleFileNameW not existing on this platform, skipping comparison between A- and W-calls\n");
323 is_unicode_enabled = FALSE;
324 }
325
326 if (is_unicode_enabled)
327 {
328 retvalW = GetFileVersionInfoSizeW( mypathW, &hdlW);
329 pVersionInfoW = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, retvalW );
330 retW = GetFileVersionInfoW( mypathW, 0, retvalW, pVersionInfoW );
331 }
332
333 GetModuleFileNameA(NULL, mypathA, MAX_PATH);
334 retvalA = GetFileVersionInfoSizeA( mypathA, &hdlA);
335 pVersionInfoA = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, retvalA );
336 retA = GetFileVersionInfoA( mypathA, 0, retvalA, pVersionInfoA );
337
338 if (is_unicode_enabled)
339 {
340 ok( retvalA == retvalW, "The size of the struct should be the same for both A/W calls, it is (%d) vs. (%d)\n",
341 retvalA, retvalW);
342 ok( !memcmp(pVersionInfoA, pVersionInfoW, retvalA), "Both structs should be the same, they aren't\n");
343 }
344
345 /* The structs on Windows are bigger than just the struct for the basic information. The total struct
346 * contains also an empty part, which is used for converted strings. The converted strings are a result
347 * of calling VerQueryValueA on a 32bit resource and calling VerQueryValueW on a 16bit resource.
348 * The first WORD of the structure (wLength) shows the size of the base struct. The total struct size depends
349 * on the Windows version:
350 *
351 * 16bits resource (numbers are from a sample app):
352 *
353 * Windows Version Retrieved with A/W wLength StructSize
354 * ====================================================================================
355 * Win98 A 0x01B4 (436) 436
356 * NT4 A/W 0x01B4 (436) 2048 ???
357 * W2K/XP/W2K3 A/W 0x01B4 (436) 1536 which is (436 - sizeof(VS_FIXEDFILEINFO)) * 4
358 *
359 * 32bits resource (numbers are from this test executable version_crosstest.exe):
360 * Windows Version Retrieved with A/W wLength StructSize
361 * =============================================================
362 * Win98 A 0x01E0 (480) 848 (structure data doesn't seem correct)
363 * NT4 A/W 0x0350 (848) 1272 (848 * 1.5)
364 * W2K/XP/W2K3 A/W 0x0350 (848) 1700 which is (848 * 2) + 4
365 *
366 * Wine will follow the implementation (eventually) of W2K/XP/W2K3
367 */
368
369 /* Now some tests for the above (only if we are unicode enabled) */
370
371 if (is_unicode_enabled)
372 {
373 VS_VERSION_INFO_STRUCT32 *vvis = (VS_VERSION_INFO_STRUCT32 *)pVersionInfoW;
374 ok ( retvalW == ((vvis->wLength * 2) + 4) || retvalW == (vvis->wLength * 1.5),
375 "Structure is not of the correct size\n");
376 }
377
378 /* Although the 32bit resource structures contain Unicode strings, VerQueryValueA will always return normal strings,
379 * VerQueryValueW will always return Unicode ones. (That means everything returned for StringFileInfo requests).
380 */
381
382 /* Get the VS_FIXEDFILEINFO information, this must be the same for both A- and W-Calls */
383
384 retA = VerQueryValueA( pVersionInfoA, rootA, (LPVOID *)&pBufA, &uiLengthA );
385 ok (retA, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
386 ok ( uiLengthA == sizeof(VS_FIXEDFILEINFO), "Size (%d) doesn't match the size of the VS_FIXEDFILEINFO struct\n", uiLengthA);
387
388 if (is_unicode_enabled)
389 {
390 retW = VerQueryValueW( pVersionInfoW, rootW, (LPVOID *)&pBufW, &uiLengthW );
391 ok (retW, "VerQueryValueW failed: GetLastError = %u\n", GetLastError());
392 ok ( uiLengthA == sizeof(VS_FIXEDFILEINFO), "Size (%d) doesn't match the size of the VS_FIXEDFILEINFO struct\n", uiLengthA);
393
394 ok( uiLengthA == uiLengthW, "The size of VS_FIXEDFILEINFO should be the same for both A/W calls, it is (%d) vs. (%d)\n",
395 uiLengthA, uiLengthW);
396 ok( !memcmp(pBufA, pBufW, uiLengthA), "Both values should be the same, they aren't\n");
397 }
398
399 /* Get some VarFileInfo information, this must be the same for both A- and W-Calls */
400
401 retA = VerQueryValueA( pVersionInfoA, varfileinfoA, (LPVOID *)&pBufA, &uiLengthA );
402 ok (retA, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
403 ok( !memcmp(pBufA, WineVarFileInfoA, uiLengthA), "The VarFileInfo should have matched 0904e404 (non case sensitive)\n");
404
405 if (is_unicode_enabled)
406 {
407 retW = VerQueryValueW( pVersionInfoW, varfileinfoW, (LPVOID *)&pBufW, &uiLengthW );
408 ok (retW, "VerQueryValueW failed: GetLastError = %u\n", GetLastError());
409 ok( uiLengthA == uiLengthW, "The size of the VarFileInfo information should be the same for both A/W calls, it is (%d) vs. (%d)\n",
410 uiLengthA, uiLengthW);
411 ok( !memcmp(pBufA, pBufW, uiLengthA), "Both values should be the same, they aren't\n");
412 }
413
414 /* Get some StringFileInfo information, this will be ANSI for A-Calls and Unicode for W-Calls */
415
416 retA = VerQueryValueA( pVersionInfoA, FileDescriptionA, (LPVOID *)&pBufA, &uiLengthA );
417 ok (retA, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
418 ok( !lstrcmpA(WineFileDescriptionA, pBufA), "expected '%s' got '%s'\n",
419 WineFileDescriptionA, pBufA);
420
421 /* Test a second time */
422 retA = VerQueryValueA( pVersionInfoA, FileDescriptionA, (LPVOID *)&pBufA, &uiLengthA );
423 ok (retA, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
424 ok( !lstrcmpA(WineFileDescriptionA, pBufA), "expected '%s' got '%s'\n",
425 WineFileDescriptionA, pBufA);
426
427 if (is_unicode_enabled)
428 {
429 retW = VerQueryValueW( pVersionInfoW, FileDescriptionW, (LPVOID *)&pBufW, &uiLengthW );
430 ok (retW, "VerQueryValueW failed: GetLastError = %u\n", GetLastError());
431 ok( !lstrcmpW(WineFileDescriptionW, pBufW), "FileDescription should have been '%s'\n", WineFileDescriptionA);
432 }
433
434 HeapFree( GetProcessHeap(), 0, pVersionInfoA);
435 if (is_unicode_enabled)
436 HeapFree( GetProcessHeap(), 0, pVersionInfoW);
437 }
438
439 static void test_VerQueryValue(void)
440 {
441 static const char * const value_name[] = {
442 "Product", "CompanyName", "FileDescription", "Internal",
443 "ProductVersion", "InternalName", "File", "LegalCopyright",
444 "FileVersion", "Legal", "OriginalFilename", "ProductName",
445 "Company", "Original" };
446 char *ver, *p;
447 UINT len, ret, translation, i;
448 char buf[MAX_PATH];
449
450 ret = GetModuleFileName(NULL, buf, sizeof(buf));
451 assert(ret);
452
453 SetLastError(0xdeadbeef);
454 len = GetFileVersionInfoSize(buf, NULL);
455 ok(len, "GetFileVersionInfoSize(%s) error %u\n", buf, GetLastError());
456
457 ver = HeapAlloc(GetProcessHeap(), 0, len);
458 assert(ver);
459
460 SetLastError(0xdeadbeef);
461 ret = GetFileVersionInfo(buf, 0, len, ver);
462 ok(ret, "GetFileVersionInfo error %u\n", GetLastError());
463
464 p = (char *)0xdeadbeef;
465 len = 0xdeadbeef;
466 SetLastError(0xdeadbeef);
467 ret = VerQueryValue(ver, "\\VarFileInfo\\Translation", (LPVOID*)&p, &len);
468 ok(ret, "VerQueryValue error %u\n", GetLastError());
469 ok(len == 4, "VerQueryValue returned %u, expected 4\n", len);
470
471 translation = *(UINT *)p;
472 translation = MAKELONG(HIWORD(translation), LOWORD(translation));
473
474 p = (char *)0xdeadbeef;
475 len = 0xdeadbeef;
476 SetLastError(0xdeadbeef);
477 ret = VerQueryValue(ver, "String", (LPVOID*)&p, &len);
478 ok(!ret, "VerQueryValue should fail\n");
479 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND ||
480 GetLastError() == 0xdeadbeef /* Win9x, NT4, W2K */,
481 "VerQueryValue returned %u\n", GetLastError());
482 ok(p == (char *)0xdeadbeef, "expected 0xdeadbeef got %p\n", p);
483 ok(len == 0, "expected 0 got %x\n", len);
484
485 p = (char *)0xdeadbeef;
486 len = 0xdeadbeef;
487 SetLastError(0xdeadbeef);
488 ret = VerQueryValue(ver, "StringFileInfo", (LPVOID*)&p, &len);
489 ok(ret, "VerQueryValue error %u\n", GetLastError());
490 todo_wine ok(len == 0, "VerQueryValue returned %u, expected 0\n", len);
491 ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n");
492
493 p = (char *)0xdeadbeef;
494 len = 0xdeadbeef;
495 SetLastError(0xdeadbeef);
496 ret = VerQueryValue(ver, "\\StringFileInfo", (LPVOID*)&p, &len);
497 ok(ret, "VerQueryValue error %u\n", GetLastError());
498 todo_wine ok(len == 0, "VerQueryValue returned %u, expected 0\n", len);
499 ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n");
500
501 p = (char *)0xdeadbeef;
502 len = 0xdeadbeef;
503 SetLastError(0xdeadbeef);
504 ret = VerQueryValue(ver, "\\\\StringFileInfo", (LPVOID*)&p, &len);
505 ok(ret, "VerQueryValue error %u\n", GetLastError());
506 todo_wine ok(len == 0, "VerQueryValue returned %u, expected 0\n", len);
507 ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n");
508
509 p = (char *)0xdeadbeef;
510 len = 0xdeadbeef;
511 SetLastError(0xdeadbeef);
512 ret = VerQueryValue(ver, "\\StringFileInfo\\\\", (LPVOID*)&p, &len);
513 ok(ret, "VerQueryValue error %u\n", GetLastError());
514 todo_wine ok(len == 0, "VerQueryValue returned %u, expected 0\n", len);
515 ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n");
516
517 sprintf(buf, "\\StringFileInfo\\%08x", translation);
518 p = (char *)0xdeadbeef;
519 len = 0xdeadbeef;
520 SetLastError(0xdeadbeef);
521 ret = VerQueryValue(ver, buf, (LPVOID*)&p, &len);
522 ok(ret, "VerQueryValue error %u\n", GetLastError());
523 todo_wine ok(len == 0, "VerQueryValue returned %u, expected 0\n", len);
524 ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n");
525
526 for (i = 0; i < sizeof(value_name)/sizeof(value_name[0]); i++)
527 {
528 sprintf(buf, "\\StringFileInfo\\%08x\\%s", translation, value_name[i]);
529 p = (char *)0xdeadbeef;
530 len = 0xdeadbeef;
531 SetLastError(0xdeadbeef);
532 ret = VerQueryValue(ver, buf, (LPVOID*)&p, &len);
533 ok(ret, "VerQueryValue(%s) error %u\n", buf, GetLastError());
534 ok(len == strlen(value_name[i]) + 1, "VerQueryValue returned %u\n", len);
535 ok(!strcmp(value_name[i], p), "expected \"%s\", got \"%s\"\n",
536 value_name[i], p);
537
538 /* test partial value names */
539 len = lstrlen(buf);
540 buf[len - 2] = 0;
541 p = (char *)0xdeadbeef;
542 len = 0xdeadbeef;
543 SetLastError(0xdeadbeef);
544 ret = VerQueryValue(ver, buf, (LPVOID*)&p, &len);
545 ok(!ret, "VerQueryValue(%s) succeeded\n", buf);
546 ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND ||
547 GetLastError() == 0xdeadbeef /* Win9x, NT4, W2K */,
548 "VerQueryValue returned %u\n", GetLastError());
549 ok(p == (char *)0xdeadbeef, "expected 0xdeadbeef got %p\n", p);
550 ok(len == 0, "expected 0 got %x\n", len);
551 }
552
553 HeapFree(GetProcessHeap(), 0, ver);
554 }
555
556 START_TEST(info)
557 {
558 test_info_size();
559 test_info();
560 test_32bit_win();
561 test_VerQueryValue();
562 }