Changeset 488 for trunk/src/version/version.cpp
- Timestamp:
- Aug 13, 1999, 1:33:38 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/version/version.cpp
r369 r488 1 /* $Id: version.cpp,v 1. 4 1999-07-23 07:30:49 sandervlExp $ */1 /* $Id: version.cpp,v 1.5 1999-08-12 23:33:37 phaller Exp $ */ 2 2 3 3 /* … … 17 17 #include <stdlib.h> 18 18 #include <string.h> 19 #include <odinwrap.h> 19 20 #include <misc.h> 20 21 #include <unicode.h> 21 #include "version.h" 22 23 #include "lzexpand.h" 24 25 26 /******************************************************************************/ 27 /******************************************************************************/ 28 BOOL WIN32API VERSION_GetFileVersionInfoA(LPTSTR lpszFile, 29 DWORD dwHandle, 30 DWORD cbBuf, 31 LPVOID lpvData) 32 { 33 dprintf(("VERSION: GetFileVersionInfoA %s\n", 34 lpszFile)); 35 36 return GetVersionStruct(lpszFile, 37 (char *)lpvData, 38 cbBuf); 39 } 40 /******************************************************************************/ 41 /******************************************************************************/ 42 BOOL WIN32API VERSION_GetFileVersionInfoW(LPWSTR lpszFile, 43 DWORD dwHandle, 44 DWORD cbBuf, 45 LPVOID lpvData) 46 { 47 BOOL rc; 48 char *astring = UnicodeToAsciiString(lpszFile); 49 50 dprintf(("VERSION: GetFileVersionInfoW (%s,%08xh,%08xh,%08xh)\n", 51 lpszFile, 52 dwHandle, 53 cbBuf, 54 lpvData)); 22 #include <heapstring.h> 23 #include <version.h> 24 #include <lzexpand.h> 25 #include <win\winreg.h> 26 27 28 ODINDEBUGCHANNEL(VERSION) 29 30 /***************************************************************************** 31 * Name : 32 * Purpose : 33 * Parameters: 34 * Variables : 35 * Result : 36 * Remark : 37 * Status : UNTESTED STUB 38 * 39 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 40 *****************************************************************************/ 41 42 VS_VERSION_INFO_STRUCT16 *VersionInfo16_FindChild(VS_VERSION_INFO_STRUCT16 *info, 43 LPCSTR szKey, 44 UINT cbKey ) 45 { 46 VS_VERSION_INFO_STRUCT16 *child = VersionInfo16_Children( info ); 47 48 while ( (DWORD)child < (DWORD)info + info->wLength ) 49 { 50 if ( !strnicmp( child->szKey, szKey, cbKey ) ) 51 return child; 52 53 if (!(child->wLength)) return NULL; 54 child = VersionInfo16_Next( child ); 55 } 56 57 return NULL; 58 } 59 60 61 /***************************************************************************** 62 * Name : 63 * Purpose : 64 * Parameters: 65 * Variables : 66 * Result : 67 * Remark : 68 * Status : UNTESTED STUB 69 * 70 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 71 *****************************************************************************/ 72 73 VS_VERSION_INFO_STRUCT32 *VersionInfo32_FindChild(VS_VERSION_INFO_STRUCT32 *info, 74 LPCWSTR szKey, 75 UINT cbKey ) 76 { 77 VS_VERSION_INFO_STRUCT32 *child = VersionInfo32_Children( info ); 78 79 while ( (DWORD)child < (DWORD)info + info->wLength ) 80 { 81 // if ( !lstrcmpniW( child->szKey, szKey, cbKey ) ) 82 if ( !lstrcmpiW( child->szKey, szKey) ) 83 return child; 84 85 child = VersionInfo32_Next( child ); 86 } 87 88 return NULL; 89 } 90 91 92 /****************************************************************************** 93 * 94 * void ver_dstring( 95 * char const * prologue, 96 * char const * teststring, 97 * char const * epilogue ) 98 * 99 * This function will print via dprintf[_]ver to stddeb the prologue string, 100 * followed by the address of teststring and the string it contains if 101 * teststring is non-null or "(null)" otherwise, and then the epilogue 102 * string followed by a new line. 103 * 104 * Revision history 105 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 106 * Original implementation as dprintf[_]ver_string 107 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu) 108 * Fixed problem that caused bug with tools/make_debug -- renaming 109 * this function should fix the problem. 110 * 15-Feb-1998 Dimitrie Paun (dimi@cs.toronto.edu) 111 * Modified it to make it print the message using only one 112 * dprintf[_]ver call. 113 * 114 *****************************************************************************/ 115 116 static void ver_dstring(char const * prologue, 117 char const * teststring, 118 char const * epilogue ) 119 { 120 dprintf(("VERSION: ver_dstring(%s, %s, %s)\n", 121 prologue, 122 teststring, 123 epilogue)); 124 } 125 126 127 /****************************************************************************** 128 * 129 * int testFileExistence( 130 * char const * path, 131 * char const * file ) 132 * 133 * Tests whether a given path/file combination exists. If the file does 134 * not exist, the return value is zero. If it does exist, the return 135 * value is non-zero. 136 * 137 * Revision history 138 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 139 * Original implementation 140 * 141 *****************************************************************************/ 142 143 static int testFileExistence(char const * path, 144 char const * file ) 145 { 146 char filename[1024]; 147 int filenamelen; 148 OFSTRUCT fileinfo; 149 int retval; 150 151 fileinfo.cBytes = sizeof(OFSTRUCT); 152 153 strcpy(filename, path); 154 filenamelen = strlen(filename); 155 156 /* Add a trailing \ if necessary */ 157 if(filenamelen) 158 { 159 if(filename[filenamelen - 1] != '\\') 160 strcat(filename, "\\"); 161 } 162 else /* specify the current directory */ 163 strcpy(filename, ".\\"); 164 165 /* Create the full pathname */ 166 strcat(filename, file); 167 168 if(OpenFile(filename, &fileinfo, OF_EXIST) == HFILE_ERROR) 169 retval = 0; 170 else 171 retval = 1; 172 173 return retval; 174 } 175 176 177 /****************************************************************************** 178 * 179 * int testFileExclusiveExistence( 180 * char const * path, 181 * char const * file ) 182 * 183 * Tests whether a given path/file combination exists and ensures that no 184 * other programs have handles to the given file. If the file does not 185 * exist or is open, the return value is zero. If it does exist, the 186 * return value is non-zero. 187 * 188 * Revision history 189 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 190 * Original implementation 191 * 192 *****************************************************************************/ 193 194 static int testFileExclusiveExistence(char const * path, 195 char const * file ) 196 { 197 char filename[1024]; 198 int filenamelen; 199 OFSTRUCT fileinfo; 200 int retval; 201 202 fileinfo.cBytes = sizeof(OFSTRUCT); 203 204 strcpy(filename, path); 205 filenamelen = strlen(filename); 206 207 /* Add a trailing \ if necessary */ 208 if(filenamelen) 209 { 210 if(filename[filenamelen - 1] != '\\') 211 strcat(filename, "\\"); 212 } 213 else /* specify the current directory */ 214 strcpy(filename, ".\\"); 215 216 /* Create the full pathname */ 217 strcat(filename, file); 218 219 if(OpenFile(filename, 220 &fileinfo, 221 OF_EXIST | OF_SHARE_EXCLUSIVE) == HFILE_ERROR) 222 retval = 0; 223 else 224 retval = 1; 225 226 return retval; 227 } 228 229 230 static LPBYTE _fetch_versioninfo(LPSTR fn,VS_FIXEDFILEINFO **vffi) 231 { 232 DWORD alloclen; 233 LPBYTE buf; 234 DWORD ret; 235 236 alloclen = 1000; 237 buf = (LPBYTE)malloc(alloclen); 238 239 while (1) 240 { 241 ret = GetFileVersionInfoA(fn, 242 0, 243 alloclen, 244 buf); 245 if (!ret) 246 { 247 free(buf); 248 return 0; 249 } 250 251 if (alloclen<*(WORD*)buf) 252 { 253 free(buf); 254 alloclen = *(WORD*)buf; 255 buf = (LPBYTE)malloc(alloclen); 256 } 257 else 258 { 259 *vffi = (VS_FIXEDFILEINFO*)(buf+0x14); 260 261 if ((*vffi)->dwSignature == 0x004f0049) /* hack to detect unicode */ 262 *vffi = (VS_FIXEDFILEINFO*)(buf+0x28); 263 264 if ((*vffi)->dwSignature != VS_FFI_SIGNATURE) 265 dprintf(("VERSION: _fetch_versioninfo: Bad VS_FIXEDFILEINFO signature 0x%08lx\n", 266 (*vffi)->dwSignature)); 267 268 return buf; 269 } 270 } 271 } 272 273 static DWORD _error2vif(DWORD error) 274 { 275 switch (error) 276 { 277 case ERROR_ACCESS_DENIED: 278 return VIF_ACCESSVIOLATION; 279 280 case ERROR_SHARING_VIOLATION: 281 return VIF_SHARINGVIOLATION; 282 283 default: 284 return 0; 285 } 286 } 287 288 289 290 /***************************************************************************** 291 * Name : 292 * Purpose : 293 * Parameters: 294 * Variables : 295 * Result : 296 * Remark : 297 * Status : UNTESTED STUB 298 * 299 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 300 *****************************************************************************/ 301 302 ODINFUNCTION4(BOOL,GetFileVersionInfoA,LPSTR, lpszFile, 303 DWORD, dwHandle, 304 DWORD, cbBuf, 305 LPVOID,lpvData) 306 { 307 return GetVersionStruct((char *)lpszFile, 308 (char *)lpvData, 309 cbBuf); 310 } 311 312 313 /***************************************************************************** 314 * Name : 315 * Purpose : 316 * Parameters: 317 * Variables : 318 * Result : 319 * Remark : 320 * Status : UNTESTED STUB 321 * 322 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 323 *****************************************************************************/ 324 325 ODINFUNCTION4(BOOL,GetFileVersionInfoW,LPWSTR, lpszFile, 326 DWORD, dwHandle, 327 DWORD, cbBuf, 328 LPVOID, lpvData) 329 { 330 BOOL rc; 331 char *astring = UnicodeToAsciiString(lpszFile); 55 332 56 333 rc = GetVersionStruct(astring, (char *)lpvData, cbBuf); … … 58 335 return(rc); 59 336 } 60 /******************************************************************************/ 61 /******************************************************************************/ 62 DWORD WIN32API VERSION_GetFileVersionInfoSizeA(LPTSTR lpszFile, 63 LPDWORD lpdwHandle) 64 { 65 dprintf(("VERSION: GetFileVersionInfoSizeA(%s,%08xh)\n", 66 lpszFile, 67 lpdwHandle)); 68 337 338 339 /***************************************************************************** 340 * Name : 341 * Purpose : 342 * Parameters: 343 * Variables : 344 * Result : 345 * Remark : 346 * Status : UNTESTED STUB 347 * 348 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 349 *****************************************************************************/ 350 351 ODINFUNCTION2(DWORD,GetFileVersionInfoSizeA,LPSTR, lpszFile, 352 LPDWORD, lpdwHandle) 353 { 69 354 if(lpdwHandle) 70 355 lpdwHandle = 0; … … 72 357 return GetVersionSize(lpszFile); 73 358 } 74 /******************************************************************************/ 75 /******************************************************************************/ 76 DWORD WIN32API VERSION_GetFileVersionInfoSizeW(LPWSTR lpszFile, 77 LPDWORD lpdwHandle) 78 { 79 char *astring = UnicodeToAsciiString(lpszFile); 80 DWORD rc; 81 82 dprintf(("VERSION: GetFileVersionInfoSizeW(%08xh,%08xh)\n", 83 lpszFile, 84 lpdwHandle)); 85 86 if(lpdwHandle) 87 lpdwHandle = 0; 88 89 rc = GetVersionSize(astring); 90 FreeAsciiString(astring); 91 return(rc); 92 } 93 /******************************************************************************/ 94 /******************************************************************************/ 95 INT WIN32API lstrncmpiW( LPCWSTR str1, LPCWSTR str2, INT n ) 96 { 97 INT res; 98 99 if (!n) return 0; 100 while ((--n > 0) && *str1) 101 { 102 if ((res = towupper(*str1) - towupper(*str2)) != 0) return res; 103 str1++; 104 str2++; 105 } 106 return towupper(*str1) - towupper(*str2); 107 } 108 /*********************************************************************** 109 * VersionInfo16_FindChild [internal] 110 */ 111 VS_VERSION_INFO_STRUCT16 *VersionInfo16_FindChild( VS_VERSION_INFO_STRUCT16 *info, 112 LPCSTR szKey, UINT cbKey ) 113 { 114 VS_VERSION_INFO_STRUCT16 *child = VersionInfo16_Children( info ); 115 116 while ( (DWORD)child < (DWORD)info + info->wLength ) 117 { 118 if ( !strnicmp( child->szKey, szKey, cbKey ) ) 119 return child; 120 121 if (!(child->wLength)) return NULL; 122 child = VersionInfo16_Next( child ); 123 } 124 125 return NULL; 126 } 127 /*********************************************************************** 128 * VersionInfo32_FindChild [internal] 129 */ 130 VS_VERSION_INFO_STRUCT32 *VersionInfo32_FindChild( VS_VERSION_INFO_STRUCT32 *info, 131 LPCWSTR szKey, UINT cbKey ) 132 { 133 VS_VERSION_INFO_STRUCT32 *child = VersionInfo32_Children( info ); 134 135 while ( (DWORD)child < (DWORD)info + info->wLength ) 136 { 137 if ( !lstrncmpiW( child->szKey, szKey, cbKey ) ) 138 return child; 139 140 child = VersionInfo32_Next( child ); 141 } 142 143 return NULL; 144 } 145 /******************************************************************************/ 146 /****************************************************************************** 147 * VerQueryValue32W [VERSION.13] 148 */ 149 BOOL WIN32API VERSION_VerQueryValueW( LPVOID pBlock, LPCWSTR lpSubBlock, 150 LPVOID *lplpBuffer, UINT *puLen ) 359 360 361 /***************************************************************************** 362 * Name : 363 * Purpose : 364 * Parameters: 365 * Variables : 366 * Result : 367 * Remark : 368 * Status : UNTESTED STUB 369 * 370 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 371 *****************************************************************************/ 372 373 ODINFUNCTION2(DWORD,GetFileVersionInfoSizeW,LPWSTR, lpszFile, 374 LPDWORD, lpdwHandle) 375 { 376 char *astring = UnicodeToAsciiString((LPWSTR)lpszFile); 377 DWORD rc; 378 379 380 if(lpdwHandle) 381 lpdwHandle = 0; 382 383 rc = GetVersionSize(astring); 384 FreeAsciiString(astring); 385 return(rc); 386 } 387 388 389 390 /***************************************************************************** 391 * Name : 392 * Purpose : 393 * Parameters: 394 * Variables : 395 * Result : 396 * Remark : 397 * Status : UNTESTED STUB 398 * 399 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 400 *****************************************************************************/ 401 402 ODINFUNCTION4(BOOL,VerQueryValueW, LPVOID, pBlock, 403 LPWSTR, lpSubBlock, 404 LPVOID*, lplpBuffer, 405 UINT*, puLen) 151 406 { 152 407 VS_VERSION_INFO_STRUCT32 *info = (VS_VERSION_INFO_STRUCT32 *)pBlock; … … 156 411 return FALSE; 157 412 } 158 159 dprintf(("VERSION: (%p,%s,%p,%p)\n",160 pBlock, lpSubBlock, lplpBuffer, puLen ));161 413 162 414 while ( *lpSubBlock ) … … 177 429 /* We have a non-empty component: search info for key */ 178 430 info = VersionInfo32_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock ); 179 if ( !info ) return FALSE; 431 if ( !info ) 432 return FALSE; 180 433 181 434 /* Skip path component */ 182 lpSubBlock = lpNextSlash;435 lpSubBlock = (LPWSTR)lpNextSlash; 183 436 } 184 437 … … 189 442 return TRUE; 190 443 } 191 /******************************************************************************/ 192 /******************************************************************************/ 193 /*********************************************************************** 194 * VerQueryValue32A [VERSION.12] 195 */ 196 BOOL WIN32API VERSION_VerQueryValueA( LPVOID pBlock, LPCSTR lpSubBlock, 197 LPVOID *lplpBuffer, UINT *puLen ) 444 445 446 /***************************************************************************** 447 * Name : 448 * Purpose : 449 * Parameters: 450 * Variables : 451 * Result : 452 * Remark : 453 * Status : UNTESTED STUB 454 * 455 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 456 *****************************************************************************/ 457 458 ODINFUNCTION4(BOOL,VerQueryValueA,LPVOID, pBlock, 459 LPSTR, lpSubBlock, 460 LPVOID*, lplpBuffer, 461 UINT*, puLen ) 198 462 { 199 463 VS_VERSION_INFO_STRUCT16 *info = (VS_VERSION_INFO_STRUCT16 *)pBlock; 200 464 if ( !VersionInfoIs16( info ) ) 201 465 { 202 // this is a quick hack, not much tested 466 // this is a quick hack, not much tested 203 467 WCHAR *ustring = (WCHAR *)malloc(strlen((char *)lpSubBlock)*2+1); 204 468 LPVOID ubuffer; … … 210 474 211 475 AsciiToUnicode((char *)lpSubBlock, ustring); 212 rc = V ERSION_VerQueryValueW( pBlock, (LPCWSTR)ustring, &ubuffer, &len);476 rc = VerQueryValueW( pBlock, (LPWSTR)ustring, &ubuffer, &len); 213 477 if(lpSubBlock[0] == '\\' && lpSubBlock[1] == 0) 214 478 *lplpBuffer = ubuffer; … … 223 487 } 224 488 225 dprintf(("VERSION: (%p,%s,%p,%p)\n",226 pBlock, lpSubBlock, lplpBuffer, puLen ));227 228 489 while ( *lpSubBlock ) 229 490 { … … 246 507 247 508 /* Skip path component */ 248 lpSubBlock = lpNextSlash;509 lpSubBlock = (LPSTR)lpNextSlash; 249 510 } 250 511 … … 255 516 return TRUE; 256 517 } 257 /******************************************************************************/ 258 259 260 /****************************************************************************** 261 * 262 * void ver_dstring( 263 * char const * prologue, 264 * char const * teststring, 265 * char const * epilogue ) 266 * 267 * This function will print via dprintf[_]ver to stddeb the prologue string, 268 * followed by the address of teststring and the string it contains if 269 * teststring is non-null or "(null)" otherwise, and then the epilogue 270 * string followed by a new line. 271 * 272 * Revision history 273 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 274 * Original implementation as dprintf[_]ver_string 275 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu) 276 * Fixed problem that caused bug with tools/make_debug -- renaming 277 * this function should fix the problem. 278 * 15-Feb-1998 Dimitrie Paun (dimi@cs.toronto.edu) 279 * Modified it to make it print the message using only one 280 * dprintf[_]ver call. 281 * 282 *****************************************************************************/ 283 284 static void ver_dstring(char const * prologue, 285 char const * teststring, 286 char const * epilogue ) 287 { 288 dprintf(("VERSION: ver_dstring(%s, %s, %s)\n", 289 prologue, 290 teststring, 291 epilogue)); 292 } 293 294 295 /****************************************************************************** 296 * 297 * int testFileExistence( 298 * char const * path, 299 * char const * file ) 300 * 301 * Tests whether a given path/file combination exists. If the file does 302 * not exist, the return value is zero. If it does exist, the return 303 * value is non-zero. 304 * 305 * Revision history 306 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 307 * Original implementation 308 * 309 *****************************************************************************/ 310 311 static int testFileExistence(char const * path, 312 char const * file ) 313 { 314 char filename[1024]; 315 int filenamelen; 316 OFSTRUCT fileinfo; 317 int retval; 318 319 fileinfo.cBytes = sizeof(OFSTRUCT); 320 321 strcpy(filename, path); 322 filenamelen = strlen(filename); 323 324 /* Add a trailing \ if necessary */ 325 if(filenamelen) 326 { 327 if(filename[filenamelen - 1] != '\\') 328 strcat(filename, "\\"); 329 } 330 else /* specify the current directory */ 331 strcpy(filename, ".\\"); 332 333 /* Create the full pathname */ 334 strcat(filename, file); 335 336 if(OpenFile(filename, &fileinfo, OF_EXIST) == HFILE_ERROR) 337 retval = 0; 338 else 339 retval = 1; 340 341 return retval; 342 } 343 344 345 /****************************************************************************** 346 * 347 * int testFileExclusiveExistence( 348 * char const * path, 349 * char const * file ) 350 * 351 * Tests whether a given path/file combination exists and ensures that no 352 * other programs have handles to the given file. If the file does not 353 * exist or is open, the return value is zero. If it does exist, the 354 * return value is non-zero. 355 * 356 * Revision history 357 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu) 358 * Original implementation 359 * 360 *****************************************************************************/ 361 362 static int testFileExclusiveExistence(char const * path, 363 char const * file ) 364 { 365 char filename[1024]; 366 int filenamelen; 367 OFSTRUCT fileinfo; 368 int retval; 369 370 fileinfo.cBytes = sizeof(OFSTRUCT); 371 372 strcpy(filename, path); 373 filenamelen = strlen(filename); 374 375 /* Add a trailing \ if necessary */ 376 if(filenamelen) 377 { 378 if(filename[filenamelen - 1] != '\\') 379 strcat(filename, "\\"); 380 } 381 else /* specify the current directory */ 382 strcpy(filename, ".\\"); 383 384 /* Create the full pathname */ 385 strcat(filename, file); 386 387 if(OpenFile(filename, 388 &fileinfo, 389 OF_EXIST | OF_SHARE_EXCLUSIVE) == HFILE_ERROR) 390 retval = 0; 391 else 392 retval = 1; 393 394 return retval; 395 } 518 519 396 520 397 521 … … 409 533 ****************************************************************************/ 410 534 411 /* VerFindFile32A [VERSION.5] */ 412 DWORD WIN32API VERSION_VerFindFileA(UINT flags, 413 LPCSTR lpszFilename, 414 LPCSTR lpszWinDir, 415 LPCSTR lpszAppDir, 416 LPSTR lpszCurDir, 417 UINT *lpuCurDirLen, 418 LPSTR lpszDestDir, 419 UINT *lpuDestDirLen ) 535 ODINFUNCTION8(DWORD,VerFindFileA,DWORD, flags, 536 LPSTR, lpszFilename, 537 LPSTR, lpszWinDir, 538 LPSTR, lpszAppDir, 539 LPSTR, lpszCurDir, 540 PUINT, lpuCurDirLen, 541 LPSTR, lpszDestDir, 542 PUINT, lpuDestDirLen ) 420 543 { 421 544 DWORD retval; … … 426 549 427 550 retval = 0; 428 429 /* Print out debugging information */430 dprintf(("VERSION: VerFindFileA(%08xh,%s,%s,%s,%08xh,%08xh,%08xh,%08xh)\n",431 flags,432 lpszFilename,433 lpszWinDir,434 lpszAppDir,435 lpszCurDir,436 lpuCurDirLen,437 lpszDestDir,438 lpuDestDirLen));439 551 440 552 ver_dstring("\tlpszFilename = ", lpszFilename, ""); … … 559 671 } 560 672 561 /* VerFindFile32W [VERSION.6] */ 562 DWORD WIN32API VERSION_VerFindFileW(UINT flags, 563 LPWSTR filename, 564 LPWSTR windir, 565 LPWSTR appdir, 566 LPWSTR curdir, 567 UINT *pcurdirlen, 568 LPWSTR destdir, 569 UINT *pdestdirlen) 673 674 /***************************************************************************** 675 * Name : 676 * Purpose : 677 * Parameters: 678 * Variables : 679 * Result : 680 * Remark : 681 * Status : UNTESTED STUB 682 * 683 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 684 *****************************************************************************/ 685 686 ODINFUNCTION8(DWORD,VerFindFileW,DWORD, flags, 687 LPWSTR, lpszFilename, 688 LPWSTR, lpszWinDir, 689 LPWSTR, lpszAppDir, 690 LPWSTR, lpszCurDir, 691 PUINT, lpuCurDirLen, 692 LPWSTR, lpszDestDir, 693 PUINT, lpuDestDirLen ) 570 694 { 571 695 UINT curdirlen, … … 578 702 DWORD ret; 579 703 580 wfn = UnicodeToAsciiString( filename );581 wwd = UnicodeToAsciiString( windir );582 wad = UnicodeToAsciiString( appdir );583 wcd = (LPSTR)HeapAlloc( GetProcessHeap(), 0, * pcurdirlen );584 wdd = (LPSTR)HeapAlloc( GetProcessHeap(), 0, * pdestdirlen );585 586 ret = V ERSION_VerFindFileA(flags,587 588 589 590 591 592 593 594 595 AsciiToUnicodeN(wcd, curdir,*pcurdirlen);596 AsciiToUnicodeN(wdd, destdir,*pdestdirlen);597 * pcurdirlen = strlen(wcd);598 * pdestdirlen = strlen(wdd);704 wfn = UnicodeToAsciiString(lpszFilename ); 705 wwd = UnicodeToAsciiString(lpszWinDir ); 706 wad = UnicodeToAsciiString(lpszAppDir ); 707 wcd = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpuCurDirLen ); 708 wdd = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpuDestDirLen ); 709 710 ret = VerFindFileA(flags, 711 wfn, 712 wwd, 713 wad, 714 wcd, 715 &curdirlen, 716 wdd, 717 &destdirlen); 718 719 AsciiToUnicodeN(wcd,lpszCurDir,*lpuCurDirLen); 720 AsciiToUnicodeN(wdd,lpszDestDir,*lpuDestDirLen); 721 *lpuCurDirLen = strlen(wcd); 722 *lpuDestDirLen = strlen(wdd); 599 723 600 724 FreeAsciiString(wfn ); … … 606 730 } 607 731 608 static LPBYTE _fetch_versioninfo(LPSTR fn,VS_FIXEDFILEINFO **vffi) 609 { 610 DWORD alloclen; 611 LPBYTE buf; 612 DWORD ret; 613 614 alloclen = 1000; 615 buf = (LPBYTE)malloc(alloclen); 616 617 while (1) 618 { 619 ret = VERSION_GetFileVersionInfoA(fn, 620 0, 621 alloclen, 622 buf); 623 if (!ret) 624 { 625 free(buf); 626 return 0; 627 } 628 629 if (alloclen<*(WORD*)buf) 630 { 631 free(buf); 632 alloclen = *(WORD*)buf; 633 buf = (LPBYTE)malloc(alloclen); 634 } 635 else 636 { 637 *vffi = (VS_FIXEDFILEINFO*)(buf+0x14); 638 639 if ((*vffi)->dwSignature == 0x004f0049) /* hack to detect unicode */ 640 *vffi = (VS_FIXEDFILEINFO*)(buf+0x28); 641 642 if ((*vffi)->dwSignature != VS_FFI_SIGNATURE) 643 dprintf(("VERSION: _fetch_versioninfo: Bad VS_FIXEDFILEINFO signature 0x%08lx\n", 644 (*vffi)->dwSignature)); 645 646 return buf; 647 } 648 } 649 } 650 651 static DWORD _error2vif(DWORD error) 652 { 653 switch (error) 654 { 655 case ERROR_ACCESS_DENIED: 656 return VIF_ACCESSVIOLATION; 657 658 case ERROR_SHARING_VIOLATION: 659 return VIF_SHARINGVIOLATION; 660 661 default: 662 return 0; 663 } 664 } 665 666 667 /****************************************************************************** 668 * VerInstallFile32A [VERSION.7] 669 */ 670 DWORD WIN32API VERSION_VerInstallFileA(UINT flags, 671 LPCSTR srcfilename, 672 LPCSTR destfilename, 673 LPCSTR srcdir, 674 LPCSTR destdir, 675 LPCSTR curdir, 676 LPSTR tmpfile, 677 UINT *tmpfilelen ) 732 733 /***************************************************************************** 734 * Name : 735 * Purpose : 736 * Parameters: 737 * Variables : 738 * Result : 739 * Remark : 740 * Status : UNTESTED STUB 741 * 742 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 743 *****************************************************************************/ 744 745 ODINFUNCTION8(DWORD,VerInstallFileA,DWORD, flags, 746 LPSTR, srcfilename, 747 LPSTR, destfilename, 748 LPSTR, srcdir, 749 LPSTR, destdir, 750 LPSTR, curdir, 751 LPSTR, tmpfile, 752 PUINT, tmpfilelen ) 678 753 { 679 754 LPCSTR pdest; … … 690 765 OFSTRUCT ofs; 691 766 692 dprintf(("VERSION: VerInstallFileA(%x,%s,%s,%s,%s,%s,%p,%d)\n", 693 flags, 694 srcfilename, 695 destfilename, 696 srcdir, 697 destdir, 698 curdir, 699 tmpfile, 700 *tmpfilelen)); 701 702 #if 1 703 dprintf(("VERSION: VersInstallFileA not implemented\n")); 704 705 return 0; 706 #else 767 707 768 xret = 0; 708 769 … … 868 929 LZClose(hfsrc); 869 930 return xret; 870 #endif 871 } 872 873 874 /* VerInstallFile32W [VERSION.8] */ 875 DWORD WIN32API VERSION_VerInstallFileW(UINT flags, 876 LPWSTR srcfilename, 877 LPWSTR destfilename, 878 LPWSTR srcdir, 879 LPWSTR destdir, 880 LPWSTR curdir, 881 LPWSTR tmpfile, 882 UINT *tmpfilelen ) 931 } 932 933 934 /***************************************************************************** 935 * Name : 936 * Purpose : 937 * Parameters: 938 * Variables : 939 * Result : 940 * Remark : 941 * Status : UNTESTED STUB 942 * 943 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 944 *****************************************************************************/ 945 946 ODINFUNCTION8(DWORD,VerInstallFileW,DWORD, flags, 947 LPWSTR, srcfilename, 948 LPWSTR, destfilename, 949 LPWSTR, srcdir, 950 LPWSTR, destdir, 951 LPWSTR, curdir, 952 LPWSTR, tmpfile, 953 PUINT, tmpfilelen ) 883 954 { 884 955 LPSTR wsrcf, … … 897 968 wcurd = UnicodeToAsciiString(curdir ); 898 969 899 ret = V ERSION_VerInstallFileA(flags,900 901 902 903 904 905 906 970 ret = VerInstallFileA(flags, 971 wsrcf, 972 wdestf, 973 wsrcd, 974 wdestd, 975 wcurd, 976 wtmpf, 977 tmpfilelen); 907 978 if (!ret) 908 979 AsciiToUnicodeN(wtmpf, … … 923 994 924 995 925 /*********************************************************************** 926 * VerLanguageName32A [VERSION.9] 927 */ 928 DWORD WIN32API VERSION_VerLanguageNameA(UINT wLang, 929 LPSTR szLang, 930 UINT nSize) 931 { 932 char buffer[80]; 933 LPCSTR name; 934 DWORD result; 935 936 dprintf(("VERSION: VerLanguageNameA(%08xh,%08xh,%08xh) not implemented.\n", 937 wLang, 938 szLang, 939 nSize)); 940 941 #if 0 942 /* 943 * First, check \System\CurrentControlSet\control\Nls\Locale\<langid> 944 * from the registry. 945 */ 946 947 sprintf( buffer, 948 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x", 949 wLang ); 950 951 result = RegQueryValueA(HKEY_LOCAL_MACHINE, 952 buffer, 953 szLang, 954 (LPDWORD)&nSize ); 955 if (result == ERROR_SUCCESS || 956 result == ERROR_MORE_DATA) 957 return nSize; 958 959 /* 960 * If that fails, use the internal table 961 * (actually, Windows stores the names in a string table resource ...) 962 */ 963 964 name = WINE_GetLanguageName( wLang ); 965 lstrcpynA( szLang, name, nSize ); 966 return lstrlenA( name ); 967 #endif 968 969 return 0; 970 } 971 972 /*********************************************************************** 973 * VerLanguageName32W [VERSION.10] 974 */ 975 DWORD WIN32API VERSION_VerLanguageNameW(UINT wLang, 976 LPWSTR szLang, 977 UINT nSize ) 978 { 979 char buffer[80]; 980 LPWSTR keyname; 981 LPCSTR name; 982 DWORD result; 983 984 dprintf(("VERSION: VerLanguageNameW(%08xh,%08xh,%08xh) not implemented.\n", 985 wLang, 986 szLang, 987 nSize)); 988 989 #if 0 990 /* 991 * First, check \System\CurrentControlSet\control\Nls\Locale\<langid> 992 * from the registry. 993 */ 994 995 sprintf( buffer, 996 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x", 997 wLang ); 998 999 keyname = HEAP_strdupAtoW( GetProcessHeap(), 0, buffer ); 1000 result = RegQueryValueW( HKEY_LOCAL_MACHINE, keyname, szLang, (LPDWORD)&nSize ); 1001 HeapFree( GetProcessHeap(), 0, keyname ); 1002 1003 if (result == ERROR_SUCCESS || 1004 result == ERROR_MORE_DATA) 1005 return nSize; 1006 1007 /* 1008 * If that fails, use the internal table 1009 * (actually, Windows stores the names in a string table resource ...) 1010 */ 1011 1012 name = WINE_GetLanguageName( wLang ); 1013 lstrcpynAtoW( szLang, name, nSize ); 1014 return lstrlenA( name ); 1015 #else 1016 return 0; 1017 #endif 1018 } 1019 1020 996
Note:
See TracChangeset
for help on using the changeset viewer.