Remember (do not reset) font size and style parameters in the initial
[wine] / dlls / setupapi / install.c
1 /*
2  * Setupapi install routines
3  *
4  * Copyright 2002 Alexandre Julliard 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
19  */
20
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winreg.h"
26 #include "winternl.h"
27 #include "winerror.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winnls.h"
31 #include "setupapi.h"
32 #include "setupapi_private.h"
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
37
38 /* info passed to callback functions dealing with files */
39 struct files_callback_info
40 {
41     HSPFILEQ queue;
42     PCWSTR   src_root;
43     UINT     copy_flags;
44     HINF     layout;
45 };
46
47 /* info passed to callback functions dealing with the registry */
48 struct registry_callback_info
49 {
50     HKEY default_root;
51     BOOL delete;
52 };
53
54 typedef BOOL (*iterate_fields_func)( HINF hinf, PCWSTR field, void *arg );
55
56 /* Unicode constants */
57 static const WCHAR CopyFiles[]  = {'C','o','p','y','F','i','l','e','s',0};
58 static const WCHAR DelFiles[]   = {'D','e','l','F','i','l','e','s',0};
59 static const WCHAR RenFiles[]   = {'R','e','n','F','i','l','e','s',0};
60 static const WCHAR Ini2Reg[]    = {'I','n','i','2','R','e','g',0};
61 static const WCHAR LogConf[]    = {'L','o','g','C','o','n','f',0};
62 static const WCHAR AddReg[]     = {'A','d','d','R','e','g',0};
63 static const WCHAR DelReg[]     = {'D','e','l','R','e','g',0};
64 static const WCHAR UpdateInis[] = {'U','p','d','a','t','e','I','n','i','s',0};
65 static const WCHAR UpdateIniFields[] = {'U','p','d','a','t','e','I','n','i','F','i','e','l','d','s',0};
66
67
68 /***********************************************************************
69  *            get_field_string
70  *
71  * Retrieve the contents of a field, dynamically growing the buffer if necessary.
72  */
73 static WCHAR *get_field_string( INFCONTEXT *context, DWORD index, WCHAR *buffer,
74                                 WCHAR *static_buffer, DWORD *size )
75 {
76     DWORD required;
77
78     if (SetupGetStringFieldW( context, index, buffer, *size, &required )) return buffer;
79     if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
80     {
81         /* now grow the buffer */
82         if (buffer != static_buffer) HeapFree( GetProcessHeap(), 0, buffer );
83         if (!(buffer = HeapAlloc( GetProcessHeap(), 0, required*sizeof(WCHAR) ))) return NULL;
84         *size = required;
85         if (SetupGetStringFieldW( context, index, buffer, *size, &required )) return buffer;
86     }
87     if (buffer != static_buffer) HeapFree( GetProcessHeap(), 0, buffer );
88     return NULL;
89 }
90
91
92 /***********************************************************************
93  *            copy_files_callback
94  *
95  * Called once for each CopyFiles entry in a given section.
96  */
97 static BOOL copy_files_callback( HINF hinf, PCWSTR field, void *arg )
98 {
99     struct files_callback_info *info = arg;
100
101     if (field[0] == '@')  /* special case: copy single file */
102         SetupQueueDefaultCopyW( info->queue, info->layout, info->src_root, NULL, field, info->copy_flags );
103     else
104         SetupQueueCopySectionW( info->queue, info->src_root, info->layout, hinf, field, info->copy_flags );
105     return TRUE;
106 }
107
108
109 /***********************************************************************
110  *            delete_files_callback
111  *
112  * Called once for each DelFiles entry in a given section.
113  */
114 static BOOL delete_files_callback( HINF hinf, PCWSTR field, void *arg )
115 {
116     struct files_callback_info *info = arg;
117     SetupQueueDeleteSectionW( info->queue, hinf, 0, field );
118     return TRUE;
119 }
120
121
122 /***********************************************************************
123  *            rename_files_callback
124  *
125  * Called once for each RenFiles entry in a given section.
126  */
127 static BOOL rename_files_callback( HINF hinf, PCWSTR field, void *arg )
128 {
129     struct files_callback_info *info = arg;
130     SetupQueueRenameSectionW( info->queue, hinf, 0, field );
131     return TRUE;
132 }
133
134
135 /***********************************************************************
136  *            get_root_key
137  *
138  * Retrieve the registry root key from its name.
139  */
140 static HKEY get_root_key( const WCHAR *name, HKEY def_root )
141 {
142     static const WCHAR HKCR[] = {'H','K','C','R',0};
143     static const WCHAR HKCU[] = {'H','K','C','U',0};
144     static const WCHAR HKLM[] = {'H','K','L','M',0};
145     static const WCHAR HKU[]  = {'H','K','U',0};
146     static const WCHAR HKR[]  = {'H','K','R',0};
147
148     if (!strcmpiW( name, HKCR )) return HKEY_CLASSES_ROOT;
149     if (!strcmpiW( name, HKCU )) return HKEY_CURRENT_USER;
150     if (!strcmpiW( name, HKLM )) return HKEY_LOCAL_MACHINE;
151     if (!strcmpiW( name, HKU )) return HKEY_USERS;
152     if (!strcmpiW( name, HKR )) return def_root;
153     return 0;
154 }
155
156
157 /***********************************************************************
158  *            append_multi_sz_value
159  *
160  * Append a multisz string to a multisz registry value.
161  */
162 static void append_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *strings,
163                                    DWORD str_size )
164 {
165     DWORD size, type, total;
166     WCHAR *buffer, *p;
167
168     if (RegQueryValueExW( hkey, value, NULL, &type, NULL, &size )) return;
169     if (type != REG_MULTI_SZ) return;
170
171     if (!(buffer = HeapAlloc( GetProcessHeap(), 0, (size + str_size) * sizeof(WCHAR) ))) return;
172     if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)buffer, &size )) goto done;
173
174     /* compare each string against all the existing ones */
175     total = size;
176     while (*strings)
177     {
178         int len = strlenW(strings) + 1;
179
180         for (p = buffer; *p; p += strlenW(p) + 1)
181             if (!strcmpiW( p, strings )) break;
182
183         if (!*p)  /* not found, need to append it */
184         {
185             memcpy( p, strings, len * sizeof(WCHAR) );
186             p[len] = 0;
187             total += len;
188         }
189         strings += len;
190     }
191     if (total != size)
192     {
193         TRACE( "setting value %s to %s\n", debugstr_w(value), debugstr_w(buffer) );
194         RegSetValueExW( hkey, value, 0, REG_MULTI_SZ, (BYTE *)buffer, total );
195     }
196  done:
197     HeapFree( GetProcessHeap(), 0, buffer );
198 }
199
200
201 /***********************************************************************
202  *            delete_multi_sz_value
203  *
204  * Remove a string from a multisz registry value.
205  */
206 static void delete_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *string )
207 {
208     DWORD size, type;
209     WCHAR *buffer, *src, *dst;
210
211     if (RegQueryValueExW( hkey, value, NULL, &type, NULL, &size )) return;
212     if (type != REG_MULTI_SZ) return;
213     /* allocate double the size, one for value before and one for after */
214     if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size * 2 * sizeof(WCHAR) ))) return;
215     if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)buffer, &size )) goto done;
216     src = buffer;
217     dst = buffer + size;
218     while (*src)
219     {
220         int len = strlenW(src) + 1;
221         if (strcmpiW( src, string ))
222         {
223             memcpy( dst, src, len * sizeof(WCHAR) );
224             dst += len;
225         }
226         src += len;
227     }
228     *dst++ = 0;
229     if (dst != buffer + 2*size)  /* did we remove something? */
230     {
231         TRACE( "setting value %s to %s\n", debugstr_w(value), debugstr_w(buffer + size) );
232         RegSetValueExW( hkey, value, 0, REG_MULTI_SZ,
233                         (BYTE *)(buffer + size), dst - (buffer + size) );
234     }
235  done:
236     HeapFree( GetProcessHeap(), 0, buffer );
237 }
238
239
240 /***********************************************************************
241  *            do_reg_operation
242  *
243  * Perform an add/delete registry operation depending on the flags.
244  */
245 static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context, INT flags )
246 {
247     DWORD type, size;
248
249     if (flags & (FLG_ADDREG_DELREG_BIT | FLG_ADDREG_DELVAL))  /* deletion */
250     {
251         if (*value && !(flags & FLG_DELREG_KEYONLY_COMMON))
252         {
253             if ((flags & FLG_DELREG_MULTI_SZ_DELSTRING) == FLG_DELREG_MULTI_SZ_DELSTRING)
254             {
255                 WCHAR *str;
256
257                 if (!SetupGetStringFieldW( context, 5, NULL, 0, &size ) || !size) return TRUE;
258                 if (!(str = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE;
259                 SetupGetStringFieldW( context, 5, str, size, NULL );
260                 delete_multi_sz_value( hkey, value, str );
261                 HeapFree( GetProcessHeap(), 0, str );
262             }
263             else RegDeleteValueW( hkey, value );
264         }
265         else RegDeleteKeyW( hkey, NULL );
266         return TRUE;
267     }
268
269     if (flags & (FLG_ADDREG_KEYONLY|FLG_ADDREG_KEYONLY_COMMON)) return TRUE;
270
271     if (flags & (FLG_ADDREG_NOCLOBBER|FLG_ADDREG_OVERWRITEONLY))
272     {
273         BOOL exists = !RegQueryValueExW( hkey, value, NULL, NULL, NULL, NULL );
274         if (exists && (flags & FLG_ADDREG_NOCLOBBER)) return TRUE;
275         if (!exists & (flags & FLG_ADDREG_OVERWRITEONLY)) return TRUE;
276     }
277
278     switch(flags & FLG_ADDREG_TYPE_MASK)
279     {
280     case FLG_ADDREG_TYPE_SZ:        type = REG_SZ; break;
281     case FLG_ADDREG_TYPE_MULTI_SZ:  type = REG_MULTI_SZ; break;
282     case FLG_ADDREG_TYPE_EXPAND_SZ: type = REG_EXPAND_SZ; break;
283     case FLG_ADDREG_TYPE_BINARY:    type = REG_BINARY; break;
284     case FLG_ADDREG_TYPE_DWORD:     type = REG_DWORD; break;
285     case FLG_ADDREG_TYPE_NONE:      type = REG_NONE; break;
286     default:                        type = flags >> 16; break;
287     }
288
289     if (!(flags & FLG_ADDREG_BINVALUETYPE) ||
290         (type == REG_DWORD && SetupGetFieldCount(context) == 5))
291     {
292         static const WCHAR empty;
293         WCHAR *str = NULL;
294
295         if (type == REG_MULTI_SZ)
296         {
297             if (!SetupGetMultiSzFieldW( context, 5, NULL, 0, &size )) size = 0;
298             if (size)
299             {
300                 if (!(str = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE;
301                 SetupGetMultiSzFieldW( context, 5, str, size, NULL );
302             }
303             if (flags & FLG_ADDREG_APPEND)
304             {
305                 if (!str) return TRUE;
306                 append_multi_sz_value( hkey, value, str, size );
307                 HeapFree( GetProcessHeap(), 0, str );
308                 return TRUE;
309             }
310             /* else fall through to normal string handling */
311         }
312         else
313         {
314             if (!SetupGetStringFieldW( context, 5, NULL, 0, &size )) size = 0;
315             if (size)
316             {
317                 if (!(str = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE;
318                 SetupGetStringFieldW( context, 5, str, size, NULL );
319             }
320         }
321
322         if (type == REG_DWORD)
323         {
324             DWORD dw = str ? strtoulW( str, NULL, 16 ) : 0;
325             TRACE( "setting dword %s to %lx\n", debugstr_w(value), dw );
326             RegSetValueExW( hkey, value, 0, type, (BYTE *)&dw, sizeof(dw) );
327         }
328         else
329         {
330             TRACE( "setting value %s to %s\n", debugstr_w(value), debugstr_w(str) );
331             if (str) RegSetValueExW( hkey, value, 0, type, (BYTE *)str, size * sizeof(WCHAR) );
332             else RegSetValueExW( hkey, value, 0, type, (BYTE *)&empty, sizeof(WCHAR) );
333         }
334         HeapFree( GetProcessHeap(), 0, str );
335         return TRUE;
336     }
337     else  /* get the binary data */
338     {
339         BYTE *data = NULL;
340
341         if (!SetupGetBinaryField( context, 5, NULL, 0, &size )) size = 0;
342         if (size)
343         {
344             if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE;
345             TRACE( "setting binary data %s len %ld\n", debugstr_w(value), size );
346             SetupGetBinaryField( context, 5, data, size, NULL );
347         }
348         RegSetValueExW( hkey, value, 0, type, data, size );
349         HeapFree( GetProcessHeap(), 0, data );
350         return TRUE;
351     }
352 }
353
354
355 /***********************************************************************
356  *            registry_callback
357  *
358  * Called once for each AddReg and DelReg entry in a given section.
359  */
360 static BOOL registry_callback( HINF hinf, PCWSTR field, void *arg )
361 {
362     struct registry_callback_info *info = arg;
363     INFCONTEXT context;
364     HKEY root_key, hkey;
365
366     BOOL ok = SetupFindFirstLineW( hinf, field, NULL, &context );
367
368     for (; ok; ok = SetupFindNextLine( &context, &context ))
369     {
370         WCHAR buffer[MAX_INF_STRING_LENGTH];
371         INT flags;
372
373         /* get root */
374         if (!SetupGetStringFieldW( &context, 1, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
375             continue;
376         if (!(root_key = get_root_key( buffer, info->default_root )))
377             continue;
378
379         /* get key */
380         if (!SetupGetStringFieldW( &context, 2, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
381             *buffer = 0;
382
383         /* get flags */
384         if (!SetupGetIntField( &context, 4, &flags )) flags = 0;
385
386         if (!info->delete)
387         {
388             if (flags & FLG_ADDREG_DELREG_BIT) continue;  /* ignore this entry */
389         }
390         else
391         {
392             if (!flags) flags = FLG_ADDREG_DELREG_BIT;
393             else if (!(flags & FLG_ADDREG_DELREG_BIT)) continue;  /* ignore this entry */
394         }
395
396         if (info->delete || (flags & FLG_ADDREG_OVERWRITEONLY))
397         {
398             if (RegOpenKeyW( root_key, buffer, &hkey )) continue;  /* ignore if it doesn't exist */
399         }
400         else if (RegCreateKeyW( root_key, buffer, &hkey ))
401         {
402             ERR( "could not create key %p %s\n", root_key, debugstr_w(buffer) );
403             continue;
404         }
405         TRACE( "key %p %s\n", root_key, debugstr_w(buffer) );
406
407         /* get value name */
408         if (!SetupGetStringFieldW( &context, 3, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
409             *buffer = 0;
410
411         /* and now do it */
412         if (!do_reg_operation( hkey, buffer, &context, flags ))
413         {
414             RegCloseKey( hkey );
415             return FALSE;
416         }
417         RegCloseKey( hkey );
418     }
419     return TRUE;
420 }
421
422
423 static BOOL update_ini_callback( HINF hinf, PCWSTR field, void *arg )
424 {
425     INFCONTEXT context;
426
427     BOOL ok = SetupFindFirstLineW( hinf, field, NULL, &context );
428
429     for (; ok; ok = SetupFindNextLine( &context, &context ))
430     {
431         WCHAR buffer[MAX_INF_STRING_LENGTH];
432         WCHAR  filename[MAX_INF_STRING_LENGTH];
433         WCHAR  section[MAX_INF_STRING_LENGTH];
434         WCHAR  entry[MAX_INF_STRING_LENGTH];
435         WCHAR  string[MAX_INF_STRING_LENGTH];
436         LPWSTR divider;
437
438         if (!SetupGetStringFieldW( &context, 1, filename,
439                                    sizeof(filename)/sizeof(WCHAR), NULL ))
440             continue;
441
442         if (!SetupGetStringFieldW( &context, 2, section,
443                                    sizeof(section)/sizeof(WCHAR), NULL ))
444             continue;
445
446         if (!SetupGetStringFieldW( &context, 4, buffer,
447                                    sizeof(buffer)/sizeof(WCHAR), NULL ))
448             continue;
449
450         divider = strchrW(buffer,'=');
451         if (divider)
452         {
453             *divider = 0;
454             strcpyW(entry,buffer);
455             divider++;
456             strcpyW(string,divider);
457         }
458         else
459         {
460             strcpyW(entry,buffer);
461             string[0]=0;
462         }
463
464         TRACE("Writing %s = %s in %s of file %s\n",debugstr_w(entry),
465                debugstr_w(string),debugstr_w(section),debugstr_w(filename));
466         WritePrivateProfileStringW(section,entry,string,filename);
467
468     }
469     return TRUE;
470 }
471
472 static BOOL update_ini_fields_callback( HINF hinf, PCWSTR field, void *arg )
473 {
474     FIXME( "should update ini fields %s\n", debugstr_w(field) );
475     return TRUE;
476 }
477
478 static BOOL ini2reg_callback( HINF hinf, PCWSTR field, void *arg )
479 {
480     FIXME( "should do ini2reg %s\n", debugstr_w(field) );
481     return TRUE;
482 }
483
484 static BOOL logconf_callback( HINF hinf, PCWSTR field, void *arg )
485 {
486     FIXME( "should do logconf %s\n", debugstr_w(field) );
487     return TRUE;
488 }
489
490
491 /***********************************************************************
492  *            iterate_section_fields
493  *
494  * Iterate over all fields of a certain key of a certain section
495  */
496 static BOOL iterate_section_fields( HINF hinf, PCWSTR section, PCWSTR key,
497                                     iterate_fields_func callback, void *arg )
498 {
499     WCHAR static_buffer[200];
500     WCHAR *buffer = static_buffer;
501     DWORD size = sizeof(static_buffer)/sizeof(WCHAR);
502     INFCONTEXT context;
503     BOOL ret = FALSE;
504
505     BOOL ok = SetupFindFirstLineW( hinf, section, key, &context );
506     while (ok)
507     {
508         UINT i, count = SetupGetFieldCount( &context );
509         for (i = 1; i <= count; i++)
510         {
511             if (!(buffer = get_field_string( &context, i, buffer, static_buffer, &size )))
512                 goto done;
513             if (!callback( hinf, buffer, arg ))
514             {
515                 ERR("callback failed for %s %s\n", debugstr_w(section), debugstr_w(buffer) );
516                 goto done;
517             }
518         }
519         ok = SetupFindNextMatchLineW( &context, key, &context );
520     }
521     ret = TRUE;
522  done:
523     if (buffer && buffer != static_buffer) HeapFree( GetProcessHeap(), 0, buffer );
524     return ret;
525 }
526
527
528 /***********************************************************************
529  *            SetupInstallFilesFromInfSectionA   (SETUPAPI.@)
530  */
531 BOOL WINAPI SetupInstallFilesFromInfSectionA( HINF hinf, HINF hlayout, HSPFILEQ queue,
532                                               PCSTR section, PCSTR src_root, UINT flags )
533 {
534     UNICODE_STRING sectionW;
535     BOOL ret = FALSE;
536
537     if (!RtlCreateUnicodeStringFromAsciiz( &sectionW, section ))
538     {
539         SetLastError( ERROR_NOT_ENOUGH_MEMORY );
540         return FALSE;
541     }
542     if (!src_root)
543         ret = SetupInstallFilesFromInfSectionW( hinf, hlayout, queue, sectionW.Buffer,
544                                                 NULL, flags );
545     else
546     {
547         UNICODE_STRING srcW;
548         if (RtlCreateUnicodeStringFromAsciiz( &srcW, src_root ))
549         {
550             ret = SetupInstallFilesFromInfSectionW( hinf, hlayout, queue, sectionW.Buffer,
551                                                     srcW.Buffer, flags );
552             RtlFreeUnicodeString( &srcW );
553         }
554         else SetLastError( ERROR_NOT_ENOUGH_MEMORY );
555     }
556     RtlFreeUnicodeString( &sectionW );
557     return ret;
558 }
559
560
561 /***********************************************************************
562  *            SetupInstallFilesFromInfSectionW   (SETUPAPI.@)
563  */
564 BOOL WINAPI SetupInstallFilesFromInfSectionW( HINF hinf, HINF hlayout, HSPFILEQ queue,
565                                               PCWSTR section, PCWSTR src_root, UINT flags )
566 {
567     struct files_callback_info info;
568
569     info.queue      = queue;
570     info.src_root   = src_root;
571     info.copy_flags = flags;
572     info.layout     = hlayout;
573     return iterate_section_fields( hinf, section, CopyFiles, copy_files_callback, &info );
574 }
575
576
577 /***********************************************************************
578  *            SetupInstallFromInfSectionA   (SETUPAPI.@)
579  */
580 BOOL WINAPI SetupInstallFromInfSectionA( HWND owner, HINF hinf, PCSTR section, UINT flags,
581                                          HKEY key_root, PCSTR src_root, UINT copy_flags,
582                                          PSP_FILE_CALLBACK_A callback, PVOID context,
583                                          HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data )
584 {
585     UNICODE_STRING sectionW, src_rootW;
586     struct callback_WtoA_context ctx;
587     BOOL ret = FALSE;
588
589     src_rootW.Buffer = NULL;
590     if (src_root && !RtlCreateUnicodeStringFromAsciiz( &src_rootW, src_root ))
591     {
592         SetLastError( ERROR_NOT_ENOUGH_MEMORY );
593         return FALSE;
594     }
595
596     if (RtlCreateUnicodeStringFromAsciiz( &sectionW, section ))
597     {
598         ctx.orig_context = context;
599         ctx.orig_handler = callback;
600         ret = SetupInstallFromInfSectionW( owner, hinf, sectionW.Buffer, flags, key_root,
601                                            src_rootW.Buffer, copy_flags, QUEUE_callback_WtoA,
602                                            &ctx, devinfo, devinfo_data );
603         RtlFreeUnicodeString( &sectionW );
604     }
605     else SetLastError( ERROR_NOT_ENOUGH_MEMORY );
606
607     RtlFreeUnicodeString( &src_rootW );
608     return ret;
609 }
610
611
612 /***********************************************************************
613  *            SetupInstallFromInfSectionW   (SETUPAPI.@)
614  */
615 BOOL WINAPI SetupInstallFromInfSectionW( HWND owner, HINF hinf, PCWSTR section, UINT flags,
616                                          HKEY key_root, PCWSTR src_root, UINT copy_flags,
617                                          PSP_FILE_CALLBACK_W callback, PVOID context,
618                                          HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data )
619 {
620     if (flags & SPINST_FILES)
621     {
622         struct files_callback_info info;
623         HSPFILEQ queue;
624         BOOL ret;
625
626         if (!(queue = SetupOpenFileQueue())) return FALSE;
627         info.queue      = queue;
628         info.src_root   = src_root;
629         info.copy_flags = copy_flags;
630         info.layout     = hinf;
631         ret = (iterate_section_fields( hinf, section, CopyFiles, copy_files_callback, &info ) &&
632                iterate_section_fields( hinf, section, DelFiles, delete_files_callback, &info ) &&
633                iterate_section_fields( hinf, section, RenFiles, rename_files_callback, &info ) &&
634                SetupCommitFileQueueW( owner, queue, callback, context ));
635         SetupCloseFileQueue( queue );
636         if (!ret) return FALSE;
637     }
638     if (flags & SPINST_INIFILES)
639     {
640         if (!iterate_section_fields( hinf, section, UpdateInis, update_ini_callback, NULL ) ||
641             !iterate_section_fields( hinf, section, UpdateIniFields,
642                                      update_ini_fields_callback, NULL ))
643             return FALSE;
644     }
645     if (flags & SPINST_INI2REG)
646     {
647         if (!iterate_section_fields( hinf, section, Ini2Reg, ini2reg_callback, NULL ))
648             return FALSE;
649     }
650
651     if (flags & SPINST_LOGCONFIG)
652     {
653         if (!iterate_section_fields( hinf, section, LogConf, logconf_callback, NULL ))
654             return FALSE;
655     }
656
657     if (flags & SPINST_REGISTRY)
658     {
659         struct registry_callback_info info;
660
661         info.default_root = key_root;
662         info.delete = TRUE;
663         if (!iterate_section_fields( hinf, section, DelReg, registry_callback, &info ))
664             return FALSE;
665         info.delete = FALSE;
666         if (!iterate_section_fields( hinf, section, AddReg, registry_callback, &info ))
667             return FALSE;
668     }
669     if (flags & (SPINST_BITREG|SPINST_REGSVR|SPINST_UNREGSVR|SPINST_PROFILEITEMS|SPINST_COPYINF))
670         FIXME( "unsupported flags %x\n", flags );
671     return TRUE;
672 }