- Timestamp:
- Oct 24, 2003, 4:47:25 PM (22 years ago)
- Location:
- trunk/src/version
- Files:
-
- 2 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/version/LICENSE.TXT
r6379 r10296 1 $Id: LICENSE.TXT,v 1. 1 2001-07-21 08:51:25sandervl Exp $2 @cThis is an additional Odin license agreement.3 @cIt supercedes the main Odin license, but is only valid in4 @cthe source directory in which it is present.1 $Id: LICENSE.TXT,v 1.2 2003-10-24 14:47:24 sandervl Exp $ 2 This is an additional Odin license agreement. 3 It supercedes the main Odin license, but is only valid in 4 the source directory in which it is present. 5 5 6 @c This file is processed by GNU's TeXinfo 7 @c If you modify it or move it to another location, make sure that 8 @c TeXinfo works (type `make' in directory documentation). 9 10 Copyright (c) 1993-2000 the Wine project authors (see the file AUTHORS 6 Copyright (c) 1993-2002 the Wine project authors (see the file AUTHORS 11 7 for a complete list) 12 8 13 Permission is hereby granted, free of charge, to any person obtaining a copy 14 of this software and associated documentation files (the "Software"), to deal 15 in the Software without restriction, including without limitation the rights 16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 copies of the Software, and to permit persons to whom the Software is 18 furnished to do so, subject to the following conditions: 9 Wine is free software; you can redistribute it and/or modify it under 10 the terms of the GNU Lesser General Public License as published by the 11 Free Software Foundation; either version 2.1 of the License, or (at 12 your option) any later version. 19 13 20 The above copyright notice and this permission notice shall be included in 21 all copies or substantial portions of the Software. 14 This program is distributed in the hope that it will be useful, but 15 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. 22 18 23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 27 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 A copy of the GNU Lesser General Public License is included in the 20 Wine distribution in the file COPYING.LIB. If you did not receive this 21 copy, write to the Free Software Foundation, Inc., 59 Temple Place, 22 Suite 330, Boston, MA 02111-1307 USA. -
trunk/src/version/VERSION.DEF
r2347 r10296 1 ; $Id: VERSION.DEF,v 1. 8 2000-01-06 20:10:06sandervl Exp $1 ; $Id: VERSION.DEF,v 1.9 2003-10-24 14:47:25 sandervl Exp $ 2 2 3 3 ; … … 22 22 ; VerQueryValueIndexA = _VerQueryValueIndexA@16 @12 23 23 ; VerQueryValueIndexW = _VerQueryValueIndexW@16 @13 24 ; VerQueryValueW = _VerQueryValueW@16 @14 -
trunk/src/version/info.c
r9676 r10296 1 /* $Id: info.c,v 1.4 2003-01-15 10:42:34 sandervl Exp $ */ 2 /* 3 * Implementation of VERSION.DLL - Version Info access (Wine 991212) 4 * 1 /* 2 * Implementation of VERSION.DLL - Version Info access 3 * 5 4 * Copyright 1996,1997 Marcus Meissner 6 5 * Copyright 1997 David Cuthbert 7 6 * Copyright 1999 Ulrich Weigand 8 */ 9 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * 22 * TODO 23 * o Verify VerQueryValue() 24 */ 25 26 #include <stdarg.h> 10 27 #include <stdlib.h> 11 28 #include <string.h> 12 29 30 #include "windef.h" 31 #include "winbase.h" 13 32 #include "winreg.h" 14 33 #include "winver.h" 15 #include "wine/winestring.h" 34 #include "wine/winuser16.h" 35 #include "wine/unicode.h" 16 36 #include "winerror.h" 17 #include "heap.h" 18 #include "crtdll.h" 19 #include "debugtools.h" 20 #include <misc.h> 21 #include <unicode.h> 22 23 DEFAULT_DEBUG_CHANNEL(ver) 37 #include "wine/debug.h" 38 39 WINE_DEFAULT_DEBUG_CHANNEL(ver); 24 40 25 41 … … 32 48 * 33 49 *****************************************************************************/ 50 #ifdef DEBUG 34 51 static void print_vffi_debug(VS_FIXEDFILEINFO *vffi) 35 52 { … … 50 67 51 68 TRACE("("); 52 DPRINTF(" OS=0x%x.0x%x ",69 TRACE(" OS=0x%x.0x%x ", 53 70 HIWORD(vffi->dwFileOS), 54 71 LOWORD(vffi->dwFileOS) 55 72 ); 56 73 switch (vffi->dwFileOS&0xFFFF0000) { 57 case VOS_DOS: DPRINTF("DOS,");break;58 case VOS_OS216: DPRINTF("OS/2-16,");break;59 case VOS_OS232: DPRINTF("OS/2-32,");break;60 case VOS_NT: DPRINTF("NT,");break;74 case VOS_DOS:TRACE("DOS,");break; 75 case VOS_OS216:TRACE("OS/2-16,");break; 76 case VOS_OS232:TRACE("OS/2-32,");break; 77 case VOS_NT:TRACE("NT,");break; 61 78 case VOS_UNKNOWN: 62 79 default: 63 DPRINTF("UNKNOWN(0x%lx),",vffi->dwFileOS&0xFFFF0000);break;80 TRACE("UNKNOWN(0x%lx),",vffi->dwFileOS&0xFFFF0000);break; 64 81 } 65 82 switch (LOWORD(vffi->dwFileOS)) { 66 case VOS__BASE: DPRINTF("BASE");break;67 case VOS__WINDOWS16: DPRINTF("WIN16");break;68 case VOS__WINDOWS32: DPRINTF("WIN32");break;69 case VOS__PM16: DPRINTF("PM16");break;70 case VOS__PM32: DPRINTF("PM32");break;71 default: DPRINTF("UNKNOWN(0x%x)",LOWORD(vffi->dwFileOS));break;83 case VOS__BASE:TRACE("BASE");break; 84 case VOS__WINDOWS16:TRACE("WIN16");break; 85 case VOS__WINDOWS32:TRACE("WIN32");break; 86 case VOS__PM16:TRACE("PM16");break; 87 case VOS__PM32:TRACE("PM32");break; 88 default:TRACE("UNKNOWN(0x%x)",LOWORD(vffi->dwFileOS));break; 72 89 } 73 DPRINTF(")\n");90 TRACE(")\n"); 74 91 75 92 switch (vffi->dwFileType) { … … 85 102 default: 86 103 case VFT2_UNKNOWN: 87 DPRINTF("UNKNOWN(0x%lx)",vffi->dwFileSubtype);104 TRACE("UNKNOWN(0x%lx)",vffi->dwFileSubtype); 88 105 break; 89 106 case VFT2_DRV_PRINTER: 90 DPRINTF("PRINTER");107 TRACE("PRINTER"); 91 108 break; 92 109 case VFT2_DRV_KEYBOARD: 93 DPRINTF("KEYBOARD");110 TRACE("KEYBOARD"); 94 111 break; 95 112 case VFT2_DRV_LANGUAGE: 96 DPRINTF("LANGUAGE");113 TRACE("LANGUAGE"); 97 114 break; 98 115 case VFT2_DRV_DISPLAY: 99 DPRINTF("DISPLAY");116 TRACE("DISPLAY"); 100 117 break; 101 118 case VFT2_DRV_MOUSE: 102 DPRINTF("MOUSE");119 TRACE("MOUSE"); 103 120 break; 104 121 case VFT2_DRV_NETWORK: 105 DPRINTF("NETWORK");122 TRACE("NETWORK"); 106 123 break; 107 124 case VFT2_DRV_SYSTEM: 108 DPRINTF("SYSTEM");125 TRACE("SYSTEM"); 109 126 break; 110 127 case VFT2_DRV_INSTALLABLE: 111 DPRINTF("INSTALLABLE");128 TRACE("INSTALLABLE"); 112 129 break; 113 130 case VFT2_DRV_SOUND: 114 DPRINTF("SOUND");131 TRACE("SOUND"); 115 132 break; 116 133 case VFT2_DRV_COMM: 117 DPRINTF("COMM");134 TRACE("COMM"); 118 135 break; 119 136 case VFT2_DRV_INPUTMETHOD: 120 DPRINTF("INPUTMETHOD");137 TRACE("INPUTMETHOD"); 121 138 break; 122 139 } … … 126 143 switch (vffi->dwFileSubtype) { 127 144 default: 128 DPRINTF("UNKNOWN(0x%lx)",vffi->dwFileSubtype);129 break; 130 case VFT2_FONT_RASTER: DPRINTF("RASTER");break;131 case VFT2_FONT_VECTOR: DPRINTF("VECTOR");break;132 case VFT2_FONT_TRUETYPE: DPRINTF("TRUETYPE");break;145 TRACE("UNKNOWN(0x%lx)",vffi->dwFileSubtype); 146 break; 147 case VFT2_FONT_RASTER:TRACE("RASTER");break; 148 case VFT2_FONT_VECTOR:TRACE("VECTOR");break; 149 case VFT2_FONT_TRUETYPE:TRACE("TRUETYPE");break; 133 150 } 134 151 break; … … 136 153 case VFT_STATIC_LIB:TRACE("filetype=STATIC_LIB");break; 137 154 } 138 DPRINTF("\n");155 TRACE("\n"); 139 156 TRACE(" filedata=0x%lx.0x%lx\n", 140 157 vffi->dwFileDateMS,vffi->dwFileDateLS); 141 158 } 142 159 #else 160 #define print_vffi_debug(a) 161 #endif 143 162 144 163 /*********************************************************************** … … 176 195 ( ((VS_VERSION_INFO_STRUCT16 *)ver)->szKey[0] >= ' ' ) 177 196 178 #define DWORD_ALIGN( ptr ) ((LPBYTE)( (((DWORD)(ptr)) + 3) & ~3 )) 197 #define DWORD_ALIGN( base, ptr ) \ 198 ( (LPBYTE)(base) + ((((LPBYTE)(ptr) - (LPBYTE)(base)) + 3) & ~3) ) 179 199 180 200 #define VersionInfo16_Value( ver ) \ 181 DWORD_ALIGN( (ver) ->szKey + lstrlenA((ver)->szKey) + 1 )201 DWORD_ALIGN( (ver), (ver)->szKey + strlen((ver)->szKey) + 1 ) 182 202 #define VersionInfo32_Value( ver ) \ 183 DWORD_ALIGN( (ver) ->szKey + lstrlenW((ver)->szKey) + 1 )203 DWORD_ALIGN( (ver), (ver)->szKey + strlenW((ver)->szKey) + 1 ) 184 204 185 205 #define VersionInfo16_Children( ver ) \ … … 196 216 (VS_VERSION_INFO_STRUCT32 *)( (LPBYTE)ver + (((ver)->wLength + 3) & ~3) ) 197 217 198 #ifndef __WIN32OS2__199 218 /*********************************************************************** 200 219 * ConvertVersionInfo32To16 [internal] 201 220 */ 202 void ConvertVersionInfo32To16( VS_VERSION_INFO_STRUCT32 *info32, 221 void ConvertVersionInfo32To16( VS_VERSION_INFO_STRUCT32 *info32, 203 222 VS_VERSION_INFO_STRUCT16 *info16 ) 204 223 { … … 211 230 VS_VERSION_INFO_STRUCT16 *child16; 212 231 213 TRACE("Converting %p to %p\n", info32, info16);214 TRACE("wLength %d, wValueLength %d, bText %d, value %p, child %p\n",215 wLength, wValueLength, bText, lpValue, child32 ) ;232 dprintf(("Converting %p to %p\n", info32, info16 )); 233 dprintf(("wLength %d, wValueLength %d, bText %d, value %p, child %p\n", 234 wLength, wValueLength, bText, lpValue, child32 )); 216 235 217 236 /* Convert key */ 218 lstrcpyWtoA( info16->szKey, info32->szKey);219 220 TRACE("Copied key from %p to %p: %s\n", info32->szKey, info16->szKey,221 debugstr_a(info16->szKey) ) ;237 WideCharToMultiByte( CP_ACP, 0, info32->szKey, -1, info16->szKey, 0x7fffffff, NULL, NULL ); 238 239 dprintf(("Copied key from %p to %p: %s\n", info32->szKey, info16->szKey, 240 debugstr_a(info16->szKey) )); 222 241 223 242 /* Convert value */ … … 225 244 { 226 245 info16->wValueLength = 0; 227 TRACE("No value present\n");246 dprintf(("No value present\n" )); 228 247 } 229 248 else if ( bText ) 230 249 { 231 info16->wValueLength = lstrlenW( (LPCWSTR)lpValue ) + 1; 232 lstrcpyWtoA( VersionInfo16_Value( info16 ), (LPCWSTR)lpValue ); 233 234 TRACE("Copied value from %p to %p: %s\n", lpValue, 235 VersionInfo16_Value( info16 ), 250 info16->wValueLength = WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)lpValue, -1, NULL, 0, NULL, NULL ); 251 WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)lpValue, -1, 252 VersionInfo16_Value( info16 ), info16->wValueLength, NULL, NULL ); 253 254 dprintf(("Copied value from %p to %p: %s\n", lpValue, 255 VersionInfo16_Value( info16 )), 236 256 debugstr_a(VersionInfo16_Value( info16 )) ); 237 257 } … … 241 261 memmove( VersionInfo16_Value( info16 ), lpValue, wValueLength ); 242 262 243 TRACE("Copied value from %p to %p: %d bytes\n", lpValue,244 VersionInfo16_Value( info16 ), wValueLength ) ;263 dprintf(("Copied value from %p to %p: %d bytes\n", lpValue, 264 VersionInfo16_Value( info16 ), wValueLength )); 245 265 } 246 266 247 267 /* Convert children */ 248 268 child16 = VersionInfo16_Children( info16 ); 249 while ( (DWORD)child32 < (DWORD)info32 + wLength )269 while ( (DWORD)child32 < (DWORD)info32 + wLength && child32->wLength != 0 ) 250 270 { 251 271 VS_VERSION_INFO_STRUCT32 *nextChild = VersionInfo32_Next( child32 ); … … 260 280 info16->wLength = (DWORD)child16 - (DWORD)info16; 261 281 262 TRACE("Finished, length is %d (%p - %p)\n", 263 info16->wLength, info16, child16 ); 264 } 265 266 267 /*********************************************************************** 268 * GetFileVersionInfoSize32A [VERSION.2] 282 dprintf(("Finished, length is %d (%p - %p)\n", 283 info16->wLength, info16, child16 )); 284 } 285 286 /*********************************************************************** 287 * VERSION_GetFileVersionInfo_PE [internal] 288 * 289 * NOTE: returns size of the PE VERSION resource or 0xFFFFFFFF 290 * in the case if file exists, but VERSION_INFO not found. 291 * FIXME: handle is not used. 292 */ 293 static DWORD VERSION_GetFileVersionInfo_PE( LPCSTR filename, LPDWORD handle, 294 DWORD datasize, LPVOID data ) 295 { 296 VS_FIXEDFILEINFO *vffi; 297 DWORD len; 298 BYTE *buf; 299 HMODULE hModule; 300 HRSRC hRsrc; 301 HGLOBAL hMem; 302 303 dprintf(("(%s,%p)\n", debugstr_a(filename), handle )); 304 305 hModule = GetModuleHandleA(filename); 306 if(!hModule) 307 hModule = LoadLibraryExA(filename, 0, LOAD_LIBRARY_AS_DATAFILE); 308 else 309 hModule = LoadLibraryExA(filename, 0, 0); 310 if(!hModule) 311 { 312 WARN("Could not load %s\n", debugstr_a(filename)); 313 return 0; 314 } 315 hRsrc = FindResourceW(hModule, 316 MAKEINTRESOURCEW(VS_VERSION_INFO), 317 MAKEINTRESOURCEW(VS_FILE_INFO)); 318 if(!hRsrc) 319 { 320 WARN("Could not find VS_VERSION_INFO in %s\n", debugstr_a(filename)); 321 FreeLibrary(hModule); 322 return 0xFFFFFFFF; 323 } 324 len = SizeofResource(hModule, hRsrc); 325 hMem = LoadResource(hModule, hRsrc); 326 if(!hMem) 327 { 328 WARN("Could not load VS_VERSION_INFO from %s\n", debugstr_a(filename)); 329 FreeLibrary(hModule); 330 return 0xFFFFFFFF; 331 } 332 buf = LockResource(hMem); 333 334 vffi = (VS_FIXEDFILEINFO *)VersionInfo32_Value( (VS_VERSION_INFO_STRUCT32 *)buf ); 335 336 if ( vffi->dwSignature != VS_FFI_SIGNATURE ) 337 { 338 WARN("vffi->dwSignature is 0x%08lx, but not 0x%08lx!\n", 339 vffi->dwSignature, VS_FFI_SIGNATURE ); 340 len = 0xFFFFFFFF; 341 goto END; 342 } 343 #ifdef DEBUG 344 if ( TRACE_ON(ver) ) 345 print_vffi_debug( vffi ); 346 #endif 347 if(data) 348 { 349 if(datasize < len) 350 len = datasize; /* truncate data */ 351 if(len) 352 memcpy(data, buf, len); 353 else 354 len = 0xFFFFFFFF; 355 } 356 END: 357 FreeResource(hMem); 358 FreeLibrary(hModule); 359 360 return len; 361 } 362 363 #ifndef __WIN32OS2__ 364 /*********************************************************************** 365 * VERSION_GetFileVersionInfo_16 [internal] 366 * 367 * NOTE: returns size of the 16-bit VERSION resource or 0xFFFFFFFF 368 * in the case if file exists, but VERSION_INFO not found. 369 * FIXME: handle is not used. 370 */ 371 static DWORD VERSION_GetFileVersionInfo_16( LPCSTR filename, LPDWORD handle, 372 DWORD datasize, LPVOID data ) 373 { 374 VS_FIXEDFILEINFO *vffi; 375 DWORD len; 376 BYTE *buf; 377 HMODULE16 hModule; 378 HRSRC16 hRsrc; 379 HGLOBAL16 hMem; 380 381 TRACE("(%s,%p)\n", debugstr_a(filename), handle ); 382 383 hModule = LoadLibrary16(filename); 384 if(hModule < 32) 385 { 386 WARN("Could not load %s\n", debugstr_a(filename)); 387 return 0; 388 } 389 hRsrc = FindResource16(hModule, 390 MAKEINTRESOURCEA(VS_VERSION_INFO), 391 MAKEINTRESOURCEA(VS_FILE_INFO)); 392 if(!hRsrc) 393 { 394 WARN("Could not find VS_VERSION_INFO in %s\n", debugstr_a(filename)); 395 FreeLibrary16(hModule); 396 return 0xFFFFFFFF; 397 } 398 len = SizeofResource16(hModule, hRsrc); 399 hMem = LoadResource16(hModule, hRsrc); 400 if(!hMem) 401 { 402 WARN("Could not load VS_VERSION_INFO from %s\n", debugstr_a(filename)); 403 FreeLibrary16(hModule); 404 return 0xFFFFFFFF; 405 } 406 buf = LockResource16(hMem); 407 408 if(!VersionInfoIs16(buf)) 409 goto END; 410 411 vffi = (VS_FIXEDFILEINFO *)VersionInfo16_Value( (VS_VERSION_INFO_STRUCT16 *)buf ); 412 413 if ( vffi->dwSignature != VS_FFI_SIGNATURE ) 414 { 415 WARN("vffi->dwSignature is 0x%08lx, but not 0x%08lx!\n", 416 vffi->dwSignature, VS_FFI_SIGNATURE ); 417 len = 0xFFFFFFFF; 418 goto END; 419 } 420 421 if ( TRACE_ON(ver) ) 422 print_vffi_debug( vffi ); 423 424 if(data) 425 { 426 if(datasize < len) 427 len = datasize; /* truncate data */ 428 if(len) 429 memcpy(data, buf, len); 430 else 431 len = 0xFFFFFFFF; 432 } 433 END: 434 FreeResource16(hMem); 435 FreeLibrary16(hModule); 436 437 return len; 438 } 439 #endif 440 441 /*********************************************************************** 442 * GetFileVersionInfoSizeA [VERSION.@] 269 443 */ 270 444 DWORD WINAPI GetFileVersionInfoSizeA( LPCSTR filename, LPDWORD handle ) … … 274 448 BYTE buf[144]; 275 449 276 TRACE("(%s,%p)\n", debugstr_a(filename), handle ); 277 278 len = GetFileResourceSize( filename, 450 dprintf(("(%s,%p)\n", debugstr_a(filename), handle )); 451 452 len = VERSION_GetFileVersionInfo_PE(filename, handle, 0, NULL); 453 /* 0xFFFFFFFF means: file exists, but VERSION_INFO not found */ 454 if(len == 0xFFFFFFFF) 455 { 456 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); 457 return 0; 458 } 459 if(len) return len; 460 #ifndef __WIN32OS2__ 461 len = VERSION_GetFileVersionInfo_16(filename, handle, 0, NULL); 462 /* 0xFFFFFFFF means: file exists, but VERSION_INFO not found */ 463 if(len == 0xFFFFFFFF) 464 { 465 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); 466 return 0; 467 } 468 if(len) return len; 469 #endif 470 len = GetFileResourceSize16( filename, 279 471 MAKEINTRESOURCEA(VS_FILE_INFO), 280 472 MAKEINTRESOURCEA(VS_VERSION_INFO), … … 282 474 if (!len) return 0; 283 475 284 ret = GetFileResource ( filename,476 ret = GetFileResource16( filename, 285 477 MAKEINTRESOURCEA(VS_FILE_INFO), 286 478 MAKEINTRESOURCEA(VS_VERSION_INFO), … … 289 481 290 482 if ( handle ) *handle = offset; 291 483 292 484 if ( VersionInfoIs16( buf ) ) 293 485 vffi = (VS_FIXEDFILEINFO *)VersionInfo16_Value( (VS_VERSION_INFO_STRUCT16 *)buf ); … … 297 489 if ( vffi->dwSignature != VS_FFI_SIGNATURE ) 298 490 { 299 WARN("vffi->dwSignature is 0x%08lx, but not 0x%08lx!\n",300 vffi->dwSignature, VS_FFI_SIGNATURE ) ;491 dprintf(("vffi->dwSignature is 0x%08lx, but not 0x%08lx!\n", 492 vffi->dwSignature, VS_FFI_SIGNATURE )); 301 493 return 0; 302 494 } … … 305 497 len = ((VS_VERSION_INFO_STRUCT16 *)buf)->wLength; 306 498 499 #ifdef DEBUG 307 500 if ( TRACE_ON(ver) ) 308 501 print_vffi_debug( vffi ); 502 #endif 309 503 310 504 return len; … … 312 506 313 507 /*********************************************************************** 314 * GetFileVersionInfoSize 32W [VERSION.3]508 * GetFileVersionInfoSizeW [VERSION.@] 315 509 */ 316 510 DWORD WINAPI GetFileVersionInfoSizeW( LPCWSTR filename, LPDWORD handle ) 317 511 { 318 LPSTR fn = HEAP_strdupWtoA( GetProcessHeap(), 0, filename ); 319 DWORD ret = GetFileVersionInfoSizeA( fn, handle ); 512 DWORD ret, len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL ); 513 LPSTR fn = HeapAlloc( GetProcessHeap(), 0, len ); 514 WideCharToMultiByte( CP_ACP, 0, filename, -1, fn, len, NULL, NULL ); 515 ret = GetFileVersionInfoSizeA( fn, handle ); 320 516 HeapFree( GetProcessHeap(), 0, fn ); 321 517 return ret; … … 323 519 324 520 /*********************************************************************** 325 * GetFileVersionInfo 32A [VERSION.1]326 */ 327 DWORDWINAPI GetFileVersionInfoA( LPCSTR filename, DWORD handle,521 * GetFileVersionInfoA [VERSION.@] 522 */ 523 BOOL WINAPI GetFileVersionInfoA( LPCSTR filename, DWORD handle, 328 524 DWORD datasize, LPVOID data ) 329 525 { 330 TRACE("(%s,%ld,size=%ld,data=%p)\n", 331 debugstr_a(filename), handle, datasize, data ); 332 333 if ( !GetFileResource( filename, MAKEINTRESOURCEA(VS_FILE_INFO), 526 DWORD len; 527 528 dprintf(("(%s,%ld,size=%ld,data=%p)\n", 529 debugstr_a(filename), handle, datasize, data )); 530 531 len = VERSION_GetFileVersionInfo_PE(filename, &handle, datasize, data); 532 /* 0xFFFFFFFF means: file exists, but VERSION_INFO not found */ 533 if(len == 0xFFFFFFFF) return FALSE; 534 if(len) 535 goto DO_CONVERT; 536 #ifndef __WIN32OS2__ 537 len = VERSION_GetFileVersionInfo_16(filename, &handle, datasize, data); 538 /* 0xFFFFFFFF means: file exists, but VERSION_INFO not found */ 539 if(len == 0xFFFFFFFF) return FALSE; 540 if(len) 541 goto DO_CONVERT; 542 #endif 543 544 if ( !GetFileResource16( filename, MAKEINTRESOURCEA(VS_FILE_INFO), 334 545 MAKEINTRESOURCEA(VS_VERSION_INFO), 335 546 handle, datasize, data ) ) 336 547 return FALSE; 337 548 DO_CONVERT: 338 549 if ( datasize >= sizeof(VS_VERSION_INFO_STRUCT16) 339 && datasize >= ((VS_VERSION_INFO_STRUCT16 *)data)->wLength 550 && datasize >= ((VS_VERSION_INFO_STRUCT16 *)data)->wLength 340 551 && !VersionInfoIs16( data ) ) 341 552 { 342 553 /* convert resource from PE format to NE format */ 343 ConvertVersionInfo32To16( (VS_VERSION_INFO_STRUCT32 *)data, 554 ConvertVersionInfo32To16( (VS_VERSION_INFO_STRUCT32 *)data, 344 555 (VS_VERSION_INFO_STRUCT16 *)data ); 345 556 } … … 349 560 350 561 /*********************************************************************** 351 * GetFileVersionInfo 32W [VERSION.4]352 */ 353 DWORDWINAPI GetFileVersionInfoW( LPCWSTR filename, DWORD handle,562 * GetFileVersionInfoW [VERSION.@] 563 */ 564 BOOL WINAPI GetFileVersionInfoW( LPCWSTR filename, DWORD handle, 354 565 DWORD datasize, LPVOID data ) 355 566 { 356 LPSTR fn = HEAP_strdupWtoA( GetProcessHeap(), 0, filename ); 567 DWORD len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL ); 568 LPSTR fn = HeapAlloc( GetProcessHeap(), 0, len ); 357 569 DWORD retv = TRUE; 358 570 359 TRACE("(%s,%ld,size=%ld,data=%p)\n", 360 debugstr_a(fn), handle, datasize, data ); 361 362 if ( !GetFileResource( fn, MAKEINTRESOURCEA(VS_FILE_INFO), 571 WideCharToMultiByte( CP_ACP, 0, filename, -1, fn, len, NULL, NULL ); 572 573 dprintf(("(%s,%ld,size=%ld,data=%p)\n", 574 debugstr_w(filename), handle, datasize, data )); 575 576 if(VERSION_GetFileVersionInfo_PE(fn, &handle, datasize, data)) 577 goto END; 578 #ifndef __WIN32OS2__ 579 if(VERSION_GetFileVersionInfo_16(fn, &handle, datasize, data)) 580 goto END; 581 #endif 582 if ( !GetFileResource16( fn, MAKEINTRESOURCEA(VS_FILE_INFO), 363 583 MAKEINTRESOURCEA(VS_VERSION_INFO), 364 584 handle, datasize, data ) ) … … 366 586 367 587 else if ( datasize >= sizeof(VS_VERSION_INFO_STRUCT16) 368 && datasize >= ((VS_VERSION_INFO_STRUCT16 *)data)->wLength 588 && datasize >= ((VS_VERSION_INFO_STRUCT16 *)data)->wLength 369 589 && VersionInfoIs16( data ) ) 370 590 { 371 ERR("Cannot access NE resource in %s\n", debugstr_a(fn));591 dprintf(("Cannot access NE resource in %s\n", debugstr_a(fn) )); 372 592 retv = FALSE; 373 593 } 374 594 END: 375 595 HeapFree( GetProcessHeap(), 0, fn ); 376 596 return retv; 377 597 } 378 #endif //!__WIN32OS2__ 598 379 599 380 600 /*********************************************************************** 381 601 * VersionInfo16_FindChild [internal] 382 602 */ 383 VS_VERSION_INFO_STRUCT16 *VersionInfo16_FindChild( VS_VERSION_INFO_STRUCT16 *info, 603 static VS_VERSION_INFO_STRUCT16 *VersionInfo16_FindChild( VS_VERSION_INFO_STRUCT16 *info, 384 604 LPCSTR szKey, UINT cbKey ) 385 605 { … … 388 608 while ( (DWORD)child < (DWORD)info + info->wLength ) 389 609 { 390 if ( ! lstrncmpiA( child->szKey, szKey, cbKey ) )610 if ( !strncasecmp( child->szKey, szKey, cbKey ) ) 391 611 return child; 392 612 … … 401 621 * VersionInfo32_FindChild [internal] 402 622 */ 403 VS_VERSION_INFO_STRUCT32 *VersionInfo32_FindChild( VS_VERSION_INFO_STRUCT32 *info, 623 static VS_VERSION_INFO_STRUCT32 *VersionInfo32_FindChild( VS_VERSION_INFO_STRUCT32 *info, 404 624 LPCWSTR szKey, UINT cbKey ) 405 625 { … … 408 628 while ( (DWORD)child < (DWORD)info + info->wLength ) 409 629 { 410 #ifdef __WIN32OS2__ 411 if ( !lstrncmpiW( child->szKey, szKey, cbKey ) ) 412 #else 413 if ( !CRTDLL_wcsnicmp( child->szKey, szKey, cbKey ) ) 414 #endif 630 if ( !strncmpiW( child->szKey, szKey, cbKey ) ) 415 631 return child; 416 632 … … 422 638 423 639 /*********************************************************************** 424 * VerQueryValue32W [VERSION.13] 425 */ 426 DWORD VerQueryValue32W( LPVOID pBlock, LPCWSTR lpSubBlock, 427 LPVOID *lplpBuffer, UINT *puLen, BOOL *bText) 428 { 429 VS_VERSION_INFO_STRUCT32 *info = (VS_VERSION_INFO_STRUCT32 *)pBlock; 430 if ( VersionInfoIs16( info ) ) 431 { 432 ERR("called on NE resource!\n" ); 433 return FALSE; 434 } 435 436 #if defined(__WIN32OS2__) 437 dprintf(("VerQueryValueW %x %x %x %x", pBlock, lpSubBlock, lplpBuffer, puLen)); 438 #else 439 TRACE("(%p,%s,%p,%p)\n", 440 pBlock, debugstr_w(lpSubBlock), lplpBuffer, puLen ); 441 #endif 640 * VerQueryValueA [VERSION.@] 641 */ 642 DWORD WINAPI VerQueryValueA( LPVOID pBlock, LPCSTR lpSubBlock, 643 LPVOID *lplpBuffer, UINT *puLen ) 644 { 645 VS_VERSION_INFO_STRUCT16 *info = (VS_VERSION_INFO_STRUCT16 *)pBlock; 646 if ( !VersionInfoIs16( info ) ) 647 { 648 INT len; 649 LPWSTR wide_str; 650 DWORD give; 651 652 /* <lawson_whitney@juno.com> Feb 2001 */ 653 /* AOL 5.0 does this, expecting to get this: */ 654 len = MultiByteToWideChar(CP_ACP, 0, lpSubBlock, -1, NULL, 0); 655 wide_str = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); 656 MultiByteToWideChar(CP_ACP, 0, lpSubBlock, -1, wide_str, len); 657 658 give = VerQueryValueW(pBlock, wide_str, lplpBuffer, puLen); 659 HeapFree(GetProcessHeap(), 0, wide_str); 660 return give; 661 } 662 663 dprintf(("(%p,%s,%p,%p)\n", 664 pBlock, debugstr_a(lpSubBlock), lplpBuffer, puLen )); 442 665 443 666 while ( *lpSubBlock ) 444 667 { 445 668 /* Find next path component */ 446 LPC WSTR lpNextSlash;669 LPCSTR lpNextSlash; 447 670 for ( lpNextSlash = lpSubBlock; *lpNextSlash; lpNextSlash++ ) 448 671 if ( *lpNextSlash == '\\' ) … … 457 680 458 681 /* We have a non-empty component: search info for key */ 459 info = VersionInfo 32_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock );682 info = VersionInfo16_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock ); 460 683 if ( !info ) return FALSE; 461 684 … … 465 688 466 689 /* Return value */ 467 *lplpBuffer = VersionInfo 32_Value( info );690 *lplpBuffer = VersionInfo16_Value( info ); 468 691 *puLen = info->wValueLength; 469 *bText = info->bText; 470 471 #if defined(__WIN32OS2__) 472 dprintf(("VerQueryValueW successful")); 473 #endif 692 474 693 return TRUE; 475 694 } 476 695 477 478 #if defined(__WIN32OS2__) 479 DWORD VerQueryValueW( LPVOID pBlock, LPCWSTR lpSubBlock, 480 LPVOID *lplpBuffer, UINT *puLen) 481 { 482 BOOL bText; 483 484 return VerQueryValue32W(pBlock, lpSubBlock, lplpBuffer, puLen, &bText); 485 } 486 #endif 487 488 /*********************************************************************** 489 * VerQueryValue32A [VERSION.12] 490 */ 491 DWORD WINAPI VerQueryValueA( LPVOID pBlock, LPCSTR lpSubBlock, 696 /*********************************************************************** 697 * VerQueryValueW [VERSION.@] 698 */ 699 DWORD WINAPI VerQueryValueW( LPVOID pBlock, LPCWSTR lpSubBlock, 492 700 LPVOID *lplpBuffer, UINT *puLen ) 493 701 { 494 VS_VERSION_INFO_STRUCT16 *info = (VS_VERSION_INFO_STRUCT16 *)pBlock; 495 if ( !VersionInfoIs16( info ) ) 496 { 497 #ifdef __WIN32OS2__ 498 // this is a quick hack, not much tested 499 WCHAR *ustring = (WCHAR *)malloc(strlen((char *)lpSubBlock)*2+2); 500 LPVOID ubuffer; 501 char *abuffer; 502 UINT len = *puLen * 2; 503 BOOL rc, bText; 504 505 dprintf(("VERSION: called on PE unicode resource!\n" )); 506 507 AsciiToUnicode((char *)lpSubBlock, ustring); 508 rc = VerQueryValue32W( pBlock, (LPWSTR)ustring, &ubuffer, &len, &bText); 509 if(rc == 0) { 510 free(ustring); 511 return 0; 512 } 513 if(!bText) { 514 *lplpBuffer = ubuffer; 515 } 516 else 517 { 518 *lplpBuffer = malloc(len+1); // FIXME: no free, memory leak!! 519 UnicodeToAsciiN((WCHAR *)ubuffer, (char *)*lplpBuffer, len); 520 } 521 *puLen = len; 522 free(ustring); 523 return rc; 524 #else 525 ERR("called on PE resource!\n" ); 702 VS_VERSION_INFO_STRUCT32 *info = (VS_VERSION_INFO_STRUCT32 *)pBlock; 703 if ( VersionInfoIs16( info ) ) 704 { 705 dprintf(("called on NE resource!\n" )); 526 706 return FALSE; 527 #endif //__WIN32OS2__ 528 } 529 530 TRACE("(%p,%s,%p,%p)\n", 531 pBlock, debugstr_a(lpSubBlock), lplpBuffer, puLen ); 707 } 708 709 dprintf(("(%p,%s,%p,%p)\n", 710 pBlock, debugstr_w(lpSubBlock), lplpBuffer, puLen )); 532 711 533 712 while ( *lpSubBlock ) 534 713 { 535 714 /* Find next path component */ 536 LPC STR lpNextSlash;715 LPCWSTR lpNextSlash; 537 716 for ( lpNextSlash = lpSubBlock; *lpNextSlash; lpNextSlash++ ) 538 717 if ( *lpNextSlash == '\\' ) … … 547 726 548 727 /* We have a non-empty component: search info for key */ 549 info = VersionInfo 16_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock );728 info = VersionInfo32_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock ); 550 729 if ( !info ) return FALSE; 551 730 … … 555 734 556 735 /* Return value */ 557 *lplpBuffer = VersionInfo 16_Value( info );736 *lplpBuffer = VersionInfo32_Value( info ); 558 737 *puLen = info->wValueLength; 559 738 -
trunk/src/version/install.c
r2373 r10296 1 /* $Id: install.c,v 1.2 2000-01-08 14:27:33 sandervl Exp $ */ 2 /* 3 * Implementation of VERSION.DLL - File Installer routines (Wine 991212) 4 * 1 /* 2 * Implementation of VERSION.DLL - File Installer routines 3 * 5 4 * Copyright 1996,1997 Marcus Meissner 6 5 * Copyright 1997 David Cuthbert 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * 21 * TODO 22 * o Check the installation functions. 7 23 */ 8 24 9 25 #include <stdlib.h> 26 #include <stdarg.h> 27 #include <stdio.h> 10 28 #include <string.h> 11 29 12 30 #include "windef.h" 31 #include "winbase.h" 13 32 #include "winver.h" 14 #include "wine/winestring.h" 33 #include "winnls.h" 34 #include "wine/unicode.h" 15 35 #include "winerror.h" 16 #include "heap.h"17 36 #include "lzexpand.h" 18 #include "xmalloc.h" 19 #include "debugtools.h" 20 #include <misc.h> 21 22 DEFAULT_DEBUG_CHANNEL(ver) 37 #include "wine/debug.h" 38 39 WINE_DEFAULT_DEBUG_CHANNEL(ver); 23 40 24 41 25 42 /****************************************************************************** 26 * 27 * void ver_dstring( 28 * char const * prologue, 29 * char const * teststring, 30 * char const * epilogue ) 31 * 32 * This function will print via dprintf[_]ver to stddeb the prologue string, 33 * followed by the address of teststring and the string it contains if 34 * teststring is non-null or "(null)" otherwise, and then the epilogue 35 * string followed by a new line. 36 * 37 * Revision history 38 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 39 * Original implementation as dprintf[_]ver_string 40 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu) 41 * Fixed problem that caused bug with tools/make_debug -- renaming 42 * this function should fix the problem. 43 * 15-Feb-1998 Dimitrie Paun (dimi@cs.toronto.edu) 44 * Modified it to make it print the message using only one 45 * dprintf[_]ver call. 46 * 47 *****************************************************************************/ 48 49 static void ver_dstring( 50 char const * prologue, 51 char const * teststring, 52 char const * epilogue ) 53 { 54 TRACE("%s %p (\"%s\") %s\n", prologue, 55 (void const *) teststring, 56 teststring ? teststring : "(null)", 57 epilogue); 58 } 59 60 /****************************************************************************** 61 * 62 * int testFileExistence( 63 * char const * path, 64 * char const * file ) 43 * testFileExistenceA 65 44 * 66 45 * Tests whether a given path/file combination exists. If the file does … … 72 51 * Original implementation 73 52 * 74 *****************************************************************************/ 75 76 static int testFileExistence( 77 char const * path, 78 char const * file ) 53 */ 54 static int testFileExistenceA( char const * path, char const * file, BOOL excl ) 79 55 { 80 56 char filename[1024]; 81 57 int filenamelen; 82 58 OFSTRUCT fileinfo; 83 int retval;84 59 85 60 fileinfo.cBytes = sizeof(OFSTRUCT); … … 99 74 strcat(filename, file); 100 75 101 if(OpenFile(filename, &fileinfo, OF_EXIST) == HFILE_ERROR) 102 retval = 0; 103 else 104 retval = 1; 105 106 return retval; 76 return (OpenFile(filename, &fileinfo, 77 OF_EXIST | (excl ? OF_SHARE_EXCLUSIVE : 0)) != HFILE_ERROR); 107 78 } 108 79 109 80 /****************************************************************************** 110 * 111 * int testFileExclusiveExistence( 112 * char const * path, 113 * char const * file ) 114 * 115 * Tests whether a given path/file combination exists and ensures that no 116 * other programs have handles to the given file. If the file does not 117 * exist or is open, the return value is zero. If it does exist, the 118 * return value is non-zero. 119 * 120 * Revision history 121 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 122 * Original implementation 123 * 124 *****************************************************************************/ 125 126 static int testFileExclusiveExistence( 127 char const * path, 128 char const * file ) 81 * testFileExistenceW 82 */ 83 static int testFileExistenceW( const WCHAR *path, const WCHAR *file, BOOL excl ) 129 84 { 130 char filename[1024];131 int filenamelen;132 OFSTRUCT fileinfo;133 int retval;85 char *filename; 86 DWORD pathlen, filelen; 87 int ret; 88 OFSTRUCT fileinfo; 134 89 135 90 fileinfo.cBytes = sizeof(OFSTRUCT); 136 91 137 strcpy(filename, path); 138 filenamelen = strlen(filename); 139 92 pathlen = WideCharToMultiByte( CP_ACP, 0, path, -1, NULL, 0, NULL, NULL ); 93 filelen = WideCharToMultiByte( CP_ACP, 0, file, -1, NULL, 0, NULL, NULL ); 94 filename = HeapAlloc( GetProcessHeap(), 0, pathlen+filelen+2 ); 95 96 WideCharToMultiByte( CP_ACP, 0, path, -1, filename, pathlen, NULL, NULL ); 140 97 /* Add a trailing \ if necessary */ 141 if (filenamelen) {142 if(filename[filenamelen - 1] != '\\') 143 strcat(filename, "\\");98 if (pathlen > 1) 99 { 100 if (filename[pathlen-2] != '\\') strcpy( &filename[pathlen-1], "\\" ); 144 101 } 145 102 else /* specify the current directory */ 146 strcpy(filename, ".\\"); 147 148 /* Create the full pathname */ 149 strcat(filename, file); 150 151 if(OpenFile(filename, &fileinfo, OF_EXIST | OF_SHARE_EXCLUSIVE) == 152 HFILE_ERROR) 153 retval = 0; 154 else 155 retval = 1; 156 157 return retval; 103 strcpy(filename, ".\\"); 104 105 WideCharToMultiByte( CP_ACP, 0, file, -1, filename+strlen(filename), filelen, NULL, NULL ); 106 107 ret = (OpenFile(filename, &fileinfo, 108 OF_EXIST | (excl ? OF_SHARE_EXCLUSIVE : 0)) != HFILE_ERROR); 109 HeapFree( GetProcessHeap(), 0, filename ); 110 return ret; 158 111 } 159 112 160 113 /***************************************************************************** 161 * 162 * VerFindFile() [VER.8]114 * VerFindFileA [VERSION.@] 115 * 163 116 * Determines where to install a file based on whether it locates another 164 117 * version of the file in the system. The values VerFindFile returns are … … 168 121 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 169 122 * Reimplementation of VerFindFile from original stub. 170 * 171 ****************************************************************************/ 172 173 /* VerFindFile32A [VERSION.5] */ 123 */ 174 124 DWORD WINAPI VerFindFileA( 175 125 UINT flags, … … 182 132 UINT *lpuDestDirLen ) 183 133 { 184 DWORD retval ;185 c har curDir[256];186 c har destDir[256];134 DWORD retval = 0; 135 const char *curDir; 136 const char *destDir; 187 137 unsigned int curDirSizeReq; 188 138 unsigned int destDirSizeReq; 189 190 retval = 0; 139 char systemDir[MAX_PATH]; 191 140 192 141 /* Print out debugging information */ 193 TRACE("called with parameters:\n" 194 "\tflags = %x", flags); 195 if(flags & VFFF_ISSHAREDFILE) 196 TRACE(" (VFFF_ISSHAREDFILE)\n"); 197 else 198 TRACE("\n"); 199 200 ver_dstring("\tlpszFilename = ", lpszFilename, ""); 201 ver_dstring("\tlpszWinDir = ", lpszWinDir, ""); 202 ver_dstring("\tlpszAppDir = ", lpszAppDir, ""); 203 204 TRACE("\tlpszCurDir = %p\n", lpszCurDir); 205 if(lpuCurDirLen) 206 TRACE("\tlpuCurDirLen = %p (%u)\n", 207 lpuCurDirLen, *lpuCurDirLen); 208 else 209 TRACE("\tlpuCurDirLen = (null)\n"); 210 211 TRACE("\tlpszDestDir = %p\n", lpszDestDir); 212 if(lpuDestDirLen) 213 TRACE("\tlpuDestDirLen = %p (%u)\n", 214 lpuDestDirLen, *lpuDestDirLen); 142 TRACE("flags = %x filename=%s windir=%s appdir=%s curdirlen=%p(%u) destdirlen=%p(%u)\n", 143 flags, debugstr_a(lpszFilename), debugstr_a(lpszWinDir), debugstr_a(lpszAppDir), 144 lpuCurDirLen, lpuCurDirLen ? *lpuCurDirLen : 0, 145 lpuDestDirLen, lpuDestDirLen ? *lpuDestDirLen : 0 ); 215 146 216 147 /* Figure out where the file should go; shared files default to the 217 148 system directory */ 218 149 219 strcpy(curDir, ""); 220 strcpy(destDir, ""); 221 222 if(flags & VFFF_ISSHAREDFILE) { 223 GetSystemDirectoryA(destDir, 256); 224 225 /* Were we given a filename? If so, try to find the file. */ 226 if(lpszFilename) { 227 if(testFileExistence(destDir, lpszFilename)) { 228 strcpy(curDir, destDir); 229 230 if(!testFileExclusiveExistence(destDir, lpszFilename)) 231 retval |= VFF_FILEINUSE; 232 } 233 else if(lpszAppDir && testFileExistence(lpszAppDir, 234 lpszFilename)) { 235 strcpy(curDir, lpszAppDir); 236 retval |= VFF_CURNEDEST; 237 238 if(!testFileExclusiveExistence(lpszAppDir, lpszFilename)) 239 retval |= VFF_FILEINUSE; 240 } 241 } 242 } 243 else if(!(flags & VFFF_ISSHAREDFILE)) { /* not a shared file */ 244 if(lpszAppDir) { 245 char systemDir[256]; 246 GetSystemDirectoryA(systemDir, 256); 247 248 strcpy(destDir, lpszAppDir); 249 250 if(lpszFilename) { 251 if(testFileExistence(lpszAppDir, lpszFilename)) { 252 strcpy(curDir, lpszAppDir); 253 254 if(!testFileExclusiveExistence(lpszAppDir, lpszFilename)) 255 retval |= VFF_FILEINUSE; 256 } 257 else if(testFileExistence(systemDir, lpszFilename)) { 258 strcpy(curDir, systemDir); 259 retval |= VFF_CURNEDEST; 260 261 if(!testFileExclusiveExistence(systemDir, lpszFilename)) 262 retval |= VFF_FILEINUSE; 263 } 264 } 265 } 266 } 150 GetSystemDirectoryA(systemDir, sizeof(systemDir)); 151 curDir = ""; 152 destDir = ""; 153 154 if(flags & VFFF_ISSHAREDFILE) 155 { 156 destDir = systemDir; 157 /* Were we given a filename? If so, try to find the file. */ 158 if(lpszFilename) 159 { 160 if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir; 161 else if(lpszAppDir && testFileExistenceA(lpszAppDir, lpszFilename, FALSE)) 162 { 163 curDir = lpszAppDir; 164 retval |= VFF_CURNEDEST; 165 } 166 } 167 } 168 else /* not a shared file */ 169 { 170 if(lpszAppDir) 171 { 172 destDir = lpszAppDir; 173 if(lpszFilename) 174 { 175 if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir; 176 else if(testFileExistenceA(systemDir, lpszFilename, FALSE)) 177 { 178 curDir = systemDir; 179 retval |= VFF_CURNEDEST; 180 } 181 } 182 } 183 } 184 185 if (lpszFilename && !testFileExistenceA(curDir, lpszFilename, TRUE)) 186 retval |= VFF_FILEINUSE; 267 187 268 188 curDirSizeReq = strlen(curDir) + 1; 269 189 destDirSizeReq = strlen(destDir) + 1; 270 271 272 190 273 191 /* Make sure that the pointers to the size of the buffers are … … 275 193 is valid, then make sure that the buffer pointer is valid, too! */ 276 194 277 if(lpuDestDirLen && lpszDestDir) { 278 if(*lpuDestDirLen < destDirSizeReq) { 279 retval |= VFF_BUFFTOOSMALL; 280 if (*lpuDestDirLen) { 281 lstrcpynA(lpszDestDir, destDir, *lpuDestDirLen); 282 } 283 } 284 else 285 strcpy(lpszDestDir, destDir); 286 287 *lpuDestDirLen = destDirSizeReq; 288 } 289 290 if(lpuCurDirLen && lpszCurDir) { 291 if(*lpuCurDirLen < curDirSizeReq) { 292 retval |= VFF_BUFFTOOSMALL; 293 if (*lpuCurDirLen) { 294 lstrcpynA(lpszCurDir, curDir, *lpuCurDirLen); 295 } 296 } 297 else 298 strcpy(lpszCurDir, curDir); 299 300 *lpuCurDirLen = curDirSizeReq; 301 } 302 303 TRACE("ret = %lu (%s%s%s)\n", retval, 304 (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "", 305 (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "", 306 (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : ""); 307 308 ver_dstring("\t(Exit) lpszCurDir = ", lpszCurDir, ""); 309 if(lpuCurDirLen) 310 TRACE("\t(Exit) lpuCurDirLen = %p (%u)\n", 311 lpuCurDirLen, *lpuCurDirLen); 312 else 313 TRACE("\t(Exit) lpuCurDirLen = (null)\n"); 314 315 ver_dstring("\t(Exit) lpszDestDir = ", lpszDestDir, ""); 316 if(lpuDestDirLen) 317 TRACE("\t(Exit) lpuDestDirLen = %p (%u)\n", 318 lpuDestDirLen, *lpuDestDirLen); 195 if(lpuDestDirLen && lpszDestDir) 196 { 197 if (*lpuDestDirLen < destDirSizeReq) retval |= VFF_BUFFTOOSMALL; 198 lstrcpynA(lpszDestDir, destDir, *lpuDestDirLen); 199 *lpuDestDirLen = destDirSizeReq; 200 } 201 if(lpuCurDirLen && lpszCurDir) 202 { 203 if(*lpuCurDirLen < curDirSizeReq) retval |= VFF_BUFFTOOSMALL; 204 lstrcpynA(lpszCurDir, curDir, *lpuCurDirLen); 205 *lpuCurDirLen = curDirSizeReq; 206 } 207 208 TRACE("ret = %lu (%s%s%s) curdir=%s destdir=%s\n", retval, 209 (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "", 210 (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "", 211 (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : "", 212 debugstr_a(lpszCurDir), debugstr_a(lpszDestDir)); 319 213 320 214 return retval; 321 215 } 322 216 323 /* VerFindFile32W [VERSION.6] */ 324 DWORD WINAPI VerFindFileW( 325 UINT flags,LPCWSTR filename,LPCWSTR windir,LPCWSTR appdir, 326 LPWSTR curdir,UINT *pcurdirlen,LPWSTR destdir,UINT *pdestdirlen ) 217 /***************************************************************************** 218 * VerFindFileW [VERSION.@] 219 */ 220 DWORD WINAPI VerFindFileW( UINT flags,LPCWSTR lpszFilename,LPCWSTR lpszWinDir, 221 LPCWSTR lpszAppDir, LPWSTR lpszCurDir,UINT *lpuCurDirLen, 222 LPWSTR lpszDestDir,UINT *lpuDestDirLen ) 327 223 { 328 UINT curdirlen, destdirlen; 329 LPSTR wfn,wwd,wad,wdd,wcd; 330 DWORD ret; 331 332 wfn = HEAP_strdupWtoA( GetProcessHeap(), 0, filename ); 333 wwd = HEAP_strdupWtoA( GetProcessHeap(), 0, windir ); 334 wad = HEAP_strdupWtoA( GetProcessHeap(), 0, appdir ); 335 wcd = HeapAlloc( GetProcessHeap(), 0, *pcurdirlen ); 336 wdd = HeapAlloc( GetProcessHeap(), 0, *pdestdirlen ); 337 ret = VerFindFileA(flags,wfn,wwd,wad,wcd,&curdirlen,wdd,&destdirlen); 338 lstrcpynAtoW(curdir,wcd,*pcurdirlen); 339 lstrcpynAtoW(destdir,wdd,*pdestdirlen); 340 *pcurdirlen = strlen(wcd); 341 *pdestdirlen = strlen(wdd); 342 HeapFree( GetProcessHeap(), 0, wfn ); 343 HeapFree( GetProcessHeap(), 0, wwd ); 344 HeapFree( GetProcessHeap(), 0, wad ); 345 HeapFree( GetProcessHeap(), 0, wcd ); 346 HeapFree( GetProcessHeap(), 0, wdd ); 347 return ret; 224 static const WCHAR emptyW; 225 DWORD retval = 0; 226 const WCHAR *curDir; 227 const WCHAR *destDir; 228 unsigned int curDirSizeReq; 229 unsigned int destDirSizeReq; 230 WCHAR systemDir[MAX_PATH]; 231 232 /* Print out debugging information */ 233 TRACE("flags = %x filename=%s windir=%s appdir=%s curdirlen=%p(%u) destdirlen=%p(%u)\n", 234 flags, debugstr_w(lpszFilename), debugstr_w(lpszWinDir), debugstr_w(lpszAppDir), 235 lpuCurDirLen, lpuCurDirLen ? *lpuCurDirLen : 0, 236 lpuDestDirLen, lpuDestDirLen ? *lpuDestDirLen : 0 ); 237 238 /* Figure out where the file should go; shared files default to the 239 system directory */ 240 241 GetSystemDirectoryW(systemDir, sizeof(systemDir)/sizeof(WCHAR)); 242 curDir = &emptyW; 243 destDir = &emptyW; 244 245 if(flags & VFFF_ISSHAREDFILE) 246 { 247 destDir = systemDir; 248 /* Were we given a filename? If so, try to find the file. */ 249 if(lpszFilename) 250 { 251 if(testFileExistenceW(destDir, lpszFilename, FALSE)) curDir = destDir; 252 else if(lpszAppDir && testFileExistenceW(lpszAppDir, lpszFilename, FALSE)) 253 { 254 curDir = lpszAppDir; 255 retval |= VFF_CURNEDEST; 256 } 257 } 258 } 259 else /* not a shared file */ 260 { 261 if(lpszAppDir) 262 { 263 destDir = lpszAppDir; 264 if(lpszFilename) 265 { 266 if(testFileExistenceW(destDir, lpszFilename, FALSE)) curDir = destDir; 267 else if(testFileExistenceW(systemDir, lpszFilename, FALSE)) 268 { 269 curDir = systemDir; 270 retval |= VFF_CURNEDEST; 271 } 272 } 273 } 274 } 275 276 if (lpszFilename && !testFileExistenceW(curDir, lpszFilename, TRUE)) 277 retval |= VFF_FILEINUSE; 278 279 curDirSizeReq = strlenW(curDir) + 1; 280 destDirSizeReq = strlenW(destDir) + 1; 281 282 /* Make sure that the pointers to the size of the buffers are 283 valid; if not, do NOTHING with that buffer. If that pointer 284 is valid, then make sure that the buffer pointer is valid, too! */ 285 286 if(lpuDestDirLen && lpszDestDir) 287 { 288 if (*lpuDestDirLen < destDirSizeReq) retval |= VFF_BUFFTOOSMALL; 289 lstrcpynW(lpszDestDir, destDir, *lpuDestDirLen); 290 *lpuDestDirLen = destDirSizeReq; 291 } 292 if(lpuCurDirLen && lpszCurDir) 293 { 294 if(*lpuCurDirLen < curDirSizeReq) retval |= VFF_BUFFTOOSMALL; 295 lstrcpynW(lpszCurDir, curDir, *lpuCurDirLen); 296 *lpuCurDirLen = curDirSizeReq; 297 } 298 299 TRACE("ret = %lu (%s%s%s) curdir=%s destdir=%s\n", retval, 300 (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "", 301 (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "", 302 (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : "", 303 debugstr_w(lpszCurDir), debugstr_w(lpszDestDir)); 304 return retval; 348 305 } 349 306 … … 355 312 356 313 alloclen = 1000; 357 buf= xmalloc(alloclen); 314 buf=HeapAlloc(GetProcessHeap(), 0, alloclen); 315 if(buf == NULL) { 316 WARN("Memory exausted while fetching version info!\n"); 317 return NULL; 318 } 358 319 while (1) { 359 320 ret = GetFileVersionInfoA(fn,0,alloclen,buf); 360 321 if (!ret) { 361 free(buf);362 return 0;322 HeapFree(GetProcessHeap(), 0, buf); 323 return NULL; 363 324 } 364 325 if (alloclen<*(WORD*)buf) { 365 free(buf);366 326 alloclen = *(WORD*)buf; 367 buf = xmalloc(alloclen); 327 HeapFree(GetProcessHeap(), 0, buf); 328 buf = HeapAlloc(GetProcessHeap(), 0, alloclen); 329 if(buf == NULL) { 330 WARN("Memory exausted while fetching version info!\n"); 331 return NULL; 332 } 368 333 } else { 369 334 *vffi = (VS_FIXEDFILEINFO*)(buf+0x14); … … 391 356 392 357 /****************************************************************************** 393 * VerInstallFile 32A [VERSION.7]358 * VerInstallFileA [VERSION.@] 394 359 */ 395 360 DWORD WINAPI VerInstallFileA( … … 413 378 sprintf(destfn,"%s\\%s",pdest,destfilename); 414 379 hfsrc=LZOpenFileA(srcfn,&ofs,OF_READ); 415 if (hfsrc ==HFILE_ERROR)380 if (hfsrc < 0) 416 381 return VIF_CANNOTREADSRC; 417 382 sprintf(tmpfn,"%s\\%s",pdest,destfilename); 418 383 tmplast=strlen(pdest)+1; 419 384 attr = GetFileAttributesA(tmpfn); 420 if (attr !=-1) {385 if (attr != INVALID_FILE_ATTRIBUTES) { 421 386 if (attr & FILE_ATTRIBUTE_READONLY) { 422 387 LZClose(hfsrc); … … 425 390 /* FIXME: check if file currently in use and return VIF_FILEINUSE */ 426 391 } 427 attr = -1;392 attr = INVALID_FILE_ATTRIBUTES; 428 393 if (flags & VIFF_FORCEINSTALL) { 429 394 if (tmpfile[0]) { … … 432 397 attr = GetFileAttributesA(tmpfn); 433 398 /* if it exists, it has been copied by the call before. 434 * we jump over the copy part... 399 * we jump over the copy part... 435 400 */ 436 401 } 437 402 } 438 if (attr == -1) {403 if (attr == INVALID_FILE_ATTRIBUTES) { 439 404 char *s; 440 405 … … 463 428 case LZERROR_BADOUTHANDLE: 464 429 case LZERROR_WRITE: 465 ret = VIF_OUTOF MEMORY; /* FIXME: correct? */430 ret = VIF_OUTOFSPACE; 466 431 break; 467 432 case LZERROR_GLOBALLOC: 468 433 case LZERROR_GLOBLOCK: 469 ret = VIF_OUTOF SPACE;434 ret = VIF_OUTOFMEMORY; 470 435 break; 471 436 default: /* unknown error, should not happen */ … … 506 471 VerQueryValueA(buf2,"\\VarFileInfo\\Translation",(LPVOID*)&tbuf2,&len2) 507 472 ) { 508 /* irgendwas mit tbuf1 und tbuf2 machen 473 /* irgendwas mit tbuf1 und tbuf2 machen 509 474 * generiert DIFFLANG|MISMATCH 510 475 */ 511 476 } 512 free(buf2);477 HeapFree(GetProcessHeap(), 0, buf2); 513 478 } else 514 479 xret=VIF_MISMATCH|VIF_SRCOLD; 515 free(buf1);480 HeapFree(GetProcessHeap(), 0, buf1); 516 481 } 517 482 } … … 533 498 return xret; 534 499 } 535 if ((!(flags & VIFF_DONTDELETEOLD)) && 536 curdir && 500 if ((!(flags & VIFF_DONTDELETEOLD)) && 501 curdir && 537 502 *curdir && 538 503 lstrcmpiA(curdir,pdest) … … 541 506 542 507 sprintf(curfn,"%s\\%s",curdir,destfilename); 543 if ( -1!=GetFileAttributesA(curfn)) {508 if (INVALID_FILE_ATTRIBUTES != GetFileAttributesA(curfn)) { 544 509 /* FIXME: check if in use ... if it is, VIF_CANNOTDELETECUR */ 545 510 if (!DeleteFileA(curfn)) … … 557 522 558 523 559 /* VerInstallFile32W [VERSION.8] */ 524 /****************************************************************************** 525 * VerInstallFileW [VERSION.@] 526 */ 560 527 DWORD WINAPI VerInstallFileW( 561 528 UINT flags,LPCWSTR srcfilename,LPCWSTR destfilename,LPCWSTR srcdir, 562 529 LPCWSTR destdir,LPCWSTR curdir,LPWSTR tmpfile,UINT *tmpfilelen ) 563 530 { 564 LPSTR wsrcf ,wsrcd,wdestf,wdestd,wtmpf,wcurd;531 LPSTR wsrcf = NULL, wsrcd = NULL, wdestf = NULL, wdestd = NULL, wtmpf = NULL, wcurd = NULL; 565 532 DWORD ret; 566 567 wsrcf = HEAP_strdupWtoA( GetProcessHeap(), 0, srcfilename ); 568 wsrcd = HEAP_strdupWtoA( GetProcessHeap(), 0, srcdir ); 569 wdestf = HEAP_strdupWtoA( GetProcessHeap(), 0, destfilename ); 570 wdestd = HEAP_strdupWtoA( GetProcessHeap(), 0, destdir ); 571 wtmpf = HEAP_strdupWtoA( GetProcessHeap(), 0, tmpfile ); 572 wcurd = HEAP_strdupWtoA( GetProcessHeap(), 0, curdir ); 573 ret = VerInstallFileA(flags,wsrcf,wdestf,wsrcd,wdestd,wcurd,wtmpf,tmpfilelen); 533 UINT len; 534 535 if (srcfilename) 536 { 537 len = WideCharToMultiByte( CP_ACP, 0, srcfilename, -1, NULL, 0, NULL, NULL ); 538 if ((wsrcf = HeapAlloc( GetProcessHeap(), 0, len ))) 539 WideCharToMultiByte( CP_ACP, 0, srcfilename, -1, wsrcf, len, NULL, NULL ); 540 } 541 if (srcdir) 542 { 543 len = WideCharToMultiByte( CP_ACP, 0, srcdir, -1, NULL, 0, NULL, NULL ); 544 if ((wsrcd = HeapAlloc( GetProcessHeap(), 0, len ))) 545 WideCharToMultiByte( CP_ACP, 0, srcdir, -1, wsrcd, len, NULL, NULL ); 546 } 547 if (destfilename) 548 { 549 len = WideCharToMultiByte( CP_ACP, 0, destfilename, -1, NULL, 0, NULL, NULL ); 550 if ((wdestf = HeapAlloc( GetProcessHeap(), 0, len ))) 551 WideCharToMultiByte( CP_ACP, 0, destfilename, -1, wdestf, len, NULL, NULL ); 552 } 553 if (destdir) 554 { 555 len = WideCharToMultiByte( CP_ACP, 0, destdir, -1, NULL, 0, NULL, NULL ); 556 if ((wdestd = HeapAlloc( GetProcessHeap(), 0, len ))) 557 WideCharToMultiByte( CP_ACP, 0, destdir, -1, wdestd, len, NULL, NULL ); 558 } 559 if (curdir) 560 { 561 len = WideCharToMultiByte( CP_ACP, 0, curdir, -1, NULL, 0, NULL, NULL ); 562 if ((wcurd = HeapAlloc( GetProcessHeap(), 0, len ))) 563 WideCharToMultiByte( CP_ACP, 0, curdir, -1, wcurd, len, NULL, NULL ); 564 } 565 len = *tmpfilelen * sizeof(WCHAR); 566 wtmpf = HeapAlloc( GetProcessHeap(), 0, len ); 567 ret = VerInstallFileA(flags,wsrcf,wdestf,wsrcd,wdestd,wcurd,wtmpf,&len); 574 568 if (!ret) 575 lstrcpynAtoW(tmpfile,wtmpf,*tmpfilelen); 569 *tmpfilelen = MultiByteToWideChar( CP_ACP, 0, wtmpf, -1, tmpfile, *tmpfilelen ); 570 else if (ret & VIF_BUFFTOOSMALL) 571 *tmpfilelen = len; /* FIXME: not correct */ 572 576 573 HeapFree( GetProcessHeap(), 0, wsrcf ); 577 574 HeapFree( GetProcessHeap(), 0, wsrcd ); … … 579 576 HeapFree( GetProcessHeap(), 0, wdestd ); 580 577 HeapFree( GetProcessHeap(), 0, wtmpf ); 581 if (wcurd) 582 HeapFree( GetProcessHeap(), 0, wcurd ); 578 HeapFree( GetProcessHeap(), 0, wcurd ); 583 579 return ret; 584 580 } 585 -
trunk/src/version/makefile
r9676 r10296 1 # $Id: makefile,v 1.2 0 2003-01-15 10:42:50sandervl Exp $1 # $Id: makefile,v 1.21 2003-10-24 14:47:25 sandervl Exp $ 2 2 3 3 # … … 6 6 # version.dll makefile 7 7 # 8 9 !if "$(DEBUG)" == "1" 10 DEFFILE = versiondbg.def 11 ORGDEFFILE = version.def 12 !endif 8 13 9 14 … … 18 23 # 19 24 OBJS = \ 20 $(OBJDIR)\version.obj \21 25 $(OBJDIR)\install.obj \ 22 26 $(OBJDIR)\info.obj \ 27 $(OBJDIR)\resource.obj \ 28 !ifdef DEBUG 29 $(OBJDIR)\dbgwrap.obj \ 30 !endif 23 31 $(OBJDIR)\versionrsrc.obj \ 24 32 $(DLLENTRY)
Note:
See TracChangeset
for help on using the changeset viewer.