2002-06-01 01:06:46 +02:00
|
|
|
/*
|
1999-01-31 11:11:54 +01:00
|
|
|
* Implementation of VERSION.DLL - Version Info access
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
1999-01-31 11:11:54 +01:00
|
|
|
* Copyright 1996,1997 Marcus Meissner
|
|
|
|
* Copyright 1997 David Cuthbert
|
|
|
|
* Copyright 1999 Ulrich Weigand
|
2005-07-30 21:04:01 +02:00
|
|
|
* Copyright 2005 Paul Vriens
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2003-09-27 04:22:21 +02:00
|
|
|
*
|
1999-01-31 11:11:54 +01:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-01-31 11:11:54 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
1999-02-17 14:51:06 +01:00
|
|
|
#include "winreg.h"
|
|
|
|
#include "winver.h"
|
2004-04-06 00:51:37 +02:00
|
|
|
#include "winternl.h"
|
2000-10-23 03:38:29 +02:00
|
|
|
#include "wine/winuser16.h"
|
2000-06-13 03:10:29 +02:00
|
|
|
#include "wine/unicode.h"
|
1999-01-31 11:11:54 +01:00
|
|
|
#include "winerror.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ver);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-01-31 11:11:54 +01:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2005-07-28 12:14:08 +02:00
|
|
|
* This function will print via standard TRACE, debug info regarding
|
1999-01-31 11:11:54 +01:00
|
|
|
* the file info structure vffi.
|
|
|
|
* 15-Feb-1998 Dimitrie Paun (dimi@cs.toronto.edu)
|
|
|
|
* Added this function to clean up the code.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static void print_vffi_debug(VS_FIXEDFILEINFO *vffi)
|
|
|
|
{
|
2005-07-28 12:14:08 +02:00
|
|
|
TRACE("structversion=%u.%u, fileversion=%u.%u.%u.%u, productversion=%u.%u.%u.%u, flagmask=0x%lx, flags=%s%s%s%s%s%s\n",
|
|
|
|
HIWORD(vffi->dwStrucVersion),LOWORD(vffi->dwStrucVersion),
|
|
|
|
HIWORD(vffi->dwFileVersionMS),LOWORD(vffi->dwFileVersionMS),
|
|
|
|
HIWORD(vffi->dwFileVersionLS),LOWORD(vffi->dwFileVersionLS),
|
|
|
|
HIWORD(vffi->dwProductVersionMS),LOWORD(vffi->dwProductVersionMS),
|
|
|
|
HIWORD(vffi->dwProductVersionLS),LOWORD(vffi->dwProductVersionLS),
|
|
|
|
vffi->dwFileFlagsMask,
|
|
|
|
(vffi->dwFileFlags & VS_FF_DEBUG) ? "DEBUG," : "",
|
|
|
|
(vffi->dwFileFlags & VS_FF_PRERELEASE) ? "PRERELEASE," : "",
|
|
|
|
(vffi->dwFileFlags & VS_FF_PATCHED) ? "PATCHED," : "",
|
|
|
|
(vffi->dwFileFlags & VS_FF_PRIVATEBUILD) ? "PRIVATEBUILD," : "",
|
|
|
|
(vffi->dwFileFlags & VS_FF_INFOINFERRED) ? "INFOINFERRED," : "",
|
|
|
|
(vffi->dwFileFlags & VS_FF_SPECIALBUILD) ? "SPECIALBUILD," : "");
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2005-07-28 12:14:08 +02:00
|
|
|
TRACE("(");
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2005-07-28 12:14:08 +02:00
|
|
|
TRACE("OS=0x%x.0x%x ", HIWORD(vffi->dwFileOS), LOWORD(vffi->dwFileOS));
|
|
|
|
|
|
|
|
switch (vffi->dwFileOS&0xFFFF0000)
|
|
|
|
{
|
|
|
|
case VOS_DOS:TRACE("DOS,");break;
|
|
|
|
case VOS_OS216:TRACE("OS/2-16,");break;
|
|
|
|
case VOS_OS232:TRACE("OS/2-32,");break;
|
|
|
|
case VOS_NT:TRACE("NT,");break;
|
|
|
|
case VOS_UNKNOWN:
|
|
|
|
default:
|
|
|
|
TRACE("UNKNOWN(0x%lx),",vffi->dwFileOS&0xFFFF0000);break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (LOWORD(vffi->dwFileOS))
|
|
|
|
{
|
|
|
|
case VOS__BASE:TRACE("BASE");break;
|
|
|
|
case VOS__WINDOWS16:TRACE("WIN16");break;
|
|
|
|
case VOS__WINDOWS32:TRACE("WIN32");break;
|
|
|
|
case VOS__PM16:TRACE("PM16");break;
|
|
|
|
case VOS__PM32:TRACE("PM32");break;
|
|
|
|
default:
|
|
|
|
TRACE("UNKNOWN(0x%x)",LOWORD(vffi->dwFileOS));break;
|
|
|
|
}
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2005-07-28 12:14:08 +02:00
|
|
|
TRACE(")\n");
|
|
|
|
|
|
|
|
switch (vffi->dwFileType)
|
|
|
|
{
|
|
|
|
case VFT_APP:TRACE("filetype=APP");break;
|
|
|
|
case VFT_DLL:TRACE("filetype=DLL");break;
|
|
|
|
case VFT_DRV:
|
|
|
|
TRACE("filetype=DRV,");
|
|
|
|
switch(vffi->dwFileSubtype)
|
|
|
|
{
|
|
|
|
case VFT2_DRV_PRINTER:TRACE("PRINTER");break;
|
|
|
|
case VFT2_DRV_KEYBOARD:TRACE("KEYBOARD");break;
|
|
|
|
case VFT2_DRV_LANGUAGE:TRACE("LANGUAGE");break;
|
|
|
|
case VFT2_DRV_DISPLAY:TRACE("DISPLAY");break;
|
|
|
|
case VFT2_DRV_MOUSE:TRACE("MOUSE");break;
|
|
|
|
case VFT2_DRV_NETWORK:TRACE("NETWORK");break;
|
|
|
|
case VFT2_DRV_SYSTEM:TRACE("SYSTEM");break;
|
|
|
|
case VFT2_DRV_INSTALLABLE:TRACE("INSTALLABLE");break;
|
|
|
|
case VFT2_DRV_SOUND:TRACE("SOUND");break;
|
|
|
|
case VFT2_DRV_COMM:TRACE("COMM");break;
|
|
|
|
case VFT2_DRV_INPUTMETHOD:TRACE("INPUTMETHOD");break;
|
|
|
|
case VFT2_UNKNOWN:
|
|
|
|
default:
|
|
|
|
TRACE("UNKNOWN(0x%lx)",vffi->dwFileSubtype);break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VFT_FONT:
|
|
|
|
TRACE("filetype=FONT,");
|
|
|
|
switch (vffi->dwFileSubtype)
|
|
|
|
{
|
|
|
|
case VFT2_FONT_RASTER:TRACE("RASTER");break;
|
|
|
|
case VFT2_FONT_VECTOR:TRACE("VECTOR");break;
|
|
|
|
case VFT2_FONT_TRUETYPE:TRACE("TRUETYPE");break;
|
|
|
|
default:TRACE("UNKNOWN(0x%lx)",vffi->dwFileSubtype);break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VFT_VXD:TRACE("filetype=VXD");break;
|
|
|
|
case VFT_STATIC_LIB:TRACE("filetype=STATIC_LIB");break;
|
|
|
|
case VFT_UNKNOWN:
|
|
|
|
default:
|
|
|
|
TRACE("filetype=Unknown(0x%lx)",vffi->dwFileType);break;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
TRACE("filedate=0x%lx.0x%lx\n",vffi->dwFileDateMS,vffi->dwFileDateLS);
|
|
|
|
}
|
1999-01-31 11:11:54 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Version Info Structure
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WORD wLength;
|
|
|
|
WORD wValueLength;
|
|
|
|
CHAR szKey[1];
|
|
|
|
#if 0 /* variable length structure */
|
|
|
|
/* DWORD aligned */
|
|
|
|
BYTE Value[];
|
|
|
|
/* DWORD aligned */
|
1999-02-17 16:33:17 +01:00
|
|
|
VS_VERSION_INFO_STRUCT16 Children[];
|
1999-01-31 11:11:54 +01:00
|
|
|
#endif
|
1999-02-17 16:33:17 +01:00
|
|
|
} VS_VERSION_INFO_STRUCT16;
|
1999-01-31 11:11:54 +01:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WORD wLength;
|
|
|
|
WORD wValueLength;
|
2005-07-26 20:25:34 +02:00
|
|
|
WORD wType;
|
1999-01-31 11:11:54 +01:00
|
|
|
WCHAR szKey[1];
|
|
|
|
#if 0 /* variable length structure */
|
|
|
|
/* DWORD aligned */
|
|
|
|
BYTE Value[];
|
|
|
|
/* DWORD aligned */
|
1999-02-17 16:33:17 +01:00
|
|
|
VS_VERSION_INFO_STRUCT32 Children[];
|
1999-01-31 11:11:54 +01:00
|
|
|
#endif
|
1999-02-17 16:33:17 +01:00
|
|
|
} VS_VERSION_INFO_STRUCT32;
|
1999-01-31 11:11:54 +01:00
|
|
|
|
|
|
|
#define VersionInfoIs16( ver ) \
|
1999-02-17 16:33:17 +01:00
|
|
|
( ((VS_VERSION_INFO_STRUCT16 *)ver)->szKey[0] >= ' ' )
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2000-01-08 23:19:46 +01:00
|
|
|
#define DWORD_ALIGN( base, ptr ) \
|
|
|
|
( (LPBYTE)(base) + ((((LPBYTE)(ptr) - (LPBYTE)(base)) + 3) & ~3) )
|
1999-08-21 15:03:34 +02:00
|
|
|
|
1999-01-31 11:11:54 +01:00
|
|
|
#define VersionInfo16_Value( ver ) \
|
2000-08-14 16:41:19 +02:00
|
|
|
DWORD_ALIGN( (ver), (ver)->szKey + strlen((ver)->szKey) + 1 )
|
1999-01-31 11:11:54 +01:00
|
|
|
#define VersionInfo32_Value( ver ) \
|
2000-08-14 16:41:19 +02:00
|
|
|
DWORD_ALIGN( (ver), (ver)->szKey + strlenW((ver)->szKey) + 1 )
|
1999-01-31 11:11:54 +01:00
|
|
|
|
|
|
|
#define VersionInfo16_Children( ver ) \
|
1999-02-17 16:33:17 +01:00
|
|
|
(VS_VERSION_INFO_STRUCT16 *)( VersionInfo16_Value( ver ) + \
|
1999-01-31 11:11:54 +01:00
|
|
|
( ( (ver)->wValueLength + 3 ) & ~3 ) )
|
|
|
|
#define VersionInfo32_Children( ver ) \
|
1999-02-17 16:33:17 +01:00
|
|
|
(VS_VERSION_INFO_STRUCT32 *)( VersionInfo32_Value( ver ) + \
|
1999-01-31 11:11:54 +01:00
|
|
|
( ( (ver)->wValueLength * \
|
2005-07-26 20:25:34 +02:00
|
|
|
((ver)->wType? 2 : 1) + 3 ) & ~3 ) )
|
1999-01-31 11:11:54 +01:00
|
|
|
|
|
|
|
#define VersionInfo16_Next( ver ) \
|
1999-02-17 16:33:17 +01:00
|
|
|
(VS_VERSION_INFO_STRUCT16 *)( (LPBYTE)ver + (((ver)->wLength + 3) & ~3) )
|
1999-01-31 11:11:54 +01:00
|
|
|
#define VersionInfo32_Next( ver ) \
|
1999-02-17 16:33:17 +01:00
|
|
|
(VS_VERSION_INFO_STRUCT32 *)( (LPBYTE)ver + (((ver)->wLength + 3) & ~3) )
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2001-02-23 21:37:13 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* VERSION_GetFileVersionInfo_PE [internal]
|
|
|
|
*
|
2001-03-14 18:26:16 +01:00
|
|
|
* NOTE: returns size of the PE VERSION resource or 0xFFFFFFFF
|
2004-08-26 20:10:24 +02:00
|
|
|
* in the case the file is a PE module, but VERSION_INFO not found.
|
2001-02-23 21:37:13 +01:00
|
|
|
*/
|
2004-08-26 20:10:24 +02:00
|
|
|
static DWORD VERSION_GetFileVersionInfo_PE( LPCWSTR filename, DWORD datasize, LPVOID data )
|
2001-02-23 21:37:13 +01:00
|
|
|
{
|
|
|
|
VS_FIXEDFILEINFO *vffi;
|
|
|
|
DWORD len;
|
|
|
|
BYTE *buf;
|
|
|
|
HMODULE hModule;
|
|
|
|
HRSRC hRsrc;
|
|
|
|
HGLOBAL hMem;
|
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
TRACE("%s\n", debugstr_w(filename));
|
2001-02-23 21:37:13 +01:00
|
|
|
|
2004-04-06 00:51:37 +02:00
|
|
|
hModule = GetModuleHandleW(filename);
|
2001-02-23 21:37:13 +01:00
|
|
|
if(!hModule)
|
2004-04-06 00:51:37 +02:00
|
|
|
hModule = LoadLibraryExW(filename, 0, LOAD_LIBRARY_AS_DATAFILE);
|
2002-04-02 04:45:09 +02:00
|
|
|
else
|
2004-04-06 00:51:37 +02:00
|
|
|
hModule = LoadLibraryExW(filename, 0, 0);
|
2001-02-23 21:37:13 +01:00
|
|
|
if(!hModule)
|
|
|
|
{
|
2004-04-06 00:51:37 +02:00
|
|
|
WARN("Could not load %s\n", debugstr_w(filename));
|
2001-02-23 21:37:13 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
hRsrc = FindResourceW(hModule,
|
|
|
|
MAKEINTRESOURCEW(VS_VERSION_INFO),
|
|
|
|
MAKEINTRESOURCEW(VS_FILE_INFO));
|
|
|
|
if(!hRsrc)
|
|
|
|
{
|
2004-04-06 00:51:37 +02:00
|
|
|
WARN("Could not find VS_VERSION_INFO in %s\n", debugstr_w(filename));
|
2002-04-02 04:45:09 +02:00
|
|
|
FreeLibrary(hModule);
|
2001-03-14 18:26:16 +01:00
|
|
|
return 0xFFFFFFFF;
|
2001-02-23 21:37:13 +01:00
|
|
|
}
|
|
|
|
len = SizeofResource(hModule, hRsrc);
|
|
|
|
hMem = LoadResource(hModule, hRsrc);
|
|
|
|
if(!hMem)
|
|
|
|
{
|
2004-04-06 00:51:37 +02:00
|
|
|
WARN("Could not load VS_VERSION_INFO from %s\n", debugstr_w(filename));
|
2002-04-02 04:45:09 +02:00
|
|
|
FreeLibrary(hModule);
|
2001-03-14 18:26:16 +01:00
|
|
|
return 0xFFFFFFFF;
|
2001-02-23 21:37:13 +01:00
|
|
|
}
|
|
|
|
buf = LockResource(hMem);
|
|
|
|
|
|
|
|
vffi = (VS_FIXEDFILEINFO *)VersionInfo32_Value( (VS_VERSION_INFO_STRUCT32 *)buf );
|
|
|
|
|
|
|
|
if ( vffi->dwSignature != VS_FFI_SIGNATURE )
|
|
|
|
{
|
|
|
|
WARN("vffi->dwSignature is 0x%08lx, but not 0x%08lx!\n",
|
|
|
|
vffi->dwSignature, VS_FFI_SIGNATURE );
|
2001-03-14 18:26:16 +01:00
|
|
|
len = 0xFFFFFFFF;
|
2001-02-23 21:37:13 +01:00
|
|
|
goto END;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( TRACE_ON(ver) )
|
|
|
|
print_vffi_debug( vffi );
|
|
|
|
|
|
|
|
if(data)
|
|
|
|
{
|
2001-03-19 20:15:36 +01:00
|
|
|
if(datasize < len)
|
|
|
|
len = datasize; /* truncate data */
|
|
|
|
if(len)
|
2001-02-23 21:37:13 +01:00
|
|
|
memcpy(data, buf, len);
|
|
|
|
else
|
2001-03-14 18:26:16 +01:00
|
|
|
len = 0xFFFFFFFF;
|
2001-02-23 21:37:13 +01:00
|
|
|
}
|
|
|
|
END:
|
|
|
|
FreeResource(hMem);
|
2002-04-02 04:45:09 +02:00
|
|
|
FreeLibrary(hModule);
|
2001-02-23 21:37:13 +01:00
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* VERSION_GetFileVersionInfo_16 [internal]
|
|
|
|
*
|
2001-03-14 18:26:16 +01:00
|
|
|
* NOTE: returns size of the 16-bit VERSION resource or 0xFFFFFFFF
|
2004-08-26 20:10:24 +02:00
|
|
|
* in the case the file exists, but VERSION_INFO not found.
|
2001-02-23 21:37:13 +01:00
|
|
|
*/
|
2004-08-26 20:10:24 +02:00
|
|
|
static DWORD VERSION_GetFileVersionInfo_16( LPCSTR filename, DWORD datasize, LPVOID data )
|
2001-02-23 21:37:13 +01:00
|
|
|
{
|
|
|
|
VS_FIXEDFILEINFO *vffi;
|
2004-08-26 20:10:24 +02:00
|
|
|
DWORD len, offset;
|
2001-02-23 21:37:13 +01:00
|
|
|
BYTE *buf;
|
|
|
|
HMODULE16 hModule;
|
|
|
|
HRSRC16 hRsrc;
|
|
|
|
HGLOBAL16 hMem;
|
2004-08-26 20:10:24 +02:00
|
|
|
char dllname[20], owner[20], *p;
|
|
|
|
const char *basename;
|
|
|
|
BOOL is_builtin = FALSE;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_a(filename));
|
2001-02-23 21:37:13 +01:00
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
/* strip path information */
|
2001-02-23 21:37:13 +01:00
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
basename = filename;
|
|
|
|
if (basename[0] && basename[1] == ':') basename += 2; /* strip drive specification */
|
|
|
|
if ((p = strrchr( basename, '\\' ))) basename = p + 1;
|
|
|
|
if ((p = strrchr( basename, '/' ))) basename = p + 1;
|
|
|
|
|
|
|
|
if (strlen(basename) < sizeof(dllname)-4)
|
|
|
|
{
|
|
|
|
int file_exists;
|
|
|
|
|
|
|
|
strcpy( dllname, basename );
|
|
|
|
p = strrchr( dllname, '.' );
|
|
|
|
if (!p) strcat( dllname, ".dll" );
|
|
|
|
for (p = dllname; *p; p++) if (*p >= 'A' && *p <= 'Z') *p += 32;
|
|
|
|
|
|
|
|
if (wine_dll_get_owner( dllname, owner, sizeof(owner), &file_exists ) == 0)
|
|
|
|
is_builtin = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* first try without loading a 16-bit module */
|
|
|
|
if (is_builtin)
|
|
|
|
len = 0;
|
|
|
|
else
|
|
|
|
len = GetFileResourceSize16( filename,
|
|
|
|
MAKEINTRESOURCEA(VS_FILE_INFO),
|
|
|
|
MAKEINTRESOURCEA(VS_VERSION_INFO),
|
|
|
|
&offset );
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
if (!data) return len;
|
|
|
|
|
|
|
|
len = GetFileResource16( filename,
|
|
|
|
MAKEINTRESOURCEA(VS_FILE_INFO),
|
|
|
|
MAKEINTRESOURCEA(VS_VERSION_INFO),
|
|
|
|
offset, datasize, data );
|
|
|
|
if (len)
|
|
|
|
{
|
2005-07-27 17:14:33 +02:00
|
|
|
vffi = (VS_FIXEDFILEINFO *)VersionInfo16_Value( (VS_VERSION_INFO_STRUCT16 *)data );
|
2004-08-26 20:10:24 +02:00
|
|
|
|
|
|
|
if ( vffi->dwSignature == VS_FFI_SIGNATURE )
|
|
|
|
{
|
|
|
|
if ( ((VS_VERSION_INFO_STRUCT16 *)data)->wLength < len )
|
|
|
|
len = ((VS_VERSION_INFO_STRUCT16 *)data)->wLength;
|
|
|
|
|
|
|
|
if ( TRACE_ON(ver) )
|
|
|
|
print_vffi_debug( vffi );
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this might be a builtin 16-bit module */
|
2002-04-02 04:45:09 +02:00
|
|
|
hModule = LoadLibrary16(filename);
|
2001-02-23 21:37:13 +01:00
|
|
|
if(hModule < 32)
|
|
|
|
{
|
|
|
|
WARN("Could not load %s\n", debugstr_a(filename));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
hRsrc = FindResource16(hModule,
|
|
|
|
MAKEINTRESOURCEA(VS_VERSION_INFO),
|
|
|
|
MAKEINTRESOURCEA(VS_FILE_INFO));
|
|
|
|
if(!hRsrc)
|
|
|
|
{
|
|
|
|
WARN("Could not find VS_VERSION_INFO in %s\n", debugstr_a(filename));
|
2002-04-02 04:45:09 +02:00
|
|
|
FreeLibrary16(hModule);
|
2001-03-14 18:26:16 +01:00
|
|
|
return 0xFFFFFFFF;
|
2001-02-23 21:37:13 +01:00
|
|
|
}
|
|
|
|
len = SizeofResource16(hModule, hRsrc);
|
|
|
|
hMem = LoadResource16(hModule, hRsrc);
|
|
|
|
if(!hMem)
|
|
|
|
{
|
|
|
|
WARN("Could not load VS_VERSION_INFO from %s\n", debugstr_a(filename));
|
2002-04-02 04:45:09 +02:00
|
|
|
FreeLibrary16(hModule);
|
2001-03-14 18:26:16 +01:00
|
|
|
return 0xFFFFFFFF;
|
2001-02-23 21:37:13 +01:00
|
|
|
}
|
|
|
|
buf = LockResource16(hMem);
|
|
|
|
|
|
|
|
if(!VersionInfoIs16(buf))
|
2004-08-26 20:10:24 +02:00
|
|
|
{
|
|
|
|
len = 0xFFFFFFFF;
|
2001-02-23 21:37:13 +01:00
|
|
|
goto END;
|
2004-08-26 20:10:24 +02:00
|
|
|
}
|
2001-02-23 21:37:13 +01:00
|
|
|
|
|
|
|
vffi = (VS_FIXEDFILEINFO *)VersionInfo16_Value( (VS_VERSION_INFO_STRUCT16 *)buf );
|
|
|
|
|
|
|
|
if ( vffi->dwSignature != VS_FFI_SIGNATURE )
|
|
|
|
{
|
|
|
|
WARN("vffi->dwSignature is 0x%08lx, but not 0x%08lx!\n",
|
|
|
|
vffi->dwSignature, VS_FFI_SIGNATURE );
|
2001-03-14 18:26:16 +01:00
|
|
|
len = 0xFFFFFFFF;
|
2001-02-23 21:37:13 +01:00
|
|
|
goto END;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( TRACE_ON(ver) )
|
|
|
|
print_vffi_debug( vffi );
|
|
|
|
|
|
|
|
if(data)
|
|
|
|
{
|
2001-03-19 20:15:36 +01:00
|
|
|
if(datasize < len)
|
|
|
|
len = datasize; /* truncate data */
|
|
|
|
if(len)
|
2001-02-23 21:37:13 +01:00
|
|
|
memcpy(data, buf, len);
|
|
|
|
else
|
2001-03-14 18:26:16 +01:00
|
|
|
len = 0xFFFFFFFF;
|
2001-02-23 21:37:13 +01:00
|
|
|
}
|
|
|
|
END:
|
|
|
|
FreeResource16(hMem);
|
2002-04-02 04:45:09 +02:00
|
|
|
FreeLibrary16(hModule);
|
2001-02-23 21:37:13 +01:00
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
1999-01-31 11:11:54 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2004-04-06 00:51:37 +02:00
|
|
|
* GetFileVersionInfoSizeW [VERSION.@]
|
1999-01-31 11:11:54 +01:00
|
|
|
*/
|
2004-04-06 00:51:37 +02:00
|
|
|
DWORD WINAPI GetFileVersionInfoSizeW( LPCWSTR filename, LPDWORD handle )
|
1999-01-31 11:11:54 +01:00
|
|
|
{
|
2004-08-26 20:10:24 +02:00
|
|
|
DWORD len;
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2004-04-06 00:51:37 +02:00
|
|
|
TRACE("(%s,%p)\n", debugstr_w(filename), handle );
|
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
if (handle) *handle = 0;
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2004-08-31 19:31:40 +02:00
|
|
|
if (!filename)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!*filename)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_BAD_PATHNAME);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
len = VERSION_GetFileVersionInfo_PE(filename, 0, NULL);
|
|
|
|
/* 0xFFFFFFFF means: file is a PE module, but VERSION_INFO not found */
|
2002-08-14 23:04:54 +02:00
|
|
|
if(len == 0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
|
2004-08-26 20:10:24 +02:00
|
|
|
return 0;
|
2004-04-06 00:51:37 +02:00
|
|
|
}
|
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
if (!len)
|
2002-08-14 23:04:54 +02:00
|
|
|
{
|
2004-08-26 20:10:24 +02:00
|
|
|
LPSTR filenameA;
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
|
|
|
|
filenameA = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, filename, -1, filenameA, len, NULL, NULL );
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
len = VERSION_GetFileVersionInfo_16(filenameA, 0, NULL);
|
|
|
|
HeapFree( GetProcessHeap(), 0, filenameA );
|
|
|
|
/* 0xFFFFFFFF means: file exists, but VERSION_INFO not found */
|
2004-08-31 19:31:40 +02:00
|
|
|
if (!len)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_FILE_NOT_FOUND);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (len == 0xFFFFFFFF)
|
2004-08-26 20:10:24 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-08-29 16:17:27 +02:00
|
|
|
|
|
|
|
/* We have a 16bit resource.
|
|
|
|
*
|
|
|
|
* XP/W2K/W2K3 uses a buffer which is more than the actual needed space:
|
|
|
|
*
|
|
|
|
* (info->wLength - sizeof(VS_FIXEDFILEINFO)) * 4
|
|
|
|
*
|
|
|
|
* This extra buffer is used for ANSI to Unicode conversions in W-Calls.
|
|
|
|
* info->wLength should be the same as len. Currently it isn't but that
|
|
|
|
* doesn't seem to be a problem (len is bigger then info->wLength).
|
|
|
|
*/
|
|
|
|
len = (len - sizeof(VS_FIXEDFILEINFO)) * 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We have a 32bit resource.
|
|
|
|
*
|
|
|
|
* XP/W2K/W2K3 uses a buffer which is 2 times the actual needed space + 4 bytes "FE2X"
|
|
|
|
* This extra buffer is used for Unicode to ANSI conversions in A-Calls
|
|
|
|
*/
|
|
|
|
len = (len * 2) + 4;
|
1999-01-31 11:11:54 +01:00
|
|
|
}
|
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
SetLastError(0);
|
1999-01-31 11:11:54 +01:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2004-04-06 00:51:37 +02:00
|
|
|
* GetFileVersionInfoSizeA [VERSION.@]
|
1999-01-31 11:11:54 +01:00
|
|
|
*/
|
2004-04-06 00:51:37 +02:00
|
|
|
DWORD WINAPI GetFileVersionInfoSizeA( LPCSTR filename, LPDWORD handle )
|
2005-07-26 17:50:17 +02:00
|
|
|
{
|
|
|
|
UNICODE_STRING filenameW;
|
2004-04-06 00:51:37 +02:00
|
|
|
DWORD retval;
|
2005-07-20 12:29:29 +02:00
|
|
|
|
|
|
|
TRACE("(%s,%p)\n", debugstr_a(filename), handle );
|
|
|
|
|
2005-07-26 17:50:17 +02:00
|
|
|
if(filename)
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
|
|
|
|
else
|
|
|
|
filenameW.Buffer = NULL;
|
2001-03-14 18:26:16 +01:00
|
|
|
|
2005-07-26 17:50:17 +02:00
|
|
|
retval = GetFileVersionInfoSizeW(filenameW.Buffer, handle);
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2004-04-06 00:51:37 +02:00
|
|
|
RtlFreeUnicodeString(&filenameW);
|
2004-08-26 20:10:24 +02:00
|
|
|
|
2005-07-26 17:50:17 +02:00
|
|
|
return retval;
|
1999-01-31 11:11:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* GetFileVersionInfoW [VERSION.@]
|
1999-01-31 11:11:54 +01:00
|
|
|
*/
|
2001-03-16 17:42:20 +01:00
|
|
|
BOOL WINAPI GetFileVersionInfoW( LPCWSTR filename, DWORD handle,
|
1999-01-31 11:11:54 +01:00
|
|
|
DWORD datasize, LPVOID data )
|
|
|
|
{
|
2004-08-26 20:10:24 +02:00
|
|
|
DWORD len;
|
2005-08-29 16:17:27 +02:00
|
|
|
VS_VERSION_INFO_STRUCT32* vvis = (VS_VERSION_INFO_STRUCT32*)data;
|
2000-11-16 01:28:52 +01:00
|
|
|
|
1999-05-14 10:17:14 +02:00
|
|
|
TRACE("(%s,%ld,size=%ld,data=%p)\n",
|
2000-11-16 01:28:52 +01:00
|
|
|
debugstr_w(filename), handle, datasize, data );
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2005-01-04 21:35:46 +01:00
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_DATA);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-08-26 20:10:24 +02:00
|
|
|
len = VERSION_GetFileVersionInfo_PE(filename, datasize, data);
|
|
|
|
/* 0xFFFFFFFF means: file is a PE module, but VERSION_INFO not found */
|
|
|
|
if (len == 0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-02-23 21:37:13 +01:00
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
if (!len)
|
|
|
|
{
|
|
|
|
LPSTR filenameA;
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2004-08-26 20:10:24 +02:00
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
|
|
|
|
filenameA = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, filename, -1, filenameA, len, NULL, NULL );
|
|
|
|
|
|
|
|
len = VERSION_GetFileVersionInfo_16(filenameA, datasize, data);
|
|
|
|
HeapFree( GetProcessHeap(), 0, filenameA );
|
|
|
|
/* 0xFFFFFFFF means: file exists, but VERSION_INFO not found */
|
|
|
|
if (!len || len == 0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-08-29 16:17:27 +02:00
|
|
|
/* We have a 16bit resource. */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-04 13:30:20 +02:00
|
|
|
static const char signature[] = "FE2X";
|
|
|
|
DWORD bufsize = vvis->wLength + strlen(signature);
|
2005-08-29 16:17:27 +02:00
|
|
|
DWORD convbuf;
|
|
|
|
|
|
|
|
/* We have a 32bit resource.
|
|
|
|
*
|
|
|
|
* XP/W2K/W2K3 uses a buffer which is 2 times the actual needed space + 4 bytes "FE2X"
|
|
|
|
* This extra buffer is used for Unicode to ANSI conversions in A-Calls
|
|
|
|
*/
|
|
|
|
|
2005-10-04 13:30:20 +02:00
|
|
|
/* information is truncated to datasize bytes */
|
|
|
|
if (datasize >= bufsize)
|
|
|
|
{
|
|
|
|
convbuf = datasize - vvis->wLength;
|
|
|
|
memcpy( ((char*)(data))+vvis->wLength, signature, convbuf > 4 ? 4 : convbuf );
|
|
|
|
}
|
2004-08-26 20:10:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SetLastError(0);
|
|
|
|
return TRUE;
|
1999-01-31 11:11:54 +01:00
|
|
|
}
|
|
|
|
|
2005-07-26 17:50:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetFileVersionInfoA [VERSION.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetFileVersionInfoA( LPCSTR filename, DWORD handle,
|
|
|
|
DWORD datasize, LPVOID data )
|
|
|
|
{
|
|
|
|
UNICODE_STRING filenameW;
|
|
|
|
BOOL retval;
|
2005-07-29 16:15:56 +02:00
|
|
|
|
2005-07-26 17:50:17 +02:00
|
|
|
TRACE("(%s,%ld,size=%ld,data=%p)\n",
|
|
|
|
debugstr_a(filename), handle, datasize, data );
|
2005-07-29 16:15:56 +02:00
|
|
|
|
2005-07-26 17:50:17 +02:00
|
|
|
if(filename)
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
|
|
|
|
else
|
|
|
|
filenameW.Buffer = NULL;
|
2005-07-29 16:15:56 +02:00
|
|
|
|
2005-07-26 17:50:17 +02:00
|
|
|
retval = GetFileVersionInfoW(filenameW.Buffer, handle, datasize, data);
|
2005-07-29 16:15:56 +02:00
|
|
|
|
2005-07-30 21:04:01 +02:00
|
|
|
RtlFreeUnicodeString(&filenameW);
|
|
|
|
|
2005-07-26 17:50:17 +02:00
|
|
|
return retval;
|
|
|
|
}
|
1999-01-31 11:11:54 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* VersionInfo16_FindChild [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static VS_VERSION_INFO_STRUCT16 *VersionInfo16_FindChild( VS_VERSION_INFO_STRUCT16 *info,
|
1999-02-26 12:11:13 +01:00
|
|
|
LPCSTR szKey, UINT cbKey )
|
1999-01-31 11:11:54 +01:00
|
|
|
{
|
1999-02-17 16:33:17 +01:00
|
|
|
VS_VERSION_INFO_STRUCT16 *child = VersionInfo16_Children( info );
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2005-09-12 17:14:06 +02:00
|
|
|
while ((char *)child < (char *)info + info->wLength )
|
1999-01-31 11:11:54 +01:00
|
|
|
{
|
2000-09-26 01:30:56 +02:00
|
|
|
if ( !strncasecmp( child->szKey, szKey, cbKey ) )
|
1999-01-31 11:11:54 +01:00
|
|
|
return child;
|
|
|
|
|
1999-02-19 15:12:16 +01:00
|
|
|
if (!(child->wLength)) return NULL;
|
1999-01-31 11:11:54 +01:00
|
|
|
child = VersionInfo16_Next( child );
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* VersionInfo32_FindChild [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static VS_VERSION_INFO_STRUCT32 *VersionInfo32_FindChild( VS_VERSION_INFO_STRUCT32 *info,
|
1999-02-26 12:11:13 +01:00
|
|
|
LPCWSTR szKey, UINT cbKey )
|
1999-01-31 11:11:54 +01:00
|
|
|
{
|
1999-02-17 16:33:17 +01:00
|
|
|
VS_VERSION_INFO_STRUCT32 *child = VersionInfo32_Children( info );
|
1999-01-31 11:11:54 +01:00
|
|
|
|
2005-09-12 17:14:06 +02:00
|
|
|
while ((char *)child < (char *)info + info->wLength )
|
1999-01-31 11:11:54 +01:00
|
|
|
{
|
2000-06-13 03:10:29 +02:00
|
|
|
if ( !strncmpiW( child->szKey, szKey, cbKey ) )
|
1999-01-31 11:11:54 +01:00
|
|
|
return child;
|
|
|
|
|
|
|
|
child = VersionInfo32_Next( child );
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2004-01-28 21:06:14 +01:00
|
|
|
* VersionInfo16_QueryValue [internal]
|
|
|
|
*
|
|
|
|
* Gets a value from a 16-bit NE resource
|
1999-01-31 11:11:54 +01:00
|
|
|
*/
|
2005-07-28 20:32:32 +02:00
|
|
|
static BOOL WINAPI VersionInfo16_QueryValue( VS_VERSION_INFO_STRUCT16 *info, LPCSTR lpSubBlock,
|
1999-02-26 12:11:13 +01:00
|
|
|
LPVOID *lplpBuffer, UINT *puLen )
|
1999-01-31 11:11:54 +01:00
|
|
|
{
|
|
|
|
while ( *lpSubBlock )
|
|
|
|
{
|
|
|
|
/* Find next path component */
|
|
|
|
LPCSTR lpNextSlash;
|
|
|
|
for ( lpNextSlash = lpSubBlock; *lpNextSlash; lpNextSlash++ )
|
|
|
|
if ( *lpNextSlash == '\\' )
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Skip empty components */
|
|
|
|
if ( lpNextSlash == lpSubBlock )
|
|
|
|
{
|
|
|
|
lpSubBlock++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have a non-empty component: search info for key */
|
|
|
|
info = VersionInfo16_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock );
|
|
|
|
if ( !info ) return FALSE;
|
|
|
|
|
|
|
|
/* Skip path component */
|
|
|
|
lpSubBlock = lpNextSlash;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return value */
|
|
|
|
*lplpBuffer = VersionInfo16_Value( info );
|
2005-01-04 21:35:46 +01:00
|
|
|
if (puLen)
|
|
|
|
*puLen = info->wValueLength;
|
1999-01-31 11:11:54 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-28 20:32:32 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* VersionInfo32_QueryValue [internal]
|
|
|
|
*
|
|
|
|
* Gets a value from a 32-bit PE resource
|
|
|
|
*/
|
|
|
|
static BOOL WINAPI VersionInfo32_QueryValue( VS_VERSION_INFO_STRUCT32 *info, LPCWSTR lpSubBlock,
|
|
|
|
LPVOID *lplpBuffer, UINT *puLen )
|
|
|
|
{
|
|
|
|
TRACE("lpSubBlock : (%s)\n", debugstr_w(lpSubBlock));
|
|
|
|
|
|
|
|
while ( *lpSubBlock )
|
|
|
|
{
|
|
|
|
/* Find next path component */
|
|
|
|
LPCWSTR lpNextSlash;
|
|
|
|
for ( lpNextSlash = lpSubBlock; *lpNextSlash; lpNextSlash++ )
|
|
|
|
if ( *lpNextSlash == '\\' )
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Skip empty components */
|
|
|
|
if ( lpNextSlash == lpSubBlock )
|
|
|
|
{
|
|
|
|
lpSubBlock++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have a non-empty component: search info for key */
|
|
|
|
info = VersionInfo32_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock );
|
|
|
|
if ( !info ) return FALSE;
|
|
|
|
|
|
|
|
/* Skip path component */
|
|
|
|
lpSubBlock = lpNextSlash;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return value */
|
|
|
|
*lplpBuffer = VersionInfo32_Value( info );
|
|
|
|
if (puLen)
|
|
|
|
*puLen = info->wValueLength;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-01-28 21:06:14 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* VerQueryValueA [VERSION.@]
|
|
|
|
*/
|
2005-07-28 12:47:37 +02:00
|
|
|
BOOL WINAPI VerQueryValueA( LPVOID pBlock, LPCSTR lpSubBlock,
|
2004-01-28 21:06:14 +01:00
|
|
|
LPVOID *lplpBuffer, UINT *puLen )
|
|
|
|
{
|
2005-07-29 16:15:56 +02:00
|
|
|
static const char rootA[] = "\\";
|
|
|
|
static const char varfileinfoA[] = "\\VarFileInfo\\Translation";
|
2004-01-28 21:06:14 +01:00
|
|
|
VS_VERSION_INFO_STRUCT16 *info = (VS_VERSION_INFO_STRUCT16 *)pBlock;
|
|
|
|
|
|
|
|
TRACE("(%p,%s,%p,%p)\n",
|
|
|
|
pBlock, debugstr_a(lpSubBlock), lplpBuffer, puLen );
|
|
|
|
|
|
|
|
if ( !VersionInfoIs16( info ) )
|
|
|
|
{
|
2005-07-29 16:15:56 +02:00
|
|
|
BOOL ret;
|
|
|
|
INT len;
|
|
|
|
LPWSTR lpSubBlockW;
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, lpSubBlock, -1, NULL, 0);
|
|
|
|
lpSubBlockW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (!lpSubBlockW)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpSubBlock, -1, lpSubBlockW, len);
|
|
|
|
|
|
|
|
ret = VersionInfo32_QueryValue(pBlock, lpSubBlockW, lplpBuffer, puLen);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpSubBlockW);
|
|
|
|
|
2005-08-03 13:04:13 +02:00
|
|
|
if (ret && strcasecmp( lpSubBlock, rootA ) && strcasecmp( lpSubBlock, varfileinfoA ))
|
2005-07-29 16:15:56 +02:00
|
|
|
{
|
2005-08-29 17:10:02 +02:00
|
|
|
LPSTR lpBufferA = (LPSTR)pBlock + info->wLength + 4;
|
|
|
|
DWORD pos = (LPSTR)*lplpBuffer - (LPSTR)pBlock;
|
2005-07-29 16:15:56 +02:00
|
|
|
|
2005-08-29 17:10:02 +02:00
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)*lplpBuffer, -1,
|
|
|
|
lpBufferA + pos, info->wLength - pos, NULL, NULL);
|
|
|
|
*lplpBuffer = lpBufferA + pos;
|
2005-07-29 16:15:56 +02:00
|
|
|
*puLen = len;
|
|
|
|
}
|
2005-08-03 13:04:13 +02:00
|
|
|
return ret;
|
2004-01-28 21:06:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return VersionInfo16_QueryValue(info, lpSubBlock, lplpBuffer, puLen);
|
|
|
|
}
|
|
|
|
|
1999-01-31 11:11:54 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* VerQueryValueW [VERSION.@]
|
1999-01-31 11:11:54 +01:00
|
|
|
*/
|
2005-07-28 12:47:37 +02:00
|
|
|
BOOL WINAPI VerQueryValueW( LPVOID pBlock, LPCWSTR lpSubBlock,
|
1999-02-26 12:11:13 +01:00
|
|
|
LPVOID *lplpBuffer, UINT *puLen )
|
1999-01-31 11:11:54 +01:00
|
|
|
{
|
2005-07-29 16:15:56 +02:00
|
|
|
static const WCHAR rootW[] = { '\\', 0 };
|
|
|
|
static const 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 };
|
|
|
|
|
1999-02-17 16:33:17 +01:00
|
|
|
VS_VERSION_INFO_STRUCT32 *info = (VS_VERSION_INFO_STRUCT32 *)pBlock;
|
1999-01-31 11:11:54 +01:00
|
|
|
|
1999-05-14 10:17:14 +02:00
|
|
|
TRACE("(%p,%s,%p,%p)\n",
|
1999-01-31 11:11:54 +01:00
|
|
|
pBlock, debugstr_w(lpSubBlock), lplpBuffer, puLen );
|
|
|
|
|
2004-01-28 21:06:14 +01:00
|
|
|
if ( VersionInfoIs16( info ) )
|
|
|
|
{
|
2005-07-28 12:47:37 +02:00
|
|
|
BOOL ret;
|
2005-07-29 16:15:56 +02:00
|
|
|
int len;
|
|
|
|
LPSTR lpSubBlockA;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, lpSubBlock, -1, NULL, 0, NULL, NULL);
|
|
|
|
lpSubBlockA = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
|
|
|
|
|
2004-01-28 21:06:14 +01:00
|
|
|
if (!lpSubBlockA)
|
|
|
|
return FALSE;
|
2005-07-29 16:15:56 +02:00
|
|
|
|
2004-01-28 21:06:14 +01:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpSubBlock, -1, lpSubBlockA, len, NULL, NULL);
|
2005-07-29 16:15:56 +02:00
|
|
|
|
2004-01-28 21:06:14 +01:00
|
|
|
ret = VersionInfo16_QueryValue(pBlock, lpSubBlockA, lplpBuffer, puLen);
|
2005-07-29 16:15:56 +02:00
|
|
|
|
2004-01-28 21:06:14 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpSubBlockA);
|
2005-07-29 16:15:56 +02:00
|
|
|
|
2005-08-03 13:04:13 +02:00
|
|
|
if (ret && strcmpiW( lpSubBlock, rootW ) && strcmpiW( lpSubBlock, varfileinfoW ))
|
2005-07-29 16:15:56 +02:00
|
|
|
{
|
2005-08-29 17:10:02 +02:00
|
|
|
LPWSTR lpBufferW = (LPWSTR)((LPSTR)pBlock + info->wLength);
|
|
|
|
DWORD pos = (LPSTR)*lplpBuffer - (LPSTR)pBlock;
|
|
|
|
DWORD max = (info->wLength - sizeof(VS_FIXEDFILEINFO)) * 4 - info->wLength;
|
2005-07-29 16:15:56 +02:00
|
|
|
|
2005-08-29 17:10:02 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*lplpBuffer, -1,
|
|
|
|
lpBufferW + pos, max/sizeof(WCHAR) - pos );
|
|
|
|
*lplpBuffer = lpBufferW + pos;
|
2005-07-29 16:15:56 +02:00
|
|
|
*puLen = len;
|
|
|
|
}
|
2005-08-03 13:04:13 +02:00
|
|
|
return ret;
|
2004-01-28 21:06:14 +01:00
|
|
|
}
|
|
|
|
|
2005-07-28 20:32:32 +02:00
|
|
|
return VersionInfo32_QueryValue(info, lpSubBlock, lplpBuffer, puLen);
|
1999-01-31 11:11:54 +01:00
|
|
|
}
|