2004-04-06 00:54:03 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004 Stefan Leichter
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-06 00:54:03 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2005-01-04 21:35:46 +01:00
|
|
|
#include <stdio.h>
|
2007-04-16 09:09:32 +02:00
|
|
|
#include <assert.h>
|
2004-04-06 00:54:03 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winver.h"
|
2007-04-16 09:09:32 +02:00
|
|
|
#include "wine/test.h"
|
2004-04-06 00:54:03 +02:00
|
|
|
|
2005-09-13 17:00:32 +02:00
|
|
|
#define MY_LAST_ERROR ((DWORD)-1)
|
2004-11-09 21:11:07 +01:00
|
|
|
#define EXPECT_BAD_PATH__NOT_FOUND \
|
|
|
|
ok( (ERROR_PATH_NOT_FOUND == GetLastError()) || \
|
|
|
|
(ERROR_RESOURCE_DATA_NOT_FOUND == GetLastError()) || \
|
2004-12-16 15:34:18 +01:00
|
|
|
(ERROR_FILE_NOT_FOUND == GetLastError()) || \
|
2004-11-09 21:11:07 +01:00
|
|
|
(ERROR_BAD_PATHNAME == GetLastError()), \
|
|
|
|
"Last error wrong! ERROR_RESOURCE_DATA_NOT_FOUND/ERROR_BAD_PATHNAME (98)/" \
|
2004-12-16 15:34:18 +01:00
|
|
|
"ERROR_PATH_NOT_FOUND (NT4)/ERROR_FILE_NOT_FOUND (2k3)" \
|
2007-01-05 21:47:39 +01:00
|
|
|
"expected, got %u\n", GetLastError());
|
2004-11-09 21:11:07 +01:00
|
|
|
#define EXPECT_INVALID__NOT_FOUND \
|
|
|
|
ok( (ERROR_PATH_NOT_FOUND == GetLastError()) || \
|
|
|
|
(ERROR_RESOURCE_DATA_NOT_FOUND == GetLastError()) || \
|
2004-12-16 15:34:18 +01:00
|
|
|
(ERROR_FILE_NOT_FOUND == GetLastError()) || \
|
2004-11-09 21:11:07 +01:00
|
|
|
(ERROR_INVALID_PARAMETER == GetLastError()), \
|
|
|
|
"Last error wrong! ERROR_RESOURCE_DATA_NOT_FOUND/ERROR_INVALID_PARAMETER (98)/" \
|
2004-12-16 15:34:18 +01:00
|
|
|
"ERROR_PATH_NOT_FOUND (NT4)/ERROR_FILE_NOT_FOUND (2k3)" \
|
2007-01-05 21:47:39 +01:00
|
|
|
"expected, got %u\n", GetLastError());
|
2004-11-09 21:11:07 +01:00
|
|
|
|
2004-04-06 00:54:03 +02:00
|
|
|
static void test_info_size(void)
|
|
|
|
{ DWORD hdl, retval;
|
2005-05-31 11:33:59 +02:00
|
|
|
char mypath[MAX_PATH] = "";
|
2004-04-06 00:54:03 +02:00
|
|
|
|
2004-11-09 21:11:07 +01:00
|
|
|
SetLastError(MY_LAST_ERROR);
|
2004-04-06 00:54:03 +02:00
|
|
|
retval = GetFileVersionInfoSizeA( NULL, NULL);
|
|
|
|
ok( !retval,
|
2006-10-09 21:27:08 +02:00
|
|
|
"GetFileVersionInfoSizeA result wrong! 0L expected, got 0x%08x\n",
|
2004-04-06 00:54:03 +02:00
|
|
|
retval);
|
2004-11-09 21:11:07 +01:00
|
|
|
EXPECT_INVALID__NOT_FOUND;
|
2004-04-06 00:54:03 +02:00
|
|
|
|
|
|
|
hdl = 0x55555555;
|
2004-11-09 21:11:07 +01:00
|
|
|
SetLastError(MY_LAST_ERROR);
|
2004-04-06 00:54:03 +02:00
|
|
|
retval = GetFileVersionInfoSizeA( NULL, &hdl);
|
|
|
|
ok( !retval,
|
2006-10-09 21:27:08 +02:00
|
|
|
"GetFileVersionInfoSizeA result wrong! 0L expected, got 0x%08x\n",
|
2004-04-06 00:54:03 +02:00
|
|
|
retval);
|
2004-11-09 21:11:07 +01:00
|
|
|
EXPECT_INVALID__NOT_FOUND;
|
2004-04-06 00:54:03 +02:00
|
|
|
ok( hdl == 0L,
|
2006-10-09 21:27:08 +02:00
|
|
|
"Handle wrong! 0L expected, got 0x%08x\n", hdl);
|
2004-04-06 00:54:03 +02:00
|
|
|
|
2004-11-09 21:11:07 +01:00
|
|
|
SetLastError(MY_LAST_ERROR);
|
2004-04-06 00:54:03 +02:00
|
|
|
retval = GetFileVersionInfoSizeA( "", NULL);
|
|
|
|
ok( !retval,
|
2006-10-09 21:27:08 +02:00
|
|
|
"GetFileVersionInfoSizeA result wrong! 0L expected, got 0x%08x\n",
|
2004-04-06 00:54:03 +02:00
|
|
|
retval);
|
2004-11-09 21:11:07 +01:00
|
|
|
EXPECT_BAD_PATH__NOT_FOUND;
|
2004-04-06 00:54:03 +02:00
|
|
|
|
|
|
|
hdl = 0x55555555;
|
2004-11-09 21:11:07 +01:00
|
|
|
SetLastError(MY_LAST_ERROR);
|
2004-04-06 00:54:03 +02:00
|
|
|
retval = GetFileVersionInfoSizeA( "", &hdl);
|
|
|
|
ok( !retval,
|
2006-10-09 21:27:08 +02:00
|
|
|
"GetFileVersionInfoSizeA result wrong! 0L expected, got 0x%08x\n",
|
2004-04-06 00:54:03 +02:00
|
|
|
retval);
|
2004-11-09 21:11:07 +01:00
|
|
|
EXPECT_BAD_PATH__NOT_FOUND;
|
2004-04-06 00:54:03 +02:00
|
|
|
ok( hdl == 0L,
|
2006-10-09 21:27:08 +02:00
|
|
|
"Handle wrong! 0L expected, got 0x%08x\n", hdl);
|
2004-04-06 00:54:03 +02:00
|
|
|
|
2004-11-09 21:11:07 +01:00
|
|
|
SetLastError(MY_LAST_ERROR);
|
2004-04-06 00:54:03 +02:00
|
|
|
retval = GetFileVersionInfoSizeA( "kernel32.dll", NULL);
|
|
|
|
ok( retval,
|
2006-10-09 21:27:08 +02:00
|
|
|
"GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08x\n",
|
2004-04-06 00:54:03 +02:00
|
|
|
retval);
|
2004-11-19 19:19:31 +01:00
|
|
|
ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()),
|
2007-01-05 21:47:39 +01:00
|
|
|
"Last error wrong! NO_ERROR/0x%08x (NT4) expected, got %u\n",
|
2004-11-19 19:19:31 +01:00
|
|
|
MY_LAST_ERROR, GetLastError());
|
2004-04-06 00:54:03 +02:00
|
|
|
|
|
|
|
hdl = 0x55555555;
|
2004-11-09 21:11:07 +01:00
|
|
|
SetLastError(MY_LAST_ERROR);
|
2004-04-06 00:54:03 +02:00
|
|
|
retval = GetFileVersionInfoSizeA( "kernel32.dll", &hdl);
|
|
|
|
ok( retval,
|
2006-10-09 21:27:08 +02:00
|
|
|
"GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08x\n",
|
2004-04-06 00:54:03 +02:00
|
|
|
retval);
|
2004-11-09 21:11:07 +01:00
|
|
|
ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()),
|
2007-01-05 21:47:39 +01:00
|
|
|
"Last error wrong! NO_ERROR/0x%08x (NT4) expected, got %u\n",
|
2004-11-09 21:11:07 +01:00
|
|
|
MY_LAST_ERROR, GetLastError());
|
2004-04-06 00:54:03 +02:00
|
|
|
ok( hdl == 0L,
|
2006-10-09 21:27:08 +02:00
|
|
|
"Handle wrong! 0L expected, got 0x%08x\n", hdl);
|
2004-04-06 00:54:03 +02:00
|
|
|
|
2004-11-09 21:11:07 +01:00
|
|
|
SetLastError(MY_LAST_ERROR);
|
2004-04-06 00:54:03 +02:00
|
|
|
retval = GetFileVersionInfoSizeA( "notexist.dll", NULL);
|
|
|
|
ok( !retval,
|
2006-10-09 21:27:08 +02:00
|
|
|
"GetFileVersionInfoSizeA result wrong! 0L expected, got 0x%08x\n",
|
2004-04-06 00:54:03 +02:00
|
|
|
retval);
|
2005-01-04 21:35:46 +01:00
|
|
|
ok( (ERROR_FILE_NOT_FOUND == GetLastError()) ||
|
2004-11-09 21:11:07 +01:00
|
|
|
(ERROR_RESOURCE_DATA_NOT_FOUND == GetLastError()) ||
|
|
|
|
(MY_LAST_ERROR == GetLastError()),
|
2004-06-29 01:51:35 +02:00
|
|
|
"Last error wrong! ERROR_FILE_NOT_FOUND/ERROR_RESOURCE_DATA_NOT_FOUND "
|
2007-01-05 21:47:39 +01:00
|
|
|
"(XP)/0x%08x (NT4) expected, got %u\n", MY_LAST_ERROR, GetLastError());
|
2005-05-31 11:33:59 +02:00
|
|
|
|
|
|
|
/* test a currently loaded executable */
|
|
|
|
if(GetModuleFileNameA(NULL, mypath, MAX_PATH)) {
|
|
|
|
hdl = 0x55555555;
|
|
|
|
SetLastError(MY_LAST_ERROR);
|
|
|
|
retval = GetFileVersionInfoSizeA( mypath, &hdl);
|
|
|
|
ok( retval,
|
2006-10-09 21:27:08 +02:00
|
|
|
"GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08x\n",
|
2005-05-31 11:33:59 +02:00
|
|
|
retval);
|
|
|
|
ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()),
|
2007-01-05 21:47:39 +01:00
|
|
|
"Last error wrong! NO_ERROR/0x%08x (NT4) expected, got %u\n",
|
2005-05-31 11:33:59 +02:00
|
|
|
MY_LAST_ERROR, GetLastError());
|
|
|
|
ok( hdl == 0L,
|
2006-10-09 21:27:08 +02:00
|
|
|
"Handle wrong! 0L expected, got 0x%08x\n", hdl);
|
2005-05-31 11:33:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
trace("skipping GetModuleFileNameA(NULL,..) failed\n");
|
|
|
|
|
|
|
|
/* test a not loaded executable */
|
|
|
|
if(GetSystemDirectoryA(mypath, MAX_PATH)) {
|
|
|
|
lstrcatA(mypath, "\\regsvr32.exe");
|
|
|
|
|
|
|
|
if(INVALID_FILE_ATTRIBUTES == GetFileAttributesA(mypath))
|
|
|
|
trace("GetFileAttributesA(%s) failed\n", mypath);
|
|
|
|
else {
|
|
|
|
hdl = 0x55555555;
|
|
|
|
SetLastError(MY_LAST_ERROR);
|
|
|
|
retval = GetFileVersionInfoSizeA( mypath, &hdl);
|
|
|
|
ok( retval,
|
2006-10-09 21:27:08 +02:00
|
|
|
"GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08x\n",
|
2005-05-31 11:33:59 +02:00
|
|
|
retval);
|
|
|
|
ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()),
|
2007-01-05 21:47:39 +01:00
|
|
|
"Last error wrong! NO_ERROR/0x%08x (NT4) expected, got %u\n",
|
2005-05-31 11:33:59 +02:00
|
|
|
MY_LAST_ERROR, GetLastError());
|
|
|
|
ok( hdl == 0L,
|
2006-10-09 21:27:08 +02:00
|
|
|
"Handle wrong! 0L expected, got 0x%08x\n", hdl);
|
2005-05-31 11:33:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
trace("skipping GetModuleFileNameA(NULL,..) failed\n");
|
2004-04-06 00:54:03 +02:00
|
|
|
}
|
|
|
|
|
2005-01-04 21:35:46 +01:00
|
|
|
static void VersionDwordLong2String(DWORDLONG Version, LPSTR lpszVerString)
|
|
|
|
{
|
|
|
|
WORD a, b, c, d;
|
|
|
|
|
|
|
|
a = (WORD)(Version >> 48);
|
|
|
|
b = (WORD)((Version >> 32) & 0xffff);
|
|
|
|
c = (WORD)((Version >> 16) & 0xffff);
|
|
|
|
d = (WORD)(Version & 0xffff);
|
|
|
|
|
|
|
|
sprintf(lpszVerString, "%d.%d.%d.%d", a, b, c, d);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_info(void)
|
|
|
|
{
|
|
|
|
DWORD hdl, retval;
|
|
|
|
PVOID pVersionInfo = NULL;
|
|
|
|
BOOL boolret;
|
|
|
|
VS_FIXEDFILEINFO *pFixedVersionInfo;
|
|
|
|
UINT uiLength;
|
|
|
|
char VersionString[MAX_PATH];
|
2006-08-09 23:12:44 +02:00
|
|
|
static CHAR backslash[] = "\\";
|
2005-01-04 21:35:46 +01:00
|
|
|
DWORDLONG dwlVersion;
|
|
|
|
|
|
|
|
hdl = 0x55555555;
|
|
|
|
SetLastError(MY_LAST_ERROR);
|
|
|
|
retval = GetFileVersionInfoSizeA( "kernel32.dll", &hdl);
|
|
|
|
ok( retval,
|
2006-10-09 21:27:08 +02:00
|
|
|
"GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08x\n",
|
2005-01-04 21:35:46 +01:00
|
|
|
retval);
|
|
|
|
ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()),
|
2007-01-05 21:47:39 +01:00
|
|
|
"Last error wrong! NO_ERROR/0x%08x (NT4) expected, got %u\n",
|
2005-01-04 21:35:46 +01:00
|
|
|
MY_LAST_ERROR, GetLastError());
|
|
|
|
ok( hdl == 0L,
|
2006-10-09 21:27:08 +02:00
|
|
|
"Handle wrong! 0L expected, got 0x%08x\n", hdl);
|
2005-01-04 21:35:46 +01:00
|
|
|
|
|
|
|
if ( retval == 0 || hdl != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pVersionInfo = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, retval );
|
|
|
|
ok(pVersionInfo != 0, "HeapAlloc failed\n" );
|
|
|
|
if (pVersionInfo == 0)
|
|
|
|
return;
|
|
|
|
|
2006-12-14 18:10:59 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2005-02-25 17:19:19 +01:00
|
|
|
/* this test crashes on WinNT4
|
|
|
|
*/
|
2005-01-04 21:35:46 +01:00
|
|
|
boolret = GetFileVersionInfoA( "kernel32.dll", 0, retval, 0);
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (!boolret, "GetFileVersionInfoA should have failed: GetLastError = %u\n", GetLastError());
|
2005-02-08 14:43:41 +01:00
|
|
|
ok ((GetLastError() == ERROR_INVALID_DATA) || (GetLastError() == ERROR_BAD_PATHNAME) ||
|
|
|
|
(GetLastError() == NO_ERROR),
|
|
|
|
"Last error wrong! ERROR_INVALID_DATA/ERROR_BAD_PATHNAME (ME)/"
|
2007-01-05 21:47:39 +01:00
|
|
|
"NO_ERROR (95) expected, got %u\n",
|
2005-01-04 21:35:46 +01:00
|
|
|
GetLastError());
|
2006-12-14 18:10:59 +01:00
|
|
|
}
|
2005-01-04 21:35:46 +01:00
|
|
|
|
|
|
|
boolret = GetFileVersionInfoA( "kernel32.dll", 0, retval, pVersionInfo );
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (boolret, "GetFileVersionInfoA failed: GetLastError = %u\n", GetLastError());
|
2005-01-04 21:35:46 +01:00
|
|
|
if (!boolret)
|
2006-12-04 22:21:24 +01:00
|
|
|
goto cleanup;
|
2005-01-04 21:35:46 +01:00
|
|
|
|
2006-08-09 23:12:44 +02:00
|
|
|
boolret = VerQueryValueA( pVersionInfo, backslash, (LPVOID *)&pFixedVersionInfo, &uiLength );
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (boolret, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
|
2005-01-04 21:35:46 +01:00
|
|
|
if (!boolret)
|
2006-12-04 22:21:24 +01:00
|
|
|
goto cleanup;
|
2005-01-04 21:35:46 +01:00
|
|
|
|
|
|
|
dwlVersion = (((DWORDLONG)pFixedVersionInfo->dwFileVersionMS) << 32) +
|
|
|
|
pFixedVersionInfo->dwFileVersionLS;
|
|
|
|
|
|
|
|
VersionDwordLong2String(dwlVersion, VersionString);
|
|
|
|
|
|
|
|
trace("kernel32.dll version: %s\n", VersionString);
|
|
|
|
|
2006-12-14 18:10:59 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2005-02-25 17:19:19 +01:00
|
|
|
/* this test crashes on WinNT4
|
|
|
|
*/
|
2006-12-16 13:15:53 +01:00
|
|
|
boolret = VerQueryValueA( pVersionInfo, backslash, (LPVOID *)&pFixedVersionInfo, 0);
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (boolret, "VerQueryValue failed: GetLastError = %u\n", GetLastError());
|
2006-12-14 18:10:59 +01:00
|
|
|
}
|
2006-12-04 22:21:24 +01:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
HeapFree( GetProcessHeap(), 0, pVersionInfo);
|
2005-01-04 21:35:46 +01:00
|
|
|
}
|
|
|
|
|
2005-07-20 12:29:29 +02:00
|
|
|
static void test_32bit_win(void)
|
2005-07-15 18:32:53 +02:00
|
|
|
{
|
|
|
|
DWORD hdlA, retvalA;
|
2005-07-26 12:33:22 +02:00
|
|
|
DWORD hdlW, retvalW = 0;
|
2005-07-15 18:32:53 +02:00
|
|
|
BOOL retA,retW;
|
|
|
|
PVOID pVersionInfoA = NULL;
|
|
|
|
PVOID pVersionInfoW = NULL;
|
2005-07-20 12:29:29 +02:00
|
|
|
char *pBufA;
|
|
|
|
WCHAR *pBufW;
|
2005-07-26 12:33:22 +02:00
|
|
|
UINT uiLengthA, uiLengthW;
|
2005-07-20 12:29:29 +02:00
|
|
|
char mypathA[MAX_PATH];
|
2005-07-15 18:32:53 +02:00
|
|
|
WCHAR mypathW[MAX_PATH];
|
2005-07-26 12:33:22 +02:00
|
|
|
char rootA[] = "\\";
|
|
|
|
WCHAR rootW[] = { '\\', 0 };
|
|
|
|
char varfileinfoA[] = "\\VarFileInfo\\Translation";
|
|
|
|
WCHAR varfileinfoW[] = { '\\','V','a','r','F','i','l','e','I','n','f','o',
|
|
|
|
'\\','T','r','a','n','s','l','a','t','i','o','n', 0 };
|
|
|
|
char WineVarFileInfoA[] = { 0x09, 0x04, 0xE4, 0x04 };
|
|
|
|
char FileDescriptionA[] = "\\StringFileInfo\\040904E4\\FileDescription";
|
|
|
|
WCHAR FileDescriptionW[] = { '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
|
|
|
|
'\\','0','4','0','9','0','4','E','4',
|
|
|
|
'\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n', 0 };
|
2007-04-16 09:09:32 +02:00
|
|
|
char WineFileDescriptionA[] = "FileDescription";
|
|
|
|
WCHAR WineFileDescriptionW[] = { 'F','i','l','e','D','e','s','c','r','i','p','t','i','o','n', 0 };
|
2005-07-26 12:33:22 +02:00
|
|
|
BOOL is_unicode_enabled = TRUE;
|
2005-07-15 18:32:53 +02:00
|
|
|
|
2005-08-29 16:17:27 +02:00
|
|
|
/* A copy from dlls/version/info.c */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WORD wLength;
|
|
|
|
WORD wValueLength;
|
|
|
|
WORD wType;
|
|
|
|
WCHAR szKey[1];
|
|
|
|
#if 0 /* variable length structure */
|
|
|
|
/* DWORD aligned */
|
|
|
|
BYTE Value[];
|
|
|
|
/* DWORD aligned */
|
|
|
|
VS_VERSION_INFO_STRUCT32 Children[];
|
|
|
|
#endif
|
|
|
|
} VS_VERSION_INFO_STRUCT32;
|
|
|
|
|
2005-10-18 14:00:59 +02:00
|
|
|
/* If we call GetFileVersionInfoA on a system that supports Unicode, NT/W2K/XP/W2K3 (by default) and Wine,
|
|
|
|
* the versioninfo will contain Unicode strings.
|
2005-07-26 12:33:22 +02:00
|
|
|
* Part of the test is to call both the A and W versions, which should have the same Version Information
|
|
|
|
* for some requests, on systems that support both calls.
|
2005-07-15 18:32:53 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* First get the versioninfo via the W versions */
|
2007-04-16 09:09:32 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2005-07-15 18:32:53 +02:00
|
|
|
GetModuleFileNameW(NULL, mypathW, MAX_PATH);
|
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
2005-07-26 12:33:22 +02:00
|
|
|
trace("GetModuleFileNameW not existing on this platform, skipping comparison between A- and W-calls\n");
|
|
|
|
is_unicode_enabled = FALSE;
|
2005-07-15 18:32:53 +02:00
|
|
|
}
|
|
|
|
|
2005-07-26 12:33:22 +02:00
|
|
|
if (is_unicode_enabled)
|
|
|
|
{
|
|
|
|
retvalW = GetFileVersionInfoSizeW( mypathW, &hdlW);
|
|
|
|
pVersionInfoW = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, retvalW );
|
|
|
|
retW = GetFileVersionInfoW( mypathW, 0, retvalW, pVersionInfoW );
|
|
|
|
}
|
2005-07-15 18:32:53 +02:00
|
|
|
|
|
|
|
GetModuleFileNameA(NULL, mypathA, MAX_PATH);
|
|
|
|
retvalA = GetFileVersionInfoSizeA( mypathA, &hdlA);
|
|
|
|
pVersionInfoA = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, retvalA );
|
|
|
|
retA = GetFileVersionInfoA( mypathA, 0, retvalA, pVersionInfoA );
|
|
|
|
|
2005-07-26 12:33:22 +02:00
|
|
|
if (is_unicode_enabled)
|
|
|
|
{
|
2006-10-09 21:27:08 +02:00
|
|
|
ok( retvalA == retvalW, "The size of the struct should be the same for both A/W calls, it is (%d) vs. (%d)\n",
|
2005-07-26 12:33:22 +02:00
|
|
|
retvalA, retvalW);
|
|
|
|
ok( !memcmp(pVersionInfoA, pVersionInfoW, retvalA), "Both structs should be the same, they aren't\n");
|
|
|
|
}
|
2005-07-20 12:29:29 +02:00
|
|
|
|
2007-06-07 11:48:55 +02:00
|
|
|
/* The structs on Windows are bigger than just the struct for the basic information. The total struct
|
2005-08-29 16:17:27 +02:00
|
|
|
* contains also an empty part, which is used for converted strings. The converted strings are a result
|
|
|
|
* of calling VerQueryValueA on a 32bit resource and calling VerQueryValueW on a 16bit resource.
|
|
|
|
* The first WORD of the structure (wLength) shows the size of the base struct. The total struct size depends
|
|
|
|
* on the Windows version:
|
|
|
|
*
|
|
|
|
* 16bits resource (numbers are from a sample app):
|
2005-07-20 12:29:29 +02:00
|
|
|
*
|
2005-08-29 16:17:27 +02:00
|
|
|
* Windows Version Retrieved with A/W wLength StructSize
|
|
|
|
* ====================================================================================
|
|
|
|
* Win98 A 0x01B4 (436) 436
|
|
|
|
* NT4 A/W 0x01B4 (436) 2048 ???
|
|
|
|
* W2K/XP/W2K3 A/W 0x01B4 (436) 1536 which is (436 - sizeof(VS_FIXEDFILEINFO)) * 4
|
|
|
|
*
|
|
|
|
* 32bits resource (numbers are from this test executable version_crosstest.exe):
|
|
|
|
* Windows Version Retrieved with A/W wLength StructSize
|
|
|
|
* =============================================================
|
|
|
|
* Win98 A 0x01E0 (480) 848 (structure data doesn't seem correct)
|
|
|
|
* NT4 A/W 0x0350 (848) 1272 (848 * 1.5)
|
|
|
|
* W2K/XP/W2K3 A/W 0x0350 (848) 1700 which is (848 * 2) + 4
|
|
|
|
*
|
|
|
|
* Wine will follow the implementation (eventually) of W2K/XP/W2K3
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Now some tests for the above (only if we are unicode enabled) */
|
|
|
|
|
|
|
|
if (is_unicode_enabled)
|
|
|
|
{
|
|
|
|
VS_VERSION_INFO_STRUCT32 *vvis = (VS_VERSION_INFO_STRUCT32 *)pVersionInfoW;
|
|
|
|
ok ( retvalW == ((vvis->wLength * 2) + 4) || retvalW == (vvis->wLength * 1.5),
|
|
|
|
"Structure is not of the correct size\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Although the 32bit resource structures contain Unicode strings, VerQueryValueA will always return normal strings,
|
2005-07-26 12:33:22 +02:00
|
|
|
* VerQueryValueW will always return Unicode ones. (That means everything returned for StringFileInfo requests).
|
2005-07-20 12:29:29 +02:00
|
|
|
*/
|
|
|
|
|
2005-07-26 12:33:22 +02:00
|
|
|
/* Get the VS_FIXEDFILEINFO information, this must be the same for both A- and W-Calls */
|
|
|
|
|
|
|
|
retA = VerQueryValueA( pVersionInfoA, rootA, (LPVOID *)&pBufA, &uiLengthA );
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (retA, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
|
2006-06-13 14:03:59 +02:00
|
|
|
ok ( uiLengthA == sizeof(VS_FIXEDFILEINFO), "Size (%d) doesn't match the size of the VS_FIXEDFILEINFO struct\n", uiLengthA);
|
2005-07-26 12:33:22 +02:00
|
|
|
|
|
|
|
if (is_unicode_enabled)
|
|
|
|
{
|
|
|
|
retW = VerQueryValueW( pVersionInfoW, rootW, (LPVOID *)&pBufW, &uiLengthW );
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (retW, "VerQueryValueW failed: GetLastError = %u\n", GetLastError());
|
2006-06-13 14:03:59 +02:00
|
|
|
ok ( uiLengthA == sizeof(VS_FIXEDFILEINFO), "Size (%d) doesn't match the size of the VS_FIXEDFILEINFO struct\n", uiLengthA);
|
2005-07-26 12:33:22 +02:00
|
|
|
|
|
|
|
ok( uiLengthA == uiLengthW, "The size of VS_FIXEDFILEINFO should be the same for both A/W calls, it is (%d) vs. (%d)\n",
|
|
|
|
uiLengthA, uiLengthW);
|
|
|
|
ok( !memcmp(pBufA, pBufW, uiLengthA), "Both values should be the same, they aren't\n");
|
|
|
|
}
|
2005-07-20 12:29:29 +02:00
|
|
|
|
2005-07-26 12:33:22 +02:00
|
|
|
/* Get some VarFileInfo information, this must be the same for both A- and W-Calls */
|
|
|
|
|
|
|
|
retA = VerQueryValueA( pVersionInfoA, varfileinfoA, (LPVOID *)&pBufA, &uiLengthA );
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (retA, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
|
2005-07-26 12:33:22 +02:00
|
|
|
ok( !memcmp(pBufA, WineVarFileInfoA, uiLengthA), "The VarFileInfo should have matched 0904e404 (non case sensitive)\n");
|
|
|
|
|
|
|
|
if (is_unicode_enabled)
|
|
|
|
{
|
|
|
|
retW = VerQueryValueW( pVersionInfoW, varfileinfoW, (LPVOID *)&pBufW, &uiLengthW );
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (retW, "VerQueryValueW failed: GetLastError = %u\n", GetLastError());
|
2005-07-26 12:33:22 +02:00
|
|
|
ok( uiLengthA == uiLengthW, "The size of the VarFileInfo information should be the same for both A/W calls, it is (%d) vs. (%d)\n",
|
|
|
|
uiLengthA, uiLengthW);
|
|
|
|
ok( !memcmp(pBufA, pBufW, uiLengthA), "Both values should be the same, they aren't\n");
|
|
|
|
}
|
2005-07-20 12:29:29 +02:00
|
|
|
|
2005-07-26 12:33:22 +02:00
|
|
|
/* Get some StringFileInfo information, this will be ANSI for A-Calls and Unicode for W-Calls */
|
2005-07-20 12:29:29 +02:00
|
|
|
|
2005-07-26 12:33:22 +02:00
|
|
|
retA = VerQueryValueA( pVersionInfoA, FileDescriptionA, (LPVOID *)&pBufA, &uiLengthA );
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (retA, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
|
2007-04-16 09:09:32 +02:00
|
|
|
ok( !lstrcmpA(WineFileDescriptionA, pBufA), "expected '%s' got '%s'\n",
|
|
|
|
WineFileDescriptionA, pBufA);
|
2005-07-20 12:29:29 +02:00
|
|
|
|
2005-08-22 20:57:22 +02:00
|
|
|
/* Test a second time */
|
|
|
|
retA = VerQueryValueA( pVersionInfoA, FileDescriptionA, (LPVOID *)&pBufA, &uiLengthA );
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (retA, "VerQueryValueA failed: GetLastError = %u\n", GetLastError());
|
2007-04-16 09:09:32 +02:00
|
|
|
ok( !lstrcmpA(WineFileDescriptionA, pBufA), "expected '%s' got '%s'\n",
|
|
|
|
WineFileDescriptionA, pBufA);
|
2005-08-22 20:57:22 +02:00
|
|
|
|
2005-07-26 12:33:22 +02:00
|
|
|
if (is_unicode_enabled)
|
|
|
|
{
|
|
|
|
retW = VerQueryValueW( pVersionInfoW, FileDescriptionW, (LPVOID *)&pBufW, &uiLengthW );
|
2007-01-05 21:47:39 +01:00
|
|
|
ok (retW, "VerQueryValueW failed: GetLastError = %u\n", GetLastError());
|
2007-04-16 09:09:32 +02:00
|
|
|
ok( !lstrcmpW(WineFileDescriptionW, pBufW), "FileDescription should have been '%s'\n", WineFileDescriptionA);
|
2005-07-26 12:33:22 +02:00
|
|
|
}
|
2005-07-15 18:32:53 +02:00
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, pVersionInfoA);
|
2005-07-26 12:33:22 +02:00
|
|
|
if (is_unicode_enabled)
|
|
|
|
HeapFree( GetProcessHeap(), 0, pVersionInfoW);
|
2005-07-15 18:32:53 +02:00
|
|
|
}
|
|
|
|
|
2007-04-16 09:09:32 +02:00
|
|
|
static void test_VerQueryValue(void)
|
|
|
|
{
|
|
|
|
static const char * const value_name[] = {
|
|
|
|
"Product", "CompanyName", "FileDescription", "Internal",
|
|
|
|
"ProductVersion", "InternalName", "File", "LegalCopyright",
|
|
|
|
"FileVersion", "Legal", "OriginalFilename", "ProductName",
|
|
|
|
"Company", "Original" };
|
|
|
|
char *ver, *p;
|
|
|
|
UINT len, ret, translation, i;
|
|
|
|
char buf[MAX_PATH];
|
|
|
|
|
|
|
|
ret = GetModuleFileName(NULL, buf, sizeof(buf));
|
|
|
|
assert(ret);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
len = GetFileVersionInfoSize(buf, NULL);
|
|
|
|
ok(len, "GetFileVersionInfoSize(%s) error %u\n", buf, GetLastError());
|
|
|
|
|
|
|
|
ver = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
assert(ver);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetFileVersionInfo(buf, 0, len, ver);
|
|
|
|
ok(ret, "GetFileVersionInfo error %u\n", GetLastError());
|
|
|
|
|
|
|
|
p = (char *)0xdeadbeef;
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = VerQueryValue(ver, "\\VarFileInfo\\Translation", (LPVOID*)&p, &len);
|
|
|
|
ok(ret, "VerQueryValue error %u\n", GetLastError());
|
|
|
|
ok(len == 4, "VerQueryValue returned %u, expected 4\n", len);
|
|
|
|
|
|
|
|
translation = *(UINT *)p;
|
|
|
|
translation = MAKELONG(HIWORD(translation), LOWORD(translation));
|
|
|
|
|
|
|
|
p = (char *)0xdeadbeef;
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = VerQueryValue(ver, "String", (LPVOID*)&p, &len);
|
|
|
|
ok(!ret, "VerQueryValue should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND,
|
|
|
|
"VerQueryValue returned %u\n", GetLastError());
|
|
|
|
ok(p == (char *)0xdeadbeef, "expected 0xdeadbeef got %p\n", p);
|
|
|
|
ok(len == 0, "expected 0 got %x\n", len);
|
|
|
|
|
|
|
|
p = (char *)0xdeadbeef;
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = VerQueryValue(ver, "StringFileInfo", (LPVOID*)&p, &len);
|
|
|
|
ok(ret, "VerQueryValue error %u\n", GetLastError());
|
|
|
|
todo_wine ok(len == 0, "VerQueryValue returned %u, expected 0\n", len);
|
|
|
|
ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n");
|
|
|
|
|
|
|
|
p = (char *)0xdeadbeef;
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = VerQueryValue(ver, "\\StringFileInfo", (LPVOID*)&p, &len);
|
|
|
|
ok(ret, "VerQueryValue error %u\n", GetLastError());
|
|
|
|
todo_wine ok(len == 0, "VerQueryValue returned %u, expected 0\n", len);
|
|
|
|
ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n");
|
|
|
|
|
|
|
|
p = (char *)0xdeadbeef;
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = VerQueryValue(ver, "\\\\StringFileInfo", (LPVOID*)&p, &len);
|
|
|
|
ok(ret, "VerQueryValue error %u\n", GetLastError());
|
|
|
|
todo_wine ok(len == 0, "VerQueryValue returned %u, expected 0\n", len);
|
|
|
|
ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n");
|
|
|
|
|
|
|
|
p = (char *)0xdeadbeef;
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = VerQueryValue(ver, "\\StringFileInfo\\\\", (LPVOID*)&p, &len);
|
|
|
|
ok(ret, "VerQueryValue error %u\n", GetLastError());
|
|
|
|
todo_wine ok(len == 0, "VerQueryValue returned %u, expected 0\n", len);
|
|
|
|
ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n");
|
|
|
|
|
|
|
|
sprintf(buf, "\\StringFileInfo\\%08x", translation);
|
|
|
|
p = (char *)0xdeadbeef;
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = VerQueryValue(ver, buf, (LPVOID*)&p, &len);
|
|
|
|
ok(ret, "VerQueryValue error %u\n", GetLastError());
|
|
|
|
todo_wine ok(len == 0, "VerQueryValue returned %u, expected 0\n", len);
|
|
|
|
ok(p != (char *)0xdeadbeef, "not expected 0xdeadbeef\n");
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(value_name)/sizeof(value_name[0]); i++)
|
|
|
|
{
|
|
|
|
sprintf(buf, "\\StringFileInfo\\%08x\\%s", translation, value_name[i]);
|
|
|
|
p = (char *)0xdeadbeef;
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = VerQueryValue(ver, buf, (LPVOID*)&p, &len);
|
|
|
|
ok(ret, "VerQueryValue(%s) error %u\n", buf, GetLastError());
|
2007-04-23 15:12:19 +02:00
|
|
|
ok(len == strlen(value_name[i]) + 1, "VerQueryValue returned %u\n", len);
|
2007-04-16 09:09:32 +02:00
|
|
|
ok(!strcmp(value_name[i], p), "expected \"%s\", got \"%s\"\n",
|
|
|
|
value_name[i], p);
|
|
|
|
|
|
|
|
/* test partial value names */
|
|
|
|
len = lstrlen(buf);
|
|
|
|
buf[len - 2] = 0;
|
|
|
|
p = (char *)0xdeadbeef;
|
|
|
|
len = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = VerQueryValue(ver, buf, (LPVOID*)&p, &len);
|
|
|
|
ok(!ret, "VerQueryValue(%s) succeeded\n", buf);
|
|
|
|
ok(GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND,
|
|
|
|
"VerQueryValue returned %u\n", GetLastError());
|
|
|
|
ok(p == (char *)0xdeadbeef, "expected 0xdeadbeef got %p\n", p);
|
|
|
|
ok(len == 0, "expected 0 got %x\n", len);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, ver);
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:54:03 +02:00
|
|
|
START_TEST(info)
|
|
|
|
{
|
|
|
|
test_info_size();
|
2005-01-04 21:35:46 +01:00
|
|
|
test_info();
|
2005-07-20 12:29:29 +02:00
|
|
|
test_32bit_win();
|
2007-04-16 09:09:32 +02:00
|
|
|
test_VerQueryValue();
|
2004-04-06 00:54:03 +02:00
|
|
|
}
|