Changeset 8421 for trunk/src


Ignore:
Timestamp:
May 15, 2002, 2:39:57 PM (23 years ago)
Author:
sandervl
Message:

wine resync

Location:
trunk/src/setupapi
Files:
8 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/setupapi/LICENSE.TXT

    r6379 r8421  
    1 $Id: LICENSE.TXT,v 1.2 2001-07-21 08:50:31 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.3 2002-05-15 12:39:53 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/setupapi/devinst.c

    r6712 r8421  
    22 * SetupAPI device installer
    33 *
     4 * Copyright 2000 Andreas Mohr for Codeweavers
     5 *
     6 * This library is free software; you can redistribute it and/or
     7 * modify it under the terms of the GNU Lesser General Public
     8 * License as published by the Free Software Foundation; either
     9 * version 2.1 of the License, or (at your option) any later version.
     10 *
     11 * This library is distributed in the hope that it will be useful,
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14 * Lesser General Public License for more details.
     15 *
     16 * You should have received a copy of the GNU Lesser General Public
     17 * License along with this library; if not, write to the Free Software
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    419 */
    520
    6 #include "debugtools.h"
    721#include "windef.h"
     22#include "winbase.h"
    823#include "setupx16.h"
    9 #include "heap.h"
     24#include "wine/debug.h"
    1025
    11 DEFAULT_DEBUG_CHANNEL(setupapi);
     26WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
    1227
    1328/***********************************************************************
  • trunk/src/setupapi/infparse.c

    r6712 r8421  
    11/*
    22 * SetupX .inf file parsing functions
     3 *
     4 * Copyright 2000 Andreas Mohr for Codeweavers
     5 *
     6 * This library is free software; you can redistribute it and/or
     7 * modify it under the terms of the GNU Lesser General Public
     8 * License as published by the Free Software Foundation; either
     9 * version 2.1 of the License, or (at your option) any later version.
     10 *
     11 * This library is distributed in the hope that it will be useful,
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14 * Lesser General Public License for more details.
     15 *
     16 * You should have received a copy of the GNU Lesser General Public
     17 * License along with this library; if not, write to the Free Software
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    319 *
    420 * FIXME:
     
    1026 */
    1127
    12 #include "debugtools.h"
     28#include <string.h>
    1329#include "windef.h"
    1430#include "winbase.h"
    15 #include "heap.h"
     31#include "ntddk.h"
    1632#include "wine/winbase16.h"
     33#include "setupapi.h"
    1734#include "setupx16.h"
    18 #include "setupx_private.h"
    19 
    20 DEFAULT_DEBUG_CHANNEL(setupx);
     35#include "setupapi_private.h"
     36#include "wine/debug.h"
     37
     38WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
     39
     40#define MAX_HANDLES 16384
     41#define FIRST_HANDLE 32
     42
     43static HINF handles[MAX_HANDLES];
     44
     45
     46static RETERR16 alloc_hinf16( HINF hinf, HINF16 *hinf16 )
     47{
     48    int i;
     49    for (i = 0; i < MAX_HANDLES; i++)
     50    {
     51        if (!handles[i])
     52        {
     53            handles[i] = hinf;
     54            *hinf16 = i + FIRST_HANDLE;
     55            return OK;
     56        }
     57    }
     58    return ERR_IP_OUT_OF_HANDLES;
     59}
     60
     61static HINF get_hinf( HINF16 hinf16 )
     62{
     63    int idx = hinf16 - FIRST_HANDLE;
     64    if (idx < 0 || idx >= MAX_HANDLES) return 0;
     65    return handles[idx];
     66}
     67
     68
     69static HINF free_hinf16( HINF16 hinf16 )
     70{
     71    HINF ret;
     72    int idx = hinf16 - FIRST_HANDLE;
     73
     74    if (idx < 0 || idx >= MAX_HANDLES) return 0;
     75    ret = handles[idx];
     76    handles[idx] = 0;
     77    return ret;
     78}
     79
     80/* convert last error code to a RETERR16 value */
     81static RETERR16 get_last_error(void)
     82{
     83    switch(GetLastError())
     84    {
     85    case ERROR_EXPECTED_SECTION_NAME:
     86    case ERROR_BAD_SECTION_NAME_LINE:
     87    case ERROR_SECTION_NAME_TOO_LONG: return ERR_IP_INVALID_SECT_NAME;
     88    case ERROR_SECTION_NOT_FOUND: return ERR_IP_SECT_NOT_FOUND;
     89    case ERROR_LINE_NOT_FOUND: return ERR_IP_LINE_NOT_FOUND;
     90    default: return IP_ERROR;  /* FIXME */
     91    }
     92}
     93
     94
     95/***********************************************************************
     96 *              IpOpen (SETUPX.2)
     97 *
     98 */
     99RETERR16 WINAPI IpOpen16( LPCSTR filename, HINF16 *hinf16 )
     100{
     101    HINF hinf = SetupOpenInfFileA( filename, NULL, INF_STYLE_WIN4, NULL );
     102    if (hinf == (HINF)INVALID_HANDLE_VALUE) return get_last_error();
     103    return alloc_hinf16( hinf, hinf16 );
     104}
     105
     106
     107/***********************************************************************
     108 *              IpClose (SETUPX.4)
     109 */
     110RETERR16 WINAPI IpClose16( HINF16 hinf16 )
     111{
     112    HINF hinf = free_hinf16( hinf16 );
     113    if (!hinf) return ERR_IP_INVALID_HINF;
     114    SetupCloseInfFile( hinf );
     115    return OK;
     116}
     117
     118
     119/***********************************************************************
     120 *              IpGetProfileString (SETUPX.210)
     121 */
     122RETERR16 WINAPI IpGetProfileString16( HINF16 hinf16, LPCSTR section, LPCSTR entry,
     123                                      LPSTR buffer, WORD buflen )
     124{
     125    DWORD required_size;
     126    HINF hinf = get_hinf( hinf16 );
     127
     128    if (!hinf) return ERR_IP_INVALID_HINF;
     129    if (!SetupGetLineTextA( NULL, hinf, section, entry, buffer, buflen, &required_size ))
     130        return get_last_error();
     131    TRACE("%p: section %s entry %s ret %s\n",
     132          hinf, debugstr_a(section), debugstr_a(entry), debugstr_a(buffer) );
     133    return OK;
     134}
     135
     136
     137/***********************************************************************
     138 *              GenFormStrWithoutPlaceHolders (SETUPX.103)
     139 *
     140 * ought to be pretty much implemented, I guess...
     141 */
     142void WINAPI GenFormStrWithoutPlaceHolders16( LPSTR dst, LPCSTR src, HINF16 hinf16 )
     143{
     144    UNICODE_STRING srcW;
     145    HINF hinf = get_hinf( hinf16 );
     146
     147    if (!hinf) return;
     148
     149    if (!RtlCreateUnicodeStringFromAsciiz( &srcW, src )) return;
     150    PARSER_string_substA( hinf, srcW.Buffer, dst, MAX_INF_STRING_LENGTH );
     151    RtlFreeUnicodeString( &srcW );
     152    TRACE( "%s -> %s\n", debugstr_a(src), debugstr_a(dst) );
     153}
     154
     155/***********************************************************************
     156 *              GenInstall (SETUPX.101)
     157 *
     158 * generic installer function for .INF file sections
     159 *
     160 * This is not perfect - patch whenever you can !
     161 *
     162 * wFlags == GENINSTALL_DO_xxx
     163 * e.g. NetMeeting:
     164 * first call GENINSTALL_DO_REGSRCPATH | GENINSTALL_DO_FILES,
     165 * second call GENINSTALL_DO_LOGCONFIG | CFGAUTO | INI2REG | REG | INI
     166 */
     167RETERR16 WINAPI GenInstall16( HINF16 hinf16, LPCSTR section, WORD genflags )
     168{
     169    UINT flags = 0;
     170    HINF hinf = get_hinf( hinf16 );
     171    RETERR16 ret = OK;
     172    void *context;
     173
     174    if (!hinf) return ERR_IP_INVALID_HINF;
     175
     176    if (genflags & GENINSTALL_DO_FILES) flags |= SPINST_FILES;
     177    if (genflags & GENINSTALL_DO_INI) flags |= SPINST_INIFILES;
     178    if (genflags & GENINSTALL_DO_REG) flags |= SPINST_REGISTRY;
     179    if (genflags & GENINSTALL_DO_INI2REG) flags |= SPINST_INI2REG;
     180    if (genflags & GENINSTALL_DO_LOGCONFIG) flags |= SPINST_LOGCONFIG;
     181    if (genflags & (GENINSTALL_DO_REGSRCPATH|GENINSTALL_DO_CFGAUTO|GENINSTALL_DO_PERUSER))
     182        FIXME( "unsupported flags %x\n", genflags );
     183
     184    context = SetupInitDefaultQueueCallback( 0 );
     185    if (!SetupInstallFromInfSectionA( 0, hinf, section, flags, 0, NULL, 0,
     186                                      SetupDefaultQueueCallbackA, context, 0, 0 ))
     187        ret = get_last_error();
     188
     189    SetupTermDefaultQueueCallback( context );
     190    return ret;
     191}
     192
    21193
    22194WORD InfNumEntries = 0;
     
    24196HINF16 IP_curr_handle = 0;
    25197
    26 RETERR16 IP_OpenInf(LPCSTR lpInfFileName, HINF16 *lphInf)
    27 {
    28     HFILE hFile = _lopen(lpInfFileName, OF_READ);
    29 
    30     if (!lphInf)
    31         return IP_ERROR;
    32 
    33     /* this could be improved by checking for already freed handles */
    34     if (IP_curr_handle == 0xffff)
    35         return ERR_IP_OUT_OF_HANDLES;
    36 
    37     if (hFile != HFILE_ERROR)
    38     {
    39         InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries+1);
    40         InfList[InfNumEntries].hInf = IP_curr_handle++;
    41         InfList[InfNumEntries].hInfFile = hFile;
    42         InfList[InfNumEntries].lpInfFileName = HeapAlloc( GetProcessHeap(), 0,
    43                                                           strlen(lpInfFileName)+1);
    44         strcpy( InfList[InfNumEntries].lpInfFileName, lpInfFileName );
    45         *lphInf = InfList[InfNumEntries].hInf;
    46         InfNumEntries++;
    47         TRACE("ret handle %d.\n", *lphInf);
    48         return OK;
    49     }
    50     *lphInf = 0xffff;
    51     return ERR_IP_INVALID_INFFILE;
    52 }
    53198
    54199BOOL IP_FindInf(HINF16 hInf, WORD *ret)
     
    76221}
    77222
    78 RETERR16 IP_CloseInf(HINF16 hInf)
    79 {
    80     int i;
    81     WORD n;
    82     RETERR16 res = ERR_IP_INVALID_HINF;
    83 
    84     if (IP_FindInf(hInf, &n))
    85     {
    86         _lclose(InfList[n].hInfFile);
    87         HeapFree(GetProcessHeap(), 0, InfList[n].lpInfFileName);
    88         for (i=n; i < InfNumEntries-1; i++)
    89             InfList[i] = InfList[i+1];
    90         InfNumEntries--;
    91         InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries);
    92         res = OK;
    93     }
    94     return res;
    95 }
    96 
    97 /***********************************************************************
    98  *              IpOpen16
    99  *
    100  */
    101 RETERR16 WINAPI IpOpen16(LPCSTR lpInfFileName, HINF16 *lphInf)
    102 {
    103     TRACE("('%s', %p)\n", lpInfFileName, lphInf);
    104     return IP_OpenInf(lpInfFileName, lphInf);
    105 }
    106 
    107 /***********************************************************************
    108  *              IpClose16
    109  */
    110 RETERR16 WINAPI IpClose16(HINF16 hInf)
    111 {
    112     return IP_CloseInf(hInf);
    113 }
    114 
    115 /***********************************************************************
    116  *              IpGetProfileString16
    117  */
    118 RETERR16 WINAPI IpGetProfileString16(HINF16 hInf, LPCSTR section, LPCSTR entry, LPSTR buffer, WORD buflen)
    119 {
    120     TRACE("'%s': section '%s' entry '%s'\n", IP_GetFileName(hInf), section, entry);
    121     GetPrivateProfileStringA(section, entry, "", buffer, buflen, IP_GetFileName(hInf));
    122     return 0;
    123 }
     223
  • trunk/src/setupapi/makefile

    r4989 r8421  
    1 # $Id: makefile,v 1.1 2001-01-20 18:06:12 sandervl Exp $
     1# $Id: makefile,v 1.2 2002-05-15 12:39:55 sandervl Exp $
    22
    33#
     
    1818#
    1919OBJS = \
     20$(OBJDIR)\devinst.obj \
     21$(OBJDIR)\dirid.obj \
     22$(OBJDIR)\infparse.obj \
     23$(OBJDIR)\install.obj \
     24$(OBJDIR)\parser.obj \
     25$(OBJDIR)\queue.obj \
    2026$(OBJDIR)\stubs.obj \
     27##$(OBJDIR)\virtcopy.obj \
    2128$(OBJDIR)\setupapirsrc.obj \
    2229$(DLLENTRY)
     
    2835LIBS = \
    2936$(ODIN32_LIB)/kernel32.lib \
     37$(ODIN32_LIB)/user32.lib \
     38$(ODIN32_LIB)/gdi32.lib \
     39$(ODIN32_LIB)/ntdll.lib \
    3040$(ODIN32_LIB)/ole32.lib \
    3141$(ODIN32_LIB)/$(ODINCRT).lib \
  • trunk/src/setupapi/setupx16.h

    r4989 r8421  
     1/*
     2 * Copyright 2000 Andreas Mohr for Codeweavers
     3 *
     4 * This library is free software; you can redistribute it and/or
     5 * modify it under the terms of the GNU Lesser General Public
     6 * License as published by the Free Software Foundation; either
     7 * version 2.1 of the License, or (at your option) any later version.
     8 *
     9 * This library is distributed in the hope that it will be useful,
     10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12 * Lesser General Public License for more details.
     13 *
     14 * You should have received a copy of the GNU Lesser General Public
     15 * License along with this library; if not, write to the Free Software
     16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     17 */
     18
    119#ifndef __SETUPX16_H
    220#define __SETUPX16_H
     
    624typedef UINT16 HINF16;
    725typedef UINT16 LOGDISKID16;
     26typedef UINT16 VHSTR;
    827
    928#define LINE_LEN        256
     
    1938#define DI_ERROR        (UINT16)500
    2039
    21 enum _IP_ERR {
     40enum {
    2241        ERR_IP_INVALID_FILENAME = IP_ERROR+1,
    2342        ERR_IP_ALLOC_ERR,
     
    3857};
    3958
    40 enum _ERR_VCP {
     59/****** virtual copy operations ******/
     60
     61typedef DWORD LPEXPANDVTBL;
     62
     63typedef struct {
     64        DWORD           dwSoFar;
     65        DWORD           dwTotal;
     66} VCPPROGRESS, *LPVCPPROGRESS;
     67
     68typedef struct {
     69        WORD            cbSize;
     70        LOGDISKID16     ldid;
     71        VHSTR           vhstrRoot;
     72        VHSTR           vhstrVolumeLabel;
     73        VHSTR           vhstrDiskName;
     74        WORD            wVolumeTime;
     75        WORD            wVolumeDate;
     76        DWORD           dwSerialNumber;
     77        WORD            fl;
     78        LPARAM          lparamRef;
     79
     80        VCPPROGRESS     prgFileRead;
     81        VCPPROGRESS     prgByteRead;
     82
     83        VCPPROGRESS     prgFileWrite;
     84        VCPPROGRESS     prgByteWrite;
     85} VCPDISKINFO, *LPVCPDISKINFO; 
     86
     87typedef struct {
     88        LOGDISKID16     ldid;
     89        VHSTR           vhstrDir;
     90        VHSTR           vhstrFileName;
     91} VCPFILESPEC, *LPVCPFILESPEC;
     92
     93typedef struct {
     94        UINT16          uiMDate;
     95        UINT16          uiMTime;
     96        UINT16          uiADate;
     97        UINT16          uiATime;
     98        UINT16          uiAttr;
     99        DWORD           llenIn;
     100        DWORD           llenOut;
     101} VCPFATTR, *LPVCPFATTR;
     102
     103typedef struct {
     104        UINT16          uDate;
     105        UINT16          uTime;
     106        DWORD           dwSize;
     107} VCPFILESTAT, *LPVCPFILESTAT;
     108
     109typedef struct
     110{
     111        HFILE16         hFileSrc;
     112        HFILE16         hFileDst;
     113        VCPFATTR        fAttr;
     114        WORD            dosError;
     115        VHSTR           vhstrFileName;
     116        WPARAM          vcpm;
     117} VIRTNODEEX, *LPVIRTNODEEX;
     118
     119typedef struct {
     120        WORD            cbSize;
     121        VCPFILESPEC     vfsSrc;
     122        VCPFILESPEC     vfsDst;
     123        WORD            fl;
     124        LPARAM          lParam;
     125        LPEXPANDVTBL    lpExpandVtbl;
     126        LPVIRTNODEEX    lpvnex;
     127        VHSTR           vhstrDstFinalName;
     128        VCPFILESTAT     vFileStat;
     129} VIRTNODE, *LPVIRTNODE;
     130
     131typedef struct {
     132        WORD            cbSize;
     133        VCPPROGRESS     prgDiskRead;
     134        VCPPROGRESS     prgFileRead;
     135        VCPPROGRESS     prgByteRead;
     136
     137        VCPPROGRESS     prgDiskWrite;
     138        VCPPROGRESS     prgFileWrite;
     139        VCPPROGRESS     prgByteWrite;
     140
     141        LPVCPDISKINFO   lpvdiIn;
     142        LPVCPDISKINFO   lpvdiOut;
     143        LPVIRTNODE      lpvn;
     144} VCPSTATUS, *LPVCPSTATUS;
     145
     146#define CNFL_BACKUP             0x0001
     147#define CNFL_DELETEONFAILURE    0x0002
     148#define CNFL_RENAMEONSUCCESS    0x0004
     149#define CNFL_CONTINUATION       0x0008
     150#define CNFL_SKIPPED            0x0010
     151#define CNFL_IGNOREERRORS       0x0020
     152#define CNFL_RETRYFILE          0x0040
     153#define CNFL_COPIED             0x0080
     154#define VNFL_UNIQUE             0x0000
     155#define VNFL_MULTIPLEOK         0x0100
     156#define VNFL_DESTROYOLD         0x0200
     157#define VNFL_COPY               0x0000
     158#define VNFL_DELETE             0x0800
     159#define VNFL_RENAME             0x1000
     160#define VNFL_NODE_TYPE          (VNFL_RENAME|VNFL_DELETE|VNFL_COPY)
     161#define VNFL_CREATED            0x2000
     162#define VNFL_REJECTED           0x4000
     163#define VNFL_DEVICEINSTALLER    0x8000
     164
     165enum {
    41166        ERR_VCP_IOFAIL = VCP_ERROR+1,
    42167        ERR_VCP_STRINGTOOLONG,
     
    65190        ERR_VCP_NO_DIGITAL_SIGNATURE_FILE
    66191};
     192
     193#define VCPN_OK         0
     194#define VCPN_PROCEED    0
     195#define VCPN_ABORT      -1
     196#define VCPN_RETRY      -2
     197#define VCPN_IGNORE     -3
     198#define VCPN_SKIP       -4
     199#define VCPN_FORCE      -5
     200#define VCPN_DEFER      -6
     201#define VCPN_FAIL       -7
     202#define VCPN_RETRYFILE  -8
     203
     204#define VCPFL_ABANDON           0x00
     205#define VCPFL_BACKUP            0x01
     206#define VCPFL_COPY              0x02
     207#define VCPFL_BACKUPANDCOPY     (VCPFL_BACKUP|VCPFL_COPY)
     208#define VCPFL_INSPECIFIEDORDER  0x04
     209#define VCPFL_DELETE            0x08
     210#define VCPFL_RENAME            0x10
     211#define VCPFL_ALL               (VCPFL_COPY|VCPFL_DELETE|VCPFL_RENAME)
     212
     213#define CFNL_BACKUP             0x0001
     214#define CFNL_DELETEONFAILURE    0x0002
     215#define CFNL_RENAMEONSUCCESS    0x0004
     216#define CFNL_CONTINUATION       0x0008
     217#define CFNL_SKIPPED            0x0010
     218#define CFNL_IGNOREERRORS       0x0020
     219#define CFNL_RETRYFILE          0x0040
     220#define CFNL_COPIED             0x0080
     221#define VFNL_MULTIPLEOK         0x0100
     222#define VFNL_DESTROYOLD         0x0200
     223#define VFNL_NOW                0x0400
     224#define VFNL_COPY               0x0000
     225#define VFNL_DELETE             0x0800
     226#define VFNL_RENAME             0x1000
     227#define VFNL_CREATED            0x2000
     228#define VFNL_REJECTED           0x4000
     229#define VCPM_DISKCLASS          0x01
     230#define VCPM_DISKFIRST          0x0100
     231#define VCPM_DISKLAST           0x01ff
     232
     233enum {
     234        VCPM_DISKCREATEINFO = VCPM_DISKFIRST,
     235        VCPM_DISKGETINFO,
     236        VCPM_DISKDESTROYINFO,
     237        VCPM_DISKPREPINFO,
     238        VCPM_DISKENSURE,
     239        VCPM_DISKPROMPT,
     240        VCPM_DISKFORMATBEGIN,
     241        VCPM_DISKFORMATTING,
     242        VCPM_DISKFORMATEND
     243};
     244
     245#define VCPM_FILEINCLASS        0x02
     246#define VCPM_FILEOUTCLASS       0x03
     247#define VCPM_FILEFIRSTIN        0x0200
     248#define VCPM_FILEFIRSTOUT       0x0300
     249#define VCPM_FILELAST           0x03ff
     250
     251enum {
     252        VCPM_FILEOPENIN = VCPM_FILEFIRSTIN,
     253        VCPM_FILEGETFATTR,
     254        VCPM_FILECLOSEIN,
     255        VCPM_FILECOPY,
     256        VCPM_FILENEEDED,
     257
     258        VCPM_FILEOPENOUT = VCPM_FILEFIRSTOUT,
     259        VCPM_FILESETFATTR,
     260        VCPM_FILECLOSEOUT,
     261        VCPM_FILEFINALIZE,
     262        VCPM_FILEDELETE,
     263        VCPM_FILERENAME
     264};
     265
     266#define VCPM_NODECLASS          0x04
     267#define VCPM_NODEFIRST          0x0400
     268#define VCPM_NODELAST           0x04ff
     269
     270enum {
     271        VCPM_NODECREATE = VCPM_NODEFIRST,
     272        VCPM_NODEACCEPT,
     273        VCPM_NODEREJECT,
     274        VCPM_NODEDESTROY,
     275        VCPM_NODECHANGEDESTDIR,
     276        VCPM_NODECOMPARE
     277};
     278
     279#define VCPM_TALLYCLASS         0x05
     280#define VCPM_TALLYFIRST         0x0500
     281#define VCPM_TALLYLAST          0x05ff
     282
     283enum {
     284        VCPM_TALLYSTART = VCPM_TALLYFIRST,
     285        VCPM_TALLYEND,
     286        VCPM_TALLYFILE,
     287        VCPM_TALLYDISK
     288};
     289
     290#define VCPM_VERCLASS           0x06
     291#define VCPM_VERFIRST           0x0600
     292#define VCPM_VERLAST            0x06ff
     293
     294enum {
     295        VCPM_VERCHECK = VCPM_VERFIRST,
     296        VCPM_VERCHECKDONE,
     297        VCPM_VERRESOLVECONFLICT
     298};
     299
     300#define VCPM_VSTATCLASS         0x07
     301#define VCPM_VSTATFIRST         0x0700
     302#define VCPM_VSTATLAST          0x07ff
     303
     304enum {
     305        VCPM_VSTATSTART = VCPM_VSTATFIRST,
     306        VCPM_VSTATEND,
     307        VCPM_VSTATREAD,
     308        VCPM_VSTATWRITE,
     309        VCPM_VSTATNEWDISK,
     310        VCPM_VSTATCLOSESTART,
     311        VCPM_VSTATCLOSEEND,
     312        VCPM_VSTATBACKUPSTART,
     313        VCPM_VSTATBACKUPEND,
     314        VCPM_VSTATRENAMESTART,
     315        VCPM_VSTATRENAMEEND,
     316        VCPM_VSTATCOPYSTART,
     317        VCPM_VSTATCOPYEND,
     318        VCPM_VSTATDELETESTART,
     319        VCPM_VSTATDELETEEND,
     320        VCPM_VSTATPATHCHECKSTART,
     321        VCPM_VSTATPATHCHECKEND,
     322        VCPM_VSTATCERTIFYSTART,
     323        VCPM_VSTATCERTIFYEND,
     324        VCPM_VSTATUSERABORT,
     325        VCPM_VSTATYIELD
     326};
     327
     328#define VCPM_PATHCLASS          0x08
     329#define VCPM_PATHFIRST          0x0800
     330#define VCPM_PATHLAST           0x08ff
     331
     332enum {
     333        VCPM_BUILDPATH = VCPM_PATHFIRST,
     334        VCPM_UNIQUEPATH,
     335        VCPM_CHECKPATH
     336};
     337
     338#define VCPM_PATCHCLASS         0x09
     339#define VCPM_PATCHFIRST         0x0900
     340#define VCPM_PATCHLAST          0x09ff
     341
     342enum {
     343        VCPM_FILEPATCHBEFORECPY = VCPM_PATCHFIRST,
     344        VCPM_FILEPATCHAFTERCPY,
     345        VCPM_FILEPATCHINFOPEN,
     346        VCPM_FILEPATCHINFCLOSE
     347};
     348
     349#define VCPM_CERTCLASS          0x0a
     350#define VCPM_CERTFIRST          0x0a00
     351#define VCPM_CERTLAST           0x0aff
     352
     353enum {
     354        VCPM_FILECERTIFY = VCPM_CERTFIRST,
     355        VCPM_FILECERTIFYWARN
     356};
     357
     358#ifdef __WIN32OS2__
     359typedef LRESULT (* CALLBACK VIFPROC)(LPVOID lpvObj, UINT16 uMsg, WPARAM wParam, LPARAM lParam, LPARAM lparamRef);
     360typedef int (* CALLBACK VCPENUMPROC)(LPVIRTNODE lpvn, LPARAM lparamRef);
     361#else
     362typedef LRESULT (CALLBACK *VIFPROC)(LPVOID lpvObj, UINT16 uMsg, WPARAM wParam, LPARAM lParam, LPARAM lparamRef);
     363typedef int (CALLBACK *VCPENUMPROC)(LPVIRTNODE lpvn, LPARAM lparamRef);
     364#endif
     365
     366RETERR16 WINAPI VcpOpen16(VIFPROC vifproc, LPARAM lparamMsgRef);
     367RETERR16 WINAPI VcpQueueCopy16(
     368        LPCSTR lpszSrcFileName, LPCSTR lpszDstFileName,
     369        LPCSTR lpszSrcDir, LPCSTR lpszDstDir,
     370        LOGDISKID16 ldidSrc, LOGDISKID16 ldidDst,
     371        LPEXPANDVTBL lpExpandVtbl,
     372        WORD fl, LPARAM lParam
     373);
     374RETERR16 VcpFlush16(WORD fl, LPCSTR lpszBackupDest);
     375RETERR16 WINAPI VcpClose16(WORD fl, LPCSTR lpszBackupDest);
     376
     377/* VcpExplain flags */
     378enum {
     379        VCPEX_SRC_DISK,
     380        VCPEX_SRC_CABINET,
     381        VCPEX_SRC_LOCN,
     382        VCPEX_DST_LOCN,
     383        VCPEX_SRC_FILE,
     384        VCPEX_DST_FILE,
     385        VCPEX_DST_FILE_FINAL,
     386        VCPEX_DOS_ERROR,
     387        VCPEX_MESSAGE,
     388        VCPEX_DOS_SOLUTION,
     389        VCPEX_SRC_FULL,
     390        VCPEX_DST_FULL,
     391        VCPEX_DST_FULL_FINAL
     392};
     393
     394LPCSTR WINAPI VcpExplain16(LPVIRTNODE lpVn, DWORD dwWhat);
    67395
    68396/****** logical disk management ******/
     
    199527
    200528
    201 typedef LRESULT (CALLBACK *VIFPROC)(LPVOID lpvObj, UINT uMsg, WPARAM wParam, LPARAM lParam, LPARAM lparamRef);
    202 
    203529extern void WINAPI GenFormStrWithoutPlaceHolders16(LPSTR,LPCSTR,HINF16);
    204530extern RETERR16 WINAPI IpOpen16(LPCSTR,HINF16 *);
     
    209535extern RETERR16 WINAPI CtlAddLdd16(LPLOGDISKDESC);
    210536extern RETERR16 WINAPI CtlDelLdd16(LOGDISKID16);
     537extern RETERR16 WINAPI CtlGetLddPath16(LOGDISKID16 ldid, LPSTR szPath);
    211538extern RETERR16 WINAPI GenInstall16(HINF16,LPCSTR,WORD);
    212539
  • trunk/src/setupapi/setupx_main.c

    r6712 r8421  
    33 *
    44 *      Copyright 1998,2000  Andreas Mohr
     5 *
     6 * This library is free software; you can redistribute it and/or
     7 * modify it under the terms of the GNU Lesser General Public
     8 * License as published by the Free Software Foundation; either
     9 * version 2.1 of the License, or (at your option) any later version.
     10 *
     11 * This library is distributed in the hope that it will be useful,
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14 * Lesser General Public License for more details.
     15 *
     16 * You should have received a copy of the GNU Lesser General Public
     17 * License along with this library; if not, write to the Free Software
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    519 *
    620 * FIXME: Rather non-functional functions for now.
     
    3044 * Ip   .INF parsing (infparse.c)
    3145 * LDD  logical device descriptor (ldd.c ?)
    32  * LDID logical device ID 
     46 * LDID logical device ID
    3347 * SU   setup (setup.c ?)
    3448 * Tp   text processing (textproc.c ?)
     
    4458#include <stdlib.h>
    4559#include <stdio.h>
     60#include <string.h>
    4661#include "winreg.h"
     62#include "winerror.h"
    4763#include "wine/winuser16.h"
     64#include "setupapi.h"
    4865#include "setupx16.h"
    49 #include "setupx_private.h"
     66#include "setupapi_private.h"
    5067#include "winerror.h"
    51 #include "heap.h"
    52 #include "debugtools.h"
    53 
    54 DEFAULT_DEBUG_CHANNEL(setupx);
    55 
    56 /***********************************************************************
    57  *              SURegOpenKey
     68#include "wine/debug.h"
     69
     70WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
     71
     72/***********************************************************************
     73 *              SURegOpenKey (SETUPX.47)
    5874 */
    5975DWORD WINAPI SURegOpenKey( HKEY hkey, LPCSTR lpszSubKey, LPHKEY retkey )
     
    6480
    6581/***********************************************************************
    66  *              SURegQueryValueEx
     82 *              SURegQueryValueEx (SETUPX.50)
    6783 */
    6884DWORD WINAPI SURegQueryValueEx( HKEY hkey, LPSTR lpszValueName,
     
    123139        p = q+1;
    124140    }
    125    
     141
    126142    /* put number of entries at beginning of list */
    127143    *(DWORD *)res = count;
     
    141157}
    142158
    143 static void SETUPX_IsolateSubString(LPSTR *begin, LPSTR *end)
    144 {
    145     LPSTR p, q;
    146 
    147     p = *begin;
    148     q = *end;
    149 
    150     while ((p < q) && ((*p == ' ') || (*p == '\t'))) p++;
    151     while ((p < q) && (*p == '"')) p++;
    152 
    153     while ((q-1 >= p) && ((*(q-1) == ' ') || (*(q-1) == '\t'))) q--;
    154     while ((q-1 >= p) && (*(q-1) == '"')) q--;
    155 
    156     *begin = p;
    157     *end = q;
    158 }
    159 
    160 /*
    161  * Example: HKLM,"Software\Microsoft\Windows\CurrentVersion","ProgramFilesDir",,"C:\"
    162  * FIXME: use SETUPX_GetSubStrings() instead.
    163  *        Hmm, but on the other hand SETUPX_GetSubStrings() will probably
    164  *        soon be replaced by InitSubstrData() etc. anyway.
    165  *
    166  */
    167 static BOOL SETUPX_LookupRegistryString(LPSTR regstr, LPSTR buffer, DWORD buflen)
    168 {
    169     HANDLE heap = GetProcessHeap();
    170     LPSTR items[5];
    171     LPSTR p, q, next;
    172     int len, n;
    173     HKEY hkey, hsubkey;
    174     DWORD dwType;
    175 
    176     TRACE("retrieving '%s'\n", regstr);
    177 
    178     p = regstr;
    179 
    180     /* isolate root key, subkey, value, flag, defval */
    181     for (n=0; n < 5; n++)
    182     {
    183         q = strchr(p, ',');
    184         if (!q)
    185         {
    186             if (n == 4)
    187                 q = p+strlen(p);
    188             else
    189                 return FALSE;
    190         }
    191         next = q+1;
    192         if (q < regstr)
    193             return FALSE;
    194         SETUPX_IsolateSubString(&p, &q);
    195         len = (int)q - (int)p;
    196         items[n] = HeapAlloc(heap, 0, len+1);
    197         strncpy(items[n], p, len);
    198         items[n][len] = '\0';
    199         p = next;
    200     }
    201     TRACE("got '%s','%s','%s','%s','%s'\n",
    202                         items[0], items[1], items[2], items[3], items[4]);
    203    
    204     /* check root key */
    205     if (!strcasecmp(items[0], "HKCR"))
    206         hkey = HKEY_CLASSES_ROOT;
    207     else
    208     if (!strcasecmp(items[0], "HKCU"))
    209         hkey = HKEY_CURRENT_USER;
    210     else
    211     if (!strcasecmp(items[0], "HKLM"))
    212         hkey = HKEY_LOCAL_MACHINE;
    213     else
    214     if (!strcasecmp(items[0], "HKU"))
    215         hkey = HKEY_USERS;
    216     else
    217     { /* HKR ? -> relative to key passed to GenInstallEx */
    218         FIXME("unsupported regkey '%s'\n", items[0]);
    219         goto regfailed;
    220     }
    221 
    222     if (RegOpenKeyA(hkey, items[1], &hsubkey) != ERROR_SUCCESS)
    223         goto regfailed;
    224 
    225     if (RegQueryValueExA(hsubkey, items[2], NULL, &dwType, buffer, &buflen)
    226                 != ERROR_SUCCESS)
    227         goto regfailed;
    228     goto done;
    229 
    230 regfailed:
    231     if (buffer) strcpy(buffer, items[4]); /* I don't care about buflen */
    232 done:
    233     for (n=0; n < 5; n++)
    234         HeapFree(heap, 0, items[n]);
    235     if (buffer)
    236         TRACE("return '%s'\n", buffer);
    237     return TRUE;
    238 }
    239 
    240 static LPSTR SETUPX_GetSections(LPCSTR filename)
    241 {
    242     LPSTR buf = NULL;
    243     DWORD len = 1024, res;
    244 
    245     do {
    246         buf = HeapReAlloc(GetProcessHeap(), 0, buf, len);
    247         res = GetPrivateProfileStringA(NULL, NULL, NULL, buf, len, filename);
    248         len *= 2;
    249     } while ((!res) && (len < 1048576));
    250     if (!res)
    251     {
    252         HeapFree(GetProcessHeap(), 0, buf);
    253         return NULL;
    254     }
    255     return buf;
    256 }
    257 
    258 static LPSTR SETUPX_GetSectionEntries(LPCSTR filename, LPCSTR section)
    259 {
    260     LPSTR buf = NULL;
    261     DWORD len = 1024, res;
    262 
    263     do {
    264         buf = HeapReAlloc(GetProcessHeap(), 0, buf, len);
    265         res = GetPrivateProfileSectionA(section, buf, len, filename);
    266         len *= 2;
    267     } while ((!res) && (len < 1048576));
    268     if (!res)
    269     {
    270         HeapFree(GetProcessHeap(), 0, buf);
    271         return NULL;
    272     }
    273     return buf;
    274 }
    275 
    276 
    277 /***********************************************************************
    278  *              InstallHinfSection
     159
     160/***********************************************************************
     161 *              InstallHinfSection (SETUPX.527)
    279162 *
    280163 * hwnd = parent window
     
    283166 * Here "DefaultInstall" is the .inf file section to be installed (optional).
    284167 * The 132 value is made of the HOW_xxx flags and sometimes 128 (-> setupx16.h).
    285  * 
     168 *
    286169 * nCmdShow = nCmdShow of CreateProcess
    287170 */
    288 typedef INT WINAPI (*MSGBOX_PROC)( HWND, LPCSTR, LPCSTR, UINT );
    289171RETERR16 WINAPI InstallHinfSection16( HWND16 hwnd, HINSTANCE16 hinst, LPCSTR lpszCmdLine, INT16 nCmdShow)
    290172{
     
    292174    DWORD count;
    293175    HINF16 hInf = 0;
    294     RETERR16 res = OK;
     176    RETERR16 res = OK, tmp;
    295177    WORD wFlags;
    296178    BOOL reboot = FALSE;
    297     HMODULE hMod;
    298     MSGBOX_PROC pMessageBoxA;
    299    
     179
    300180    TRACE("(%04x, %04x, %s, %d);\n", hwnd, hinst, lpszCmdLine, nCmdShow);
    301    
     181
    302182    pSub = SETUPX_GetSubStrings((LPSTR)lpszCmdLine, ' ');
    303183
     
    310190        goto end;
    311191    }
     192    if (VcpOpen16(NULL, 0))
     193        goto end;
    312194    if (GenInstall16(hInf, *(pSub+count-2), GENINSTALL_DO_ALL) != OK)
    313195        goto end;
     
    321203        case HOW_ALWAYS_PROMPT_REBOOT:
    322204        case HOW_PROMPT_REBOOT:
    323             if ((hMod = GetModuleHandleA("user32.dll")))
    324             {
    325               if ((pMessageBoxA = (MSGBOX_PROC)GetProcAddress( hMod, "MessageBoxA" )))
    326               {
    327                  
    328                 if (pMessageBoxA(hwnd, "You must restart Wine before the new settings will take effect.\n\nDo you want to exit Wine now ?", "Systems Settings Change", MB_YESNO|MB_ICONQUESTION) == IDYES)
    329                   reboot = TRUE;
    330               }
    331             }
     205            if (MessageBoxA(hwnd, "You must restart Wine before the new settings will take effect.\n\nDo you want to exit Wine now ?", "Systems Settings Change", MB_YESNO|MB_ICONQUESTION) == IDYES)
     206                reboot = TRUE;
    332207            break;
    333208        default:
     
    335210            goto end;
    336211    }
    337    
     212
    338213    res = OK;
    339214end:
    340     IpClose16(hInf);
     215    tmp = VcpClose16(VCPFL_ALL, NULL);
     216    if (tmp != OK)
     217        res = tmp;
     218    tmp = IpClose16(hInf);
     219    if (tmp != OK)
     220        res = tmp;
    341221    SETUPX_FreeSubStrings(pSub);
    342222    if (reboot)
     
    497377};
    498378
    499 /* 
     379/*
    500380 * LDD  == Logical Device Descriptor
    501381 * LDID == Logical Device ID
    502382 *
    503383 * The whole LDD/LDID business might go into a separate file named
    504  * ldd.c or logdevice.c.
     384 * ldd.c.
    505385 * At the moment I don't know what the hell these functions are really doing.
    506386 * That's why I added reporting stubs.
     
    575455    if (hKey) RegCloseKey(hKey);
    576456}
    577        
     457
    578458/***********************************************************************
    579459 * CtlDelLdd            (SETUPX.37)
     
    613493        pFirstLDD = NULL;
    614494    HeapFree(GetProcessHeap(), 0, pCurr);
    615    
     495
    616496    return OK;
    617497}
     
    634514 *   ERR_VCP_LDDINVALID if pldd->cbSize != structsize
    635515 *   1 in all other cases ??
    636  * 
     516 *
    637517 */
    638518RETERR16 WINAPI CtlFindLdd16(LPLOGDISKDESC pldd)
     
    641521
    642522    TRACE("(%p)\n", pldd);
    643    
     523
    644524    if (!std_LDDs_done)
    645525        SETUPX_CreateStandardLDDs();
     
    661541    memcpy(pldd, pCurr->pldd, pldd->cbSize);
    662542    /* hmm, we probably ought to strcpy() the string ptrs here */
    663    
     543
    664544    return 1; /* what is this ?? */
    665545}
     
    697577         pCurr = pCurr->next;
    698578    }
    699     if (pCurr == NULL) /* hit end of list */
     579    if (!pCurr || pldd->ldid != pCurr->pldd->ldid)
    700580    {
    701581        is_new = TRUE;
     
    716596
    717597    if (pldd->pszPath)
    718         pCurrLDD->pszPath       = HEAP_strdupA(heap, 0, pldd->pszPath);
     598    {
     599        pCurrLDD->pszPath = HeapAlloc( heap, 0, strlen(pldd->pszPath)+1 );
     600        strcpy( pCurrLDD->pszPath, pldd->pszPath );
     601    }
    719602    if (pldd->pszVolLabel)
    720         pCurrLDD->pszVolLabel   = HEAP_strdupA(heap, 0, pldd->pszVolLabel);
     603    {
     604        pCurrLDD->pszVolLabel = HeapAlloc( heap, 0, strlen(pldd->pszVolLabel)+1 );
     605        strcpy( pCurrLDD->pszVolLabel, pldd->pszVolLabel );
     606    }
    721607    if (pldd->pszDiskName)
    722         pCurrLDD->pszDiskName   = HEAP_strdupA(heap, 0, pldd->pszDiskName);
     608    {
     609        pCurrLDD->pszDiskName = HeapAlloc( heap, 0, strlen(pldd->pszDiskName)+1 );
     610        strcpy( pCurrLDD->pszDiskName, pldd->pszDiskName );
     611    }
    723612
    724613    if (is_new) /* link into list */
     
    732621            pFirstLDD = pCurr;
    733622    }
    734    
     623
    735624    return OK;
    736625}
     
    758647 * RETURN
    759648 *   ERR_VCP_LDDINVALID if pldd->cbSize != structsize
    760  * 
     649 *
    761650 */
    762651static RETERR16 SETUPX_GetLdd(LPLOGDISKDESC pldd)
     
    830719    LOGDISKDESC_S ldd;
    831720    TRACE("(%d, '%s');\n", ldid, szPath);
    832    
     721
     722    SetupSetDirectoryIdA( 0, ldid, szPath );
    833723    INIT_LDD(ldd, ldid);
    834724    ldd.pszPath = szPath;
    835725    return CtlSetLdd16(&ldd);
    836726}
    837 
    838 /*
    839  * Find the value of a custom LDID in a .inf file
    840  * e.g. for 49301:
    841  * 49300,49301=ProgramFilesDir,5
    842  * -- profile section lookup -->
    843  * [ProgramFilesDir]
    844  * HKLM,"Software\Microsoft\Windows\CurrentVersion","ProgramFilesDir",,"%24%"
    845  * -- GenFormStrWithoutPlaceHolders16 -->
    846  * HKLM,"Software\Microsoft\Windows\CurrentVersion","ProgramFilesDir",,"C:\"
    847  * -- registry lookup -->
    848  * C:\Program Files (or C:\ if not found in registry)
    849  *
    850  * FIXME:
    851  * - maybe we ought to add a caching array for speed ? - I don't care :)
    852  * - not sure whether the processing is correct - sometimes there are equal
    853  *   LDIDs for both install and removal sections.
    854  * - probably the whole function can be removed as installers add that on their
    855  *   own
    856  */
    857 static BOOL SETUPX_AddCustomLDID(int ldid, INT16 hInf)
    858 {
    859     char ldidstr[6];
    860     LPSTR sectionbuf = NULL, entrybuf = NULL, regsectionbuf = NULL;
    861     LPCSTR filename;
    862     LPSTR pSec, pEnt, pEqual, p, *pSub = NULL;
    863     BOOL ret = FALSE;
    864     char buffer[MAX_PATH];
    865     LOGDISKDESC_S ldd;
    866 
    867     sprintf(ldidstr, "%d", ldid);
    868     filename = IP_GetFileName(hInf);
    869     if (!(sectionbuf = SETUPX_GetSections(filename)))
    870     {
    871         ERR("couldn't get sections !\n");
    872         return FALSE;
    873     }
    874     for (pSec=sectionbuf; *pSec; pSec += strlen(pSec)+1)
    875     {
    876         if (!(entrybuf = SETUPX_GetSectionEntries(filename, pSec)))
    877         {
    878             ERR("couldn't get section entries !\n");
    879             goto end;
    880         }
    881         for (pEnt=entrybuf; *pEnt; pEnt += strlen(pEnt)+1)
    882         {
    883             if (strstr(pEnt, ldidstr))
    884             {
    885                 pEqual = strchr(pEnt, '=');
    886                 if (!pEqual) /* crippled entry ?? */
    887                     continue;
    888 
    889                 /* make sure we found the LDID on left side of the equation */
    890                 if (pEnt+strlen(ldidstr) <= pEqual)
    891                 { /* found */
    892 
    893                     /* but we don't want entries in the strings section */
    894                     if (!strcasecmp(pSec, "Strings"))
    895                         goto next_section;
    896                     p = pEqual+1;
    897                     goto found;
    898                 }
    899             }
    900         }
    901 next_section:
    902     }
    903     goto end;
    904 found:
    905     TRACE("found entry '%s'\n", p);
    906     pSub = SETUPX_GetSubStrings(p, ',');
    907     if (*(DWORD *)pSub > 2)
    908     {
    909         ERR("malformed entry '%s' ?\n", p);
    910         goto end;
    911     }
    912     TRACE("found section '%s'\n", *(pSub+1));
    913     /* FIXME: what are the optional flags at the end of an entry used for ?? */
    914 
    915     /* get the location of the registry key from that section */
    916     if (!(regsectionbuf = SETUPX_GetSectionEntries(filename, *(pSub+1))))
    917     {
    918         ERR("couldn't get registry section entries !\n");
    919         goto end;
    920     }
    921     /* sectionbuf is > 1024 bytes anyway, so use it */
    922     GenFormStrWithoutPlaceHolders16(sectionbuf, regsectionbuf, hInf);
    923     ret = SETUPX_LookupRegistryString(sectionbuf, buffer, MAX_PATH);
    924     TRACE("return '%s'\n", buffer);
    925     INIT_LDD(ldd, ldid);
    926     ldd.pszPath = buffer;
    927     CtlSetLdd16(&ldd);
    928 end:
    929     SETUPX_FreeSubStrings(pSub);
    930     if (sectionbuf)     HeapFree(GetProcessHeap(), 0, sectionbuf);
    931     if (entrybuf)       HeapFree(GetProcessHeap(), 0, entrybuf);
    932     if (regsectionbuf)  HeapFree(GetProcessHeap(), 0, regsectionbuf);
    933     return ret;
    934 }
    935 
    936 /*
    937  * Translate a logical disk identifier (LDID) into its string representation
    938  * I'm afraid this can be totally replaced by CtlGetLddPath().
    939  */
    940 static BOOL SETUPX_IP_TranslateLDID(int ldid, LPSTR *p, HINF16 hInf)
    941 {
    942     BOOL handled = FALSE;
    943     LOGDISKDESC_S ldd;
    944 
    945     ldd.cbSize = sizeof(LOGDISKDESC_S);
    946     ldd.ldid = ldid;
    947     if (CtlFindLdd16(&ldd) == ERR_VCP_LDDFIND)
    948     {
    949         /* hmm, it seems the installers already do the work for us
    950          * (by calling CtlSetLddPath) that SETUPX_AddCustomLDID
    951          * is supposed to do. Grmbl ;-)
    952          * Well, I'll leave it here anyway, but print error... */
    953         ERR("hmm, LDID %d not registered yet !?\n", ldid);
    954         handled = SETUPX_AddCustomLDID(ldid, hInf);
    955     }
    956     else
    957         handled = TRUE;
    958    
    959     SETUPX_GetLdd(&ldd);
    960    
    961     if (!handled)
    962     {
    963         FIXME("What is LDID %d ??\n", ldid);
    964         *p = "LDID_FIXME";
    965     }
    966     else
    967         *p = ldd.pszPath;
    968 
    969     return handled;
    970 }
    971 
    972 /***********************************************************************
    973  *              GenFormStrWithoutPlaceHolders
    974  *
    975  * ought to be pretty much implemented, I guess...
    976  */
    977 void WINAPI GenFormStrWithoutPlaceHolders16( LPSTR szDst, LPCSTR szSrc, HINF16 hInf)
    978 {
    979     LPCSTR pSrc = szSrc, pSrcEnd = szSrc + strlen(szSrc);
    980     LPSTR pDst = szDst, p, pPHBegin;
    981     int count;
    982    
    983     TRACE("(%p, '%s', %04x);\n", szDst, szSrc, hInf);
    984     while (pSrc < pSrcEnd)
    985     {
    986         p = strchr(pSrc, '%');
    987         if (p)
    988         {
    989             count = (int)p - (int)pSrc;
    990             strncpy(pDst, pSrc, count);
    991             pSrc += count;
    992             pDst += count;
    993             pPHBegin = p+1;
    994             p = strchr(pPHBegin, '%');
    995             if (p)
    996             {
    997                 char placeholder[80]; /* that really ought to be enough ;) */
    998                 int ldid;
    999                 BOOL done = TRUE;
    1000                 count = (int)p - (int)pPHBegin;
    1001                 strncpy(placeholder, pPHBegin, count);
    1002                 placeholder[count] = '\0';
    1003                 ldid = atoi(placeholder);
    1004                 if (ldid)
    1005                 {
    1006                     LPSTR p;
    1007                     done = SETUPX_IP_TranslateLDID(ldid, &p, hInf);
    1008                     strcpy(pDst, p);
    1009                     if (done)
    1010                         pDst += strlen(pDst);
    1011                 }
    1012                 else
    1013                 { /* hmm, string placeholder. Need to look up
    1014                      in the [strings] section of the hInf */
    1015                     DWORD ret;
    1016                     char buf[256]; /* long enough ? */
    1017                    
    1018                     ret = GetPrivateProfileStringA("strings", placeholder, "",
    1019                                         buf, 256, IP_GetFileName(hInf));
    1020                     if (ret)
    1021                     {
    1022                         strcpy(pDst, buf);
    1023                         pDst += strlen(buf);
    1024                     }
    1025                     else
    1026                     {
    1027                         ERR("placeholder string '%s' not found !\n", placeholder);
    1028                         done = FALSE;
    1029                     }
    1030                 }
    1031                 if (!done)
    1032                 { /* copy raw placeholder string over */
    1033                     count = (int)p - (int)pPHBegin + 2;
    1034                     strncpy(pDst, pPHBegin-1, count);
    1035                     pDst += count;
    1036                    
    1037                 }
    1038                 pSrc = p+1;
    1039                 continue;
    1040             }
    1041         }
    1042 
    1043         /* copy the remaining source string over */
    1044         strncpy(pDst, pSrc, (int)pSrcEnd - (int)pSrc + 1);
    1045         break;
    1046     }
    1047     TRACE("ret '%s'\n", szDst);
    1048 }
    1049 
    1050 /***********************************************************************
    1051  *              VcpOpen
    1052  *
    1053  * No idea what to do here.
    1054  */
    1055 RETERR16 WINAPI VcpOpen16(VIFPROC vifproc, LPARAM lparamMsgRef)
    1056 {
    1057     FIXME("(%p, %08lx), stub.\n", vifproc, lparamMsgRef);
    1058     return OK;
    1059 }
    1060 
    1061 /***********************************************************************
    1062  *              VcpClose
    1063  *
    1064  * Is fl related to VCPDISKINFO.fl ?
    1065  */
    1066 RETERR16 WINAPI VcpClose16(WORD fl, LPCSTR lpszBackupDest)
    1067 {
    1068     FIXME("(%04x, '%s'), stub.\n", fl, lpszBackupDest);
    1069     return OK;
    1070 }
    1071 
    1072 /*
    1073  * Copy all items in a CopyFiles entry over to the destination
    1074  *
    1075  * - VNLP_xxx is what is given as flags for a .INF CopyFiles section
    1076  */
    1077 static BOOL SETUPX_CopyFiles(LPSTR *pSub, HINF16 hInf)
    1078 {
    1079     BOOL res = FALSE;
    1080     unsigned int n;
    1081     LPCSTR filename = IP_GetFileName(hInf);
    1082     LPSTR pCopyEntry;
    1083     char pDestStr[MAX_PATH];
    1084     LPSTR pSrcDir, pDstDir;
    1085     LPSTR pFileEntries, p;
    1086     WORD ldid;
    1087     LOGDISKDESC_S ldd;
    1088     LPSTR *pSubFile;
    1089     LPSTR pSrcFile, pDstFile;
    1090 
    1091     for (n=0; n < *(DWORD *)pSub; n++)
    1092     {
    1093         pCopyEntry = *(pSub+1+n);
    1094         if (*pCopyEntry == '@')
    1095         {
    1096             ERR("single file not handled yet !\n");
    1097             continue;
    1098         }
    1099 
    1100         /* get source directory for that entry */
    1101         INIT_LDD(ldd, LDID_SRCPATH);
    1102         SETUPX_GetLdd(&ldd);
    1103         pSrcDir = ldd.pszPath;
    1104        
    1105         /* get destination directory for that entry */
    1106         if (!(GetPrivateProfileStringA("DestinationDirs", pCopyEntry, "",
    1107                                         pDestStr, sizeof(pDestStr), filename)))
    1108             continue;
    1109 
    1110         /* translate destination dir if given as LDID */
    1111         ldid = atoi(pDestStr);
    1112         if (ldid)
    1113         {
    1114             if (!(SETUPX_IP_TranslateLDID(ldid, &pDstDir, hInf)))
    1115                 continue;
    1116         }
    1117         else
    1118             pDstDir = pDestStr;
    1119        
    1120         /* now that we have the destination dir, iterate over files to copy */
    1121         pFileEntries = SETUPX_GetSectionEntries(filename, pCopyEntry);
    1122         for (p=pFileEntries; *p; p +=strlen(p)+1)
    1123         {
    1124             pSubFile = SETUPX_GetSubStrings(p, ',');
    1125             pSrcFile = *(pSubFile+1);
    1126             pDstFile = (*(DWORD *)pSubFile > 1) ? *(pSubFile+2) : pSrcFile;
    1127             TRACE("copying file '%s\\%s' to '%s\\%s'\n", pSrcDir, pSrcFile, pDstDir, pDstFile);
    1128             if (*(DWORD *)pSubFile > 2)
    1129             {
    1130                 WORD flag;
    1131                 if ((flag = atoi(*(pSubFile+3)))) /* ah, flag */
    1132                 {
    1133                     if (flag & 0x2c)
    1134                     FIXME("VNLP_xxx flag %d not handled yet.\n", flag);
    1135                 }
    1136                 else
    1137                     FIXME("temp file name '%s' given. Need to register in wininit.ini !\n", *(pSubFile+3)); /* strong guess that this is VcpQueueCopy() */
    1138             }
    1139             SETUPX_FreeSubStrings(pSubFile);
    1140             /* we don't copy ANYTHING yet ! (I'm too lazy and want to verify
    1141              * this first before destroying whole partitions ;-) */
    1142         }
    1143     }
    1144            
    1145     return res;
    1146 }
    1147 
    1148 /***********************************************************************
    1149  *              GenInstall
    1150  *
    1151  * general install function for .INF file sections
    1152  *
    1153  * This is not perfect - patch whenever you can !
    1154  *
    1155  * wFlags == GENINSTALL_DO_xxx
    1156  * e.g. NetMeeting:
    1157  * first call GENINSTALL_DO_REGSRCPATH | GENINSTALL_DO_FILES,
    1158  * second call GENINSTALL_DO_LOGCONFIG | CFGAUTO | INI2REG | REG | INI
    1159  */
    1160 RETERR16 WINAPI GenInstall16(HINF16 hInfFile, LPCSTR szInstallSection, WORD wFlags)
    1161 {
    1162     LPCSTR filename = IP_GetFileName(hInfFile);
    1163     LPSTR pEntries, p, pEnd;
    1164     DWORD len;
    1165     LPSTR *pSub;
    1166 
    1167     FIXME("(%04x, '%s', %04x), semi-stub. Please implement additional operations here !\n", hInfFile, szInstallSection, wFlags);
    1168     pEntries = SETUPX_GetSectionEntries(filename, szInstallSection);
    1169     if (!pEntries)
    1170     {
    1171         ERR("couldn't find entries for section '%s' !\n", szInstallSection);
    1172         return ERR_IP_SECT_NOT_FOUND;
    1173     }
    1174     for (p=pEntries; *p; p +=strlen(p)+1)
    1175     {
    1176         pEnd = strchr(p, '=');
    1177         if (!pEnd) continue;
    1178         pSub = SETUPX_GetSubStrings(pEnd+1, ','); /* split entries after the '=' */
    1179         SETUPX_IsolateSubString(&p, &pEnd);
    1180         len = (int)pEnd - (int)p;
    1181 
    1182         if (wFlags & GENINSTALL_DO_FILES)
    1183         {
    1184             if (!strncasecmp(p, "CopyFiles", len))
    1185             {
    1186                 SETUPX_CopyFiles(pSub, hInfFile);
    1187                 continue;
    1188             }
    1189 #if IMPLEMENT_THAT
    1190             else
    1191             if (!strncasecmp(p, "DelFiles", len))
    1192             {
    1193                 SETUPX_DelFiles(filename, szInstallSection, pSub);
    1194                 continue;
    1195             }
    1196 #endif
    1197         }
    1198         if (wFlags & GENINSTALL_DO_INI)
    1199         {
    1200 #if IMPLEMENT_THAT
    1201             if (!strncasecmp(p, "UpdateInis", len))
    1202             {
    1203                 SETUPX_UpdateInis(filename, szInstallSection, pSub);
    1204                 continue;
    1205             }
    1206 #endif
    1207         }
    1208         if (wFlags & GENINSTALL_DO_REG)
    1209         {
    1210 #if IMPLEMENT_THAT
    1211             /* probably use SUReg*() functions here */
    1212             if (!strncasecmp(p, "AddReg", len))
    1213             {
    1214                 SETUPX_AddReg(filename, szInstallSection, pSub);
    1215                 continue;
    1216             }
    1217             else
    1218             if (!strncasecmp(p, "DelReg", len))
    1219             {
    1220                 SETUPX_DelReg(filename, szInstallSection, pSub);
    1221                 continue;
    1222             }
    1223 #endif
    1224         }
    1225        
    1226         SETUPX_FreeSubStrings(pSub);
    1227     }
    1228     HeapFree(GetProcessHeap(), 0, pEntries);
    1229     return OK;
    1230 }
  • trunk/src/setupapi/stubs.c

    r8226 r8421  
    1 /* -*- tab-width: 8; c-basic-offset: 8 -*- */
    21/*
    32 * SetupAPI stubs
    43 *
     4 * Copyright 2000 James Hatheway
     5 *
     6 * This library is free software; you can redistribute it and/or
     7 * modify it under the terms of the GNU Lesser General Public
     8 * License as published by the Free Software Foundation; either
     9 * version 2.1 of the License, or (at your option) any later version.
     10 *
     11 * This library is distributed in the hope that it will be useful,
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14 * Lesser General Public License for more details.
     15 *
     16 * You should have received a copy of the GNU Lesser General Public
     17 * License along with this library; if not, write to the Free Software
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    519 */
    620
    7 #include "debugtools.h"
     21#include "wine/debug.h"
    822#include "windef.h"
    9 #ifdef __WIN32OS2__
    10 #include "ole2.h"
    11 #endif
    1223#include "setupapi.h"
    1324
    14 DEFAULT_DEBUG_CHANNEL(setupapi);
     25WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
    1526
    1627
    1728/***********************************************************************
    18  *              SetupCloseFileQueue
    19  */
    20 BOOL WINAPI SetupCloseFileQueue(HSPFILEQ QueueHandle)
    21 {
    22         FIXME("not implemented (setupapi.dll) \n");
    23 }
    24 
    25 /***********************************************************************
    26  *              SetupCommitFileQueueA
    27  */
    28 BOOL WINAPI SetupCommitFileQueueA(HWND Owner, HSPFILEQ QueueHandle,
    29                                   PSP_FILE_CALLBACK_A MsgHandler,
    30                                   PVOID Context)
    31 {
    32         FIXME("not implemented (setupapi.dll) \n");
    33         return FALSE;
    34 }
    35 
    36 /***********************************************************************
    37  *              SetupIterateCabinetA
     29 *              SetupIterateCabinetA (SETUPAPI.@)
    3830 */
    3931BOOL WINAPI SetupIterateCabinetA(PCSTR CabinetFile, DWORD Reserved,
     
    4537
    4638/***********************************************************************
    47  *              SetupIterateCabinetW
     39 *              SetupIterateCabinetW (SETUPAPI.@)
    4840 */
    4941BOOL WINAPI SetupIterateCabinetW(PWSTR CabinetFile, DWORD Reserved,
     
    5648
    5749/***********************************************************************
    58  *              SetupGetLineTextA
     50 *              TPWriteProfileString (SETUPX.62)
    5951 */
    60 BOOL WINAPI SetupGetLineTextA (const INFCONTEXT *Context, HINF InfHandle,
    61                         PCSTR Section, PCSTR Key, LPSTR ReturnBuffer,
    62                         DWORD ReturnBufferSize, PDWORD RequiredSize)
     52BOOL WINAPI TPWriteProfileString16( LPCSTR section, LPCSTR entry, LPCSTR string )
    6353{
    64         FIXME("not implemented (setupapi.dll) \n");
    65         return 0;
    66 }
    67 
    68 /***********************************************************************
    69  *              SetupGetStringFieldA
    70  */
    71 BOOL WINAPI SetupGetStringFieldA(const INFCONTEXT *Context, DWORD FieldIndex,
    72                                  LPSTR ReturnBuffer, DWORD ReturnBufferSize,
    73                                  PDWORD RequiredSize)
    74 {
    75         FIXME("not implemented (setupapi.dll) \n");
    76         return 0;
     54    FIXME( "%s %s %s: stub\n", debugstr_a(section), debugstr_a(entry), debugstr_a(string) );
     55    return TRUE;
    7756}
    7857
    7958
    8059/***********************************************************************
    81  *              SetupFindNextLine
     60 *              suErrorToIds  (SETUPX.61)
    8261 */
    83 BOOL WINAPI SetupFindNextLine (const INFCONTEXT *ContextIn, PINFCONTEXT ContextOut)
     62DWORD WINAPI suErrorToIds16( WORD w1, WORD w2 )
    8463{
    85         FIXME("not implemented (setupapi.dll) \n");
    86         return 0;
     64    FIXME( "%x %x: stub\n", w1, w2 );
     65    return 0;
    8766}
    88 
    89 
    90 /***********************************************************************
    91  *              SetupInitDefaultQueueCallback
    92  */
    93 PVOID WINAPI SetupInitDefaultQueueCallback(HWND OwnerWindow)
    94 {
    95         FIXME("not implemented (setupapi.dll) \n");
    96         return 0;
    97 }
    98 
    99 /***********************************************************************
    100  *              SetupInitDefaultQueueCallbackEx
    101  */
    102 PVOID WINAPI SetupInitDefaultQueueCallbackEx(HWND OwnerWindow,
    103                                              HWND AlternativeProgressWindow,
    104                                              UINT ProgressMessage,
    105                                              DWORD res1,
    106                                              PVOID res2)
    107 {
    108         FIXME("not implemented (setupapi.dll) \n");
    109         return 0;
    110 }
    111 
    112 /***********************************************************************
    113  *              SetupCloseInfFile
    114  */
    115 VOID WINAPI SetupCloseInfFile (HINF InfHandle)
    116 {
    117         FIXME("not implemented (setupapi.dll) \n");
    118 }
    119 
    120 
    121 /***********************************************************************
    122  *              SetupDefaultQueueCallbackA
    123  */
    124 UINT WINAPI SetupDefaultQueueCallbackA (PVOID Context, UINT Notification,
    125                                         UINT_PTR Param1, UINT_PTR Param2)
    126 {
    127         FIXME("not implemented (setupapi.dll) \n");
    128         return 0;
    129 }
    130 
    131 
    132 /***********************************************************************
    133  *              SetupFindFirstLineA
    134  */
    135 BOOL WINAPI SetupFindFirstLineA (HINF InfHandle, PCSTR Section, PCSTR Key,
    136                                  PINFCONTEXT Context)
    137 {
    138         FIXME("not implemented (setupapi.dll) \n");
    139         return 0;
    140 }
    141 
    142 /***********************************************************************
    143  *              SetupGetLineByIndexA
    144  */
    145 BOOL WINAPI SetupGetLineByIndexA (HINF InfHandle, PCSTR Section, DWORD Index,
    146                                  PINFCONTEXT Context)
    147 {
    148         FIXME("not implemented (setupapi.dll) \n");
    149         return FALSE;
    150 }
    151 
    152 
    153 /***********************************************************************
    154  *              SetupInstallFromInfSectionA
    155  */
    156 BOOL WINAPI SetupInstallFromInfSectionA (HWND Owner, HINF InfHandle, PCSTR SectionName,
    157                                          UINT Flags, HKEY RelativeKeyRoot, PCSTR SourceRootPath,
    158                                          UINT CopyFlags, PSP_FILE_CALLBACK_A MsgHandler,
    159                                          PVOID Context, HDEVINFO DeviceInfoSet,
    160                                          PSP_DEVINFO_DATA DeviceInfoData)
    161 {
    162         FIXME("not implemented (setupapi.dll) \n");
    163         return 0;
    164 }
    165 
    166 /***********************************************************************
    167  *              SetupOpenAppendInfFileA
    168  */
    169 BOOL WINAPI SetupOpenAppendInfFileA (PCSTR FileName, HINF InfHandle,
    170                                     PUINT ErrorLine)
    171 {
    172         FIXME("not implemented (setupapi.dll) \n");
    173         return FALSE;
    174 }
    175 
    176 /***********************************************************************
    177  *              SetupOpenFileQueue
    178  */
    179 HSPFILEQ WINAPI SetupOpenFileQueue (VOID)
    180 {
    181         FIXME("not implemented (setupapi.dll) \n");
    182         return (HSPFILEQ) INVALID_HANDLE_VALUE;
    183 }
    184 
    185 /***********************************************************************
    186  *              SetupOpenInfFileA
    187  */
    188 HINF WINAPI SetupOpenInfFileA (PCSTR FileName, PCSTR InfClass, DWORD InfStyle,
    189                                PUINT ErrorLine)
    190 {
    191         FIXME("not implemented (setupapi.dll) \n");
    192         return 0;
    193 }
    194 
    195 /***********************************************************************
    196  *              SetupQueueCopyA
    197  */
    198 BOOL WINAPI SetupQueueCopyA (HSPFILEQ QueueHandle, PCSTR SourceRootPath, PCSTR SourcePath,
    199                              PCSTR SourceFileName, PCSTR SourceDescription, PCSTR SourceTagFile,
    200                              PCSTR TargetDirectory, PCSTR TargetFileName, DWORD CopyStyle)
    201 {
    202         FIXME("not implemented (setupapi.dll) \n");
    203         return FALSE;
    204 }
    205 
    206 /***********************************************************************
    207  *              SetupSetDirectoryIdA
    208  */
    209 BOOL WINAPI SetupSetDirectoryIdA (HINF InfHandle,
    210                                   DWORD Id,
    211                                   PCSTR Directory)
    212 {
    213         FIXME("not implemented (setupapi.dll) \n");
    214         return FALSE;
    215 }
    216 
    217 
    218 /***********************************************************************
    219  *              SetupTermDefaultQueueCallback
    220  */
    221 VOID WINAPI SetupTermDefaultQueueCallback (PVOID Callback)
    222 {
    223         FIXME("not implemented (setupapi.dll) \n");
    224 }
    225 
Note: See TracChangeset for help on using the changeset viewer.