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