2 * Implementation of VERSION.DLL - Version Info access
4 * Copyright 1996,1997 Marcus Meissner
5 * Copyright 1997 David Cuthbert
6 * Copyright 1999 Ulrich Weigand
7 * Copyright 2005 Paul Vriens
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #include "wine/winuser16.h"
35 #include "wine/unicode.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(ver
);
41 /******************************************************************************
43 * This function will print via standard TRACE, debug info regarding
44 * the file info structure vffi.
45 * 15-Feb-1998 Dimitrie Paun (dimi@cs.toronto.edu)
46 * Added this function to clean up the code.
48 *****************************************************************************/
49 static void print_vffi_debug(VS_FIXEDFILEINFO
*vffi
)
51 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",
52 HIWORD(vffi
->dwStrucVersion
),LOWORD(vffi
->dwStrucVersion
),
53 HIWORD(vffi
->dwFileVersionMS
),LOWORD(vffi
->dwFileVersionMS
),
54 HIWORD(vffi
->dwFileVersionLS
),LOWORD(vffi
->dwFileVersionLS
),
55 HIWORD(vffi
->dwProductVersionMS
),LOWORD(vffi
->dwProductVersionMS
),
56 HIWORD(vffi
->dwProductVersionLS
),LOWORD(vffi
->dwProductVersionLS
),
57 vffi
->dwFileFlagsMask
,
58 (vffi
->dwFileFlags
& VS_FF_DEBUG
) ? "DEBUG," : "",
59 (vffi
->dwFileFlags
& VS_FF_PRERELEASE
) ? "PRERELEASE," : "",
60 (vffi
->dwFileFlags
& VS_FF_PATCHED
) ? "PATCHED," : "",
61 (vffi
->dwFileFlags
& VS_FF_PRIVATEBUILD
) ? "PRIVATEBUILD," : "",
62 (vffi
->dwFileFlags
& VS_FF_INFOINFERRED
) ? "INFOINFERRED," : "",
63 (vffi
->dwFileFlags
& VS_FF_SPECIALBUILD
) ? "SPECIALBUILD," : "");
67 TRACE("OS=0x%x.0x%x ", HIWORD(vffi
->dwFileOS
), LOWORD(vffi
->dwFileOS
));
69 switch (vffi
->dwFileOS
&0xFFFF0000)
71 case VOS_DOS
:TRACE("DOS,");break;
72 case VOS_OS216
:TRACE("OS/2-16,");break;
73 case VOS_OS232
:TRACE("OS/2-32,");break;
74 case VOS_NT
:TRACE("NT,");break;
77 TRACE("UNKNOWN(0x%lx),",vffi
->dwFileOS
&0xFFFF0000);break;
80 switch (LOWORD(vffi
->dwFileOS
))
82 case VOS__BASE
:TRACE("BASE");break;
83 case VOS__WINDOWS16
:TRACE("WIN16");break;
84 case VOS__WINDOWS32
:TRACE("WIN32");break;
85 case VOS__PM16
:TRACE("PM16");break;
86 case VOS__PM32
:TRACE("PM32");break;
88 TRACE("UNKNOWN(0x%x)",LOWORD(vffi
->dwFileOS
));break;
93 switch (vffi
->dwFileType
)
95 case VFT_APP
:TRACE("filetype=APP");break;
96 case VFT_DLL
:TRACE("filetype=DLL");break;
98 TRACE("filetype=DRV,");
99 switch(vffi
->dwFileSubtype
)
101 case VFT2_DRV_PRINTER
:TRACE("PRINTER");break;
102 case VFT2_DRV_KEYBOARD
:TRACE("KEYBOARD");break;
103 case VFT2_DRV_LANGUAGE
:TRACE("LANGUAGE");break;
104 case VFT2_DRV_DISPLAY
:TRACE("DISPLAY");break;
105 case VFT2_DRV_MOUSE
:TRACE("MOUSE");break;
106 case VFT2_DRV_NETWORK
:TRACE("NETWORK");break;
107 case VFT2_DRV_SYSTEM
:TRACE("SYSTEM");break;
108 case VFT2_DRV_INSTALLABLE
:TRACE("INSTALLABLE");break;
109 case VFT2_DRV_SOUND
:TRACE("SOUND");break;
110 case VFT2_DRV_COMM
:TRACE("COMM");break;
111 case VFT2_DRV_INPUTMETHOD
:TRACE("INPUTMETHOD");break;
114 TRACE("UNKNOWN(0x%lx)",vffi
->dwFileSubtype
);break;
118 TRACE("filetype=FONT,");
119 switch (vffi
->dwFileSubtype
)
121 case VFT2_FONT_RASTER
:TRACE("RASTER");break;
122 case VFT2_FONT_VECTOR
:TRACE("VECTOR");break;
123 case VFT2_FONT_TRUETYPE
:TRACE("TRUETYPE");break;
124 default:TRACE("UNKNOWN(0x%lx)",vffi
->dwFileSubtype
);break;
127 case VFT_VXD
:TRACE("filetype=VXD");break;
128 case VFT_STATIC_LIB
:TRACE("filetype=STATIC_LIB");break;
131 TRACE("filetype=Unknown(0x%lx)",vffi
->dwFileType
);break;
135 TRACE("filedate=0x%lx.0x%lx\n",vffi
->dwFileDateMS
,vffi
->dwFileDateLS
);
138 /***********************************************************************
139 * Version Info Structure
147 #if 0 /* variable length structure */
151 VS_VERSION_INFO_STRUCT16 Children
[];
153 } VS_VERSION_INFO_STRUCT16
;
161 #if 0 /* variable length structure */
165 VS_VERSION_INFO_STRUCT32 Children
[];
167 } VS_VERSION_INFO_STRUCT32
;
169 #define VersionInfoIs16( ver ) \
170 ( ((VS_VERSION_INFO_STRUCT16 *)ver)->szKey[0] >= ' ' )
172 #define DWORD_ALIGN( base, ptr ) \
173 ( (LPBYTE)(base) + ((((LPBYTE)(ptr) - (LPBYTE)(base)) + 3) & ~3) )
175 #define VersionInfo16_Value( ver ) \
176 DWORD_ALIGN( (ver), (ver)->szKey + strlen((ver)->szKey) + 1 )
177 #define VersionInfo32_Value( ver ) \
178 DWORD_ALIGN( (ver), (ver)->szKey + strlenW((ver)->szKey) + 1 )
180 #define VersionInfo16_Children( ver ) \
181 (VS_VERSION_INFO_STRUCT16 *)( VersionInfo16_Value( ver ) + \
182 ( ( (ver)->wValueLength + 3 ) & ~3 ) )
183 #define VersionInfo32_Children( ver ) \
184 (VS_VERSION_INFO_STRUCT32 *)( VersionInfo32_Value( ver ) + \
185 ( ( (ver)->wValueLength * \
186 ((ver)->wType? 2 : 1) + 3 ) & ~3 ) )
188 #define VersionInfo16_Next( ver ) \
189 (VS_VERSION_INFO_STRUCT16 *)( (LPBYTE)ver + (((ver)->wLength + 3) & ~3) )
190 #define VersionInfo32_Next( ver ) \
191 (VS_VERSION_INFO_STRUCT32 *)( (LPBYTE)ver + (((ver)->wLength + 3) & ~3) )
193 /***********************************************************************
194 * VERSION_GetFileVersionInfo_PE [internal]
196 * NOTE: returns size of the PE VERSION resource or 0xFFFFFFFF
197 * in the case the file is a PE module, but VERSION_INFO not found.
199 static DWORD
VERSION_GetFileVersionInfo_PE( LPCWSTR filename
, DWORD datasize
, LPVOID data
)
201 VS_FIXEDFILEINFO
*vffi
;
208 TRACE("%s\n", debugstr_w(filename
));
210 hModule
= GetModuleHandleW(filename
);
212 hModule
= LoadLibraryExW(filename
, 0, LOAD_LIBRARY_AS_DATAFILE
);
214 hModule
= LoadLibraryExW(filename
, 0, 0);
217 WARN("Could not load %s\n", debugstr_w(filename
));
220 hRsrc
= FindResourceW(hModule
,
221 MAKEINTRESOURCEW(VS_VERSION_INFO
),
222 MAKEINTRESOURCEW(VS_FILE_INFO
));
225 WARN("Could not find VS_VERSION_INFO in %s\n", debugstr_w(filename
));
226 FreeLibrary(hModule
);
229 len
= SizeofResource(hModule
, hRsrc
);
230 hMem
= LoadResource(hModule
, hRsrc
);
233 WARN("Could not load VS_VERSION_INFO from %s\n", debugstr_w(filename
));
234 FreeLibrary(hModule
);
237 buf
= LockResource(hMem
);
239 vffi
= (VS_FIXEDFILEINFO
*)VersionInfo32_Value( (VS_VERSION_INFO_STRUCT32
*)buf
);
241 if ( vffi
->dwSignature
!= VS_FFI_SIGNATURE
)
243 WARN("vffi->dwSignature is 0x%08lx, but not 0x%08lx!\n",
244 vffi
->dwSignature
, VS_FFI_SIGNATURE
);
250 print_vffi_debug( vffi
);
255 len
= datasize
; /* truncate data */
257 memcpy(data
, buf
, len
);
263 FreeLibrary(hModule
);
268 /***********************************************************************
269 * VERSION_GetFileVersionInfo_16 [internal]
271 * NOTE: returns size of the 16-bit VERSION resource or 0xFFFFFFFF
272 * in the case the file exists, but VERSION_INFO not found.
274 static DWORD
VERSION_GetFileVersionInfo_16( LPCSTR filename
, DWORD datasize
, LPVOID data
)
276 VS_FIXEDFILEINFO
*vffi
;
282 char dllname
[20], owner
[20], *p
;
283 const char *basename
;
284 BOOL is_builtin
= FALSE
;
286 TRACE("%s\n", debugstr_a(filename
));
288 /* strip path information */
291 if (basename
[0] && basename
[1] == ':') basename
+= 2; /* strip drive specification */
292 if ((p
= strrchr( basename
, '\\' ))) basename
= p
+ 1;
293 if ((p
= strrchr( basename
, '/' ))) basename
= p
+ 1;
295 if (strlen(basename
) < sizeof(dllname
)-4)
299 strcpy( dllname
, basename
);
300 p
= strrchr( dllname
, '.' );
301 if (!p
) strcat( dllname
, ".dll" );
302 for (p
= dllname
; *p
; p
++) if (*p
>= 'A' && *p
<= 'Z') *p
+= 32;
304 if (wine_dll_get_owner( dllname
, owner
, sizeof(owner
), &file_exists
) == 0)
308 /* first try without loading a 16-bit module */
312 len
= GetFileResourceSize16( filename
,
313 MAKEINTRESOURCEA(VS_FILE_INFO
),
314 MAKEINTRESOURCEA(VS_VERSION_INFO
),
318 if (!data
) return len
;
320 len
= GetFileResource16( filename
,
321 MAKEINTRESOURCEA(VS_FILE_INFO
),
322 MAKEINTRESOURCEA(VS_VERSION_INFO
),
323 offset
, datasize
, data
);
326 vffi
= (VS_FIXEDFILEINFO
*)VersionInfo16_Value( (VS_VERSION_INFO_STRUCT16
*)data
);
328 if ( vffi
->dwSignature
== VS_FFI_SIGNATURE
)
330 if ( ((VS_VERSION_INFO_STRUCT16
*)data
)->wLength
< len
)
331 len
= ((VS_VERSION_INFO_STRUCT16
*)data
)->wLength
;
334 print_vffi_debug( vffi
);
341 /* this might be a builtin 16-bit module */
342 hModule
= LoadLibrary16(filename
);
345 WARN("Could not load %s\n", debugstr_a(filename
));
348 hRsrc
= FindResource16(hModule
,
349 MAKEINTRESOURCEA(VS_VERSION_INFO
),
350 MAKEINTRESOURCEA(VS_FILE_INFO
));
353 WARN("Could not find VS_VERSION_INFO in %s\n", debugstr_a(filename
));
354 FreeLibrary16(hModule
);
357 len
= SizeofResource16(hModule
, hRsrc
);
358 hMem
= LoadResource16(hModule
, hRsrc
);
361 WARN("Could not load VS_VERSION_INFO from %s\n", debugstr_a(filename
));
362 FreeLibrary16(hModule
);
365 buf
= LockResource16(hMem
);
367 if(!VersionInfoIs16(buf
))
373 vffi
= (VS_FIXEDFILEINFO
*)VersionInfo16_Value( (VS_VERSION_INFO_STRUCT16
*)buf
);
375 if ( vffi
->dwSignature
!= VS_FFI_SIGNATURE
)
377 WARN("vffi->dwSignature is 0x%08lx, but not 0x%08lx!\n",
378 vffi
->dwSignature
, VS_FFI_SIGNATURE
);
384 print_vffi_debug( vffi
);
389 len
= datasize
; /* truncate data */
391 memcpy(data
, buf
, len
);
396 FreeResource16(hMem
);
397 FreeLibrary16(hModule
);
402 /***********************************************************************
403 * GetFileVersionInfoSizeW [VERSION.@]
405 DWORD WINAPI
GetFileVersionInfoSizeW( LPCWSTR filename
, LPDWORD handle
)
409 TRACE("(%s,%p)\n", debugstr_w(filename
), handle
);
411 if (handle
) *handle
= 0;
415 SetLastError(ERROR_INVALID_PARAMETER
);
420 SetLastError(ERROR_BAD_PATHNAME
);
424 len
= VERSION_GetFileVersionInfo_PE(filename
, 0, NULL
);
425 /* 0xFFFFFFFF means: file is a PE module, but VERSION_INFO not found */
426 if(len
== 0xFFFFFFFF)
428 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND
);
436 len
= WideCharToMultiByte( CP_ACP
, 0, filename
, -1, NULL
, 0, NULL
, NULL
);
437 filenameA
= HeapAlloc( GetProcessHeap(), 0, len
);
438 WideCharToMultiByte( CP_ACP
, 0, filename
, -1, filenameA
, len
, NULL
, NULL
);
440 len
= VERSION_GetFileVersionInfo_16(filenameA
, 0, NULL
);
441 HeapFree( GetProcessHeap(), 0, filenameA
);
442 /* 0xFFFFFFFF means: file exists, but VERSION_INFO not found */
445 SetLastError(ERROR_FILE_NOT_FOUND
);
448 if (len
== 0xFFFFFFFF)
450 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND
);
454 /* We have a 16bit resource.
456 * XP/W2K/W2K3 uses a buffer which is more than the actual needed space:
458 * (info->wLength - sizeof(VS_FIXEDFILEINFO)) * 4
460 * This extra buffer is used for ANSI to Unicode conversions in W-Calls.
461 * info->wLength should be the same as len. Currently it isn't but that
462 * doesn't seem to be a problem (len is bigger then info->wLength).
464 len
= (len
- sizeof(VS_FIXEDFILEINFO
)) * 4;
468 /* We have a 32bit resource.
470 * XP/W2K/W2K3 uses a buffer which is 2 times the actual needed space + 4 bytes "FE2X"
471 * This extra buffer is used for Unicode to ANSI conversions in A-Calls
480 /***********************************************************************
481 * GetFileVersionInfoSizeA [VERSION.@]
483 DWORD WINAPI
GetFileVersionInfoSizeA( LPCSTR filename
, LPDWORD handle
)
485 UNICODE_STRING filenameW
;
488 TRACE("(%s,%p)\n", debugstr_a(filename
), handle
);
491 RtlCreateUnicodeStringFromAsciiz(&filenameW
, filename
);
493 filenameW
.Buffer
= NULL
;
495 retval
= GetFileVersionInfoSizeW(filenameW
.Buffer
, handle
);
497 RtlFreeUnicodeString(&filenameW
);
502 /***********************************************************************
503 * GetFileVersionInfoW [VERSION.@]
505 BOOL WINAPI
GetFileVersionInfoW( LPCWSTR filename
, DWORD handle
,
506 DWORD datasize
, LPVOID data
)
509 VS_VERSION_INFO_STRUCT32
* vvis
= (VS_VERSION_INFO_STRUCT32
*)data
;
511 TRACE("(%s,%ld,size=%ld,data=%p)\n",
512 debugstr_w(filename
), handle
, datasize
, data
);
516 SetLastError(ERROR_INVALID_DATA
);
519 len
= VERSION_GetFileVersionInfo_PE(filename
, datasize
, data
);
520 /* 0xFFFFFFFF means: file is a PE module, but VERSION_INFO not found */
521 if (len
== 0xFFFFFFFF)
523 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND
);
531 len
= WideCharToMultiByte( CP_ACP
, 0, filename
, -1, NULL
, 0, NULL
, NULL
);
532 filenameA
= HeapAlloc( GetProcessHeap(), 0, len
);
533 WideCharToMultiByte( CP_ACP
, 0, filename
, -1, filenameA
, len
, NULL
, NULL
);
535 len
= VERSION_GetFileVersionInfo_16(filenameA
, datasize
, data
);
536 HeapFree( GetProcessHeap(), 0, filenameA
);
537 /* 0xFFFFFFFF means: file exists, but VERSION_INFO not found */
538 if (!len
|| len
== 0xFFFFFFFF)
540 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND
);
543 /* We have a 16bit resource. */
549 /* We have a 32bit resource.
551 * XP/W2K/W2K3 uses a buffer which is 2 times the actual needed space + 4 bytes "FE2X"
552 * This extra buffer is used for Unicode to ANSI conversions in A-Calls
555 convbuf
= datasize
- vvis
->wLength
;
556 memcpy( ((char*)(data
))+vvis
->wLength
, "FE2X", convbuf
> 4 ? 4 : convbuf
);
563 /***********************************************************************
564 * GetFileVersionInfoA [VERSION.@]
566 BOOL WINAPI
GetFileVersionInfoA( LPCSTR filename
, DWORD handle
,
567 DWORD datasize
, LPVOID data
)
569 UNICODE_STRING filenameW
;
572 TRACE("(%s,%ld,size=%ld,data=%p)\n",
573 debugstr_a(filename
), handle
, datasize
, data
);
576 RtlCreateUnicodeStringFromAsciiz(&filenameW
, filename
);
578 filenameW
.Buffer
= NULL
;
580 retval
= GetFileVersionInfoW(filenameW
.Buffer
, handle
, datasize
, data
);
582 RtlFreeUnicodeString(&filenameW
);
587 /***********************************************************************
588 * VersionInfo16_FindChild [internal]
590 static VS_VERSION_INFO_STRUCT16
*VersionInfo16_FindChild( VS_VERSION_INFO_STRUCT16
*info
,
591 LPCSTR szKey
, UINT cbKey
)
593 VS_VERSION_INFO_STRUCT16
*child
= VersionInfo16_Children( info
);
595 while ((char *)child
< (char *)info
+ info
->wLength
)
597 if ( !strncasecmp( child
->szKey
, szKey
, cbKey
) )
600 if (!(child
->wLength
)) return NULL
;
601 child
= VersionInfo16_Next( child
);
607 /***********************************************************************
608 * VersionInfo32_FindChild [internal]
610 static VS_VERSION_INFO_STRUCT32
*VersionInfo32_FindChild( VS_VERSION_INFO_STRUCT32
*info
,
611 LPCWSTR szKey
, UINT cbKey
)
613 VS_VERSION_INFO_STRUCT32
*child
= VersionInfo32_Children( info
);
615 while ((char *)child
< (char *)info
+ info
->wLength
)
617 if ( !strncmpiW( child
->szKey
, szKey
, cbKey
) )
620 child
= VersionInfo32_Next( child
);
626 /***********************************************************************
627 * VersionInfo16_QueryValue [internal]
629 * Gets a value from a 16-bit NE resource
631 static BOOL WINAPI
VersionInfo16_QueryValue( VS_VERSION_INFO_STRUCT16
*info
, LPCSTR lpSubBlock
,
632 LPVOID
*lplpBuffer
, UINT
*puLen
)
634 while ( *lpSubBlock
)
636 /* Find next path component */
638 for ( lpNextSlash
= lpSubBlock
; *lpNextSlash
; lpNextSlash
++ )
639 if ( *lpNextSlash
== '\\' )
642 /* Skip empty components */
643 if ( lpNextSlash
== lpSubBlock
)
649 /* We have a non-empty component: search info for key */
650 info
= VersionInfo16_FindChild( info
, lpSubBlock
, lpNextSlash
-lpSubBlock
);
651 if ( !info
) return FALSE
;
653 /* Skip path component */
654 lpSubBlock
= lpNextSlash
;
658 *lplpBuffer
= VersionInfo16_Value( info
);
660 *puLen
= info
->wValueLength
;
665 /***********************************************************************
666 * VersionInfo32_QueryValue [internal]
668 * Gets a value from a 32-bit PE resource
670 static BOOL WINAPI
VersionInfo32_QueryValue( VS_VERSION_INFO_STRUCT32
*info
, LPCWSTR lpSubBlock
,
671 LPVOID
*lplpBuffer
, UINT
*puLen
)
673 TRACE("lpSubBlock : (%s)\n", debugstr_w(lpSubBlock
));
675 while ( *lpSubBlock
)
677 /* Find next path component */
679 for ( lpNextSlash
= lpSubBlock
; *lpNextSlash
; lpNextSlash
++ )
680 if ( *lpNextSlash
== '\\' )
683 /* Skip empty components */
684 if ( lpNextSlash
== lpSubBlock
)
690 /* We have a non-empty component: search info for key */
691 info
= VersionInfo32_FindChild( info
, lpSubBlock
, lpNextSlash
-lpSubBlock
);
692 if ( !info
) return FALSE
;
694 /* Skip path component */
695 lpSubBlock
= lpNextSlash
;
699 *lplpBuffer
= VersionInfo32_Value( info
);
701 *puLen
= info
->wValueLength
;
706 /***********************************************************************
707 * VerQueryValueA [VERSION.@]
709 BOOL WINAPI
VerQueryValueA( LPVOID pBlock
, LPCSTR lpSubBlock
,
710 LPVOID
*lplpBuffer
, UINT
*puLen
)
712 static const char rootA
[] = "\\";
713 static const char varfileinfoA
[] = "\\VarFileInfo\\Translation";
714 VS_VERSION_INFO_STRUCT16
*info
= (VS_VERSION_INFO_STRUCT16
*)pBlock
;
716 TRACE("(%p,%s,%p,%p)\n",
717 pBlock
, debugstr_a(lpSubBlock
), lplpBuffer
, puLen
);
719 if ( !VersionInfoIs16( info
) )
725 len
= MultiByteToWideChar(CP_ACP
, 0, lpSubBlock
, -1, NULL
, 0);
726 lpSubBlockW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
731 MultiByteToWideChar(CP_ACP
, 0, lpSubBlock
, -1, lpSubBlockW
, len
);
733 ret
= VersionInfo32_QueryValue(pBlock
, lpSubBlockW
, lplpBuffer
, puLen
);
735 HeapFree(GetProcessHeap(), 0, lpSubBlockW
);
737 if (ret
&& strcasecmp( lpSubBlock
, rootA
) && strcasecmp( lpSubBlock
, varfileinfoA
))
739 LPSTR lpBufferA
= (LPSTR
)pBlock
+ info
->wLength
+ 4;
740 DWORD pos
= (LPSTR
)*lplpBuffer
- (LPSTR
)pBlock
;
742 len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*lplpBuffer
, -1,
743 lpBufferA
+ pos
, info
->wLength
- pos
, NULL
, NULL
);
744 *lplpBuffer
= lpBufferA
+ pos
;
750 return VersionInfo16_QueryValue(info
, lpSubBlock
, lplpBuffer
, puLen
);
753 /***********************************************************************
754 * VerQueryValueW [VERSION.@]
756 BOOL WINAPI
VerQueryValueW( LPVOID pBlock
, LPCWSTR lpSubBlock
,
757 LPVOID
*lplpBuffer
, UINT
*puLen
)
759 static const WCHAR rootW
[] = { '\\', 0 };
760 static const WCHAR varfileinfoW
[] = { '\\','V','a','r','F','i','l','e','I','n','f','o',
761 '\\','T','r','a','n','s','l','a','t','i','o','n', 0 };
763 VS_VERSION_INFO_STRUCT32
*info
= (VS_VERSION_INFO_STRUCT32
*)pBlock
;
765 TRACE("(%p,%s,%p,%p)\n",
766 pBlock
, debugstr_w(lpSubBlock
), lplpBuffer
, puLen
);
768 if ( VersionInfoIs16( info
) )
774 len
= WideCharToMultiByte(CP_ACP
, 0, lpSubBlock
, -1, NULL
, 0, NULL
, NULL
);
775 lpSubBlockA
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(char));
780 WideCharToMultiByte(CP_ACP
, 0, lpSubBlock
, -1, lpSubBlockA
, len
, NULL
, NULL
);
782 ret
= VersionInfo16_QueryValue(pBlock
, lpSubBlockA
, lplpBuffer
, puLen
);
784 HeapFree(GetProcessHeap(), 0, lpSubBlockA
);
786 if (ret
&& strcmpiW( lpSubBlock
, rootW
) && strcmpiW( lpSubBlock
, varfileinfoW
))
788 LPWSTR lpBufferW
= (LPWSTR
)((LPSTR
)pBlock
+ info
->wLength
);
789 DWORD pos
= (LPSTR
)*lplpBuffer
- (LPSTR
)pBlock
;
790 DWORD max
= (info
->wLength
- sizeof(VS_FIXEDFILEINFO
)) * 4 - info
->wLength
;
792 len
= MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)*lplpBuffer
, -1,
793 lpBufferW
+ pos
, max
/sizeof(WCHAR
) - pos
);
794 *lplpBuffer
= lpBufferW
+ pos
;
800 return VersionInfo32_QueryValue(info
, lpSubBlock
, lplpBuffer
, puLen
);