Changeset 10296 for trunk/src


Ignore:
Timestamp:
Oct 24, 2003, 4:47:25 PM (22 years ago)
Author:
sandervl
Message:

Wine resync

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:25 sandervl Exp $
    2 @c This is an additional Odin license agreement.
    3 @c It supercedes the main Odin license, but is only valid in
    4 @c the source directory in which it is present.
     1$Id: LICENSE.TXT,v 1.2 2003-10-24 14:47:24 sandervl Exp $
     2This is an additional Odin license agreement.
     3It supercedes the main Odin license, but is only valid in
     4the source directory in which it is present.
    55
    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
     6Copyright (c) 1993-2002 the Wine project authors (see the file AUTHORS
    117for a complete list)
    128
    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:
     9Wine is free software; you can redistribute it and/or modify it under
     10the terms of the GNU Lesser General Public License as published by the
     11Free Software Foundation; either version 2.1 of the License, or (at
     12your option) any later version.
    1913
    20 The above copyright notice and this permission notice shall be included in
    21 all copies or substantial portions of the Software.
     14This program is distributed in the hope that it will be useful, but
     15WITHOUT ANY WARRANTY; without even the implied warranty of
     16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     17Lesser General Public License for more details.
    2218
    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.
     19A copy of the GNU Lesser General Public License is included in the
     20Wine distribution in the file COPYING.LIB. If you did not receive this
     21copy, write to the Free Software Foundation, Inc., 59 Temple Place,
     22Suite 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:06 sandervl Exp $
     1; $Id: VERSION.DEF,v 1.9 2003-10-24 14:47:25 sandervl Exp $
    22
    33;
     
    2222;    VerQueryValueIndexA        = _VerQueryValueIndexA@16     @12
    2323;    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 *
    54 * Copyright 1996,1997 Marcus Meissner
    65 * Copyright 1997 David Cuthbert
    76 * 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>
    1027#include <stdlib.h>
    1128#include <string.h>
    1229
     30#include "windef.h"
     31#include "winbase.h"
    1332#include "winreg.h"
    1433#include "winver.h"
    15 #include "wine/winestring.h"
     34#include "wine/winuser16.h"
     35#include "wine/unicode.h"
    1636#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
     39WINE_DEFAULT_DEBUG_CHANNEL(ver);
    2440
    2541
     
    3248 *
    3349 *****************************************************************************/
     50#ifdef DEBUG
    3451static void print_vffi_debug(VS_FIXEDFILEINFO *vffi)
    3552{
     
    5067
    5168        TRACE("(");
    52         DPRINTF(" OS=0x%x.0x%x ",
     69        TRACE(" OS=0x%x.0x%x ",
    5370                HIWORD(vffi->dwFileOS),
    5471                LOWORD(vffi->dwFileOS)
    5572        );
    5673        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;
    6178        case VOS_UNKNOWN:
    6279        default:
    63                 DPRINTF("UNKNOWN(0x%lx),",vffi->dwFileOS&0xFFFF0000);break;
     80                TRACE("UNKNOWN(0x%lx),",vffi->dwFileOS&0xFFFF0000);break;
    6481        }
    6582        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;
    7289        }
    73         DPRINTF(")\n");
     90        TRACE(")\n");
    7491
    7592        switch (vffi->dwFileType) {
     
    85102                default:
    86103                case VFT2_UNKNOWN:
    87                         DPRINTF("UNKNOWN(0x%lx)",vffi->dwFileSubtype);
     104                        TRACE("UNKNOWN(0x%lx)",vffi->dwFileSubtype);
    88105                        break;
    89106                case VFT2_DRV_PRINTER:
    90                         DPRINTF("PRINTER");
     107                        TRACE("PRINTER");
    91108                        break;
    92109                case VFT2_DRV_KEYBOARD:
    93                         DPRINTF("KEYBOARD");
     110                        TRACE("KEYBOARD");
    94111                        break;
    95112                case VFT2_DRV_LANGUAGE:
    96                         DPRINTF("LANGUAGE");
     113                        TRACE("LANGUAGE");
    97114                        break;
    98115                case VFT2_DRV_DISPLAY:
    99                         DPRINTF("DISPLAY");
     116                        TRACE("DISPLAY");
    100117                        break;
    101118                case VFT2_DRV_MOUSE:
    102                         DPRINTF("MOUSE");
     119                        TRACE("MOUSE");
    103120                        break;
    104121                case VFT2_DRV_NETWORK:
    105                         DPRINTF("NETWORK");
     122                        TRACE("NETWORK");
    106123                        break;
    107124                case VFT2_DRV_SYSTEM:
    108                         DPRINTF("SYSTEM");
     125                        TRACE("SYSTEM");
    109126                        break;
    110127                case VFT2_DRV_INSTALLABLE:
    111                         DPRINTF("INSTALLABLE");
     128                        TRACE("INSTALLABLE");
    112129                        break;
    113130                case VFT2_DRV_SOUND:
    114                         DPRINTF("SOUND");
     131                        TRACE("SOUND");
    115132                        break;
    116133                case VFT2_DRV_COMM:
    117                         DPRINTF("COMM");
     134                        TRACE("COMM");
    118135                        break;
    119136                case VFT2_DRV_INPUTMETHOD:
    120                         DPRINTF("INPUTMETHOD");
     137                        TRACE("INPUTMETHOD");
    121138                        break;
    122139                }
     
    126143                switch (vffi->dwFileSubtype) {
    127144                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;
    133150                }
    134151                break;
     
    136153        case VFT_STATIC_LIB:TRACE("filetype=STATIC_LIB");break;
    137154        }
    138         DPRINTF("\n");
     155        TRACE("\n");
    139156        TRACE("  filedata=0x%lx.0x%lx\n",
    140157                    vffi->dwFileDateMS,vffi->dwFileDateLS);
    141158}
    142 
     159#else
     160#define print_vffi_debug(a)
     161#endif
    143162
    144163/***********************************************************************
     
    176195    ( ((VS_VERSION_INFO_STRUCT16 *)ver)->szKey[0] >= ' ' )
    177196
    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) )
    179199
    180200#define VersionInfo16_Value( ver )  \
    181     DWORD_ALIGN( (ver)->szKey + lstrlenA((ver)->szKey) + 1 )
     201    DWORD_ALIGN( (ver), (ver)->szKey + strlen((ver)->szKey) + 1 )
    182202#define VersionInfo32_Value( ver )  \
    183     DWORD_ALIGN( (ver)->szKey + lstrlenW((ver)->szKey) + 1 )
     203    DWORD_ALIGN( (ver), (ver)->szKey + strlenW((ver)->szKey) + 1 )
    184204
    185205#define VersionInfo16_Children( ver )  \
     
    196216    (VS_VERSION_INFO_STRUCT32 *)( (LPBYTE)ver + (((ver)->wLength + 3) & ~3) )
    197217
    198 #ifndef __WIN32OS2__
    199218/***********************************************************************
    200219 *           ConvertVersionInfo32To16        [internal]
    201220 */
    202 void ConvertVersionInfo32To16( VS_VERSION_INFO_STRUCT32 *info32, 
     221void ConvertVersionInfo32To16( VS_VERSION_INFO_STRUCT32 *info32,
    203222                               VS_VERSION_INFO_STRUCT16 *info16 )
    204223{
     
    211230    VS_VERSION_INFO_STRUCT16 *child16;
    212231
    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 ));
    216235
    217236    /* 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) ));
    222241
    223242    /* Convert value */
     
    225244    {
    226245        info16->wValueLength = 0;
    227         TRACE("No value present\n" );
     246        dprintf(("No value present\n" ));
    228247    }
    229248    else if ( bText )
    230249    {
    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 )),
    236256                    debugstr_a(VersionInfo16_Value( info16 )) );
    237257    }
     
    241261        memmove( VersionInfo16_Value( info16 ), lpValue, wValueLength );
    242262
    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 ));
    245265    }
    246266
    247267    /* Convert children */
    248268    child16 = VersionInfo16_Children( info16 );
    249     while ( (DWORD)child32 < (DWORD)info32 + wLength )
     269    while ( (DWORD)child32 < (DWORD)info32 + wLength && child32->wLength != 0 )
    250270    {
    251271        VS_VERSION_INFO_STRUCT32 *nextChild = VersionInfo32_Next( child32 );
     
    260280    info16->wLength = (DWORD)child16 - (DWORD)info16;
    261281
    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 */
     293static 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    }
     356END:
     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 */
     371static 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    }
     433END:
     434    FreeResource16(hMem);
     435    FreeLibrary16(hModule);
     436
     437    return len;
     438}
     439#endif
     440
     441/***********************************************************************
     442 *           GetFileVersionInfoSizeA         [VERSION.@]
    269443 */
    270444DWORD WINAPI GetFileVersionInfoSizeA( LPCSTR filename, LPDWORD handle )
     
    274448    BYTE buf[144];
    275449
    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,
    279471                                 MAKEINTRESOURCEA(VS_FILE_INFO),
    280472                                 MAKEINTRESOURCEA(VS_VERSION_INFO),
     
    282474    if (!len) return 0;
    283475
    284     ret = GetFileResource( filename,
     476    ret = GetFileResource16( filename,
    285477                             MAKEINTRESOURCEA(VS_FILE_INFO),
    286478                             MAKEINTRESOURCEA(VS_VERSION_INFO),
     
    289481
    290482    if ( handle ) *handle = offset;
    291    
     483
    292484    if ( VersionInfoIs16( buf ) )
    293485        vffi = (VS_FIXEDFILEINFO *)VersionInfo16_Value( (VS_VERSION_INFO_STRUCT16 *)buf );
     
    297489    if ( vffi->dwSignature != VS_FFI_SIGNATURE )
    298490    {
    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 ));
    301493        return 0;
    302494    }
     
    305497        len = ((VS_VERSION_INFO_STRUCT16 *)buf)->wLength;
    306498
     499#ifdef DEBUG
    307500    if ( TRACE_ON(ver) )
    308501        print_vffi_debug( vffi );
     502#endif
    309503
    310504    return len;
     
    312506
    313507/***********************************************************************
    314  *           GetFileVersionInfoSize32W         [VERSION.3]
     508 *           GetFileVersionInfoSizeW         [VERSION.@]
    315509 */
    316510DWORD WINAPI GetFileVersionInfoSizeW( LPCWSTR filename, LPDWORD handle )
    317511{
    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 );
    320516    HeapFree( GetProcessHeap(), 0, fn );
    321517    return ret;
     
    323519
    324520/***********************************************************************
    325  *           GetFileVersionInfo32A             [VERSION.1]
    326  */
    327 DWORD WINAPI GetFileVersionInfoA( LPCSTR filename, DWORD handle,
     521 *           GetFileVersionInfoA             [VERSION.@]
     522 */
     523BOOL WINAPI GetFileVersionInfoA( LPCSTR filename, DWORD handle,
    328524                                    DWORD datasize, LPVOID data )
    329525{
    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),
    334545                                       MAKEINTRESOURCEA(VS_VERSION_INFO),
    335546                                       handle, datasize, data ) )
    336547        return FALSE;
    337 
     548DO_CONVERT:
    338549    if (    datasize >= sizeof(VS_VERSION_INFO_STRUCT16)
    339          && datasize >= ((VS_VERSION_INFO_STRUCT16 *)data)->wLength 
     550         && datasize >= ((VS_VERSION_INFO_STRUCT16 *)data)->wLength
    340551         && !VersionInfoIs16( data ) )
    341552    {
    342553        /* convert resource from PE format to NE format */
    343         ConvertVersionInfo32To16( (VS_VERSION_INFO_STRUCT32 *)data, 
     554        ConvertVersionInfo32To16( (VS_VERSION_INFO_STRUCT32 *)data,
    344555                                  (VS_VERSION_INFO_STRUCT16 *)data );
    345556    }
     
    349560
    350561/***********************************************************************
    351  *           GetFileVersionInfo32W             [VERSION.4]
    352  */
    353 DWORD WINAPI GetFileVersionInfoW( LPCWSTR filename, DWORD handle,
     562 *           GetFileVersionInfoW             [VERSION.@]
     563 */
     564BOOL WINAPI GetFileVersionInfoW( LPCWSTR filename, DWORD handle,
    354565                                    DWORD datasize, LPVOID data )
    355566{
    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 );
    357569    DWORD retv = TRUE;
    358570
    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),
    363583                                 MAKEINTRESOURCEA(VS_VERSION_INFO),
    364584                                 handle, datasize, data ) )
     
    366586
    367587    else if (    datasize >= sizeof(VS_VERSION_INFO_STRUCT16)
    368               && datasize >= ((VS_VERSION_INFO_STRUCT16 *)data)->wLength 
     588              && datasize >= ((VS_VERSION_INFO_STRUCT16 *)data)->wLength
    369589              && VersionInfoIs16( data ) )
    370590    {
    371         ERR("Cannot access NE resource in %s\n", debugstr_a(fn) );
     591        dprintf(("Cannot access NE resource in %s\n", debugstr_a(fn) ));
    372592        retv =  FALSE;
    373593    }
    374 
     594END:
    375595    HeapFree( GetProcessHeap(), 0, fn );
    376596    return retv;
    377597}
    378 #endif //!__WIN32OS2__
     598
    379599
    380600/***********************************************************************
    381601 *           VersionInfo16_FindChild             [internal]
    382602 */
    383 VS_VERSION_INFO_STRUCT16 *VersionInfo16_FindChild( VS_VERSION_INFO_STRUCT16 *info,
     603static VS_VERSION_INFO_STRUCT16 *VersionInfo16_FindChild( VS_VERSION_INFO_STRUCT16 *info,
    384604                                            LPCSTR szKey, UINT cbKey )
    385605{
     
    388608    while ( (DWORD)child < (DWORD)info + info->wLength )
    389609    {
    390         if ( !lstrncmpiA( child->szKey, szKey, cbKey ) )
     610        if ( !strncasecmp( child->szKey, szKey, cbKey ) )
    391611            return child;
    392612
     
    401621 *           VersionInfo32_FindChild             [internal]
    402622 */
    403 VS_VERSION_INFO_STRUCT32 *VersionInfo32_FindChild( VS_VERSION_INFO_STRUCT32 *info,
     623static VS_VERSION_INFO_STRUCT32 *VersionInfo32_FindChild( VS_VERSION_INFO_STRUCT32 *info,
    404624                                            LPCWSTR szKey, UINT cbKey )
    405625{
     
    408628    while ( (DWORD)child < (DWORD)info + info->wLength )
    409629    {
    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 ) )
    415631            return child;
    416632
     
    422638
    423639/***********************************************************************
    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 */
     642DWORD 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 ));
    442665
    443666    while ( *lpSubBlock )
    444667    {
    445668        /* Find next path component */
    446         LPCWSTR lpNextSlash;
     669        LPCSTR lpNextSlash;
    447670        for ( lpNextSlash = lpSubBlock; *lpNextSlash; lpNextSlash++ )
    448671            if ( *lpNextSlash == '\\' )
     
    457680
    458681        /* We have a non-empty component: search info for key */
    459         info = VersionInfo32_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock );
     682        info = VersionInfo16_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock );
    460683        if ( !info ) return FALSE;
    461684
     
    465688
    466689    /* Return value */
    467     *lplpBuffer = VersionInfo32_Value( info );
     690    *lplpBuffer = VersionInfo16_Value( info );
    468691    *puLen = info->wValueLength;
    469     *bText = info->bText;
    470 
    471 #if defined(__WIN32OS2__)
    472     dprintf(("VerQueryValueW successful"));
    473 #endif
     692
    474693    return TRUE;
    475694}
    476695
    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 */
     699DWORD WINAPI VerQueryValueW( LPVOID pBlock, LPCWSTR lpSubBlock,
    492700                               LPVOID *lplpBuffer, UINT *puLen )
    493701{
    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" ));
    526706        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 ));
    532711
    533712    while ( *lpSubBlock )
    534713    {
    535714        /* Find next path component */
    536         LPCSTR lpNextSlash;
     715        LPCWSTR lpNextSlash;
    537716        for ( lpNextSlash = lpSubBlock; *lpNextSlash; lpNextSlash++ )
    538717            if ( *lpNextSlash == '\\' )
     
    547726
    548727        /* We have a non-empty component: search info for key */
    549         info = VersionInfo16_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock );
     728        info = VersionInfo32_FindChild( info, lpSubBlock, lpNextSlash-lpSubBlock );
    550729        if ( !info ) return FALSE;
    551730
     
    555734
    556735    /* Return value */
    557     *lplpBuffer = VersionInfo16_Value( info );
     736    *lplpBuffer = VersionInfo32_Value( info );
    558737    *puLen = info->wValueLength;
    559738
  • 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 *
    54 * Copyright 1996,1997 Marcus Meissner
    65 * 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.
    723 */
    824
    925#include <stdlib.h>
     26#include <stdarg.h>
     27#include <stdio.h>
    1028#include <string.h>
    1129
    1230#include "windef.h"
     31#include "winbase.h"
    1332#include "winver.h"
    14 #include "wine/winestring.h"
     33#include "winnls.h"
     34#include "wine/unicode.h"
    1535#include "winerror.h"
    16 #include "heap.h"
    1736#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
     39WINE_DEFAULT_DEBUG_CHANNEL(ver);
    2340
    2441
    2542/******************************************************************************
    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
    6544 *
    6645 *   Tests whether a given path/file combination exists.  If the file does
     
    7251 *         Original implementation
    7352 *
    74  *****************************************************************************/
    75 
    76 static int  testFileExistence(
    77    char const * path,
    78    char const * file )
     53 */
     54static int testFileExistenceA( char const * path, char const * file, BOOL excl )
    7955{
    8056    char  filename[1024];
    8157    int  filenamelen;
    8258    OFSTRUCT  fileinfo;
    83     int  retval;
    8459
    8560    fileinfo.cBytes = sizeof(OFSTRUCT);
     
    9974    strcat(filename, file);
    10075
    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);
    10778}
    10879
    10980/******************************************************************************
    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 */
     83static int testFileExistenceW( const WCHAR *path, const WCHAR *file, BOOL excl )
    12984{
    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;
    13489
    13590    fileinfo.cBytes = sizeof(OFSTRUCT);
    13691
    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 );
    14097    /* 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], "\\" );
    144101    }
    145102    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;
    158111}
    159112
    160113/*****************************************************************************
    161  *
    162  *   VerFindFile() [VER.8]
     114 *   VerFindFileA [VERSION.@]
     115 *
    163116 *   Determines where to install a file based on whether it locates another
    164117 *   version of the file in the system.  The values VerFindFile returns are
     
    168121 *      30-May-1997   Dave Cuthbert (dacut@ece.cmu.edu)
    169122 *         Reimplementation of VerFindFile from original stub.
    170  *
    171  ****************************************************************************/
    172 
    173 /* VerFindFile32A                                               [VERSION.5] */
     123 */
    174124DWORD WINAPI VerFindFileA(
    175125    UINT flags,
     
    182132    UINT *lpuDestDirLen )
    183133{
    184     DWORD  retval;
    185     char  curDir[256];
    186     char  destDir[256];
     134    DWORD  retval = 0;
     135    const char *curDir;
     136    const char *destDir;
    187137    unsigned int  curDirSizeReq;
    188138    unsigned int  destDirSizeReq;
    189 
    190     retval = 0;
     139    char  systemDir[MAX_PATH];
    191140
    192141    /* 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 );
    215146
    216147    /* Figure out where the file should go; shared files default to the
    217148       system directory */
    218149
    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;
    267187
    268188    curDirSizeReq = strlen(curDir) + 1;
    269189    destDirSizeReq = strlen(destDir) + 1;
    270 
    271 
    272190
    273191    /* Make sure that the pointers to the size of the buffers are
     
    275193       is valid, then make sure that the buffer pointer is valid, too! */
    276194
    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));
    319213
    320214    return retval;
    321215}
    322216
    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 */
     220DWORD WINAPI VerFindFileW( UINT flags,LPCWSTR lpszFilename,LPCWSTR lpszWinDir,
     221                           LPCWSTR lpszAppDir, LPWSTR lpszCurDir,UINT *lpuCurDirLen,
     222                           LPWSTR lpszDestDir,UINT *lpuDestDirLen )
    327223{
    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;
    348305}
    349306
     
    355312
    356313    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    }
    358319    while (1) {
    359320        ret = GetFileVersionInfoA(fn,0,alloclen,buf);
    360321        if (!ret) {
    361             free(buf);
    362             return 0;
     322            HeapFree(GetProcessHeap(), 0, buf);
     323            return NULL;
    363324        }
    364325        if (alloclen<*(WORD*)buf) {
    365             free(buf);
    366326            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            }
    368333        } else {
    369334            *vffi = (VS_FIXEDFILEINFO*)(buf+0x14);
     
    391356
    392357/******************************************************************************
    393  * VerInstallFile32A [VERSION.7]
     358 * VerInstallFileA [VERSION.@]
    394359 */
    395360DWORD WINAPI VerInstallFileA(
     
    413378    sprintf(destfn,"%s\\%s",pdest,destfilename);
    414379    hfsrc=LZOpenFileA(srcfn,&ofs,OF_READ);
    415     if (hfsrc==HFILE_ERROR)
     380    if (hfsrc < 0)
    416381        return VIF_CANNOTREADSRC;
    417382    sprintf(tmpfn,"%s\\%s",pdest,destfilename);
    418383    tmplast=strlen(pdest)+1;
    419384    attr = GetFileAttributesA(tmpfn);
    420     if (attr!=-1) {
     385    if (attr != INVALID_FILE_ATTRIBUTES) {
    421386        if (attr & FILE_ATTRIBUTE_READONLY) {
    422387            LZClose(hfsrc);
     
    425390        /* FIXME: check if file currently in use and return VIF_FILEINUSE */
    426391    }
    427     attr = -1;
     392    attr = INVALID_FILE_ATTRIBUTES;
    428393    if (flags & VIFF_FORCEINSTALL) {
    429394        if (tmpfile[0]) {
     
    432397            attr = GetFileAttributesA(tmpfn);
    433398            /* 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...
    435400             */
    436401        }
    437402    }
    438     if (attr == -1) {
     403    if (attr == INVALID_FILE_ATTRIBUTES) {
    439404        char    *s;
    440405
     
    463428            case LZERROR_BADOUTHANDLE:
    464429            case LZERROR_WRITE:
    465                 ret = VIF_OUTOFMEMORY; /* FIXME: correct? */
     430                ret = VIF_OUTOFSPACE;
    466431                break;
    467432            case LZERROR_GLOBALLOC:
    468433            case LZERROR_GLOBLOCK:
    469                 ret = VIF_OUTOFSPACE;
     434                ret = VIF_OUTOFMEMORY;
    470435                break;
    471436            default: /* unknown error, should not happen */
     
    506471                    VerQueryValueA(buf2,"\\VarFileInfo\\Translation",(LPVOID*)&tbuf2,&len2)
    507472                ) {
    508                     /* irgendwas mit tbuf1 und tbuf2 machen 
     473                    /* irgendwas mit tbuf1 und tbuf2 machen
    509474                     * generiert DIFFLANG|MISMATCH
    510475                     */
    511476                }
    512                 free(buf2);
     477                HeapFree(GetProcessHeap(), 0, buf2);
    513478            } else
    514479                xret=VIF_MISMATCH|VIF_SRCOLD;
    515             free(buf1);
     480            HeapFree(GetProcessHeap(), 0, buf1);
    516481        }
    517482    }
     
    533498                return xret;
    534499            }
    535         if ((!(flags & VIFF_DONTDELETEOLD))     && 
    536             curdir                              && 
     500        if ((!(flags & VIFF_DONTDELETEOLD))     &&
     501            curdir                              &&
    537502            *curdir                             &&
    538503            lstrcmpiA(curdir,pdest)
     
    541506
    542507            sprintf(curfn,"%s\\%s",curdir,destfilename);
    543             if (-1!=GetFileAttributesA(curfn)) {
     508            if (INVALID_FILE_ATTRIBUTES != GetFileAttributesA(curfn)) {
    544509                /* FIXME: check if in use ... if it is, VIF_CANNOTDELETECUR */
    545510                if (!DeleteFileA(curfn))
     
    557522
    558523
    559 /* VerInstallFile32W                            [VERSION.8] */
     524/******************************************************************************
     525 * VerInstallFileW                              [VERSION.@]
     526 */
    560527DWORD WINAPI VerInstallFileW(
    561528        UINT flags,LPCWSTR srcfilename,LPCWSTR destfilename,LPCWSTR srcdir,
    562529        LPCWSTR destdir,LPCWSTR curdir,LPWSTR tmpfile,UINT *tmpfilelen )
    563530{
    564     LPSTR wsrcf,wsrcd,wdestf,wdestd,wtmpf,wcurd;
     531    LPSTR wsrcf = NULL, wsrcd = NULL, wdestf = NULL, wdestd = NULL, wtmpf = NULL, wcurd = NULL;
    565532    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);
    574568    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
    576573    HeapFree( GetProcessHeap(), 0, wsrcf );
    577574    HeapFree( GetProcessHeap(), 0, wsrcd );
     
    579576    HeapFree( GetProcessHeap(), 0, wdestd );
    580577    HeapFree( GetProcessHeap(), 0, wtmpf );
    581     if (wcurd)
    582         HeapFree( GetProcessHeap(), 0, wcurd );
     578    HeapFree( GetProcessHeap(), 0, wcurd );
    583579    return ret;
    584580}
    585 
  • trunk/src/version/makefile

    r9676 r10296  
    1 # $Id: makefile,v 1.20 2003-01-15 10:42:50 sandervl Exp $
     1# $Id: makefile,v 1.21 2003-10-24 14:47:25 sandervl Exp $
    22
    33#
     
    66#       version.dll makefile
    77#
     8
     9!if "$(DEBUG)" == "1"
     10DEFFILE    = versiondbg.def
     11ORGDEFFILE = version.def
     12!endif
    813
    914
     
    1823#
    1924OBJS = \
    20 $(OBJDIR)\version.obj \
    2125$(OBJDIR)\install.obj \
    2226$(OBJDIR)\info.obj \
     27$(OBJDIR)\resource.obj \
     28!ifdef DEBUG
     29$(OBJDIR)\dbgwrap.obj \
     30!endif
    2331$(OBJDIR)\versionrsrc.obj \
    2432$(DLLENTRY)
Note: See TracChangeset for help on using the changeset viewer.