user32: Use MAKEWPARAM instead of MAKELONG for menu messages.
[wine] / dlls / msi / source.c
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2005 Aric Stewart 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdarg.h>
22
23 #define COBJMACROS
24 #define NONAMELESSUNION
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winreg.h"
29 #include "winnls.h"
30 #include "shlwapi.h"
31 #include "wine/debug.h"
32 #include "msi.h"
33 #include "msiquery.h"
34 #include "msipriv.h"
35 #include "wincrypt.h"
36 #include "winver.h"
37 #include "winuser.h"
38 #include "wine/unicode.h"
39 #include "sddl.h"
40
41 WINE_DEFAULT_DEBUG_CHANNEL(msi);
42
43 /*
44  * These apis are defined in MSI 3.0
45  */
46
47 typedef struct tagMediaInfo
48 {
49     struct list entry;
50     LPWSTR  path;
51     WCHAR   szIndex[10];
52     DWORD   index;
53 } media_info;
54
55 static UINT OpenSourceKey(LPCWSTR szProduct, HKEY* key, DWORD dwOptions,
56                           MSIINSTALLCONTEXT context, BOOL create)
57 {
58     HKEY rootkey = 0; 
59     UINT rc = ERROR_FUNCTION_FAILED;
60     static const WCHAR szSourceList[] = {'S','o','u','r','c','e','L','i','s','t',0};
61
62     if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
63     {
64         if (dwOptions & MSICODE_PATCH)
65             rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create);
66         else
67             rc = MSIREG_OpenProductKey(szProduct, context, &rootkey, create);
68     }
69     else if (context == MSIINSTALLCONTEXT_USERMANAGED)
70     {
71         if (dwOptions & MSICODE_PATCH)
72             rc = MSIREG_OpenUserPatchesKey(szProduct, &rootkey, create);
73         else
74             rc = MSIREG_OpenProductKey(szProduct, context, &rootkey, create);
75     }
76     else if (context == MSIINSTALLCONTEXT_MACHINE)
77     {
78         if (dwOptions & MSICODE_PATCH)
79             rc = MSIREG_OpenPatchesKey(szProduct, &rootkey, create);
80         else
81             rc = MSIREG_OpenProductKey(szProduct, context, &rootkey, create);
82     }
83
84     if (rc != ERROR_SUCCESS)
85     {
86         if (dwOptions & MSICODE_PATCH)
87             return ERROR_UNKNOWN_PATCH;
88         else
89             return ERROR_UNKNOWN_PRODUCT;
90     }
91
92     if (create)
93         rc = RegCreateKeyW(rootkey, szSourceList, key);
94     else
95     {
96         rc = RegOpenKeyW(rootkey,szSourceList, key);
97         if (rc != ERROR_SUCCESS)
98             rc = ERROR_BAD_CONFIGURATION;
99     }
100
101     return rc;
102 }
103
104 static UINT OpenMediaSubkey(HKEY rootkey, HKEY *key, BOOL create)
105 {
106     UINT rc;
107     static const WCHAR media[] = {'M','e','d','i','a',0};
108
109     if (create)
110         rc = RegCreateKeyW(rootkey, media, key);
111     else
112         rc = RegOpenKeyW(rootkey,media, key); 
113
114     return rc;
115 }
116
117 static UINT OpenNetworkSubkey(HKEY rootkey, HKEY *key, BOOL create)
118 {
119     UINT rc;
120     static const WCHAR net[] = {'N','e','t',0};
121
122     if (create)
123         rc = RegCreateKeyW(rootkey, net, key);
124     else
125         rc = RegOpenKeyW(rootkey, net, key); 
126
127     return rc;
128 }
129
130 static UINT OpenURLSubkey(HKEY rootkey, HKEY *key, BOOL create)
131 {
132     UINT rc;
133     static const WCHAR URL[] = {'U','R','L',0};
134
135     if (create)
136         rc = RegCreateKeyW(rootkey, URL, key);
137     else
138         rc = RegOpenKeyW(rootkey, URL, key); 
139
140     return rc;
141 }
142
143 /******************************************************************
144  *  MsiSourceListEnumMediaDisksA   (MSI.@)
145  */
146 UINT WINAPI MsiSourceListEnumMediaDisksA(LPCSTR szProductCodeOrPatchCode,
147                                          LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext,
148                                          DWORD dwOptions, DWORD dwIndex, LPDWORD pdwDiskId,
149                                          LPSTR szVolumeLabel, LPDWORD pcchVolumeLabel,
150                                          LPSTR szDiskPrompt, LPDWORD pcchDiskPrompt)
151 {
152     LPWSTR product = NULL;
153     LPWSTR usersid = NULL;
154     LPWSTR volume = NULL;
155     LPWSTR prompt = NULL;
156     UINT r = ERROR_INVALID_PARAMETER;
157
158     TRACE("(%s, %s, %d, %d, %d, %p, %p, %p, %p, %p)\n", debugstr_a(szProductCodeOrPatchCode),
159           debugstr_a(szUserSid), dwContext, dwOptions, dwIndex, pdwDiskId,
160           szVolumeLabel, pcchVolumeLabel, szDiskPrompt, pcchDiskPrompt);
161
162     if (szDiskPrompt && !pcchDiskPrompt)
163         return ERROR_INVALID_PARAMETER;
164
165     if (szProductCodeOrPatchCode) product = strdupAtoW(szProductCodeOrPatchCode);
166     if (szUserSid) usersid = strdupAtoW(szUserSid);
167
168     /* FIXME: add tests for an invalid format */
169
170     if (pcchVolumeLabel)
171         volume = msi_alloc(*pcchVolumeLabel * sizeof(WCHAR));
172
173     if (pcchDiskPrompt)
174         prompt = msi_alloc(*pcchDiskPrompt * sizeof(WCHAR));
175
176     if (volume) *volume = '\0';
177     if (prompt) *prompt = '\0';
178     r = MsiSourceListEnumMediaDisksW(product, usersid, dwContext, dwOptions,
179                                      dwIndex, pdwDiskId, volume, pcchVolumeLabel,
180                                      prompt, pcchDiskPrompt);
181     if (r != ERROR_SUCCESS)
182         goto done;
183
184     if (szVolumeLabel && pcchVolumeLabel)
185         WideCharToMultiByte(CP_ACP, 0, volume, -1, szVolumeLabel,
186                             *pcchVolumeLabel + 1, NULL, NULL);
187
188     if (szDiskPrompt)
189         WideCharToMultiByte(CP_ACP, 0, prompt, -1, szDiskPrompt,
190                             *pcchDiskPrompt + 1, NULL, NULL);
191
192 done:
193     msi_free(product);
194     msi_free(usersid);
195     msi_free(volume);
196     msi_free(prompt);
197
198     return r;
199 }
200
201 /******************************************************************
202  *  MsiSourceListEnumMediaDisksW   (MSI.@)
203  */
204 UINT WINAPI MsiSourceListEnumMediaDisksW(LPCWSTR szProductCodeOrPatchCode,
205                                          LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext,
206                                          DWORD dwOptions, DWORD dwIndex, LPDWORD pdwDiskId,
207                                          LPWSTR szVolumeLabel, LPDWORD pcchVolumeLabel,
208                                          LPWSTR szDiskPrompt, LPDWORD pcchDiskPrompt)
209 {
210     WCHAR squished_pc[GUID_SIZE];
211     WCHAR convert[11];
212     LPWSTR value = NULL;
213     LPWSTR data = NULL;
214     LPWSTR ptr, ptr2;
215     HKEY source, media;
216     DWORD valuesz, datasz = 0;
217     DWORD type;
218     DWORD numvals, size;
219     LONG res;
220     UINT r;
221     static DWORD index = 0;
222
223     static const WCHAR fmt[] = {'#','%','d',0};
224
225     TRACE("(%s, %s, %d, %d, %d, %p, %p, %p, %p)\n", debugstr_w(szProductCodeOrPatchCode),
226           debugstr_w(szUserSid), dwContext, dwOptions, dwIndex, szVolumeLabel,
227           pcchVolumeLabel, szDiskPrompt, pcchDiskPrompt);
228
229     if (!szProductCodeOrPatchCode ||
230         !squash_guid(szProductCodeOrPatchCode, squished_pc))
231         return ERROR_INVALID_PARAMETER;
232
233     if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
234         return ERROR_INVALID_PARAMETER;
235
236     if (dwOptions != MSICODE_PRODUCT && dwOptions != MSICODE_PATCH)
237         return ERROR_INVALID_PARAMETER;
238
239     if (szDiskPrompt && !pcchDiskPrompt)
240         return ERROR_INVALID_PARAMETER;
241
242     if (dwIndex == 0)
243         index = 0;
244
245     if (dwIndex != index)
246         return ERROR_INVALID_PARAMETER;
247
248     r = OpenSourceKey(szProductCodeOrPatchCode, &source,
249                       dwOptions, dwContext, FALSE);
250     if (r != ERROR_SUCCESS)
251         return r;
252
253     r = OpenMediaSubkey(source, &media, FALSE);
254     if (r != ERROR_SUCCESS)
255     {
256         RegCloseKey(source);
257         return ERROR_NO_MORE_ITEMS;
258     }
259
260     if (!pcchVolumeLabel && !pcchDiskPrompt)
261     {
262         r = RegEnumValueW(media, dwIndex, NULL, NULL, NULL,
263                           &type, NULL, NULL);
264         goto done;
265     }
266
267     res = RegQueryInfoKeyW(media, NULL, NULL, NULL, NULL, NULL,
268                            NULL, &numvals, &valuesz, &datasz, NULL, NULL);
269     if (res != ERROR_SUCCESS)
270     {
271         r = ERROR_BAD_CONFIGURATION;
272         goto done;
273     }
274
275     value = msi_alloc(++valuesz * sizeof(WCHAR));
276     data = msi_alloc(++datasz * sizeof(WCHAR));
277     if (!value || !data)
278     {
279         r = ERROR_OUTOFMEMORY;
280         goto done;
281     }
282
283     r = RegEnumValueW(media, dwIndex, value, &valuesz,
284                       NULL, &type, (LPBYTE)data, &datasz);
285     if (r != ERROR_SUCCESS)
286         goto done;
287
288     if (pdwDiskId)
289         *pdwDiskId = atolW(value);
290
291     ptr2 = data;
292     ptr = strchrW(data, ';');
293     if (!ptr)
294         ptr = data;
295     else
296         *ptr = '\0';
297
298     if (pcchVolumeLabel)
299     {
300         if (type == REG_DWORD)
301         {
302             sprintfW(convert, fmt, *data);
303             size = lstrlenW(convert);
304             ptr2 = convert;
305         }
306         else
307             size = lstrlenW(data);
308
309         if (size >= *pcchVolumeLabel)
310             r = ERROR_MORE_DATA;
311         else if (szVolumeLabel)
312             lstrcpyW(szVolumeLabel, ptr2);
313
314         *pcchVolumeLabel = size;
315     }
316
317     if (pcchDiskPrompt)
318     {
319         if (!*ptr)
320             ptr++;
321
322         if (type == REG_DWORD)
323         {
324             sprintfW(convert, fmt, *ptr);
325             size = lstrlenW(convert);
326             ptr = convert;
327         }
328         else
329             size = lstrlenW(ptr);
330
331         size = lstrlenW(ptr);
332         if (size >= *pcchDiskPrompt)
333             r = ERROR_MORE_DATA;
334         else if (szDiskPrompt)
335             lstrcpyW(szDiskPrompt, ptr);
336
337         *pcchDiskPrompt = size;
338     }
339
340     index++;
341
342 done:
343     msi_free(value);
344     msi_free(data);
345     RegCloseKey(source);
346
347     return r;
348 }
349
350 /******************************************************************
351  *  MsiSourceListEnumSourcesA   (MSI.@)
352  */
353 UINT WINAPI MsiSourceListEnumSourcesA(LPCSTR szProductCodeOrPatch, LPCSTR szUserSid,
354                                       MSIINSTALLCONTEXT dwContext,
355                                       DWORD dwOptions, DWORD dwIndex,
356                                       LPSTR szSource, LPDWORD pcchSource)
357 {
358     LPWSTR product = NULL;
359     LPWSTR usersid = NULL;
360     LPWSTR source = NULL;
361     DWORD len = 0;
362     UINT r = ERROR_INVALID_PARAMETER;
363     static DWORD index = 0;
364
365     TRACE("(%s, %s, %d, %d, %d, %p, %p)\n", debugstr_a(szProductCodeOrPatch),
366           debugstr_a(szUserSid), dwContext, dwOptions, dwIndex, szSource, pcchSource);
367
368     if (dwIndex == 0)
369         index = 0;
370
371     if (szSource && !pcchSource)
372         goto done;
373
374     if (dwIndex != index)
375         goto done;
376
377     if (szProductCodeOrPatch) product = strdupAtoW(szProductCodeOrPatch);
378     if (szUserSid) usersid = strdupAtoW(szUserSid);
379
380     r = MsiSourceListEnumSourcesW(product, usersid, dwContext, dwOptions,
381                                   dwIndex, NULL, &len);
382     if (r != ERROR_SUCCESS)
383         goto done;
384
385     source = msi_alloc(++len * sizeof(WCHAR));
386     if (!source)
387     {
388         r = ERROR_OUTOFMEMORY;
389         goto done;
390     }
391
392     *source = '\0';
393     r = MsiSourceListEnumSourcesW(product, usersid, dwContext, dwOptions,
394                                   dwIndex, source, &len);
395     if (r != ERROR_SUCCESS)
396         goto done;
397
398     len = WideCharToMultiByte(CP_ACP, 0, source, -1, NULL, 0, NULL, NULL);
399     if (pcchSource && *pcchSource >= len)
400         WideCharToMultiByte(CP_ACP, 0, source, -1, szSource, len, NULL, NULL);
401     else if (szSource)
402         r = ERROR_MORE_DATA;
403
404     if (pcchSource)
405         *pcchSource = len - 1;
406
407 done:
408     msi_free(product);
409     msi_free(usersid);
410     msi_free(source);
411
412     if (r == ERROR_SUCCESS)
413     {
414         if (szSource || !pcchSource) index++;
415     }
416     else if (dwIndex > index)
417         index = 0;
418
419     return r;
420 }
421
422 /******************************************************************
423  *  MsiSourceListEnumSourcesW   (MSI.@)
424  */
425 UINT WINAPI MsiSourceListEnumSourcesW(LPCWSTR szProductCodeOrPatch, LPCWSTR szUserSid,
426                                       MSIINSTALLCONTEXT dwContext,
427                                       DWORD dwOptions, DWORD dwIndex,
428                                       LPWSTR szSource, LPDWORD pcchSource)
429 {
430     WCHAR squished_pc[GUID_SIZE];
431     WCHAR name[32];
432     HKEY source = NULL;
433     HKEY subkey = NULL;
434     LONG res;
435     UINT r = ERROR_INVALID_PARAMETER;
436     static DWORD index = 0;
437
438     static const WCHAR format[] = {'%','d',0};
439
440     TRACE("(%s, %s, %d, %d, %d, %p, %p)\n", debugstr_w(szProductCodeOrPatch),
441           debugstr_w(szUserSid), dwContext, dwOptions, dwIndex, szSource, pcchSource);
442
443     if (dwIndex == 0)
444         index = 0;
445
446     if (!szProductCodeOrPatch || !squash_guid(szProductCodeOrPatch, squished_pc))
447         goto done;
448
449     if (szSource && !pcchSource)
450         goto done;
451
452     if (!(dwOptions & (MSISOURCETYPE_NETWORK | MSISOURCETYPE_URL)))
453         goto done;
454
455     if ((dwOptions & MSISOURCETYPE_NETWORK) && (dwOptions & MSISOURCETYPE_URL))
456         goto done;
457
458     if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
459         goto done;
460
461     if (dwIndex != index)
462         goto done;
463
464     r = OpenSourceKey(szProductCodeOrPatch, &source,
465                       dwOptions, dwContext, FALSE);
466     if (r != ERROR_SUCCESS)
467         goto done;
468
469     if (dwOptions & MSISOURCETYPE_NETWORK)
470         r = OpenNetworkSubkey(source, &subkey, FALSE);
471     else if (dwOptions & MSISOURCETYPE_URL)
472         r = OpenURLSubkey(source, &subkey, FALSE);
473
474     if (r != ERROR_SUCCESS)
475     {
476         r = ERROR_NO_MORE_ITEMS;
477         goto done;
478     }
479
480     sprintfW(name, format, dwIndex + 1);
481
482     res = RegQueryValueExW(subkey, name, 0, 0, (LPBYTE)szSource, pcchSource);
483     if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA)
484         r = ERROR_NO_MORE_ITEMS;
485
486 done:
487     RegCloseKey(subkey);
488     RegCloseKey(source);
489
490     if (r == ERROR_SUCCESS)
491     {
492         if (szSource || !pcchSource) index++;
493     }
494     else if (dwIndex > index)
495         index = 0;
496
497     return r;
498 }
499
500 /******************************************************************
501  *  MsiSourceListGetInfoA   (MSI.@)
502  */
503 UINT WINAPI MsiSourceListGetInfoA( LPCSTR szProduct, LPCSTR szUserSid,
504                                    MSIINSTALLCONTEXT dwContext, DWORD dwOptions,
505                                    LPCSTR szProperty, LPSTR szValue,
506                                    LPDWORD pcchValue)
507 {
508     UINT ret;
509     LPWSTR product = NULL;
510     LPWSTR usersid = NULL;
511     LPWSTR property = NULL;
512     LPWSTR value = NULL;
513     DWORD len = 0;
514
515     if (szValue && !pcchValue)
516         return ERROR_INVALID_PARAMETER;
517
518     if (szProduct) product = strdupAtoW(szProduct);
519     if (szUserSid) usersid = strdupAtoW(szUserSid);
520     if (szProperty) property = strdupAtoW(szProperty);
521
522     ret = MsiSourceListGetInfoW(product, usersid, dwContext, dwOptions,
523                                 property, NULL, &len);
524     if (ret != ERROR_SUCCESS)
525         goto done;
526
527     value = msi_alloc(++len * sizeof(WCHAR));
528     if (!value)
529         return ERROR_OUTOFMEMORY;
530
531     *value = '\0';
532     ret = MsiSourceListGetInfoW(product, usersid, dwContext, dwOptions,
533                                 property, value, &len);
534     if (ret != ERROR_SUCCESS)
535         goto done;
536
537     len = WideCharToMultiByte(CP_ACP, 0, value, -1, NULL, 0, NULL, NULL);
538     if (*pcchValue >= len)
539         WideCharToMultiByte(CP_ACP, 0, value, -1, szValue, len, NULL, NULL);
540     else if (szValue)
541         ret = ERROR_MORE_DATA;
542
543     *pcchValue = len - 1;
544
545 done:
546     msi_free(product);
547     msi_free(usersid);
548     msi_free(property);
549     msi_free(value);
550     return ret;
551 }
552
553 /******************************************************************
554  *  MsiSourceListGetInfoW   (MSI.@)
555  */
556 UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
557                                    MSIINSTALLCONTEXT dwContext, DWORD dwOptions,
558                                    LPCWSTR szProperty, LPWSTR szValue, 
559                                    LPDWORD pcchValue) 
560 {
561     WCHAR squished_pc[GUID_SIZE];
562     HKEY sourcekey, media;
563     LPWSTR source, ptr;
564     DWORD size;
565     UINT rc;
566
567     static const WCHAR mediapack[] = {
568         'M','e','d','i','a','P','a','c','k','a','g','e',0};
569
570     TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szProperty));
571
572     if (!szProduct || !squash_guid(szProduct, squished_pc))
573         return ERROR_INVALID_PARAMETER;
574
575     if (szValue && !pcchValue)
576         return ERROR_INVALID_PARAMETER;
577
578     if (dwContext != MSIINSTALLCONTEXT_USERMANAGED &&
579         dwContext != MSIINSTALLCONTEXT_USERUNMANAGED &&
580         dwContext != MSIINSTALLCONTEXT_MACHINE)
581         return ERROR_INVALID_PARAMETER;
582
583     if (!szProperty)
584         return ERROR_INVALID_PARAMETER;
585
586     if (szUserSid)
587         FIXME("Unhandled UserSid %s\n",debugstr_w(szUserSid));
588
589     if (dwContext != MSIINSTALLCONTEXT_USERUNMANAGED)
590         FIXME("Unhandled context %d\n", dwContext);
591
592     rc = OpenSourceKey(szProduct, &sourcekey, dwOptions, dwContext, FALSE);
593     if (rc != ERROR_SUCCESS)
594         return rc;
595
596     if (!lstrcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW) ||
597         !lstrcmpW(szProperty, INSTALLPROPERTY_DISKPROMPTW))
598     {
599         rc = OpenMediaSubkey(sourcekey, &media, FALSE);
600         if (rc != ERROR_SUCCESS)
601         {
602             RegCloseKey(sourcekey);
603             return ERROR_SUCCESS;
604         }
605
606         if (!lstrcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW))
607             szProperty = mediapack;
608
609         RegQueryValueExW(media, szProperty, 0, 0, (LPBYTE)szValue, pcchValue);
610         RegCloseKey(media);
611     }
612     else if (!lstrcmpW(szProperty, INSTALLPROPERTY_LASTUSEDSOURCEW) ||
613              !lstrcmpW(szProperty, INSTALLPROPERTY_LASTUSEDTYPEW))
614     {
615         rc = RegQueryValueExW(sourcekey, INSTALLPROPERTY_LASTUSEDSOURCEW,
616                               0, 0, NULL, &size);
617         if (rc != ERROR_SUCCESS)
618         {
619             RegCloseKey(sourcekey);
620             return ERROR_SUCCESS;
621         }
622
623         source = msi_alloc(size);
624         RegQueryValueExW(sourcekey, INSTALLPROPERTY_LASTUSEDSOURCEW,
625                          0, 0, (LPBYTE)source, &size);
626
627         if (!*source)
628         {
629             msi_free(source);
630             RegCloseKey(sourcekey);
631             return ERROR_SUCCESS;
632         }
633
634         if (!lstrcmpW(szProperty, INSTALLPROPERTY_LASTUSEDTYPEW))
635         {
636             if (*source != 'n' && *source != 'u' && *source != 'm')
637             {
638                 msi_free(source);
639                 RegCloseKey(sourcekey);
640                 return ERROR_SUCCESS;
641             }
642
643             ptr = source;
644             source[1] = '\0';
645         }
646         else
647         {
648             ptr = strrchrW(source, ';');
649             if (!ptr)
650                 ptr = source;
651             else
652                 ptr++;
653         }
654
655         if (szValue)
656         {
657             if (strlenW(ptr) < *pcchValue)
658                 lstrcpyW(szValue, ptr);
659             else
660                 rc = ERROR_MORE_DATA;
661         }
662
663         *pcchValue = lstrlenW(ptr);
664         msi_free(source);
665     }
666     else if (strcmpW(INSTALLPROPERTY_PACKAGENAMEW, szProperty)==0)
667     {
668         *pcchValue = *pcchValue * sizeof(WCHAR);
669         rc = RegQueryValueExW(sourcekey, INSTALLPROPERTY_PACKAGENAMEW, 0, 0,
670                               (LPBYTE)szValue, pcchValue);
671         if (rc != ERROR_SUCCESS && rc != ERROR_MORE_DATA)
672         {
673             *pcchValue = 0;
674             rc = ERROR_SUCCESS;
675         }
676         else
677         {
678             if (*pcchValue)
679                 *pcchValue = (*pcchValue - 1) / sizeof(WCHAR);
680             if (szValue)
681                 szValue[*pcchValue] = '\0';
682         }
683     }
684     else
685     {
686         FIXME("Unknown property %s\n",debugstr_w(szProperty));
687         rc = ERROR_UNKNOWN_PROPERTY;
688     }
689
690     RegCloseKey(sourcekey);
691     return rc;
692 }
693
694 /******************************************************************
695  *  MsiSourceListSetInfoA   (MSI.@)
696  */
697 UINT WINAPI MsiSourceListSetInfoA(LPCSTR szProduct, LPCSTR szUserSid,
698                                   MSIINSTALLCONTEXT dwContext, DWORD dwOptions,
699                                   LPCSTR szProperty, LPCSTR szValue)
700 {
701     UINT ret;
702     LPWSTR product = NULL;
703     LPWSTR usersid = NULL;
704     LPWSTR property = NULL;
705     LPWSTR value = NULL;
706
707     if (szProduct) product = strdupAtoW(szProduct);
708     if (szUserSid) usersid = strdupAtoW(szUserSid);
709     if (szProperty) property = strdupAtoW(szProperty);
710     if (szValue) value = strdupAtoW(szValue);
711
712     ret = MsiSourceListSetInfoW(product, usersid, dwContext, dwOptions,
713                                 property, value);
714
715     msi_free(product);
716     msi_free(usersid);
717     msi_free(property);
718     msi_free(value);
719
720     return ret;
721 }
722
723 UINT msi_set_last_used_source(LPCWSTR product, LPCWSTR usersid,
724                               MSIINSTALLCONTEXT context, DWORD options,
725                               LPCWSTR value)
726 {
727     HKEY source;
728     LPWSTR buffer;
729     WCHAR typechar;
730     DWORD size;
731     UINT r;
732     int index = 1;
733
734     static const WCHAR format[] = {'%','c',';','%','i',';','%','s',0};
735
736     if (options & MSISOURCETYPE_NETWORK)
737         typechar = 'n';
738     else if (options & MSISOURCETYPE_URL)
739         typechar = 'u';
740     else if (options & MSISOURCETYPE_MEDIA)
741         typechar = 'm';
742     else
743         return ERROR_INVALID_PARAMETER;
744
745     if (!(options & MSISOURCETYPE_MEDIA))
746     {
747         r = MsiSourceListAddSourceExW(product, usersid, context,
748                                       options, value, 0);
749         if (r != ERROR_SUCCESS)
750             return r;
751
752         index = 0;
753         while ((r = MsiSourceListEnumSourcesW(product, usersid, context, options,
754                                               index, NULL, NULL)) == ERROR_SUCCESS)
755             index++;
756
757         if (r != ERROR_NO_MORE_ITEMS)
758             return r;
759     }
760
761     size = (lstrlenW(format) + lstrlenW(value) + 7) * sizeof(WCHAR);
762     buffer = msi_alloc(size);
763     if (!buffer)
764         return ERROR_OUTOFMEMORY;
765
766     r = OpenSourceKey(product, &source, MSICODE_PRODUCT, context, FALSE);
767     if (r != ERROR_SUCCESS)
768         return r;
769
770     sprintfW(buffer, format, typechar, index, value);
771
772     size = (lstrlenW(buffer) + 1) * sizeof(WCHAR);
773     r = RegSetValueExW(source, INSTALLPROPERTY_LASTUSEDSOURCEW, 0,
774                        REG_SZ, (LPBYTE)buffer, size);
775     msi_free(buffer);
776
777     RegCloseKey(source);
778     return r;
779 }
780
781 /******************************************************************
782  *  MsiSourceListSetInfoW   (MSI.@)
783  */
784 UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
785                                    MSIINSTALLCONTEXT dwContext, DWORD dwOptions,
786                                    LPCWSTR szProperty, LPCWSTR szValue)
787 {
788     WCHAR squished_pc[GUID_SIZE];
789     HKEY sourcekey, media;
790     LPCWSTR property;
791     UINT rc;
792
793     static const WCHAR media_package[] = {
794         'M','e','d','i','a','P','a','c','k','a','g','e',0
795     };
796
797     TRACE("%s %s %x %x %s %s\n", debugstr_w(szProduct), debugstr_w(szUserSid),
798             dwContext, dwOptions, debugstr_w(szProperty), debugstr_w(szValue));
799
800     if (!szProduct || !squash_guid(szProduct, squished_pc))
801         return ERROR_INVALID_PARAMETER;
802
803     if (!szProperty)
804         return ERROR_INVALID_PARAMETER;
805
806     if (!szValue)
807         return ERROR_UNKNOWN_PROPERTY;
808
809     if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
810         return ERROR_INVALID_PARAMETER;
811
812     if (dwOptions & MSICODE_PATCH)
813     {
814         FIXME("Unhandled options MSICODE_PATCH\n");
815         return ERROR_UNKNOWN_PATCH;
816     }
817
818     property = szProperty;
819     if (!lstrcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW))
820         property = media_package;
821
822     rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, dwContext, FALSE);
823     if (rc != ERROR_SUCCESS)
824         return rc;
825
826     if (lstrcmpW(szProperty, INSTALLPROPERTY_LASTUSEDSOURCEW) &&
827         dwOptions & (MSISOURCETYPE_NETWORK | MSISOURCETYPE_URL))
828     {
829         RegCloseKey(sourcekey);
830         return ERROR_INVALID_PARAMETER;
831     }
832
833     if (!lstrcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW) ||
834         !lstrcmpW(szProperty, INSTALLPROPERTY_DISKPROMPTW))
835     {
836         rc = OpenMediaSubkey(sourcekey, &media, TRUE);
837         if (rc == ERROR_SUCCESS)
838         {
839             rc = msi_reg_set_val_str(media, property, szValue);
840             RegCloseKey(media);
841         }
842     }
843     else if (strcmpW(INSTALLPROPERTY_PACKAGENAMEW, szProperty)==0)
844     {
845         DWORD size = (lstrlenW(szValue) + 1) * sizeof(WCHAR);
846         rc = RegSetValueExW(sourcekey, INSTALLPROPERTY_PACKAGENAMEW, 0,
847                 REG_SZ, (const BYTE *)szValue, size);
848         if (rc != ERROR_SUCCESS)
849             rc = ERROR_UNKNOWN_PROPERTY;
850     }
851     else if (!lstrcmpW(szProperty, INSTALLPROPERTY_LASTUSEDSOURCEW))
852     {
853         if (!(dwOptions & (MSISOURCETYPE_NETWORK | MSISOURCETYPE_URL)))
854             rc = ERROR_INVALID_PARAMETER;
855         else
856             rc = msi_set_last_used_source(szProduct, szUserSid, dwContext,
857                                           dwOptions, szValue);
858     }
859     else
860         rc = ERROR_UNKNOWN_PROPERTY;
861
862     RegCloseKey(sourcekey);
863     return rc;
864 }
865
866 /******************************************************************
867  *  MsiSourceListAddSourceW (MSI.@)
868  */
869 UINT WINAPI MsiSourceListAddSourceW( LPCWSTR szProduct, LPCWSTR szUserName,
870         DWORD dwReserved, LPCWSTR szSource)
871 {
872     WCHAR squished_pc[GUID_SIZE];
873     INT ret;
874     LPWSTR sidstr = NULL;
875     DWORD sidsize = 0;
876     DWORD domsize = 0;
877     DWORD context;
878     HKEY hkey = 0;
879     UINT r;
880
881     TRACE("%s %s %s\n", debugstr_w(szProduct), debugstr_w(szUserName), debugstr_w(szSource));
882
883     if (!szSource || !*szSource)
884         return ERROR_INVALID_PARAMETER;
885
886     if (dwReserved != 0)
887         return ERROR_INVALID_PARAMETER;
888
889     if (!szProduct || !squash_guid(szProduct, squished_pc))
890         return ERROR_INVALID_PARAMETER;
891
892     if (!szUserName || !*szUserName)
893         context = MSIINSTALLCONTEXT_MACHINE;
894     else
895     {
896         if (LookupAccountNameW(NULL, szUserName, NULL, &sidsize, NULL, &domsize, NULL))
897         {
898             PSID psid = msi_alloc(sidsize);
899
900             if (LookupAccountNameW(NULL, szUserName, psid, &sidsize, NULL, &domsize, NULL))
901                 ConvertSidToStringSidW(psid, &sidstr);
902
903             msi_free(psid);
904         }
905
906         r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
907                                   &hkey, FALSE);
908         if (r == ERROR_SUCCESS)
909             context = MSIINSTALLCONTEXT_USERMANAGED;
910         else
911         {
912             r = MSIREG_OpenProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
913                                       &hkey, FALSE);
914             if (r != ERROR_SUCCESS)
915                 return ERROR_UNKNOWN_PRODUCT;
916
917             context = MSIINSTALLCONTEXT_USERUNMANAGED;
918         }
919
920         RegCloseKey(hkey);
921     }
922
923     ret = MsiSourceListAddSourceExW(szProduct, sidstr, 
924         context, MSISOURCETYPE_NETWORK, szSource, 0);
925
926     if (sidstr)
927         LocalFree(sidstr);
928
929     return ret;
930 }
931
932 /******************************************************************
933  *  MsiSourceListAddSourceA (MSI.@)
934  */
935 UINT WINAPI MsiSourceListAddSourceA( LPCSTR szProduct, LPCSTR szUserName,
936         DWORD dwReserved, LPCSTR szSource)
937 {
938     INT ret;
939     LPWSTR szwproduct;
940     LPWSTR szwusername;
941     LPWSTR szwsource;
942
943     szwproduct = strdupAtoW( szProduct );
944     szwusername = strdupAtoW( szUserName );
945     szwsource = strdupAtoW( szSource );
946
947     ret = MsiSourceListAddSourceW(szwproduct, szwusername, dwReserved, szwsource);
948
949     msi_free(szwproduct);
950     msi_free(szwusername);
951     msi_free(szwsource);
952
953     return ret;
954 }
955
956 /******************************************************************
957  *  MsiSourceListAddSourceExA (MSI.@)
958  */
959 UINT WINAPI MsiSourceListAddSourceExA(LPCSTR szProduct, LPCSTR szUserSid,
960         MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szSource, DWORD dwIndex)
961 {
962     UINT ret;
963     LPWSTR product, usersid, source;
964
965     product = strdupAtoW(szProduct);
966     usersid = strdupAtoW(szUserSid);
967     source = strdupAtoW(szSource);
968
969     ret = MsiSourceListAddSourceExW(product, usersid, dwContext,
970                                     dwOptions, source, dwIndex);
971
972     msi_free(product);
973     msi_free(usersid);
974     msi_free(source);
975
976     return ret;
977 }
978
979 static void free_source_list(struct list *sourcelist)
980 {
981     while (!list_empty(sourcelist))
982     {
983         media_info *info = LIST_ENTRY(list_head(sourcelist), media_info, entry);
984         list_remove(&info->entry);
985         msi_free(info->path);
986         msi_free(info);
987     }
988 }
989
990 static void add_source_to_list(struct list *sourcelist, media_info *info,
991                                DWORD *index)
992 {
993     media_info *iter;
994     BOOL found = FALSE;
995     static const WCHAR fmt[] = {'%','i',0};
996
997     if (index) *index = 0;
998
999     if (list_empty(sourcelist))
1000     {
1001         list_add_head(sourcelist, &info->entry);
1002         return;
1003     }
1004
1005     LIST_FOR_EACH_ENTRY(iter, sourcelist, media_info, entry)
1006     {
1007         if (!found && info->index < iter->index)
1008         {
1009             found = TRUE;
1010             list_add_before(&iter->entry, &info->entry);
1011         }
1012
1013         /* update the rest of the list */
1014         if (found)
1015             sprintfW(iter->szIndex, fmt, ++iter->index);
1016         else if (index)
1017             (*index)++;
1018     }
1019
1020     if (!found)
1021         list_add_after(&iter->entry, &info->entry);
1022 }
1023
1024 static UINT fill_source_list(struct list *sourcelist, HKEY sourcekey, DWORD *count)
1025 {
1026     UINT r = ERROR_SUCCESS;
1027     DWORD index = 0;
1028     WCHAR name[10];
1029     DWORD size, val_size;
1030     media_info *entry;
1031
1032     *count = 0;
1033
1034     while (r == ERROR_SUCCESS)
1035     {
1036         size = sizeof(name) / sizeof(name[0]);
1037         r = RegEnumValueW(sourcekey, index, name, &size, NULL, NULL, NULL, &val_size);
1038         if (r != ERROR_SUCCESS)
1039             return r;
1040
1041         entry = msi_alloc(sizeof(media_info));
1042         if (!entry)
1043             goto error;
1044
1045         entry->path = msi_alloc(val_size);
1046         if (!entry->path)
1047         {
1048             msi_free(entry);
1049             goto error;
1050         }
1051
1052         lstrcpyW(entry->szIndex, name);
1053         entry->index = atoiW(name);
1054
1055         size++;
1056         r = RegEnumValueW(sourcekey, index, name, &size, NULL,
1057                           NULL, (LPBYTE)entry->path, &val_size);
1058         if (r != ERROR_SUCCESS)
1059         {
1060             msi_free(entry->path);
1061             msi_free(entry);
1062             goto error;
1063         }
1064
1065         index = ++(*count);
1066         add_source_to_list(sourcelist, entry, NULL);
1067     }
1068
1069 error:
1070     *count = -1;
1071     free_source_list(sourcelist);
1072     return ERROR_OUTOFMEMORY;
1073 }
1074
1075 /******************************************************************
1076  *  MsiSourceListAddSourceExW (MSI.@)
1077  */
1078 UINT WINAPI MsiSourceListAddSourceExW( LPCWSTR szProduct, LPCWSTR szUserSid,
1079         MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCWSTR szSource, 
1080         DWORD dwIndex)
1081 {
1082     HKEY sourcekey;
1083     HKEY typekey;
1084     UINT rc;
1085     struct list sourcelist;
1086     media_info *info;
1087     WCHAR squished_pc[GUID_SIZE];
1088     WCHAR name[10];
1089     LPWSTR source;
1090     LPCWSTR postfix;
1091     DWORD size, count;
1092     DWORD index;
1093
1094     static const WCHAR fmt[] = {'%','i',0};
1095     static const WCHAR one[] = {'1',0};
1096     static const WCHAR backslash[] = {'\\',0};
1097     static const WCHAR forwardslash[] = {'/',0};
1098
1099     TRACE("%s %s %x %x %s %i\n", debugstr_w(szProduct), debugstr_w(szUserSid),
1100           dwContext, dwOptions, debugstr_w(szSource), dwIndex);
1101
1102     if (!szProduct || !squash_guid(szProduct, squished_pc))
1103         return ERROR_INVALID_PARAMETER;
1104
1105     if (!szSource || !*szSource)
1106         return ERROR_INVALID_PARAMETER;
1107
1108     if (!(dwOptions & (MSISOURCETYPE_NETWORK | MSISOURCETYPE_URL)))
1109         return ERROR_INVALID_PARAMETER;
1110
1111     if (dwOptions & MSICODE_PATCH)
1112     {
1113         FIXME("Unhandled options MSICODE_PATCH\n");
1114         return ERROR_FUNCTION_FAILED;
1115     }
1116
1117     if (szUserSid && (dwContext & MSIINSTALLCONTEXT_MACHINE))
1118         return ERROR_INVALID_PARAMETER;
1119
1120     rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, dwContext, FALSE);
1121     if (rc != ERROR_SUCCESS)
1122         return rc;
1123
1124     if (dwOptions & MSISOURCETYPE_NETWORK)
1125         rc = OpenNetworkSubkey(sourcekey, &typekey, TRUE);
1126     else if (dwOptions & MSISOURCETYPE_URL)
1127         rc = OpenURLSubkey(sourcekey, &typekey, TRUE);
1128     else if (dwOptions & MSISOURCETYPE_MEDIA)
1129         rc = OpenMediaSubkey(sourcekey, &typekey, TRUE);
1130     else
1131     {
1132         ERR("unknown media type: %08x\n", dwOptions);
1133         RegCloseKey(sourcekey);
1134         return ERROR_FUNCTION_FAILED;
1135     }
1136
1137     postfix = (dwOptions & MSISOURCETYPE_NETWORK) ? backslash : forwardslash;
1138     if (szSource[lstrlenW(szSource) - 1] == *postfix)
1139         source = strdupW(szSource);
1140     else
1141     {
1142         size = lstrlenW(szSource) + 2;
1143         source = msi_alloc(size * sizeof(WCHAR));
1144         lstrcpyW(source, szSource);
1145         lstrcatW(source, postfix);
1146     }
1147
1148     list_init(&sourcelist);
1149     rc = fill_source_list(&sourcelist, typekey, &count);
1150     if (rc != ERROR_NO_MORE_ITEMS)
1151         return rc;
1152
1153     size = (lstrlenW(source) + 1) * sizeof(WCHAR);
1154
1155     if (count == 0)
1156     {
1157         rc = RegSetValueExW(typekey, one, 0, REG_EXPAND_SZ, (LPBYTE)source, size);
1158         goto done;
1159     }
1160     else if (dwIndex > count || dwIndex == 0)
1161     {
1162         sprintfW(name, fmt, count + 1);
1163         rc = RegSetValueExW(typekey, name, 0, REG_EXPAND_SZ, (LPBYTE)source, size);
1164         goto done;
1165     }
1166     else
1167     {
1168         sprintfW(name, fmt, dwIndex);
1169         info = msi_alloc(sizeof(media_info));
1170         if (!info)
1171         {
1172             rc = ERROR_OUTOFMEMORY;
1173             goto done;
1174         }
1175
1176         info->path = strdupW(source);
1177         lstrcpyW(info->szIndex, name);
1178         info->index = dwIndex;
1179         add_source_to_list(&sourcelist, info, &index);
1180
1181         LIST_FOR_EACH_ENTRY(info, &sourcelist, media_info, entry)
1182         {
1183             if (info->index < index)
1184                 continue;
1185
1186             size = (lstrlenW(info->path) + 1) * sizeof(WCHAR);
1187             rc = RegSetValueExW(typekey, info->szIndex, 0,
1188                                 REG_EXPAND_SZ, (LPBYTE)info->path, size);
1189             if (rc != ERROR_SUCCESS)
1190                 goto done;
1191         }
1192     }
1193
1194 done:
1195     free_source_list(&sourcelist);
1196     msi_free(source);
1197     RegCloseKey(typekey);
1198     RegCloseKey(sourcekey);
1199     return rc;
1200 }
1201
1202 /******************************************************************
1203  *  MsiSourceListAddMediaDiskA (MSI.@)
1204  */
1205 UINT WINAPI MsiSourceListAddMediaDiskA(LPCSTR szProduct, LPCSTR szUserSid,
1206         MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwDiskId,
1207         LPCSTR szVolumeLabel, LPCSTR szDiskPrompt)
1208 {
1209     UINT r;
1210     LPWSTR product = NULL;
1211     LPWSTR usersid = NULL;
1212     LPWSTR volume = NULL;
1213     LPWSTR prompt = NULL;
1214
1215     if (szProduct) product = strdupAtoW(szProduct);
1216     if (szUserSid) usersid = strdupAtoW(szUserSid);
1217     if (szVolumeLabel) volume = strdupAtoW(szVolumeLabel);
1218     if (szDiskPrompt) prompt = strdupAtoW(szDiskPrompt);
1219
1220     r = MsiSourceListAddMediaDiskW(product, usersid, dwContext, dwOptions,
1221                                      dwDiskId, volume, prompt);
1222
1223     msi_free(product);
1224     msi_free(usersid);
1225     msi_free(volume);
1226     msi_free(prompt);
1227
1228     return r;
1229 }
1230
1231 /******************************************************************
1232  *  MsiSourceListAddMediaDiskW (MSI.@)
1233  */
1234 UINT WINAPI MsiSourceListAddMediaDiskW(LPCWSTR szProduct, LPCWSTR szUserSid, 
1235         MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwDiskId, 
1236         LPCWSTR szVolumeLabel, LPCWSTR szDiskPrompt)
1237 {
1238     HKEY sourcekey;
1239     HKEY mediakey;
1240     UINT rc;
1241     WCHAR szIndex[10];
1242     WCHAR squished_pc[GUID_SIZE];
1243     LPWSTR buffer;
1244     DWORD size;
1245
1246     static const WCHAR fmt[] = {'%','i',0};
1247     static const WCHAR semicolon[] = {';',0};
1248
1249     TRACE("%s %s %x %x %i %s %s\n", debugstr_w(szProduct),
1250             debugstr_w(szUserSid), dwContext, dwOptions, dwDiskId,
1251             debugstr_w(szVolumeLabel), debugstr_w(szDiskPrompt));
1252
1253     if (!szProduct || !squash_guid(szProduct, squished_pc))
1254         return ERROR_INVALID_PARAMETER;
1255
1256     if (dwOptions != MSICODE_PRODUCT && dwOptions != MSICODE_PATCH)
1257         return ERROR_INVALID_PARAMETER;
1258
1259     if ((szVolumeLabel && !*szVolumeLabel) || (szDiskPrompt && !*szDiskPrompt))
1260         return ERROR_INVALID_PARAMETER;
1261
1262     if ((dwContext & MSIINSTALLCONTEXT_MACHINE) && szUserSid)
1263         return ERROR_INVALID_PARAMETER;
1264
1265     if (dwOptions & MSICODE_PATCH)
1266     {
1267         FIXME("Unhandled options MSICODE_PATCH\n");
1268         return ERROR_FUNCTION_FAILED;
1269     }
1270
1271     rc = OpenSourceKey(szProduct, &sourcekey, MSICODE_PRODUCT, dwContext, FALSE);
1272     if (rc != ERROR_SUCCESS)
1273         return rc;
1274
1275     OpenMediaSubkey(sourcekey, &mediakey, TRUE);
1276
1277     sprintfW(szIndex, fmt, dwDiskId);
1278
1279     size = 2;
1280     if (szVolumeLabel) size += lstrlenW(szVolumeLabel);
1281     if (szDiskPrompt) size += lstrlenW(szDiskPrompt);
1282
1283     size *= sizeof(WCHAR);
1284     buffer = msi_alloc(size);
1285     *buffer = '\0';
1286
1287     if (szVolumeLabel) lstrcpyW(buffer, szVolumeLabel);
1288     lstrcatW(buffer, semicolon);
1289     if (szDiskPrompt) lstrcatW(buffer, szDiskPrompt);
1290
1291     RegSetValueExW(mediakey, szIndex, 0, REG_SZ, (LPBYTE)buffer, size);
1292     msi_free(buffer);
1293
1294     RegCloseKey(sourcekey);
1295     RegCloseKey(mediakey);
1296
1297     return ERROR_SUCCESS;
1298 }
1299
1300 /******************************************************************
1301  *  MsiSourceListClearAllA (MSI.@)
1302  */
1303 UINT WINAPI MsiSourceListClearAllA( LPCSTR szProduct, LPCSTR szUserName, DWORD dwReserved )
1304 {
1305     FIXME("(%s %s %d)\n", debugstr_a(szProduct), debugstr_a(szUserName), dwReserved);
1306     return ERROR_SUCCESS;
1307 }
1308
1309 /******************************************************************
1310  *  MsiSourceListClearAllW (MSI.@)
1311  */
1312 UINT WINAPI MsiSourceListClearAllW( LPCWSTR szProduct, LPCWSTR szUserName, DWORD dwReserved )
1313 {
1314     FIXME("(%s %s %d)\n", debugstr_w(szProduct), debugstr_w(szUserName), dwReserved);
1315     return ERROR_SUCCESS;
1316 }
1317
1318 /******************************************************************
1319  *  MsiSourceListClearSourceA (MSI.@)
1320  */
1321 UINT WINAPI MsiSourceListClearSourceA(LPCSTR szProductCodeOrPatchCode, LPCSTR szUserSid,
1322                                       MSIINSTALLCONTEXT dwContext, DWORD dwOptions,
1323                                       LPCSTR szSource)
1324 {
1325     FIXME("(%s %s %x %x %s)\n", debugstr_a(szProductCodeOrPatchCode), debugstr_a(szUserSid),
1326           dwContext, dwOptions, debugstr_a(szSource));
1327     return ERROR_SUCCESS;
1328 }
1329
1330 /******************************************************************
1331  *  MsiSourceListClearSourceW (MSI.@)
1332  */
1333 UINT WINAPI MsiSourceListClearSourceW(LPCWSTR szProductCodeOrPatchCode, LPCWSTR szUserSid,
1334                                       MSIINSTALLCONTEXT dwContext, DWORD dwOptions,
1335                                       LPCWSTR szSource)
1336 {
1337     FIXME("(%s %s %x %x %s)\n", debugstr_w(szProductCodeOrPatchCode), debugstr_w(szUserSid),
1338           dwContext, dwOptions, debugstr_w(szSource));
1339     return ERROR_SUCCESS;
1340 }