2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002,2003,2004,2005 Mike McCormack for CodeWeavers
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.
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.
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
21 #define WIN32_NO_STATUS
23 #define COM_NO_WINDOWS_H
28 #define NONAMELESSUNION
36 //#include "msidefs.h"
37 //#include "msiquery.h"
39 #include <msiserver.h>
40 //#include "wincrypt.h"
42 //#include "winuser.h"
44 //#include "shobjidl.h"
46 //#include "wintrust.h"
52 #include <wine/debug.h>
53 #include <wine/unicode.h>
55 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
57 static const WCHAR installerW
[] = {'\\','I','n','s','t','a','l','l','e','r',0};
59 UINT
msi_locate_product(LPCWSTR szProduct
, MSIINSTALLCONTEXT
*context
)
63 *context
= MSIINSTALLCONTEXT_NONE
;
64 if (!szProduct
) return ERROR_UNKNOWN_PRODUCT
;
66 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
67 &hkey
, FALSE
) == ERROR_SUCCESS
)
68 *context
= MSIINSTALLCONTEXT_USERMANAGED
;
69 else if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
70 &hkey
, FALSE
) == ERROR_SUCCESS
)
71 *context
= MSIINSTALLCONTEXT_MACHINE
;
72 else if (MSIREG_OpenProductKey(szProduct
, NULL
,
73 MSIINSTALLCONTEXT_USERUNMANAGED
,
74 &hkey
, FALSE
) == ERROR_SUCCESS
)
75 *context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
79 if (*context
== MSIINSTALLCONTEXT_NONE
)
80 return ERROR_UNKNOWN_PRODUCT
;
85 UINT WINAPI
MsiOpenProductA(LPCSTR szProduct
, MSIHANDLE
*phProduct
)
88 LPWSTR szwProd
= NULL
;
90 TRACE("%s %p\n",debugstr_a(szProduct
), phProduct
);
94 szwProd
= strdupAtoW( szProduct
);
96 return ERROR_OUTOFMEMORY
;
99 r
= MsiOpenProductW( szwProd
, phProduct
);
106 static UINT
MSI_OpenProductW(LPCWSTR szProduct
, MSIPACKAGE
**package
)
111 MSIINSTALLCONTEXT context
;
113 static const WCHAR managed
[] = {
114 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0};
115 static const WCHAR local
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
117 TRACE("%s %p\n", debugstr_w(szProduct
), package
);
119 r
= msi_locate_product(szProduct
, &context
);
120 if (r
!= ERROR_SUCCESS
)
123 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &props
, FALSE
);
124 if (r
!= ERROR_SUCCESS
)
125 return ERROR_UNKNOWN_PRODUCT
;
127 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
128 path
= msi_reg_get_val_str(props
, managed
);
130 path
= msi_reg_get_val_str(props
, local
);
132 r
= ERROR_UNKNOWN_PRODUCT
;
134 if (!path
|| GetFileAttributesW(path
) == INVALID_FILE_ATTRIBUTES
)
137 if (PathIsRelativeW(path
))
139 r
= ERROR_INSTALL_PACKAGE_OPEN_FAILED
;
143 r
= MSI_OpenPackageW(path
, package
);
151 UINT WINAPI
MsiOpenProductW(LPCWSTR szProduct
, MSIHANDLE
*phProduct
)
153 MSIPACKAGE
*package
= NULL
;
154 WCHAR squished_pc
[GUID_SIZE
];
157 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
158 return ERROR_INVALID_PARAMETER
;
161 return ERROR_INVALID_PARAMETER
;
163 r
= MSI_OpenProductW(szProduct
, &package
);
164 if (r
!= ERROR_SUCCESS
)
167 *phProduct
= alloc_msihandle(&package
->hdr
);
169 r
= ERROR_NOT_ENOUGH_MEMORY
;
171 msiobj_release(&package
->hdr
);
175 UINT WINAPI
MsiAdvertiseProductA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
176 LPCSTR szTransforms
, LANGID lgidLanguage
)
178 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath
),
179 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
), lgidLanguage
);
180 return ERROR_CALL_NOT_IMPLEMENTED
;
183 UINT WINAPI
MsiAdvertiseProductW(LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
184 LPCWSTR szTransforms
, LANGID lgidLanguage
)
186 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath
),
187 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
), lgidLanguage
);
188 return ERROR_CALL_NOT_IMPLEMENTED
;
191 UINT WINAPI
MsiAdvertiseProductExA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
192 LPCSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
194 FIXME("%s %s %s %08x %08x %08x\n", debugstr_a(szPackagePath
),
195 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
),
196 lgidLanguage
, dwPlatform
, dwOptions
);
197 return ERROR_CALL_NOT_IMPLEMENTED
;
200 UINT WINAPI
MsiAdvertiseProductExW( LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
201 LPCWSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
203 FIXME("%s %s %s %08x %08x %08x\n", debugstr_w(szPackagePath
),
204 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
),
205 lgidLanguage
, dwPlatform
, dwOptions
);
206 return ERROR_CALL_NOT_IMPLEMENTED
;
209 UINT WINAPI
MsiInstallProductA(LPCSTR szPackagePath
, LPCSTR szCommandLine
)
211 LPWSTR szwPath
= NULL
, szwCommand
= NULL
;
212 UINT r
= ERROR_OUTOFMEMORY
;
214 TRACE("%s %s\n",debugstr_a(szPackagePath
), debugstr_a(szCommandLine
));
218 szwPath
= strdupAtoW( szPackagePath
);
225 szwCommand
= strdupAtoW( szCommandLine
);
230 r
= MsiInstallProductW( szwPath
, szwCommand
);
234 msi_free( szwCommand
);
239 UINT WINAPI
MsiInstallProductW(LPCWSTR szPackagePath
, LPCWSTR szCommandLine
)
241 MSIPACKAGE
*package
= NULL
;
244 TRACE("%s %s\n",debugstr_w(szPackagePath
), debugstr_w(szCommandLine
));
247 return ERROR_INVALID_PARAMETER
;
250 return ERROR_PATH_NOT_FOUND
;
252 r
= MSI_OpenPackageW( szPackagePath
, &package
);
253 if (r
== ERROR_SUCCESS
)
255 r
= MSI_InstallPackage( package
, szPackagePath
, szCommandLine
);
256 msiobj_release( &package
->hdr
);
262 UINT WINAPI
MsiReinstallProductA(LPCSTR szProduct
, DWORD dwReinstallMode
)
267 TRACE("%s %08x\n", debugstr_a(szProduct
), dwReinstallMode
);
269 wszProduct
= strdupAtoW(szProduct
);
271 rc
= MsiReinstallProductW(wszProduct
, dwReinstallMode
);
273 msi_free(wszProduct
);
277 UINT WINAPI
MsiReinstallProductW(LPCWSTR szProduct
, DWORD dwReinstallMode
)
279 TRACE("%s %08x\n", debugstr_w(szProduct
), dwReinstallMode
);
281 return MsiReinstallFeatureW(szProduct
, szAll
, dwReinstallMode
);
284 UINT WINAPI
MsiApplyPatchA(LPCSTR szPatchPackage
, LPCSTR szInstallPackage
,
285 INSTALLTYPE eInstallType
, LPCSTR szCommandLine
)
287 LPWSTR patch_package
= NULL
;
288 LPWSTR install_package
= NULL
;
289 LPWSTR command_line
= NULL
;
290 UINT r
= ERROR_OUTOFMEMORY
;
292 TRACE("%s %s %d %s\n", debugstr_a(szPatchPackage
), debugstr_a(szInstallPackage
),
293 eInstallType
, debugstr_a(szCommandLine
));
295 if (szPatchPackage
&& !(patch_package
= strdupAtoW(szPatchPackage
)))
298 if (szInstallPackage
&& !(install_package
= strdupAtoW(szInstallPackage
)))
301 if (szCommandLine
&& !(command_line
= strdupAtoW(szCommandLine
)))
304 r
= MsiApplyPatchW(patch_package
, install_package
, eInstallType
, command_line
);
307 msi_free(patch_package
);
308 msi_free(install_package
);
309 msi_free(command_line
);
314 static UINT
get_patch_product_codes( LPCWSTR szPatchPackage
, WCHAR
***product_codes
)
316 MSIHANDLE patch
, info
= 0;
319 static WCHAR empty
[] = {0};
322 r
= MsiOpenDatabaseW( szPatchPackage
, MSIDBOPEN_READONLY
, &patch
);
323 if (r
!= ERROR_SUCCESS
)
326 r
= MsiGetSummaryInformationW( patch
, NULL
, 0, &info
);
327 if (r
!= ERROR_SUCCESS
)
331 r
= MsiSummaryInfoGetPropertyW( info
, PID_TEMPLATE
, &type
, NULL
, NULL
, empty
, &size
);
332 if (r
!= ERROR_MORE_DATA
|| !size
|| type
!= VT_LPSTR
)
334 ERR("Failed to read product codes from patch\n");
335 r
= ERROR_FUNCTION_FAILED
;
339 codes
= msi_alloc( ++size
* sizeof(WCHAR
) );
342 r
= ERROR_OUTOFMEMORY
;
346 r
= MsiSummaryInfoGetPropertyW( info
, PID_TEMPLATE
, &type
, NULL
, NULL
, codes
, &size
);
347 if (r
== ERROR_SUCCESS
)
348 *product_codes
= msi_split_string( codes
, ';' );
351 MsiCloseHandle( info
);
352 MsiCloseHandle( patch
);
357 static UINT
MSI_ApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szProductCode
, LPCWSTR szCommandLine
)
359 UINT i
, r
= ERROR_FUNCTION_FAILED
;
361 LPCWSTR cmd_ptr
= szCommandLine
;
362 LPWSTR cmd
, *codes
= NULL
;
363 BOOL succeeded
= FALSE
;
365 static const WCHAR fmt
[] = {'%','s',' ','P','A','T','C','H','=','"','%','s','"',0};
366 static WCHAR empty
[] = {0};
368 if (!szPatchPackage
|| !szPatchPackage
[0])
369 return ERROR_INVALID_PARAMETER
;
371 if (!szProductCode
&& (r
= get_patch_product_codes( szPatchPackage
, &codes
)))
377 size
= strlenW(cmd_ptr
) + strlenW(fmt
) + strlenW(szPatchPackage
) + 1;
378 cmd
= msi_alloc(size
* sizeof(WCHAR
));
382 return ERROR_OUTOFMEMORY
;
384 sprintfW(cmd
, fmt
, cmd_ptr
, szPatchPackage
);
387 r
= MsiConfigureProductExW(szProductCode
, INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
390 for (i
= 0; codes
[i
]; i
++)
392 r
= MsiConfigureProductExW(codes
[i
], INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
393 if (r
== ERROR_SUCCESS
)
395 TRACE("patch applied\n");
409 UINT WINAPI
MsiApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szInstallPackage
,
410 INSTALLTYPE eInstallType
, LPCWSTR szCommandLine
)
412 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage
), debugstr_w(szInstallPackage
),
413 eInstallType
, debugstr_w(szCommandLine
));
415 if (szInstallPackage
|| eInstallType
== INSTALLTYPE_NETWORK_IMAGE
||
416 eInstallType
== INSTALLTYPE_SINGLE_INSTANCE
)
418 FIXME("Only reading target products from patch\n");
419 return ERROR_CALL_NOT_IMPLEMENTED
;
422 return MSI_ApplyPatchW(szPatchPackage
, NULL
, szCommandLine
);
425 UINT WINAPI
MsiApplyMultiplePatchesA(LPCSTR szPatchPackages
,
426 LPCSTR szProductCode
, LPCSTR szPropertiesList
)
428 LPWSTR patch_packages
= NULL
;
429 LPWSTR product_code
= NULL
;
430 LPWSTR properties_list
= NULL
;
431 UINT r
= ERROR_OUTOFMEMORY
;
433 TRACE("%s %s %s\n", debugstr_a(szPatchPackages
), debugstr_a(szProductCode
),
434 debugstr_a(szPropertiesList
));
436 if (!szPatchPackages
|| !szPatchPackages
[0])
437 return ERROR_INVALID_PARAMETER
;
439 if (!(patch_packages
= strdupAtoW(szPatchPackages
)))
440 return ERROR_OUTOFMEMORY
;
442 if (szProductCode
&& !(product_code
= strdupAtoW(szProductCode
)))
445 if (szPropertiesList
&& !(properties_list
= strdupAtoW(szPropertiesList
)))
448 r
= MsiApplyMultiplePatchesW(patch_packages
, product_code
, properties_list
);
451 msi_free(patch_packages
);
452 msi_free(product_code
);
453 msi_free(properties_list
);
458 UINT WINAPI
MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages
,
459 LPCWSTR szProductCode
, LPCWSTR szPropertiesList
)
461 UINT r
= ERROR_SUCCESS
;
464 TRACE("%s %s %s\n", debugstr_w(szPatchPackages
), debugstr_w(szProductCode
),
465 debugstr_w(szPropertiesList
));
467 if (!szPatchPackages
|| !szPatchPackages
[0])
468 return ERROR_INVALID_PARAMETER
;
470 beg
= end
= szPatchPackages
;
476 while (*beg
== ' ') beg
++;
477 while (*end
&& *end
!= ';') end
++;
480 while (len
&& beg
[len
- 1] == ' ') len
--;
482 if (!len
) return ERROR_INVALID_NAME
;
484 patch
= msi_alloc((len
+ 1) * sizeof(WCHAR
));
486 return ERROR_OUTOFMEMORY
;
488 memcpy(patch
, beg
, len
* sizeof(WCHAR
));
491 r
= MSI_ApplyPatchW(patch
, szProductCode
, szPropertiesList
);
494 if (r
!= ERROR_SUCCESS
)
502 static void free_patchinfo( DWORD count
, MSIPATCHSEQUENCEINFOW
*info
)
505 for (i
= 0; i
< count
; i
++) msi_free( (WCHAR
*)info
[i
].szPatchData
);
509 static MSIPATCHSEQUENCEINFOW
*patchinfoAtoW( DWORD count
, const MSIPATCHSEQUENCEINFOA
*info
)
512 MSIPATCHSEQUENCEINFOW
*ret
;
514 if (!(ret
= msi_alloc( count
* sizeof(MSIPATCHSEQUENCEINFOW
) ))) return NULL
;
515 for (i
= 0; i
< count
; i
++)
517 if (info
[i
].szPatchData
&& !(ret
[i
].szPatchData
= strdupAtoW( info
[i
].szPatchData
)))
519 free_patchinfo( i
, ret
);
522 ret
[i
].ePatchDataType
= info
[i
].ePatchDataType
;
523 ret
[i
].dwOrder
= info
[i
].dwOrder
;
524 ret
[i
].uStatus
= info
[i
].uStatus
;
529 UINT WINAPI
MsiDetermineApplicablePatchesA(LPCSTR szProductPackagePath
,
530 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOA pPatchInfo
)
533 WCHAR
*package_path
= NULL
;
534 MSIPATCHSEQUENCEINFOW
*psi
;
536 TRACE("%s, %u, %p\n", debugstr_a(szProductPackagePath
), cPatchInfo
, pPatchInfo
);
538 if (szProductPackagePath
&& !(package_path
= strdupAtoW( szProductPackagePath
)))
539 return ERROR_OUTOFMEMORY
;
541 if (!(psi
= patchinfoAtoW( cPatchInfo
, pPatchInfo
)))
543 msi_free( package_path
);
544 return ERROR_OUTOFMEMORY
;
546 r
= MsiDetermineApplicablePatchesW( package_path
, cPatchInfo
, psi
);
547 if (r
== ERROR_SUCCESS
)
549 for (i
= 0; i
< cPatchInfo
; i
++)
551 pPatchInfo
[i
].dwOrder
= psi
[i
].dwOrder
;
552 pPatchInfo
[i
].uStatus
= psi
[i
].uStatus
;
555 msi_free( package_path
);
556 free_patchinfo( cPatchInfo
, psi
);
560 static UINT
MSI_ApplicablePatchW( MSIPACKAGE
*package
, LPCWSTR patch
)
563 MSIDATABASE
*patch_db
;
564 UINT r
= ERROR_SUCCESS
;
566 r
= MSI_OpenDatabaseW( patch
, MSIDBOPEN_READONLY
, &patch_db
);
567 if (r
!= ERROR_SUCCESS
)
569 WARN("failed to open patch file %s\n", debugstr_w(patch
));
573 si
= MSI_GetSummaryInformationW( patch_db
->storage
, 0 );
576 msiobj_release( &patch_db
->hdr
);
577 return ERROR_FUNCTION_FAILED
;
580 r
= msi_check_patch_applicable( package
, si
);
581 if (r
!= ERROR_SUCCESS
)
582 TRACE("patch not applicable\n");
584 msiobj_release( &patch_db
->hdr
);
585 msiobj_release( &si
->hdr
);
589 /* IXMLDOMDocument should be set to XPath mode already */
590 static UINT
MSI_ApplicablePatchXML( MSIPACKAGE
*package
, IXMLDOMDocument
*desc
)
592 static const WCHAR queryW
[] = {'M','s','i','P','a','t','c','h','/',
593 'T','a','r','g','e','t','P','r','o','d','u','c','t','/',
594 'T','a','r','g','e','t','P','r','o','d','u','c','t','C','o','d','e',0};
595 UINT r
= ERROR_FUNCTION_FAILED
;
596 IXMLDOMNodeList
*list
;
602 product_code
= msi_dup_property( package
->db
, szProductCode
);
605 /* FIXME: the property ProductCode should be written into the DB somewhere */
606 ERR("no product code to check\n");
607 return ERROR_SUCCESS
;
610 s
= SysAllocString(queryW
);
611 hr
= IXMLDOMDocument_selectNodes( desc
, s
, &list
);
614 return ERROR_INVALID_PATCH_XML
;
616 while (IXMLDOMNodeList_nextNode( list
, &node
) == S_OK
&& r
!= ERROR_SUCCESS
)
618 hr
= IXMLDOMNode_get_text( node
, &s
);
619 IXMLDOMNode_Release( node
);
622 if (!strcmpW( s
, product_code
)) r
= ERROR_SUCCESS
;
626 IXMLDOMNodeList_Release( list
);
628 if (r
!= ERROR_SUCCESS
)
629 TRACE("patch not applicable\n");
631 msi_free( product_code
);
635 static UINT
determine_patch_sequence( MSIPACKAGE
*package
, DWORD count
, MSIPATCHSEQUENCEINFOW
*info
)
637 IXMLDOMDocument
*desc
= NULL
;
641 FIXME("patch ordering not supported\n");
643 for (i
= 0; i
< count
; i
++)
645 switch (info
[i
].ePatchDataType
)
647 case MSIPATCH_DATATYPE_PATCHFILE
:
649 if (MSI_ApplicablePatchW( package
, info
[i
].szPatchData
) != ERROR_SUCCESS
)
651 info
[i
].dwOrder
= ~0u;
652 info
[i
].uStatus
= ERROR_PATCH_TARGET_NOT_FOUND
;
657 info
[i
].uStatus
= ERROR_SUCCESS
;
661 case MSIPATCH_DATATYPE_XMLPATH
:
662 case MSIPATCH_DATATYPE_XMLBLOB
:
670 hr
= CoCreateInstance( &CLSID_DOMDocument30
, NULL
, CLSCTX_INPROC_SERVER
,
671 &IID_IXMLDOMDocument
, (void**)&desc
);
674 ERR("failed to create DOMDocument30 instance, 0x%08x\n", hr
);
675 return ERROR_FUNCTION_FAILED
;
679 s
= SysAllocString( info
[i
].szPatchData
);
680 if (info
[i
].ePatchDataType
== MSIPATCH_DATATYPE_XMLPATH
)
684 V_VT(&src
) = VT_BSTR
;
686 hr
= IXMLDOMDocument_load( desc
, src
, &b
);
689 hr
= IXMLDOMDocument_loadXML( desc
, s
, &b
);
693 ERR("failed to parse patch description\n");
694 IXMLDOMDocument_Release( desc
);
698 if (MSI_ApplicablePatchXML( package
, desc
) != ERROR_SUCCESS
)
700 info
[i
].dwOrder
= ~0u;
701 info
[i
].uStatus
= ERROR_PATCH_TARGET_NOT_FOUND
;
706 info
[i
].uStatus
= ERROR_SUCCESS
;
712 FIXME("unknown patch data type %u\n", info
[i
].ePatchDataType
);
714 info
[i
].uStatus
= ERROR_SUCCESS
;
719 TRACE("szPatchData: %s\n", debugstr_w(info
[i
].szPatchData
));
720 TRACE("ePatchDataType: %u\n", info
[i
].ePatchDataType
);
721 TRACE("dwOrder: %u\n", info
[i
].dwOrder
);
722 TRACE("uStatus: %u\n", info
[i
].uStatus
);
725 if (desc
) IXMLDOMDocument_Release( desc
);
727 return ERROR_SUCCESS
;
730 UINT WINAPI
MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath
,
731 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOW pPatchInfo
)
736 TRACE("%s, %u, %p\n", debugstr_w(szProductPackagePath
), cPatchInfo
, pPatchInfo
);
738 r
= MSI_OpenPackageW( szProductPackagePath
, &package
);
739 if (r
!= ERROR_SUCCESS
)
741 ERR("failed to open package %u\n", r
);
744 r
= determine_patch_sequence( package
, cPatchInfo
, pPatchInfo
);
745 msiobj_release( &package
->hdr
);
749 UINT WINAPI
MsiDeterminePatchSequenceA( LPCSTR product
, LPCSTR usersid
,
750 MSIINSTALLCONTEXT context
, DWORD count
, PMSIPATCHSEQUENCEINFOA patchinfo
)
753 WCHAR
*productW
, *usersidW
= NULL
;
754 MSIPATCHSEQUENCEINFOW
*patchinfoW
;
756 TRACE("%s, %s, %d, %d, %p\n", debugstr_a(product
), debugstr_a(usersid
),
757 context
, count
, patchinfo
);
759 if (!product
) return ERROR_INVALID_PARAMETER
;
760 if (!(productW
= strdupAtoW( product
))) return ERROR_OUTOFMEMORY
;
761 if (usersid
&& !(usersidW
= strdupAtoW( usersid
)))
763 msi_free( productW
);
764 return ERROR_OUTOFMEMORY
;
766 if (!(patchinfoW
= patchinfoAtoW( count
, patchinfo
)))
768 msi_free( productW
);
769 msi_free( usersidW
);
770 return ERROR_OUTOFMEMORY
;
772 r
= MsiDeterminePatchSequenceW( productW
, usersidW
, context
, count
, patchinfoW
);
773 if (r
== ERROR_SUCCESS
)
775 for (i
= 0; i
< count
; i
++)
777 patchinfo
[i
].dwOrder
= patchinfoW
[i
].dwOrder
;
778 patchinfo
[i
].uStatus
= patchinfoW
[i
].uStatus
;
781 msi_free( productW
);
782 msi_free( usersidW
);
783 free_patchinfo( count
, patchinfoW
);
787 static UINT
open_package( const WCHAR
*product
, const WCHAR
*usersid
,
788 MSIINSTALLCONTEXT context
, MSIPACKAGE
**package
)
792 WCHAR
*localpath
, sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
794 r
= MSIREG_OpenInstallProps( product
, context
, usersid
, &props
, FALSE
);
795 if (r
!= ERROR_SUCCESS
) return ERROR_BAD_CONFIGURATION
;
797 if ((localpath
= msi_reg_get_val_str( props
, szLocalPackage
)))
799 strcpyW( sourcepath
, localpath
);
800 msi_free( localpath
);
802 RegCloseKey( props
);
803 if (!localpath
|| GetFileAttributesW( sourcepath
) == INVALID_FILE_ATTRIBUTES
)
805 DWORD sz
= sizeof(sourcepath
);
806 MsiSourceListGetInfoW( product
, usersid
, context
, MSICODE_PRODUCT
,
807 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
808 sz
= sizeof(filename
);
809 MsiSourceListGetInfoW( product
, usersid
, context
, MSICODE_PRODUCT
,
810 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
811 strcatW( sourcepath
, filename
);
813 if (GetFileAttributesW( sourcepath
) == INVALID_FILE_ATTRIBUTES
)
814 return ERROR_INSTALL_SOURCE_ABSENT
;
816 return MSI_OpenPackageW( sourcepath
, package
);
819 UINT WINAPI
MsiDeterminePatchSequenceW( LPCWSTR product
, LPCWSTR usersid
,
820 MSIINSTALLCONTEXT context
, DWORD count
, PMSIPATCHSEQUENCEINFOW patchinfo
)
825 TRACE("%s, %s, %d, %d, %p\n", debugstr_w(product
), debugstr_w(usersid
),
826 context
, count
, patchinfo
);
828 if (!product
) return ERROR_INVALID_PARAMETER
;
829 r
= open_package( product
, usersid
, context
, &package
);
830 if (r
!= ERROR_SUCCESS
) return r
;
832 r
= determine_patch_sequence( package
, count
, patchinfo
);
833 msiobj_release( &package
->hdr
);
837 UINT WINAPI
MsiConfigureProductExW(LPCWSTR szProduct
, int iInstallLevel
,
838 INSTALLSTATE eInstallState
, LPCWSTR szCommandLine
)
840 MSIPACKAGE
* package
= NULL
;
841 MSIINSTALLCONTEXT context
;
844 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
847 static const WCHAR szInstalled
[] = {
848 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
849 static const WCHAR szMaxInstallLevel
[] = {
850 ' ','I','N','S','T','A','L','L','L','E','V','E','L','=','3','2','7','6','7',0};
851 static const WCHAR szRemoveAll
[] = {
852 ' ','R','E','M','O','V','E','=','A','L','L',0};
853 static const WCHAR szMachine
[] = {
854 ' ','A','L','L','U','S','E','R','S','=','1',0};
856 TRACE("%s %d %d %s\n",debugstr_w(szProduct
), iInstallLevel
, eInstallState
,
857 debugstr_w(szCommandLine
));
859 if (!szProduct
|| lstrlenW(szProduct
) != GUID_SIZE
- 1)
860 return ERROR_INVALID_PARAMETER
;
862 if (eInstallState
== INSTALLSTATE_ADVERTISED
||
863 eInstallState
== INSTALLSTATE_SOURCE
)
865 FIXME("State %d not implemented\n", eInstallState
);
866 return ERROR_CALL_NOT_IMPLEMENTED
;
869 r
= msi_locate_product(szProduct
, &context
);
870 if (r
!= ERROR_SUCCESS
)
873 r
= open_package(szProduct
, NULL
, context
, &package
);
874 if (r
!= ERROR_SUCCESS
)
877 sz
= lstrlenW(szInstalled
) + 1;
880 sz
+= lstrlenW(szCommandLine
);
882 if (eInstallState
!= INSTALLSTATE_DEFAULT
)
883 sz
+= lstrlenW(szMaxInstallLevel
);
885 if (eInstallState
== INSTALLSTATE_ABSENT
)
886 sz
+= lstrlenW(szRemoveAll
);
888 if (context
== MSIINSTALLCONTEXT_MACHINE
)
889 sz
+= lstrlenW(szMachine
);
891 commandline
= msi_alloc(sz
* sizeof(WCHAR
));
894 r
= ERROR_OUTOFMEMORY
;
900 lstrcpyW(commandline
,szCommandLine
);
902 if (eInstallState
!= INSTALLSTATE_DEFAULT
)
903 lstrcatW(commandline
, szMaxInstallLevel
);
905 if (eInstallState
== INSTALLSTATE_ABSENT
)
906 lstrcatW(commandline
, szRemoveAll
);
908 if (context
== MSIINSTALLCONTEXT_MACHINE
)
909 lstrcatW(commandline
, szMachine
);
911 sz
= sizeof(sourcepath
);
912 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
913 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
915 sz
= sizeof(filename
);
916 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
917 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
919 strcatW(sourcepath
, filename
);
921 r
= MSI_InstallPackage( package
, sourcepath
, commandline
);
923 msi_free(commandline
);
926 msiobj_release( &package
->hdr
);
931 UINT WINAPI
MsiConfigureProductExA(LPCSTR szProduct
, int iInstallLevel
,
932 INSTALLSTATE eInstallState
, LPCSTR szCommandLine
)
934 LPWSTR szwProduct
= NULL
;
935 LPWSTR szwCommandLine
= NULL
;
936 UINT r
= ERROR_OUTOFMEMORY
;
940 szwProduct
= strdupAtoW( szProduct
);
947 szwCommandLine
= strdupAtoW( szCommandLine
);
952 r
= MsiConfigureProductExW( szwProduct
, iInstallLevel
, eInstallState
,
955 msi_free( szwProduct
);
956 msi_free( szwCommandLine
);
961 UINT WINAPI
MsiConfigureProductA(LPCSTR szProduct
, int iInstallLevel
,
962 INSTALLSTATE eInstallState
)
964 LPWSTR szwProduct
= NULL
;
967 TRACE("%s %d %d\n",debugstr_a(szProduct
), iInstallLevel
, eInstallState
);
971 szwProduct
= strdupAtoW( szProduct
);
973 return ERROR_OUTOFMEMORY
;
976 r
= MsiConfigureProductW( szwProduct
, iInstallLevel
, eInstallState
);
977 msi_free( szwProduct
);
982 UINT WINAPI
MsiConfigureProductW(LPCWSTR szProduct
, int iInstallLevel
,
983 INSTALLSTATE eInstallState
)
985 return MsiConfigureProductExW(szProduct
, iInstallLevel
, eInstallState
, NULL
);
988 UINT WINAPI
MsiGetProductCodeA(LPCSTR szComponent
, LPSTR szBuffer
)
990 LPWSTR szwComponent
= NULL
;
992 WCHAR szwBuffer
[GUID_SIZE
];
994 TRACE("%s %p\n", debugstr_a(szComponent
), szBuffer
);
998 szwComponent
= strdupAtoW( szComponent
);
1000 return ERROR_OUTOFMEMORY
;
1004 r
= MsiGetProductCodeW( szwComponent
, szwBuffer
);
1007 WideCharToMultiByte(CP_ACP
, 0, szwBuffer
, -1, szBuffer
, GUID_SIZE
, NULL
, NULL
);
1009 msi_free( szwComponent
);
1014 UINT WINAPI
MsiGetProductCodeW(LPCWSTR szComponent
, LPWSTR szBuffer
)
1017 HKEY compkey
, prodkey
;
1018 WCHAR squished_comp
[GUID_SIZE
];
1019 WCHAR squished_prod
[GUID_SIZE
];
1020 DWORD sz
= GUID_SIZE
;
1022 TRACE("%s %p\n", debugstr_w(szComponent
), szBuffer
);
1024 if (!szComponent
|| !*szComponent
)
1025 return ERROR_INVALID_PARAMETER
;
1027 if (!squash_guid(szComponent
, squished_comp
))
1028 return ERROR_INVALID_PARAMETER
;
1030 if (MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &compkey
, FALSE
) != ERROR_SUCCESS
&&
1031 MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &compkey
, FALSE
) != ERROR_SUCCESS
)
1033 return ERROR_UNKNOWN_COMPONENT
;
1036 rc
= RegEnumValueW(compkey
, 0, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
1037 if (rc
!= ERROR_SUCCESS
)
1039 RegCloseKey(compkey
);
1040 return ERROR_UNKNOWN_COMPONENT
;
1043 /* check simple case, only one product */
1044 rc
= RegEnumValueW(compkey
, 1, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
1045 if (rc
== ERROR_NO_MORE_ITEMS
)
1052 while ((rc
= RegEnumValueW(compkey
, index
, squished_prod
, &sz
,
1053 NULL
, NULL
, NULL
, NULL
)) != ERROR_NO_MORE_ITEMS
)
1057 unsquash_guid(squished_prod
, szBuffer
);
1059 if (MSIREG_OpenProductKey(szBuffer
, NULL
,
1060 MSIINSTALLCONTEXT_USERMANAGED
,
1061 &prodkey
, FALSE
) == ERROR_SUCCESS
||
1062 MSIREG_OpenProductKey(szBuffer
, NULL
,
1063 MSIINSTALLCONTEXT_USERUNMANAGED
,
1064 &prodkey
, FALSE
) == ERROR_SUCCESS
||
1065 MSIREG_OpenProductKey(szBuffer
, NULL
,
1066 MSIINSTALLCONTEXT_MACHINE
,
1067 &prodkey
, FALSE
) == ERROR_SUCCESS
)
1069 RegCloseKey(prodkey
);
1075 rc
= ERROR_INSTALL_FAILURE
;
1078 RegCloseKey(compkey
);
1079 unsquash_guid(squished_prod
, szBuffer
);
1083 static LPWSTR
msi_reg_get_value(HKEY hkey
, LPCWSTR name
, DWORD
*type
)
1089 static const WCHAR format
[] = {'%','d',0};
1091 res
= RegQueryValueExW(hkey
, name
, NULL
, type
, NULL
, NULL
);
1092 if (res
!= ERROR_SUCCESS
)
1095 if (*type
== REG_SZ
)
1096 return msi_reg_get_val_str(hkey
, name
);
1098 if (!msi_reg_get_val_dword(hkey
, name
, &dval
))
1101 sprintfW(temp
, format
, dval
);
1102 return strdupW(temp
);
1105 static UINT
MSI_GetProductInfo(LPCWSTR szProduct
, LPCWSTR szAttribute
,
1106 awstring
*szValue
, LPDWORD pcchValueBuf
)
1108 static WCHAR empty
[] = {0};
1109 static const WCHAR sourcelist
[] = {'S','o','u','r','c','e','L','i','s','t',0};
1110 static const WCHAR display_name
[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
1111 static const WCHAR display_version
[] = {'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1112 static const WCHAR assignment
[] = {'A','s','s','i','g','n','m','e','n','t',0};
1113 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
1114 UINT r
= ERROR_UNKNOWN_PROPERTY
;
1115 HKEY prodkey
, userdata
, source
;
1117 WCHAR squished_pc
[GUID_SIZE
];
1118 WCHAR packagecode
[GUID_SIZE
];
1119 BOOL badconfig
= FALSE
;
1121 DWORD type
= REG_NONE
;
1123 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
1124 debugstr_w(szAttribute
), szValue
, pcchValueBuf
);
1126 if ((szValue
->str
.w
&& !pcchValueBuf
) || !szProduct
|| !szAttribute
)
1127 return ERROR_INVALID_PARAMETER
;
1129 if (!squash_guid(szProduct
, squished_pc
))
1130 return ERROR_INVALID_PARAMETER
;
1132 if ((r
= MSIREG_OpenProductKey(szProduct
, NULL
,
1133 MSIINSTALLCONTEXT_USERMANAGED
,
1134 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
1135 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
1136 MSIINSTALLCONTEXT_USERUNMANAGED
,
1137 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
1138 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
1139 MSIINSTALLCONTEXT_MACHINE
,
1140 &prodkey
, FALSE
)) == ERROR_SUCCESS
)
1142 context
= MSIINSTALLCONTEXT_MACHINE
;
1145 MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
1147 if (!strcmpW( szAttribute
, INSTALLPROPERTY_HELPLINKW
) ||
1148 !strcmpW( szAttribute
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
1149 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLDATEW
) ||
1150 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
1151 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
1152 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
1153 !strcmpW( szAttribute
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
1154 !strcmpW( szAttribute
, INSTALLPROPERTY_PUBLISHERW
) ||
1155 !strcmpW( szAttribute
, INSTALLPROPERTY_URLINFOABOUTW
) ||
1156 !strcmpW( szAttribute
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
1157 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONMINORW
) ||
1158 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONMAJORW
) ||
1159 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
1160 !strcmpW( szAttribute
, INSTALLPROPERTY_PRODUCTIDW
) ||
1161 !strcmpW( szAttribute
, INSTALLPROPERTY_REGCOMPANYW
) ||
1162 !strcmpW( szAttribute
, INSTALLPROPERTY_REGOWNERW
))
1166 r
= ERROR_UNKNOWN_PRODUCT
;
1171 return ERROR_UNKNOWN_PROPERTY
;
1173 if (!strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
1174 szAttribute
= display_name
;
1175 else if (!strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
))
1176 szAttribute
= display_version
;
1178 val
= msi_reg_get_value(userdata
, szAttribute
, &type
);
1182 else if (!strcmpW( szAttribute
, INSTALLPROPERTY_INSTANCETYPEW
) ||
1183 !strcmpW( szAttribute
, INSTALLPROPERTY_TRANSFORMSW
) ||
1184 !strcmpW( szAttribute
, INSTALLPROPERTY_LANGUAGEW
) ||
1185 !strcmpW( szAttribute
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
1186 !strcmpW( szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
) ||
1187 !strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGECODEW
) ||
1188 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONW
) ||
1189 !strcmpW( szAttribute
, INSTALLPROPERTY_PRODUCTICONW
) ||
1190 !strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
) ||
1191 !strcmpW( szAttribute
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
1195 r
= ERROR_UNKNOWN_PRODUCT
;
1199 if (!strcmpW( szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
1200 szAttribute
= assignment
;
1202 if (!strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
))
1204 res
= RegOpenKeyW(prodkey
, sourcelist
, &source
);
1205 if (res
!= ERROR_SUCCESS
)
1207 r
= ERROR_UNKNOWN_PRODUCT
;
1211 val
= msi_reg_get_value(source
, szAttribute
, &type
);
1215 RegCloseKey(source
);
1219 val
= msi_reg_get_value(prodkey
, szAttribute
, &type
);
1224 if (val
!= empty
&& type
!= REG_DWORD
&&
1225 !strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGECODEW
))
1227 if (lstrlenW(val
) != SQUISH_GUID_SIZE
- 1)
1231 unsquash_guid(val
, packagecode
);
1233 val
= strdupW(packagecode
);
1240 r
= ERROR_UNKNOWN_PROPERTY
;
1246 int len
= strlenW( val
);
1248 /* If szBuffer (szValue->str) is NULL, there's no need to copy the value
1249 * out. Also, *pcchValueBuf may be uninitialized in this case, so we
1250 * can't rely on its value.
1252 if (szValue
->str
.a
|| szValue
->str
.w
)
1254 DWORD size
= *pcchValueBuf
;
1256 r
= msi_strcpy_to_awstring( val
, len
, szValue
, &size
);
1258 r
= ERROR_MORE_DATA
;
1262 *pcchValueBuf
= len
;
1266 r
= ERROR_BAD_CONFIGURATION
;
1272 RegCloseKey(prodkey
);
1273 RegCloseKey(userdata
);
1277 UINT WINAPI
MsiGetProductInfoA(LPCSTR szProduct
, LPCSTR szAttribute
,
1278 LPSTR szBuffer
, LPDWORD pcchValueBuf
)
1280 LPWSTR szwProduct
, szwAttribute
= NULL
;
1281 UINT r
= ERROR_OUTOFMEMORY
;
1284 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szAttribute
),
1285 szBuffer
, pcchValueBuf
);
1287 szwProduct
= strdupAtoW( szProduct
);
1288 if( szProduct
&& !szwProduct
)
1291 szwAttribute
= strdupAtoW( szAttribute
);
1292 if( szAttribute
&& !szwAttribute
)
1295 buffer
.unicode
= FALSE
;
1296 buffer
.str
.a
= szBuffer
;
1298 r
= MSI_GetProductInfo( szwProduct
, szwAttribute
,
1299 &buffer
, pcchValueBuf
);
1302 msi_free( szwProduct
);
1303 msi_free( szwAttribute
);
1308 UINT WINAPI
MsiGetProductInfoW(LPCWSTR szProduct
, LPCWSTR szAttribute
,
1309 LPWSTR szBuffer
, LPDWORD pcchValueBuf
)
1313 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szAttribute
),
1314 szBuffer
, pcchValueBuf
);
1316 buffer
.unicode
= TRUE
;
1317 buffer
.str
.w
= szBuffer
;
1319 return MSI_GetProductInfo( szProduct
, szAttribute
,
1320 &buffer
, pcchValueBuf
);
1323 UINT WINAPI
MsiGetProductInfoExA(LPCSTR szProductCode
, LPCSTR szUserSid
,
1324 MSIINSTALLCONTEXT dwContext
, LPCSTR szProperty
,
1325 LPSTR szValue
, LPDWORD pcchValue
)
1327 LPWSTR product
= NULL
;
1328 LPWSTR usersid
= NULL
;
1329 LPWSTR property
= NULL
;
1330 LPWSTR value
= NULL
;
1334 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_a(szProductCode
),
1335 debugstr_a(szUserSid
), dwContext
, debugstr_a(szProperty
),
1336 szValue
, pcchValue
);
1338 if (szValue
&& !pcchValue
)
1339 return ERROR_INVALID_PARAMETER
;
1341 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1342 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1343 if (szProperty
) property
= strdupAtoW(szProperty
);
1345 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1347 if (r
!= ERROR_SUCCESS
)
1350 value
= msi_alloc(++len
* sizeof(WCHAR
));
1353 r
= ERROR_OUTOFMEMORY
;
1357 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1359 if (r
!= ERROR_SUCCESS
)
1365 len
= WideCharToMultiByte(CP_ACP
, 0, value
, -1, NULL
, 0, NULL
, NULL
);
1366 if (*pcchValue
>= len
)
1367 WideCharToMultiByte(CP_ACP
, 0, value
, -1, szValue
, len
, NULL
, NULL
);
1370 r
= ERROR_MORE_DATA
;
1375 if (*pcchValue
<= len
|| !szValue
)
1376 len
= len
* sizeof(WCHAR
) - 1;
1378 *pcchValue
= len
- 1;
1389 static UINT
msi_copy_outval(LPWSTR val
, LPWSTR out
, LPDWORD size
)
1391 UINT r
= ERROR_SUCCESS
;
1394 return ERROR_UNKNOWN_PROPERTY
;
1398 if (strlenW(val
) >= *size
)
1400 r
= ERROR_MORE_DATA
;
1409 *size
= lstrlenW(val
);
1414 UINT WINAPI
MsiGetProductInfoExW(LPCWSTR szProductCode
, LPCWSTR szUserSid
,
1415 MSIINSTALLCONTEXT dwContext
, LPCWSTR szProperty
,
1416 LPWSTR szValue
, LPDWORD pcchValue
)
1418 WCHAR squished_pc
[GUID_SIZE
];
1420 LPCWSTR package
= NULL
;
1421 HKEY props
= NULL
, prod
;
1422 HKEY classes
= NULL
, managed
;
1425 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1427 static const WCHAR five
[] = {'5',0};
1428 static const WCHAR displayname
[] = {
1429 'D','i','s','p','l','a','y','N','a','m','e',0};
1430 static const WCHAR displayversion
[] = {
1431 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1432 static const WCHAR managed_local_package
[] = {
1433 'M','a','n','a','g','e','d','L','o','c','a','l',
1434 'P','a','c','k','a','g','e',0};
1436 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_w(szProductCode
),
1437 debugstr_w(szUserSid
), dwContext
, debugstr_w(szProperty
),
1438 szValue
, pcchValue
);
1440 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1441 return ERROR_INVALID_PARAMETER
;
1443 if (szValue
&& !pcchValue
)
1444 return ERROR_INVALID_PARAMETER
;
1446 if (dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1447 dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1448 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1449 return ERROR_INVALID_PARAMETER
;
1451 if (!szProperty
|| !*szProperty
)
1452 return ERROR_INVALID_PARAMETER
;
1454 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1455 return ERROR_INVALID_PARAMETER
;
1457 /* FIXME: dwContext is provided, no need to search for it */
1458 MSIREG_OpenProductKey(szProductCode
, NULL
,MSIINSTALLCONTEXT_USERMANAGED
,
1460 MSIREG_OpenProductKey(szProductCode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1463 MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
, &props
, FALSE
);
1465 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1467 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1469 if (!props
&& !prod
)
1472 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1474 package
= managed_local_package
;
1476 if (!props
&& !managed
)
1479 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1481 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1482 MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
, &classes
, FALSE
);
1484 if (!props
&& !classes
)
1488 if (!strcmpW( szProperty
, INSTALLPROPERTY_HELPLINKW
) ||
1489 !strcmpW( szProperty
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
1490 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLDATEW
) ||
1491 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
1492 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
1493 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
1494 !strcmpW( szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
1495 !strcmpW( szProperty
, INSTALLPROPERTY_PUBLISHERW
) ||
1496 !strcmpW( szProperty
, INSTALLPROPERTY_URLINFOABOUTW
) ||
1497 !strcmpW( szProperty
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
1498 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONMINORW
) ||
1499 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONMAJORW
) ||
1500 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
1501 !strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTIDW
) ||
1502 !strcmpW( szProperty
, INSTALLPROPERTY_REGCOMPANYW
) ||
1503 !strcmpW( szProperty
, INSTALLPROPERTY_REGOWNERW
) ||
1504 !strcmpW( szProperty
, INSTALLPROPERTY_INSTANCETYPEW
))
1506 val
= msi_reg_get_value(props
, package
, &type
);
1509 if (prod
|| classes
)
1510 r
= ERROR_UNKNOWN_PROPERTY
;
1517 if (!strcmpW( szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
1518 szProperty
= displayname
;
1519 else if (!strcmpW( szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
))
1520 szProperty
= displayversion
;
1522 val
= msi_reg_get_value(props
, szProperty
, &type
);
1524 val
= strdupW(szEmpty
);
1526 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1528 else if (!strcmpW( szProperty
, INSTALLPROPERTY_TRANSFORMSW
) ||
1529 !strcmpW( szProperty
, INSTALLPROPERTY_LANGUAGEW
) ||
1530 !strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
1531 !strcmpW( szProperty
, INSTALLPROPERTY_PACKAGECODEW
) ||
1532 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONW
) ||
1533 !strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTICONW
) ||
1534 !strcmpW( szProperty
, INSTALLPROPERTY_PACKAGENAMEW
) ||
1535 !strcmpW( szProperty
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
1537 if (!prod
&& !classes
)
1540 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1542 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1544 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1547 val
= msi_reg_get_value(hkey
, szProperty
, &type
);
1549 val
= strdupW(szEmpty
);
1551 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1553 else if (!strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTSTATEW
))
1555 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1559 val
= msi_reg_get_value(props
, package
, &type
);
1564 val
= strdupW(five
);
1567 val
= strdupW(szOne
);
1569 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1572 else if (props
&& (val
= msi_reg_get_value(props
, package
, &type
)))
1575 val
= strdupW(five
);
1576 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1580 if (prod
|| managed
)
1581 val
= strdupW(szOne
);
1585 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1587 else if (!strcmpW( szProperty
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
1589 if (!prod
&& !classes
)
1593 val
= strdupW(szEmpty
);
1594 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1597 r
= ERROR_UNKNOWN_PROPERTY
;
1602 RegCloseKey(managed
);
1603 RegCloseKey(classes
);
1609 UINT WINAPI
MsiGetPatchInfoExA(LPCSTR szPatchCode
, LPCSTR szProductCode
,
1610 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1611 LPCSTR szProperty
, LPSTR lpValue
, DWORD
*pcchValue
)
1613 LPWSTR patch
= NULL
, product
= NULL
, usersid
= NULL
;
1614 LPWSTR property
= NULL
, val
= NULL
;
1618 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_a(szPatchCode
),
1619 debugstr_a(szProductCode
), debugstr_a(szUserSid
), dwContext
,
1620 debugstr_a(szProperty
), lpValue
, pcchValue
);
1622 if (lpValue
&& !pcchValue
)
1623 return ERROR_INVALID_PARAMETER
;
1625 if (szPatchCode
) patch
= strdupAtoW(szPatchCode
);
1626 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1627 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1628 if (szProperty
) property
= strdupAtoW(szProperty
);
1631 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1633 if (r
!= ERROR_SUCCESS
)
1636 val
= msi_alloc(++len
* sizeof(WCHAR
));
1639 r
= ERROR_OUTOFMEMORY
;
1643 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1645 if (r
!= ERROR_SUCCESS
|| !pcchValue
)
1649 WideCharToMultiByte(CP_ACP
, 0, val
, -1, lpValue
,
1650 *pcchValue
- 1, NULL
, NULL
);
1652 len
= lstrlenW(val
);
1653 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1657 r
= ERROR_MORE_DATA
;
1658 lpValue
[*pcchValue
- 1] = '\0';
1661 *pcchValue
= len
* sizeof(WCHAR
);
1676 UINT WINAPI
MsiGetPatchInfoExW(LPCWSTR szPatchCode
, LPCWSTR szProductCode
,
1677 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1678 LPCWSTR szProperty
, LPWSTR lpValue
, DWORD
*pcchValue
)
1680 WCHAR squished_pc
[GUID_SIZE
];
1681 WCHAR squished_patch
[GUID_SIZE
];
1682 HKEY udprod
= 0, prod
= 0, props
= 0;
1683 HKEY patch
= 0, patches
= 0;
1684 HKEY udpatch
= 0, datakey
= 0;
1685 HKEY prodpatches
= 0;
1687 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1691 static const WCHAR szManagedPackage
[] = {'M','a','n','a','g','e','d',
1692 'L','o','c','a','l','P','a','c','k','a','g','e',0};
1694 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_w(szPatchCode
),
1695 debugstr_w(szProductCode
), debugstr_w(szUserSid
), dwContext
,
1696 debugstr_w(szProperty
), lpValue
, pcchValue
);
1698 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1699 return ERROR_INVALID_PARAMETER
;
1701 if (!szPatchCode
|| !squash_guid(szPatchCode
, squished_patch
))
1702 return ERROR_INVALID_PARAMETER
;
1705 return ERROR_INVALID_PARAMETER
;
1707 if (lpValue
&& !pcchValue
)
1708 return ERROR_INVALID_PARAMETER
;
1710 if (dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1711 dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1712 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1713 return ERROR_INVALID_PARAMETER
;
1715 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1716 return ERROR_INVALID_PARAMETER
;
1718 if (szUserSid
&& !strcmpW( szUserSid
, szLocalSid
))
1719 return ERROR_INVALID_PARAMETER
;
1721 if (MSIREG_OpenUserDataProductKey(szProductCode
, dwContext
, NULL
,
1722 &udprod
, FALSE
) != ERROR_SUCCESS
)
1725 if (MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
,
1726 &props
, FALSE
) != ERROR_SUCCESS
)
1729 r
= ERROR_UNKNOWN_PATCH
;
1731 res
= RegOpenKeyExW(udprod
, szPatches
, 0, KEY_WOW64_64KEY
|KEY_READ
, &patches
);
1732 if (res
!= ERROR_SUCCESS
)
1735 res
= RegOpenKeyExW(patches
, squished_patch
, 0, KEY_WOW64_64KEY
|KEY_READ
, &patch
);
1736 if (res
!= ERROR_SUCCESS
)
1739 if (!strcmpW( szProperty
, INSTALLPROPERTY_TRANSFORMSW
))
1741 if (MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
,
1742 &prod
, FALSE
) != ERROR_SUCCESS
)
1745 res
= RegOpenKeyExW(prod
, szPatches
, 0, KEY_WOW64_64KEY
|KEY_ALL_ACCESS
, &prodpatches
);
1746 if (res
!= ERROR_SUCCESS
)
1749 datakey
= prodpatches
;
1750 szProperty
= squished_patch
;
1754 if (MSIREG_OpenUserDataPatchKey(szPatchCode
, dwContext
,
1755 &udpatch
, FALSE
) != ERROR_SUCCESS
)
1758 if (!strcmpW( szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1760 if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1761 szProperty
= szManagedPackage
;
1764 else if (!strcmpW( szProperty
, INSTALLPROPERTY_INSTALLDATEW
))
1767 szProperty
= szInstalled
;
1769 else if (!strcmpW( szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1773 else if (!strcmpW( szProperty
, INSTALLPROPERTY_UNINSTALLABLEW
) ||
1774 !strcmpW( szProperty
, INSTALLPROPERTY_PATCHSTATEW
) ||
1775 !strcmpW( szProperty
, INSTALLPROPERTY_DISPLAYNAMEW
) ||
1776 !strcmpW( szProperty
, INSTALLPROPERTY_MOREINFOURLW
))
1782 r
= ERROR_UNKNOWN_PROPERTY
;
1787 val
= msi_reg_get_val_str(datakey
, szProperty
);
1789 val
= strdupW(szEmpty
);
1797 lstrcpynW(lpValue
, val
, *pcchValue
);
1799 len
= lstrlenW(val
);
1800 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1803 r
= ERROR_MORE_DATA
;
1805 *pcchValue
= len
* sizeof(WCHAR
);
1812 RegCloseKey(prodpatches
);
1815 RegCloseKey(patches
);
1816 RegCloseKey(udpatch
);
1818 RegCloseKey(udprod
);
1823 UINT WINAPI
MsiGetPatchInfoA( LPCSTR patch
, LPCSTR attr
, LPSTR buffer
, LPDWORD buflen
)
1825 UINT r
= ERROR_OUTOFMEMORY
;
1827 LPWSTR patchW
= NULL
, attrW
= NULL
, bufferW
= NULL
;
1829 TRACE("%s %s %p %p\n", debugstr_a(patch
), debugstr_a(attr
), buffer
, buflen
);
1831 if (!patch
|| !attr
)
1832 return ERROR_INVALID_PARAMETER
;
1834 if (!(patchW
= strdupAtoW( patch
)))
1837 if (!(attrW
= strdupAtoW( attr
)))
1841 r
= MsiGetPatchInfoW( patchW
, attrW
, NULL
, &size
);
1842 if (r
!= ERROR_SUCCESS
)
1846 if (!(bufferW
= msi_alloc( size
* sizeof(WCHAR
) )))
1848 r
= ERROR_OUTOFMEMORY
;
1852 r
= MsiGetPatchInfoW( patchW
, attrW
, bufferW
, &size
);
1853 if (r
== ERROR_SUCCESS
)
1855 int len
= WideCharToMultiByte( CP_ACP
, 0, bufferW
, -1, NULL
, 0, NULL
, NULL
);
1857 r
= ERROR_MORE_DATA
;
1859 WideCharToMultiByte( CP_ACP
, 0, bufferW
, -1, buffer
, *buflen
, NULL
, NULL
);
1867 msi_free( bufferW
);
1871 UINT WINAPI
MsiGetPatchInfoW( LPCWSTR patch
, LPCWSTR attr
, LPWSTR buffer
, LPDWORD buflen
)
1874 WCHAR product
[GUID_SIZE
];
1877 TRACE("%s %s %p %p\n", debugstr_w(patch
), debugstr_w(attr
), buffer
, buflen
);
1879 if (!patch
|| !attr
)
1880 return ERROR_INVALID_PARAMETER
;
1882 if (strcmpW( INSTALLPROPERTY_LOCALPACKAGEW
, attr
))
1883 return ERROR_UNKNOWN_PROPERTY
;
1888 r
= MsiEnumProductsW( index
, product
);
1889 if (r
!= ERROR_SUCCESS
)
1892 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, attr
, buffer
, buflen
);
1893 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1896 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, attr
, buffer
, buflen
);
1897 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1900 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_MACHINE
, attr
, buffer
, buflen
);
1901 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1907 return ERROR_UNKNOWN_PRODUCT
;
1910 UINT WINAPI
MsiEnableLogA(DWORD dwLogMode
, LPCSTR szLogFile
, DWORD attributes
)
1912 LPWSTR szwLogFile
= NULL
;
1915 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_a(szLogFile
), attributes
);
1919 szwLogFile
= strdupAtoW( szLogFile
);
1921 return ERROR_OUTOFMEMORY
;
1923 r
= MsiEnableLogW( dwLogMode
, szwLogFile
, attributes
);
1924 msi_free( szwLogFile
);
1928 UINT WINAPI
MsiEnableLogW(DWORD dwLogMode
, LPCWSTR szLogFile
, DWORD attributes
)
1930 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_w(szLogFile
), attributes
);
1932 msi_free(gszLogFile
);
1938 if (!(attributes
& INSTALLLOGATTRIBUTES_APPEND
))
1939 DeleteFileW(szLogFile
);
1940 file
= CreateFileW(szLogFile
, GENERIC_WRITE
, FILE_SHARE_WRITE
, NULL
, OPEN_ALWAYS
,
1941 FILE_ATTRIBUTE_NORMAL
, NULL
);
1942 if (file
!= INVALID_HANDLE_VALUE
)
1944 gszLogFile
= strdupW(szLogFile
);
1948 ERR("Unable to enable log %s (%u)\n", debugstr_w(szLogFile
), GetLastError());
1951 return ERROR_SUCCESS
;
1954 UINT WINAPI
MsiEnumComponentCostsA( MSIHANDLE handle
, LPCSTR component
, DWORD index
,
1955 INSTALLSTATE state
, LPSTR drive
, DWORD
*buflen
,
1956 int *cost
, int *temp
)
1960 WCHAR
*driveW
, *componentW
= NULL
;
1962 TRACE("%d, %s, %u, %d, %p, %p, %p %p\n", handle
, debugstr_a(component
), index
,
1963 state
, drive
, buflen
, cost
, temp
);
1965 if (!drive
|| !buflen
) return ERROR_INVALID_PARAMETER
;
1966 if (component
&& !(componentW
= strdupAtoW( component
))) return ERROR_OUTOFMEMORY
;
1969 if (!(driveW
= msi_alloc( len
* sizeof(WCHAR
) )))
1971 msi_free( componentW
);
1972 return ERROR_OUTOFMEMORY
;
1974 r
= MsiEnumComponentCostsW( handle
, componentW
, index
, state
, driveW
, buflen
, cost
, temp
);
1977 WideCharToMultiByte( CP_ACP
, 0, driveW
, -1, drive
, len
, NULL
, NULL
);
1979 msi_free( componentW
);
1984 static UINT
set_drive( WCHAR
*buffer
, WCHAR letter
)
1992 UINT WINAPI
MsiEnumComponentCostsW( MSIHANDLE handle
, LPCWSTR component
, DWORD index
,
1993 INSTALLSTATE state
, LPWSTR drive
, DWORD
*buflen
,
1994 int *cost
, int *temp
)
1996 UINT r
= ERROR_NO_MORE_ITEMS
;
1997 MSICOMPONENT
*comp
= NULL
;
1998 MSIPACKAGE
*package
;
2001 WCHAR path
[MAX_PATH
];
2003 TRACE("%d, %s, %u, %d, %p, %p, %p %p\n", handle
, debugstr_w(component
), index
,
2004 state
, drive
, buflen
, cost
, temp
);
2006 if (!drive
|| !buflen
|| !cost
|| !temp
) return ERROR_INVALID_PARAMETER
;
2007 if (!(package
= msihandle2msiinfo( handle
, MSIHANDLETYPE_PACKAGE
)))
2010 IWineMsiRemotePackage
*remote_package
;
2013 if (!(remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( handle
)))
2014 return ERROR_INVALID_HANDLE
;
2016 if (component
&& !(bname
= SysAllocString( component
)))
2018 IWineMsiRemotePackage_Release( remote_package
);
2019 return ERROR_OUTOFMEMORY
;
2021 hr
= IWineMsiRemotePackage_EnumComponentCosts( remote_package
, bname
, index
, state
, drive
, buflen
, cost
, temp
);
2022 IWineMsiRemotePackage_Release( remote_package
);
2023 SysFreeString( bname
);
2026 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
) return HRESULT_CODE(hr
);
2027 return ERROR_FUNCTION_FAILED
;
2029 return ERROR_SUCCESS
;
2032 if (!msi_get_property_int( package
->db
, szCostingComplete
, 0 ))
2034 msiobj_release( &package
->hdr
);
2035 return ERROR_FUNCTION_NOT_CALLED
;
2037 if (component
&& component
[0] && !(comp
= msi_get_loaded_component( package
, component
)))
2039 msiobj_release( &package
->hdr
);
2040 return ERROR_UNKNOWN_COMPONENT
;
2045 msiobj_release( &package
->hdr
);
2046 return ERROR_MORE_DATA
;
2050 msiobj_release( &package
->hdr
);
2051 return ERROR_NO_MORE_ITEMS
;
2056 GetWindowsDirectoryW( path
, MAX_PATH
);
2057 if (component
&& component
[0])
2059 if (comp
->assembly
&& !comp
->assembly
->application
) *temp
= comp
->Cost
;
2060 if (!comp
->Enabled
|| !comp
->KeyPath
)
2063 *buflen
= set_drive( drive
, path
[0] );
2066 else if ((file
= msi_get_loaded_file( package
, comp
->KeyPath
)))
2068 *cost
= max( 8, comp
->Cost
/ 512 );
2069 *buflen
= set_drive( drive
, file
->TargetPath
[0] );
2073 else if (IStorage_Stat( package
->db
->storage
, &stat
, STATFLAG_NONAME
) == S_OK
)
2075 *temp
= max( 8, stat
.cbSize
.QuadPart
/ 512 );
2076 *buflen
= set_drive( drive
, path
[0] );
2079 msiobj_release( &package
->hdr
);
2083 UINT WINAPI
MsiQueryComponentStateA(LPCSTR szProductCode
,
2084 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
2085 LPCSTR szComponent
, INSTALLSTATE
*pdwState
)
2087 LPWSTR prodcode
= NULL
, usersid
= NULL
, comp
= NULL
;
2090 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode
),
2091 debugstr_a(szUserSid
), dwContext
, debugstr_a(szComponent
), pdwState
);
2093 if (szProductCode
&& !(prodcode
= strdupAtoW(szProductCode
)))
2094 return ERROR_OUTOFMEMORY
;
2096 if (szUserSid
&& !(usersid
= strdupAtoW(szUserSid
)))
2097 return ERROR_OUTOFMEMORY
;
2099 if (szComponent
&& !(comp
= strdupAtoW(szComponent
)))
2100 return ERROR_OUTOFMEMORY
;
2102 r
= MsiQueryComponentStateW(prodcode
, usersid
, dwContext
, comp
, pdwState
);
2111 static BOOL
msi_comp_find_prod_key(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
2116 r
= MSIREG_OpenProductKey(prodcode
, NULL
, context
, &hkey
, FALSE
);
2118 return (r
== ERROR_SUCCESS
);
2121 static BOOL
msi_comp_find_package(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
2129 static const WCHAR local_package
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
2130 static const WCHAR managed_local_package
[] = {
2131 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
2134 r
= MSIREG_OpenInstallProps(prodcode
, context
, NULL
, &hkey
, FALSE
);
2135 if (r
!= ERROR_SUCCESS
)
2138 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
2139 package
= managed_local_package
;
2141 package
= local_package
;
2144 res
= RegQueryValueExW(hkey
, package
, NULL
, NULL
, NULL
, &sz
);
2147 return (res
== ERROR_SUCCESS
);
2150 static UINT
msi_comp_find_prodcode(LPWSTR squished_pc
,
2151 MSIINSTALLCONTEXT context
,
2152 LPCWSTR comp
, LPWSTR val
, DWORD
*sz
)
2158 if (context
== MSIINSTALLCONTEXT_MACHINE
)
2159 r
= MSIREG_OpenUserDataComponentKey(comp
, szLocalSid
, &hkey
, FALSE
);
2161 r
= MSIREG_OpenUserDataComponentKey(comp
, NULL
, &hkey
, FALSE
);
2163 if (r
!= ERROR_SUCCESS
)
2166 res
= RegQueryValueExW(hkey
, squished_pc
, NULL
, NULL
, (BYTE
*)val
, sz
);
2167 if (res
!= ERROR_SUCCESS
)
2174 UINT WINAPI
MsiQueryComponentStateW(LPCWSTR szProductCode
,
2175 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
2176 LPCWSTR szComponent
, INSTALLSTATE
*pdwState
)
2178 WCHAR squished_pc
[GUID_SIZE
];
2182 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode
),
2183 debugstr_w(szUserSid
), dwContext
, debugstr_w(szComponent
), pdwState
);
2185 if (!pdwState
|| !szComponent
)
2186 return ERROR_INVALID_PARAMETER
;
2188 if (!szProductCode
|| !*szProductCode
|| lstrlenW(szProductCode
) != GUID_SIZE
- 1)
2189 return ERROR_INVALID_PARAMETER
;
2191 if (!squash_guid(szProductCode
, squished_pc
))
2192 return ERROR_INVALID_PARAMETER
;
2194 found
= msi_comp_find_prod_key(szProductCode
, dwContext
);
2196 if (!msi_comp_find_package(szProductCode
, dwContext
))
2200 *pdwState
= INSTALLSTATE_UNKNOWN
;
2201 return ERROR_UNKNOWN_COMPONENT
;
2204 return ERROR_UNKNOWN_PRODUCT
;
2207 *pdwState
= INSTALLSTATE_UNKNOWN
;
2210 if (msi_comp_find_prodcode(squished_pc
, dwContext
, szComponent
, NULL
, &sz
))
2211 return ERROR_UNKNOWN_COMPONENT
;
2214 *pdwState
= INSTALLSTATE_NOTUSED
;
2220 if (!(val
= msi_alloc( sz
))) return ERROR_OUTOFMEMORY
;
2221 if ((r
= msi_comp_find_prodcode(squished_pc
, dwContext
, szComponent
, val
, &sz
)))
2227 if (lstrlenW(val
) > 2 &&
2228 val
[0] >= '0' && val
[0] <= '9' && val
[1] >= '0' && val
[1] <= '9' && val
[2] != ':')
2230 *pdwState
= INSTALLSTATE_SOURCE
;
2233 *pdwState
= INSTALLSTATE_LOCAL
;
2237 TRACE("-> %d\n", *pdwState
);
2238 return ERROR_SUCCESS
;
2241 INSTALLSTATE WINAPI
MsiQueryProductStateA(LPCSTR szProduct
)
2243 LPWSTR szwProduct
= NULL
;
2248 szwProduct
= strdupAtoW( szProduct
);
2250 return ERROR_OUTOFMEMORY
;
2252 r
= MsiQueryProductStateW( szwProduct
);
2253 msi_free( szwProduct
);
2257 INSTALLSTATE WINAPI
MsiQueryProductStateW(LPCWSTR szProduct
)
2259 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
2260 INSTALLSTATE state
= INSTALLSTATE_ADVERTISED
;
2261 HKEY prodkey
= 0, userdata
= 0;
2265 TRACE("%s\n", debugstr_w(szProduct
));
2267 if (!szProduct
|| !*szProduct
)
2268 return INSTALLSTATE_INVALIDARG
;
2270 if (lstrlenW(szProduct
) != GUID_SIZE
- 1)
2271 return INSTALLSTATE_INVALIDARG
;
2273 if (szProduct
[0] != '{' || szProduct
[37] != '}')
2274 return INSTALLSTATE_UNKNOWN
;
2276 SetLastError( ERROR_SUCCESS
);
2278 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2279 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
2280 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2281 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
2282 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
2283 &prodkey
, FALSE
) == ERROR_SUCCESS
)
2285 context
= MSIINSTALLCONTEXT_MACHINE
;
2288 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
2289 if (r
!= ERROR_SUCCESS
)
2292 if (!msi_reg_get_val_dword(userdata
, szWindowsInstaller
, &val
))
2296 state
= INSTALLSTATE_DEFAULT
;
2298 state
= INSTALLSTATE_UNKNOWN
;
2303 state
= INSTALLSTATE_UNKNOWN
;
2306 state
= INSTALLSTATE_ABSENT
;
2309 RegCloseKey(prodkey
);
2310 RegCloseKey(userdata
);
2311 TRACE("-> %d\n", state
);
2315 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
2317 INSTALLUILEVEL old
= gUILevel
;
2318 HWND oldwnd
= gUIhwnd
;
2320 TRACE("%08x %p\n", dwUILevel
, phWnd
);
2322 gUILevel
= dwUILevel
;
2331 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
2332 DWORD dwMessageFilter
, LPVOID pvContext
)
2334 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
2336 TRACE("%p %08x %p\n", puiHandler
, dwMessageFilter
, pvContext
);
2338 gUIHandlerA
= puiHandler
;
2340 gUIFilter
= dwMessageFilter
;
2341 gUIContext
= pvContext
;
2346 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
2347 DWORD dwMessageFilter
, LPVOID pvContext
)
2349 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
2351 TRACE("%p %08x %p\n", puiHandler
, dwMessageFilter
, pvContext
);
2354 gUIHandlerW
= puiHandler
;
2355 gUIFilter
= dwMessageFilter
;
2356 gUIContext
= pvContext
;
2361 /******************************************************************
2362 * MsiLoadStringW [MSI.@]
2364 * Loads a string from MSI's string resources.
2368 * handle [I] only -1 is handled currently
2369 * id [I] id of the string to be loaded
2370 * lpBuffer [O] buffer for the string to be written to
2371 * nBufferMax [I] maximum size of the buffer in characters
2372 * lang [I] the preferred language for the string
2376 * If successful, this function returns the language id of the string loaded
2377 * If the function fails, the function returns zero.
2381 * The type of the first parameter is unknown. LoadString's prototype
2382 * suggests that it might be a module handle. I have made it an MSI handle
2383 * for starters, as -1 is an invalid MSI handle, but not an invalid module
2384 * handle. Maybe strings can be stored in an MSI database somehow.
2386 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
2387 int nBufferMax
, LANGID lang
)
2394 TRACE("%d %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
2397 FIXME("don't know how to deal with handle = %08x\n", handle
);
2400 lang
= GetUserDefaultLangID();
2402 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
2406 hResData
= LoadResource( msi_hInstance
, hres
);
2409 p
= LockResource( hResData
);
2413 for (i
= 0; i
< (id
& 0xf); i
++) p
+= *p
+ 1;
2416 if( nBufferMax
<= len
)
2419 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
2420 lpBuffer
[ len
] = 0;
2422 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
2426 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
2427 int nBufferMax
, LANGID lang
)
2433 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
2434 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
2437 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
2438 if( len
<= nBufferMax
)
2439 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
2440 lpBuffer
, nBufferMax
, NULL
, NULL
);
2448 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
2451 char szProduct
[GUID_SIZE
];
2453 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
2455 if (!szComponent
|| !pcchBuf
)
2456 return INSTALLSTATE_INVALIDARG
;
2458 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
2459 return INSTALLSTATE_UNKNOWN
;
2461 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
2464 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
2467 WCHAR szProduct
[GUID_SIZE
];
2469 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
2471 if (!szComponent
|| !pcchBuf
)
2472 return INSTALLSTATE_INVALIDARG
;
2474 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
2475 return INSTALLSTATE_UNKNOWN
;
2477 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
2480 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
2481 WORD wLanguageId
, DWORD f
)
2483 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_a(lpText
), debugstr_a(lpCaption
),
2484 uType
, wLanguageId
, f
);
2485 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
2488 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
2489 WORD wLanguageId
, DWORD f
)
2491 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_w(lpText
), debugstr_w(lpCaption
),
2492 uType
, wLanguageId
, f
);
2493 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
2496 UINT WINAPI
MsiMessageBoxExA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
2497 DWORD unknown
, WORD wLanguageId
, DWORD f
)
2499 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd
, debugstr_a(lpText
),
2500 debugstr_a(lpCaption
), uType
, unknown
, wLanguageId
, f
);
2501 return MessageBoxExA(hWnd
, lpText
, lpCaption
, uType
, wLanguageId
);
2504 UINT WINAPI
MsiMessageBoxExW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
2505 DWORD unknown
, WORD wLanguageId
, DWORD f
)
2507 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd
, debugstr_w(lpText
),
2508 debugstr_w(lpCaption
), uType
, unknown
, wLanguageId
, f
);
2509 return MessageBoxExW(hWnd
, lpText
, lpCaption
, uType
, wLanguageId
);
2512 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
2513 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
2514 LPDWORD pcchPathBuf
)
2516 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName
),
2517 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2519 return ERROR_CALL_NOT_IMPLEMENTED
;
2522 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
2523 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
2524 LPDWORD pcchPathBuf
)
2526 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName
),
2527 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2529 return ERROR_CALL_NOT_IMPLEMENTED
;
2532 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
2533 LPSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2535 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2536 return ERROR_CALL_NOT_IMPLEMENTED
;
2539 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
2540 LPWSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2542 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2543 return ERROR_CALL_NOT_IMPLEMENTED
;
2546 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR path
, DWORD flags
, PCCERT_CONTEXT
*cert
,
2547 LPBYTE hash
, LPDWORD hashlen
)
2550 WCHAR
*pathW
= NULL
;
2552 TRACE("%s %08x %p %p %p\n", debugstr_a(path
), flags
, cert
, hash
, hashlen
);
2554 if (path
&& !(pathW
= strdupAtoW( path
))) return ERROR_OUTOFMEMORY
;
2555 r
= MsiGetFileSignatureInformationW( pathW
, flags
, cert
, hash
, hashlen
);
2560 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR path
, DWORD flags
, PCCERT_CONTEXT
*cert
,
2561 LPBYTE hash
, LPDWORD hashlen
)
2563 static GUID generic_verify_v2
= WINTRUST_ACTION_GENERIC_VERIFY_V2
;
2566 WINTRUST_FILE_INFO info
;
2567 CRYPT_PROVIDER_SGNR
*signer
;
2568 CRYPT_PROVIDER_CERT
*provider
;
2570 TRACE("%s %08x %p %p %p\n", debugstr_w(path
), flags
, cert
, hash
, hashlen
);
2572 if (!path
|| !cert
) return E_INVALIDARG
;
2574 info
.cbStruct
= sizeof(info
);
2575 info
.pcwszFilePath
= path
;
2577 info
.pgKnownSubject
= NULL
;
2579 data
.cbStruct
= sizeof(data
);
2580 data
.pPolicyCallbackData
= NULL
;
2581 data
.pSIPClientData
= NULL
;
2582 data
.dwUIChoice
= WTD_UI_NONE
;
2583 data
.fdwRevocationChecks
= WTD_REVOKE_WHOLECHAIN
;
2584 data
.dwUnionChoice
= WTD_CHOICE_FILE
;
2585 data
.u
.pFile
= &info
;
2586 data
.dwStateAction
= WTD_STATEACTION_VERIFY
;
2587 data
.hWVTStateData
= NULL
;
2588 data
.pwszURLReference
= NULL
;
2589 data
.dwProvFlags
= 0;
2590 data
.dwUIContext
= WTD_UICONTEXT_INSTALL
;
2591 hr
= WinVerifyTrustEx( INVALID_HANDLE_VALUE
, &generic_verify_v2
, &data
);
2593 if (FAILED(hr
)) goto done
;
2595 if (!(signer
= WTHelperGetProvSignerFromChain( data
.hWVTStateData
, 0, FALSE
, 0 )))
2597 hr
= TRUST_E_NOSIGNATURE
;
2602 DWORD len
= signer
->psSigner
->EncryptedHash
.cbData
;
2606 hr
= HRESULT_FROM_WIN32(ERROR_MORE_DATA
);
2609 memcpy( hash
, signer
->psSigner
->EncryptedHash
.pbData
, len
);
2612 if (!(provider
= WTHelperGetProvCertFromChain( signer
, 0 )))
2614 hr
= TRUST_E_PROVIDER_UNKNOWN
;
2617 *cert
= CertDuplicateCertificateContext( provider
->pCert
);
2620 data
.dwStateAction
= WTD_STATEACTION_CLOSE
;
2621 WinVerifyTrustEx( INVALID_HANDLE_VALUE
, &generic_verify_v2
, &data
);
2625 /******************************************************************
2626 * MsiGetProductPropertyA [MSI.@]
2628 UINT WINAPI
MsiGetProductPropertyA(MSIHANDLE hProduct
, LPCSTR szProperty
,
2629 LPSTR szValue
, LPDWORD pccbValue
)
2631 LPWSTR prop
= NULL
, val
= NULL
;
2635 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_a(szProperty
),
2636 szValue
, pccbValue
);
2638 if (szValue
&& !pccbValue
)
2639 return ERROR_INVALID_PARAMETER
;
2641 if (szProperty
) prop
= strdupAtoW(szProperty
);
2644 r
= MsiGetProductPropertyW(hProduct
, prop
, NULL
, &len
);
2645 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2648 if (r
== ERROR_SUCCESS
)
2650 if (szValue
) *szValue
= '\0';
2651 if (pccbValue
) *pccbValue
= 0;
2655 val
= msi_alloc(++len
* sizeof(WCHAR
));
2658 r
= ERROR_OUTOFMEMORY
;
2662 r
= MsiGetProductPropertyW(hProduct
, prop
, val
, &len
);
2663 if (r
!= ERROR_SUCCESS
)
2666 len
= WideCharToMultiByte(CP_ACP
, 0, val
, -1, NULL
, 0, NULL
, NULL
);
2669 WideCharToMultiByte(CP_ACP
, 0, val
, -1, szValue
,
2670 *pccbValue
, NULL
, NULL
);
2674 if (len
> *pccbValue
)
2675 r
= ERROR_MORE_DATA
;
2677 *pccbValue
= len
- 1;
2687 /******************************************************************
2688 * MsiGetProductPropertyW [MSI.@]
2690 UINT WINAPI
MsiGetProductPropertyW(MSIHANDLE hProduct
, LPCWSTR szProperty
,
2691 LPWSTR szValue
, LPDWORD pccbValue
)
2693 MSIPACKAGE
*package
;
2694 MSIQUERY
*view
= NULL
;
2695 MSIRECORD
*rec
= NULL
;
2699 static const WCHAR query
[] = {
2700 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2701 '`','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2702 '`','P','r','o','p','e','r','t','y','`','=','\'','%','s','\'',0};
2704 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_w(szProperty
),
2705 szValue
, pccbValue
);
2708 return ERROR_INVALID_PARAMETER
;
2710 if (szValue
&& !pccbValue
)
2711 return ERROR_INVALID_PARAMETER
;
2713 package
= msihandle2msiinfo(hProduct
, MSIHANDLETYPE_PACKAGE
);
2715 return ERROR_INVALID_HANDLE
;
2717 r
= MSI_OpenQuery(package
->db
, &view
, query
, szProperty
);
2718 if (r
!= ERROR_SUCCESS
)
2721 r
= MSI_ViewExecute(view
, 0);
2722 if (r
!= ERROR_SUCCESS
)
2725 r
= MSI_ViewFetch(view
, &rec
);
2726 if (r
!= ERROR_SUCCESS
)
2729 val
= MSI_RecordGetString(rec
, 2);
2733 if (lstrlenW(val
) >= *pccbValue
)
2735 lstrcpynW(szValue
, val
, *pccbValue
);
2736 *pccbValue
= lstrlenW(val
);
2737 r
= ERROR_MORE_DATA
;
2741 lstrcpyW(szValue
, val
);
2742 *pccbValue
= lstrlenW(val
);
2749 MSI_ViewClose(view
);
2750 msiobj_release(&view
->hdr
);
2751 if (rec
) msiobj_release(&rec
->hdr
);
2756 if (szValue
) *szValue
= '\0';
2757 if (pccbValue
) *pccbValue
= 0;
2761 msiobj_release(&package
->hdr
);
2765 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
2768 LPWSTR szPack
= NULL
;
2770 TRACE("%s\n", debugstr_a(szPackage
) );
2774 szPack
= strdupAtoW( szPackage
);
2776 return ERROR_OUTOFMEMORY
;
2779 r
= MsiVerifyPackageW( szPack
);
2786 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
2791 TRACE("%s\n", debugstr_w(szPackage
) );
2793 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
2794 MsiCloseHandle( handle
);
2799 static INSTALLSTATE
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
2800 awstring
* lpPathBuf
, LPDWORD pcchBuf
)
2802 static const WCHAR wininstaller
[] =
2803 {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
2804 WCHAR squished_pc
[GUID_SIZE
];
2805 WCHAR squished_comp
[GUID_SIZE
];
2811 if (!szProduct
|| !szComponent
)
2812 return INSTALLSTATE_INVALIDARG
;
2814 if (lpPathBuf
->str
.w
&& !pcchBuf
)
2815 return INSTALLSTATE_INVALIDARG
;
2817 if (!squash_guid(szProduct
, squished_pc
) ||
2818 !squash_guid(szComponent
, squished_comp
))
2819 return INSTALLSTATE_INVALIDARG
;
2821 state
= INSTALLSTATE_UNKNOWN
;
2823 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2824 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2826 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2829 state
= INSTALLSTATE_ABSENT
;
2831 if ((MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
, NULL
,
2832 &hkey
, FALSE
) == ERROR_SUCCESS
||
2833 MSIREG_OpenUserDataProductKey(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2834 NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
) &&
2835 msi_reg_get_val_dword(hkey
, wininstaller
, &version
) &&
2836 GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2839 state
= INSTALLSTATE_LOCAL
;
2843 if (state
!= INSTALLSTATE_LOCAL
&&
2844 (MSIREG_OpenProductKey(szProduct
, NULL
,
2845 MSIINSTALLCONTEXT_USERUNMANAGED
,
2846 &hkey
, FALSE
) == ERROR_SUCCESS
||
2847 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
2848 &hkey
, FALSE
) == ERROR_SUCCESS
))
2852 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2853 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2856 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2859 state
= INSTALLSTATE_ABSENT
;
2861 if (GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2862 state
= INSTALLSTATE_LOCAL
;
2867 return INSTALLSTATE_UNKNOWN
;
2869 if (state
== INSTALLSTATE_LOCAL
&& !*path
)
2870 state
= INSTALLSTATE_NOTUSED
;
2872 msi_strcpy_to_awstring(path
, -1, lpPathBuf
, pcchBuf
);
2877 /******************************************************************
2878 * MsiGetComponentPathW [MSI.@]
2880 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
2881 LPWSTR lpPathBuf
, LPDWORD pcchBuf
)
2885 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
2887 path
.unicode
= TRUE
;
2888 path
.str
.w
= lpPathBuf
;
2890 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
2893 /******************************************************************
2894 * MsiGetComponentPathA [MSI.@]
2896 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
2897 LPSTR lpPathBuf
, LPDWORD pcchBuf
)
2899 LPWSTR szwProduct
, szwComponent
= NULL
;
2900 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
2903 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
2905 szwProduct
= strdupAtoW( szProduct
);
2906 if( szProduct
&& !szwProduct
)
2909 szwComponent
= strdupAtoW( szComponent
);
2910 if( szComponent
&& !szwComponent
)
2913 path
.unicode
= FALSE
;
2914 path
.str
.a
= lpPathBuf
;
2916 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
2919 msi_free( szwProduct
);
2920 msi_free( szwComponent
);
2925 static UINT
query_feature_state( const WCHAR
*product
, const WCHAR
*squashed
, const WCHAR
*usersid
,
2926 MSIINSTALLCONTEXT ctx
, const WCHAR
*feature
, INSTALLSTATE
*state
)
2930 WCHAR
*parent
, *components
, *path
;
2932 BOOL missing
= FALSE
, source
= FALSE
;
2933 WCHAR comp
[GUID_SIZE
];
2936 if (ctx
!= MSIINSTALLCONTEXT_MACHINE
) SetLastError( ERROR_SUCCESS
);
2938 if (MSIREG_OpenFeaturesKey( product
, usersid
, ctx
, &hkey
, FALSE
)) return ERROR_UNKNOWN_PRODUCT
;
2940 parent
= msi_reg_get_val_str( hkey
, feature
);
2941 RegCloseKey( hkey
);
2942 if (!parent
) return ERROR_UNKNOWN_FEATURE
;
2944 *state
= (parent
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
2946 if (*state
== INSTALLSTATE_ABSENT
)
2947 return ERROR_SUCCESS
;
2949 r
= MSIREG_OpenUserDataFeaturesKey( product
, usersid
, ctx
, &hkey
, FALSE
);
2950 if (r
!= ERROR_SUCCESS
)
2952 *state
= INSTALLSTATE_ADVERTISED
;
2953 return ERROR_SUCCESS
;
2955 components
= msi_reg_get_val_str( hkey
, feature
);
2956 RegCloseKey( hkey
);
2958 TRACE("buffer = %s\n", debugstr_w(components
));
2962 *state
= INSTALLSTATE_ADVERTISED
;
2963 return ERROR_SUCCESS
;
2965 for (p
= components
; *p
&& *p
!= 2 ; p
+= 20)
2967 if (!decode_base85_guid( p
, &guid
))
2969 if (p
!= components
) break;
2970 msi_free( components
);
2971 *state
= INSTALLSTATE_BADCONFIG
;
2972 return ERROR_BAD_CONFIGURATION
;
2974 StringFromGUID2( &guid
, comp
, GUID_SIZE
);
2975 if (ctx
== MSIINSTALLCONTEXT_MACHINE
)
2976 r
= MSIREG_OpenUserDataComponentKey( comp
, szLocalSid
, &hkey
, FALSE
);
2978 r
= MSIREG_OpenUserDataComponentKey( comp
, usersid
, &hkey
, FALSE
);
2980 if (r
!= ERROR_SUCCESS
)
2982 msi_free( components
);
2983 *state
= INSTALLSTATE_ADVERTISED
;
2984 return ERROR_SUCCESS
;
2986 path
= msi_reg_get_val_str( hkey
, squashed
);
2987 if (!path
) missing
= TRUE
;
2988 else if (strlenW( path
) > 2 &&
2989 path
[0] >= '0' && path
[0] <= '9' &&
2990 path
[1] >= '0' && path
[1] <= '9')
2996 msi_free( components
);
2999 *state
= INSTALLSTATE_ADVERTISED
;
3001 *state
= INSTALLSTATE_SOURCE
;
3003 *state
= INSTALLSTATE_LOCAL
;
3005 TRACE("returning state %d\n", *state
);
3006 return ERROR_SUCCESS
;
3009 UINT WINAPI
MsiQueryFeatureStateExA( LPCSTR product
, LPCSTR usersid
, MSIINSTALLCONTEXT ctx
,
3010 LPCSTR feature
, INSTALLSTATE
*state
)
3013 WCHAR
*productW
= NULL
, *usersidW
= NULL
, *featureW
= NULL
;
3015 if (product
&& !(productW
= strdupAtoW( product
))) return ERROR_OUTOFMEMORY
;
3016 if (usersid
&& !(usersidW
= strdupAtoW( usersid
)))
3018 msi_free( productW
);
3019 return ERROR_OUTOFMEMORY
;
3021 if (feature
&& !(featureW
= strdupAtoW( feature
)))
3023 msi_free( productW
);
3024 msi_free( usersidW
);
3025 return ERROR_OUTOFMEMORY
;
3027 r
= MsiQueryFeatureStateExW( productW
, usersidW
, ctx
, featureW
, state
);
3028 msi_free( productW
);
3029 msi_free( usersidW
);
3030 msi_free( featureW
);
3034 UINT WINAPI
MsiQueryFeatureStateExW( LPCWSTR product
, LPCWSTR usersid
, MSIINSTALLCONTEXT ctx
,
3035 LPCWSTR feature
, INSTALLSTATE
*state
)
3038 if (!squash_guid( product
, squashed
)) return ERROR_INVALID_PARAMETER
;
3039 return query_feature_state( product
, squashed
, usersid
, ctx
, feature
, state
);
3042 /******************************************************************
3043 * MsiQueryFeatureStateA [MSI.@]
3045 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
3047 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
3048 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
3050 szwProduct
= strdupAtoW( szProduct
);
3051 if ( szProduct
&& !szwProduct
)
3054 szwFeature
= strdupAtoW( szFeature
);
3055 if ( szFeature
&& !szwFeature
)
3058 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
3061 msi_free( szwProduct
);
3062 msi_free( szwFeature
);
3067 /******************************************************************
3068 * MsiQueryFeatureStateW [MSI.@]
3070 * Checks the state of a feature
3073 * szProduct [I] Product's GUID string
3074 * szFeature [I] Feature's GUID string
3077 * INSTALLSTATE_LOCAL Feature is installed and usable
3078 * INSTALLSTATE_ABSENT Feature is absent
3079 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
3080 * INSTALLSTATE_UNKNOWN An error occurred
3081 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
3084 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
3090 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
3092 if (!szProduct
|| !szFeature
|| !squash_guid( szProduct
, squashed
))
3093 return INSTALLSTATE_INVALIDARG
;
3095 r
= query_feature_state( szProduct
, squashed
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, szFeature
, &state
);
3096 if (r
== ERROR_SUCCESS
|| r
== ERROR_BAD_CONFIGURATION
) return state
;
3098 r
= query_feature_state( szProduct
, squashed
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, szFeature
, &state
);
3099 if (r
== ERROR_SUCCESS
|| r
== ERROR_BAD_CONFIGURATION
) return state
;
3101 r
= query_feature_state( szProduct
, squashed
, NULL
, MSIINSTALLCONTEXT_MACHINE
, szFeature
, &state
);
3102 if (r
== ERROR_SUCCESS
|| r
== ERROR_BAD_CONFIGURATION
) return state
;
3104 return INSTALLSTATE_UNKNOWN
;
3107 /******************************************************************
3108 * MsiGetFileVersionA [MSI.@]
3110 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
3111 LPDWORD pcchVersionBuf
, LPSTR lpLangBuf
, LPDWORD pcchLangBuf
)
3113 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
3114 UINT ret
= ERROR_OUTOFMEMORY
;
3116 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
3117 (lpLangBuf
&& !pcchLangBuf
))
3118 return ERROR_INVALID_PARAMETER
;
3122 szwFilePath
= strdupAtoW( szFilePath
);
3127 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
3129 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
3130 if( !lpwVersionBuff
)
3134 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
3136 lpwLangBuff
= msi_alloc(*pcchLangBuf
*sizeof(WCHAR
));
3141 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
3142 lpwLangBuff
, pcchLangBuf
);
3144 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwVersionBuff
)
3145 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
3146 lpVersionBuf
, *pcchVersionBuf
+ 1, NULL
, NULL
);
3147 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwLangBuff
)
3148 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
3149 lpLangBuf
, *pcchLangBuf
+ 1, NULL
, NULL
);
3152 msi_free(szwFilePath
);
3153 msi_free(lpwVersionBuff
);
3154 msi_free(lpwLangBuff
);
3159 static UINT
get_file_version( const WCHAR
*path
, WCHAR
*verbuf
, DWORD
*verlen
,
3160 WCHAR
*langbuf
, DWORD
*langlen
)
3162 static const WCHAR szVersionResource
[] = {'\\',0};
3163 static const WCHAR szVersionFormat
[] = {'%','d','.','%','d','.','%','d','.','%','d',0};
3164 static const WCHAR szLangFormat
[] = {'%','d',0};
3165 UINT ret
= ERROR_MORE_DATA
;
3168 VS_FIXEDFILEINFO
*ffi
;
3172 if (!(len
= GetFileVersionInfoSizeW( path
, NULL
)))
3174 error
= GetLastError();
3175 if (error
== ERROR_BAD_PATHNAME
) return ERROR_FILE_NOT_FOUND
;
3176 if (error
== ERROR_RESOURCE_DATA_NOT_FOUND
) return ERROR_FILE_INVALID
;
3179 if (!(version
= msi_alloc( len
))) return ERROR_OUTOFMEMORY
;
3180 if (!GetFileVersionInfoW( path
, 0, len
, version
))
3182 msi_free( version
);
3183 return GetLastError();
3185 if (!verbuf
&& !verlen
&& !langbuf
&& !langlen
)
3187 msi_free( version
);
3188 return ERROR_SUCCESS
;
3192 if (VerQueryValueW( version
, szVersionResource
, (LPVOID
*)&ffi
, &len
) && len
> 0)
3194 sprintfW( tmp
, szVersionFormat
,
3195 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
3196 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
) );
3197 if (verbuf
) lstrcpynW( verbuf
, tmp
, *verlen
);
3198 len
= strlenW( tmp
);
3199 if (*verlen
> len
) ret
= ERROR_SUCCESS
;
3204 if (verbuf
) *verbuf
= 0;
3210 if (VerQueryValueW( version
, szLangResource
, (LPVOID
*)&lang
, &len
) && len
> 0)
3212 sprintfW( tmp
, szLangFormat
, *lang
);
3213 if (langbuf
) lstrcpynW( langbuf
, tmp
, *langlen
);
3214 len
= strlenW( tmp
);
3215 if (*langlen
> len
) ret
= ERROR_SUCCESS
;
3220 if (langbuf
) *langbuf
= 0;
3224 msi_free( version
);
3229 /******************************************************************
3230 * MsiGetFileVersionW [MSI.@]
3232 UINT WINAPI
MsiGetFileVersionW( LPCWSTR path
, LPWSTR verbuf
, LPDWORD verlen
,
3233 LPWSTR langbuf
, LPDWORD langlen
)
3237 TRACE("%s %p %u %p %u\n", debugstr_w(path
), verbuf
, verlen
? *verlen
: 0,
3238 langbuf
, langlen
? *langlen
: 0);
3240 if ((verbuf
&& !verlen
) || (langbuf
&& !langlen
))
3241 return ERROR_INVALID_PARAMETER
;
3243 ret
= get_file_version( path
, verbuf
, verlen
, langbuf
, langlen
);
3244 if (ret
== ERROR_RESOURCE_DATA_NOT_FOUND
&& verlen
)
3247 WCHAR
*version
= msi_font_version_from_file( path
);
3248 if (!version
) return ERROR_FILE_INVALID
;
3249 len
= strlenW( version
);
3250 if (len
>= *verlen
) ret
= ERROR_MORE_DATA
;
3253 strcpyW( verbuf
, version
);
3254 ret
= ERROR_SUCCESS
;
3257 msi_free( version
);
3262 /***********************************************************************
3263 * MsiGetFeatureUsageW [MSI.@]
3265 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3266 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
3268 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
3269 pdwUseCount
, pwDateUsed
);
3270 return ERROR_CALL_NOT_IMPLEMENTED
;
3273 /***********************************************************************
3274 * MsiGetFeatureUsageA [MSI.@]
3276 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
3277 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
3279 LPWSTR prod
= NULL
, feat
= NULL
;
3280 UINT ret
= ERROR_OUTOFMEMORY
;
3282 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3283 pdwUseCount
, pwDateUsed
);
3285 prod
= strdupAtoW( szProduct
);
3286 if (szProduct
&& !prod
)
3289 feat
= strdupAtoW( szFeature
);
3290 if (szFeature
&& !feat
)
3293 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
3302 /***********************************************************************
3303 * MsiUseFeatureExW [MSI.@]
3305 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3306 DWORD dwInstallMode
, DWORD dwReserved
)
3310 TRACE("%s %s %i %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
3311 dwInstallMode
, dwReserved
);
3313 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
3316 return INSTALLSTATE_INVALIDARG
;
3318 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
3320 FIXME("mark product %s feature %s as used\n",
3321 debugstr_w(szProduct
), debugstr_w(szFeature
) );
3327 /***********************************************************************
3328 * MsiUseFeatureExA [MSI.@]
3330 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
3331 DWORD dwInstallMode
, DWORD dwReserved
)
3333 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
3334 LPWSTR prod
= NULL
, feat
= NULL
;
3336 TRACE("%s %s %i %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3337 dwInstallMode
, dwReserved
);
3339 prod
= strdupAtoW( szProduct
);
3340 if (szProduct
&& !prod
)
3343 feat
= strdupAtoW( szFeature
);
3344 if (szFeature
&& !feat
)
3347 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
3356 /***********************************************************************
3357 * MsiUseFeatureW [MSI.@]
3359 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
3361 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
3364 /***********************************************************************
3365 * MsiUseFeatureA [MSI.@]
3367 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
3369 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
3372 /***********************************************************************
3373 * MSI_ProvideQualifiedComponentEx [internal]
3375 static UINT
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
3376 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
3377 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
3378 LPDWORD pcchPathBuf
)
3380 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
3381 feature
[MAX_FEATURE_CHARS
+1];
3387 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
3388 if (rc
!= ERROR_SUCCESS
)
3389 return ERROR_INDEX_ABSENT
;
3391 info
= msi_reg_get_val_str( hkey
, szQualifier
);
3395 return ERROR_INDEX_ABSENT
;
3397 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
3400 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
3402 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
3406 if (rc
!= INSTALLSTATE_LOCAL
)
3407 return ERROR_FILE_NOT_FOUND
;
3409 return ERROR_SUCCESS
;
3412 /***********************************************************************
3413 * MsiProvideQualifiedComponentExW [MSI.@]
3415 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
3416 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
3417 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
3418 LPDWORD pcchPathBuf
)
3422 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_w(szComponent
),
3423 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
3424 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
3426 path
.unicode
= TRUE
;
3427 path
.str
.w
= lpPathBuf
;
3429 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
3430 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
3433 /***********************************************************************
3434 * MsiProvideQualifiedComponentExA [MSI.@]
3436 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
3437 LPCSTR szQualifier
, DWORD dwInstallMode
, LPCSTR szProduct
,
3438 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
3439 LPDWORD pcchPathBuf
)
3441 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
3442 UINT r
= ERROR_OUTOFMEMORY
;
3445 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent
),
3446 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
3447 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
3449 szwComponent
= strdupAtoW( szComponent
);
3450 if (szComponent
&& !szwComponent
)
3453 szwQualifier
= strdupAtoW( szQualifier
);
3454 if (szQualifier
&& !szwQualifier
)
3457 szwProduct
= strdupAtoW( szProduct
);
3458 if (szProduct
&& !szwProduct
)
3461 path
.unicode
= FALSE
;
3462 path
.str
.a
= lpPathBuf
;
3464 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
3465 dwInstallMode
, szwProduct
, Unused1
,
3466 Unused2
, &path
, pcchPathBuf
);
3468 msi_free(szwProduct
);
3469 msi_free(szwComponent
);
3470 msi_free(szwQualifier
);
3475 /***********************************************************************
3476 * MsiProvideQualifiedComponentW [MSI.@]
3478 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
3479 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
3480 LPDWORD pcchPathBuf
)
3482 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
3483 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3486 /***********************************************************************
3487 * MsiProvideQualifiedComponentA [MSI.@]
3489 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
3490 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
3491 LPDWORD pcchPathBuf
)
3493 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
3494 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3497 /***********************************************************************
3498 * MSI_GetUserInfo [internal]
3500 static USERINFOSTATE
MSI_GetUserInfo(LPCWSTR szProduct
,
3501 awstring
*lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3502 awstring
*lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3503 awstring
*lpSerialBuf
, LPDWORD pcchSerialBuf
)
3505 WCHAR squished_pc
[SQUISH_GUID_SIZE
];
3506 LPWSTR user
, org
, serial
;
3507 USERINFOSTATE state
;
3512 TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct
), lpUserNameBuf
,
3513 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
3516 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
3517 return USERINFOSTATE_INVALIDARG
;
3519 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
3520 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3521 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3522 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3523 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
3524 &hkey
, FALSE
) != ERROR_SUCCESS
)
3526 return USERINFOSTATE_UNKNOWN
;
3529 if (MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3530 NULL
, &props
, FALSE
) != ERROR_SUCCESS
&&
3531 MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
3532 NULL
, &props
, FALSE
) != ERROR_SUCCESS
)
3535 return USERINFOSTATE_ABSENT
;
3538 user
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGOWNERW
);
3539 org
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGCOMPANYW
);
3540 serial
= msi_reg_get_val_str(props
, INSTALLPROPERTY_PRODUCTIDW
);
3541 state
= USERINFOSTATE_ABSENT
;
3547 state
= USERINFOSTATE_PRESENT
;
3549 if (pcchUserNameBuf
)
3551 if (lpUserNameBuf
&& !user
)
3553 (*pcchUserNameBuf
)--;
3557 r
= msi_strcpy_to_awstring(user
, -1, lpUserNameBuf
, pcchUserNameBuf
);
3558 if (r
== ERROR_MORE_DATA
)
3560 state
= USERINFOSTATE_MOREDATA
;
3568 if (!orgptr
) orgptr
= szEmpty
;
3570 r
= msi_strcpy_to_awstring(orgptr
, -1, lpOrgNameBuf
, pcchOrgNameBuf
);
3571 if (r
== ERROR_MORE_DATA
)
3573 state
= USERINFOSTATE_MOREDATA
;
3586 r
= msi_strcpy_to_awstring(serial
, -1, lpSerialBuf
, pcchSerialBuf
);
3587 if (r
== ERROR_MORE_DATA
)
3588 state
= USERINFOSTATE_MOREDATA
;
3599 /***********************************************************************
3600 * MsiGetUserInfoW [MSI.@]
3602 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
3603 LPWSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3604 LPWSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3605 LPWSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3607 awstring user
, org
, serial
;
3609 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3610 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3611 (lpSerialBuf
&& !pcchSerialBuf
))
3612 return USERINFOSTATE_INVALIDARG
;
3614 user
.unicode
= TRUE
;
3615 user
.str
.w
= lpUserNameBuf
;
3617 org
.str
.w
= lpOrgNameBuf
;
3618 serial
.unicode
= TRUE
;
3619 serial
.str
.w
= lpSerialBuf
;
3621 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
3622 &org
, pcchOrgNameBuf
,
3623 &serial
, pcchSerialBuf
);
3626 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
3627 LPSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3628 LPSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3629 LPSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3631 awstring user
, org
, serial
;
3635 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3636 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3637 (lpSerialBuf
&& !pcchSerialBuf
))
3638 return USERINFOSTATE_INVALIDARG
;
3640 prod
= strdupAtoW( szProduct
);
3641 if (szProduct
&& !prod
)
3642 return ERROR_OUTOFMEMORY
;
3644 user
.unicode
= FALSE
;
3645 user
.str
.a
= lpUserNameBuf
;
3646 org
.unicode
= FALSE
;
3647 org
.str
.a
= lpOrgNameBuf
;
3648 serial
.unicode
= FALSE
;
3649 serial
.str
.a
= lpSerialBuf
;
3651 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
3652 &org
, pcchOrgNameBuf
,
3653 &serial
, pcchSerialBuf
);
3660 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
3664 MSIPACKAGE
*package
;
3665 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3667 TRACE("(%s)\n",debugstr_w(szProduct
));
3669 rc
= MsiOpenProductW(szProduct
,&handle
);
3670 if (rc
!= ERROR_SUCCESS
)
3671 return ERROR_INVALID_PARAMETER
;
3673 /* MsiCollectUserInfo cannot be called from a custom action. */
3674 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3676 return ERROR_CALL_NOT_IMPLEMENTED
;
3678 rc
= ACTION_PerformUIAction(package
, szFirstRun
, SCRIPT_NONE
);
3679 msiobj_release( &package
->hdr
);
3681 MsiCloseHandle(handle
);
3686 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
3690 MSIPACKAGE
*package
;
3691 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3693 TRACE("(%s)\n",debugstr_a(szProduct
));
3695 rc
= MsiOpenProductA(szProduct
,&handle
);
3696 if (rc
!= ERROR_SUCCESS
)
3697 return ERROR_INVALID_PARAMETER
;
3699 /* MsiCollectUserInfo cannot be called from a custom action. */
3700 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3702 return ERROR_CALL_NOT_IMPLEMENTED
;
3704 rc
= ACTION_PerformUIAction(package
, szFirstRun
, SCRIPT_NONE
);
3705 msiobj_release( &package
->hdr
);
3707 MsiCloseHandle(handle
);
3712 /***********************************************************************
3713 * MsiConfigureFeatureA [MSI.@]
3715 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
3717 LPWSTR prod
, feat
= NULL
;
3718 UINT r
= ERROR_OUTOFMEMORY
;
3720 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
3722 prod
= strdupAtoW( szProduct
);
3723 if (szProduct
&& !prod
)
3726 feat
= strdupAtoW( szFeature
);
3727 if (szFeature
&& !feat
)
3730 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
3739 /***********************************************************************
3740 * MsiConfigureFeatureW [MSI.@]
3742 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
3744 MSIPACKAGE
*package
= NULL
;
3746 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
3749 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
3751 if (!szProduct
|| !szFeature
)
3752 return ERROR_INVALID_PARAMETER
;
3754 switch (eInstallState
)
3756 case INSTALLSTATE_DEFAULT
:
3757 /* FIXME: how do we figure out the default location? */
3758 eInstallState
= INSTALLSTATE_LOCAL
;
3760 case INSTALLSTATE_LOCAL
:
3761 case INSTALLSTATE_SOURCE
:
3762 case INSTALLSTATE_ABSENT
:
3763 case INSTALLSTATE_ADVERTISED
:
3766 return ERROR_INVALID_PARAMETER
;
3769 r
= MSI_OpenProductW( szProduct
, &package
);
3770 if (r
!= ERROR_SUCCESS
)
3773 sz
= sizeof(sourcepath
);
3774 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3775 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3777 sz
= sizeof(filename
);
3778 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3779 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3781 lstrcatW( sourcepath
, filename
);
3783 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
3785 r
= ACTION_PerformUIAction( package
, szCostInitialize
, SCRIPT_NONE
);
3786 if (r
!= ERROR_SUCCESS
)
3789 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
3790 if (r
!= ERROR_SUCCESS
)
3793 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
3796 msiobj_release( &package
->hdr
);
3801 /***********************************************************************
3802 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
3804 * Notes: undocumented
3806 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
3808 WCHAR path
[MAX_PATH
];
3810 TRACE("%d\n", dwReserved
);
3814 FIXME("dwReserved=%d\n", dwReserved
);
3815 return ERROR_INVALID_PARAMETER
;
3818 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
3819 return ERROR_FUNCTION_FAILED
;
3821 lstrcatW(path
, installerW
);
3823 if (!CreateDirectoryW(path
, NULL
) && GetLastError() != ERROR_ALREADY_EXISTS
)
3824 return ERROR_FUNCTION_FAILED
;
3826 return ERROR_SUCCESS
;
3829 /***********************************************************************
3830 * MsiGetShortcutTargetA [MSI.@]
3832 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
3833 LPSTR szProductCode
, LPSTR szFeatureId
,
3834 LPSTR szComponentCode
)
3837 const int len
= MAX_FEATURE_CHARS
+1;
3838 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
3841 target
= strdupAtoW( szShortcutTarget
);
3842 if (szShortcutTarget
&& !target
)
3843 return ERROR_OUTOFMEMORY
;
3847 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
3849 if (r
== ERROR_SUCCESS
)
3851 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
3852 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
3853 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
3858 /***********************************************************************
3859 * MsiGetShortcutTargetW [MSI.@]
3861 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
3862 LPWSTR szProductCode
, LPWSTR szFeatureId
,
3863 LPWSTR szComponentCode
)
3865 IShellLinkDataList
*dl
= NULL
;
3866 IPersistFile
*pf
= NULL
;
3867 LPEXP_DARWIN_LINK darwin
= NULL
;
3870 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
3871 szProductCode
, szFeatureId
, szComponentCode
);
3873 init
= CoInitialize(NULL
);
3875 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
3876 &IID_IPersistFile
, (LPVOID
*) &pf
);
3877 if( SUCCEEDED( r
) )
3879 r
= IPersistFile_Load( pf
, szShortcutTarget
,
3880 STGM_READ
| STGM_SHARE_DENY_WRITE
);
3881 if( SUCCEEDED( r
) )
3883 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
3885 if( SUCCEEDED( r
) )
3887 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
3889 IShellLinkDataList_Release( dl
);
3892 IPersistFile_Release( pf
);
3895 if (SUCCEEDED(init
))
3898 TRACE("darwin = %p\n", darwin
);
3905 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
3906 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
3907 LocalFree( darwin
);
3911 return ERROR_FUNCTION_FAILED
;
3914 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
, DWORD dwReinstallMode
)
3916 static const WCHAR fmtW
[] = {'%','s','=','%','s',' ','%','s','=','%','s',0};
3917 MSIPACKAGE
*package
;
3918 MSIINSTALLCONTEXT context
;
3920 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
], reinstallmode
[11];
3921 WCHAR
*ptr
, *cmdline
;
3924 TRACE("%s, %s, 0x%08x\n", debugstr_w(szProduct
), debugstr_w(szFeature
), dwReinstallMode
);
3926 r
= msi_locate_product( szProduct
, &context
);
3927 if (r
!= ERROR_SUCCESS
)
3930 ptr
= reinstallmode
;
3932 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
3934 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
3936 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
3938 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
3940 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
3942 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
3944 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
3946 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
3948 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
3950 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3954 sz
= sizeof(sourcepath
);
3955 MsiSourceListGetInfoW( szProduct
, NULL
, context
, MSICODE_PRODUCT
,
3956 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3957 sz
= sizeof(filename
);
3958 MsiSourceListGetInfoW( szProduct
, NULL
, context
, MSICODE_PRODUCT
,
3959 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3960 strcatW( sourcepath
, filename
);
3962 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3963 r
= MSI_OpenPackageW( sourcepath
, &package
);
3965 r
= MSI_OpenProductW( szProduct
, &package
);
3967 if (r
!= ERROR_SUCCESS
)
3970 sz
= (strlenW( fmtW
) + strlenW( szReinstallMode
) + strlenW( reinstallmode
)) * sizeof(WCHAR
);
3971 sz
+= (strlenW( szReinstall
) + strlenW( szFeature
)) * sizeof(WCHAR
);
3972 if (!(cmdline
= msi_alloc( sz
)))
3974 msiobj_release( &package
->hdr
);
3975 return ERROR_OUTOFMEMORY
;
3977 sprintfW( cmdline
, fmtW
, szReinstallMode
, reinstallmode
, szReinstall
, szFeature
);
3979 r
= MSI_InstallPackage( package
, sourcepath
, cmdline
);
3980 msiobj_release( &package
->hdr
);
3981 msi_free( cmdline
);
3986 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
3987 DWORD dwReinstallMode
)
3993 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3996 wszProduct
= strdupAtoW(szProduct
);
3997 wszFeature
= strdupAtoW(szFeature
);
3999 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
4001 msi_free(wszProduct
);
4002 msi_free(wszFeature
);
4009 unsigned int buf
[4];
4010 unsigned char in
[64];
4011 unsigned char digest
[16];
4014 extern VOID WINAPI
MD5Init( MD5_CTX
*);
4015 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
4016 extern VOID WINAPI
MD5Final( MD5_CTX
*);
4018 /***********************************************************************
4019 * MsiGetFileHashW [MSI.@]
4021 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
4022 PMSIFILEHASHINFO pHash
)
4024 HANDLE handle
, mapping
;
4027 UINT r
= ERROR_FUNCTION_FAILED
;
4029 TRACE("%s %08x %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
4032 return ERROR_INVALID_PARAMETER
;
4035 return ERROR_PATH_NOT_FOUND
;
4038 return ERROR_INVALID_PARAMETER
;
4040 return ERROR_INVALID_PARAMETER
;
4041 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
4042 return ERROR_INVALID_PARAMETER
;
4044 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
4045 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
4046 if (handle
== INVALID_HANDLE_VALUE
)
4048 WARN("can't open file %u\n", GetLastError());
4049 return ERROR_FILE_NOT_FOUND
;
4051 length
= GetFileSize( handle
, NULL
);
4055 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
4058 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
4064 MD5Update( &ctx
, p
, length
);
4066 UnmapViewOfFile( p
);
4068 memcpy( pHash
->dwData
, ctx
.digest
, sizeof pHash
->dwData
);
4071 CloseHandle( mapping
);
4076 /* Empty file -> set hash to 0 */
4077 memset( pHash
->dwData
, 0, sizeof pHash
->dwData
);
4081 CloseHandle( handle
);
4086 /***********************************************************************
4087 * MsiGetFileHashA [MSI.@]
4089 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
4090 PMSIFILEHASHINFO pHash
)
4095 TRACE("%s %08x %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
4097 file
= strdupAtoW( szFilePath
);
4098 if (szFilePath
&& !file
)
4099 return ERROR_OUTOFMEMORY
;
4101 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
4106 /***********************************************************************
4107 * MsiAdvertiseScriptW [MSI.@]
4109 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
4110 PHKEY phRegData
, BOOL fRemoveItems
)
4112 FIXME("%s %08x %p %d\n",
4113 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
4114 return ERROR_CALL_NOT_IMPLEMENTED
;
4117 /***********************************************************************
4118 * MsiAdvertiseScriptA [MSI.@]
4120 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
4121 PHKEY phRegData
, BOOL fRemoveItems
)
4123 FIXME("%s %08x %p %d\n",
4124 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
4125 return ERROR_CALL_NOT_IMPLEMENTED
;
4128 /***********************************************************************
4129 * MsiIsProductElevatedW [MSI.@]
4131 UINT WINAPI
MsiIsProductElevatedW( LPCWSTR szProduct
, BOOL
*pfElevated
)
4133 FIXME("%s %p - stub\n",
4134 debugstr_w( szProduct
), pfElevated
);
4136 return ERROR_SUCCESS
;
4139 /***********************************************************************
4140 * MsiIsProductElevatedA [MSI.@]
4142 UINT WINAPI
MsiIsProductElevatedA( LPCSTR szProduct
, BOOL
*pfElevated
)
4144 FIXME("%s %p - stub\n",
4145 debugstr_a( szProduct
), pfElevated
);
4147 return ERROR_SUCCESS
;
4150 /***********************************************************************
4151 * MsiSetExternalUIRecord [MSI.@]
4153 UINT WINAPI
MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD handler
,
4154 DWORD filter
, LPVOID context
,
4155 PINSTALLUI_HANDLER_RECORD prev
)
4157 TRACE("%p %08x %p %p\n", handler
, filter
, context
, prev
);
4160 *prev
= gUIHandlerRecord
;
4162 gUIHandlerRecord
= handler
;
4164 gUIContext
= context
;
4166 return ERROR_SUCCESS
;
4169 /***********************************************************************
4170 * MsiInstallMissingComponentA [MSI.@]
4172 UINT WINAPI
MsiInstallMissingComponentA( LPCSTR product
, LPCSTR component
, INSTALLSTATE state
)
4175 WCHAR
*productW
= NULL
, *componentW
= NULL
;
4177 TRACE("%s, %s, %d\n", debugstr_a(product
), debugstr_a(component
), state
);
4179 if (product
&& !(productW
= strdupAtoW( product
)))
4180 return ERROR_OUTOFMEMORY
;
4182 if (component
&& !(componentW
= strdupAtoW( component
)))
4184 msi_free( productW
);
4185 return ERROR_OUTOFMEMORY
;
4188 r
= MsiInstallMissingComponentW( productW
, componentW
, state
);
4189 msi_free( productW
);
4190 msi_free( componentW
);
4194 /***********************************************************************
4195 * MsiInstallMissingComponentW [MSI.@]
4197 UINT WINAPI
MsiInstallMissingComponentW(LPCWSTR szProduct
, LPCWSTR szComponent
, INSTALLSTATE eInstallState
)
4199 FIXME("(%s %s %d\n", debugstr_w(szProduct
), debugstr_w(szComponent
), eInstallState
);
4200 return ERROR_SUCCESS
;
4203 /***********************************************************************
4204 * MsiBeginTransactionA [MSI.@]
4206 UINT WINAPI
MsiBeginTransactionA( LPCSTR name
, DWORD attrs
, MSIHANDLE
*id
, HANDLE
*event
)
4211 FIXME("%s %u %p %p\n", debugstr_a(name
), attrs
, id
, event
);
4213 nameW
= strdupAtoW( name
);
4215 return ERROR_OUTOFMEMORY
;
4217 r
= MsiBeginTransactionW( nameW
, attrs
, id
, event
);
4222 /***********************************************************************
4223 * MsiBeginTransactionW [MSI.@]
4225 UINT WINAPI
MsiBeginTransactionW( LPCWSTR name
, DWORD attrs
, MSIHANDLE
*id
, HANDLE
*event
)
4227 FIXME("%s %u %p %p\n", debugstr_w(name
), attrs
, id
, event
);
4229 *id
= (MSIHANDLE
)0xdeadbeef;
4230 *event
= (HANDLE
)0xdeadbeef;
4232 return ERROR_SUCCESS
;
4235 /***********************************************************************
4236 * MsiEndTransaction [MSI.@]
4238 UINT WINAPI
MsiEndTransaction( DWORD state
)
4240 FIXME("%u\n", state
);
4241 return ERROR_SUCCESS
;
4244 UINT WINAPI
Migrate10CachedPackagesW(void* a
, void* b
, void* c
, DWORD d
)
4246 FIXME("%p,%p,%p,%08x\n", a
, b
, c
, d
);
4247 return ERROR_SUCCESS
;