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
27 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
29 static const WCHAR installerW
[] = {'\\','I','n','s','t','a','l','l','e','r',0};
31 UINT
msi_locate_product(LPCWSTR szProduct
, MSIINSTALLCONTEXT
*context
)
35 *context
= MSIINSTALLCONTEXT_NONE
;
36 if (!szProduct
) return ERROR_UNKNOWN_PRODUCT
;
38 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
39 &hkey
, FALSE
) == ERROR_SUCCESS
)
40 *context
= MSIINSTALLCONTEXT_USERMANAGED
;
41 else if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
42 &hkey
, FALSE
) == ERROR_SUCCESS
)
43 *context
= MSIINSTALLCONTEXT_MACHINE
;
44 else if (MSIREG_OpenProductKey(szProduct
, NULL
,
45 MSIINSTALLCONTEXT_USERUNMANAGED
,
46 &hkey
, FALSE
) == ERROR_SUCCESS
)
47 *context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
51 if (*context
== MSIINSTALLCONTEXT_NONE
)
52 return ERROR_UNKNOWN_PRODUCT
;
57 UINT WINAPI
MsiOpenProductA(LPCSTR szProduct
, MSIHANDLE
*phProduct
)
60 LPWSTR szwProd
= NULL
;
62 TRACE("%s %p\n",debugstr_a(szProduct
), phProduct
);
66 szwProd
= strdupAtoW( szProduct
);
68 return ERROR_OUTOFMEMORY
;
71 r
= MsiOpenProductW( szwProd
, phProduct
);
78 static UINT
MSI_OpenProductW(LPCWSTR szProduct
, MSIPACKAGE
**package
)
83 MSIINSTALLCONTEXT context
;
85 static const WCHAR managed
[] = {
86 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0};
87 static const WCHAR local
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
89 TRACE("%s %p\n", debugstr_w(szProduct
), package
);
91 r
= msi_locate_product(szProduct
, &context
);
92 if (r
!= ERROR_SUCCESS
)
95 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &props
, FALSE
);
96 if (r
!= ERROR_SUCCESS
)
97 return ERROR_UNKNOWN_PRODUCT
;
99 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
100 path
= msi_reg_get_val_str(props
, managed
);
102 path
= msi_reg_get_val_str(props
, local
);
104 r
= ERROR_UNKNOWN_PRODUCT
;
106 if (!path
|| GetFileAttributesW(path
) == INVALID_FILE_ATTRIBUTES
)
109 if (PathIsRelativeW(path
))
111 r
= ERROR_INSTALL_PACKAGE_OPEN_FAILED
;
115 r
= MSI_OpenPackageW(path
, package
);
123 UINT WINAPI
MsiOpenProductW(LPCWSTR szProduct
, MSIHANDLE
*phProduct
)
125 MSIPACKAGE
*package
= NULL
;
126 WCHAR squished_pc
[GUID_SIZE
];
129 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
130 return ERROR_INVALID_PARAMETER
;
133 return ERROR_INVALID_PARAMETER
;
135 r
= MSI_OpenProductW(szProduct
, &package
);
136 if (r
!= ERROR_SUCCESS
)
139 *phProduct
= alloc_msihandle(&package
->hdr
);
141 r
= ERROR_NOT_ENOUGH_MEMORY
;
143 msiobj_release(&package
->hdr
);
147 UINT WINAPI
MsiAdvertiseProductA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
148 LPCSTR szTransforms
, LANGID lgidLanguage
)
150 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath
),
151 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
), lgidLanguage
);
152 return ERROR_CALL_NOT_IMPLEMENTED
;
155 UINT WINAPI
MsiAdvertiseProductW(LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
156 LPCWSTR szTransforms
, LANGID lgidLanguage
)
158 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath
),
159 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
), lgidLanguage
);
160 return ERROR_CALL_NOT_IMPLEMENTED
;
163 UINT WINAPI
MsiAdvertiseProductExA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
164 LPCSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
166 FIXME("%s %s %s %08x %08x %08x\n", debugstr_a(szPackagePath
),
167 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
),
168 lgidLanguage
, dwPlatform
, dwOptions
);
169 return ERROR_CALL_NOT_IMPLEMENTED
;
172 UINT WINAPI
MsiAdvertiseProductExW( LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
173 LPCWSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
175 FIXME("%s %s %s %08x %08x %08x\n", debugstr_w(szPackagePath
),
176 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
),
177 lgidLanguage
, dwPlatform
, dwOptions
);
178 return ERROR_CALL_NOT_IMPLEMENTED
;
181 UINT WINAPI
MsiInstallProductA(LPCSTR szPackagePath
, LPCSTR szCommandLine
)
183 LPWSTR szwPath
= NULL
, szwCommand
= NULL
;
184 UINT r
= ERROR_OUTOFMEMORY
;
186 TRACE("%s %s\n",debugstr_a(szPackagePath
), debugstr_a(szCommandLine
));
190 szwPath
= strdupAtoW( szPackagePath
);
197 szwCommand
= strdupAtoW( szCommandLine
);
202 r
= MsiInstallProductW( szwPath
, szwCommand
);
206 msi_free( szwCommand
);
211 UINT WINAPI
MsiInstallProductW(LPCWSTR szPackagePath
, LPCWSTR szCommandLine
)
213 MSIPACKAGE
*package
= NULL
;
216 TRACE("%s %s\n",debugstr_w(szPackagePath
), debugstr_w(szCommandLine
));
219 return ERROR_INVALID_PARAMETER
;
222 return ERROR_PATH_NOT_FOUND
;
224 r
= MSI_OpenPackageW( szPackagePath
, &package
);
225 if (r
== ERROR_SUCCESS
)
227 r
= MSI_InstallPackage( package
, szPackagePath
, szCommandLine
);
228 msiobj_release( &package
->hdr
);
234 UINT WINAPI
MsiReinstallProductA(LPCSTR szProduct
, DWORD dwReinstallMode
)
239 TRACE("%s %08x\n", debugstr_a(szProduct
), dwReinstallMode
);
241 wszProduct
= strdupAtoW(szProduct
);
243 rc
= MsiReinstallProductW(wszProduct
, dwReinstallMode
);
245 msi_free(wszProduct
);
249 UINT WINAPI
MsiReinstallProductW(LPCWSTR szProduct
, DWORD dwReinstallMode
)
251 TRACE("%s %08x\n", debugstr_w(szProduct
), dwReinstallMode
);
253 return MsiReinstallFeatureW(szProduct
, szAll
, dwReinstallMode
);
256 UINT WINAPI
MsiApplyPatchA(LPCSTR szPatchPackage
, LPCSTR szInstallPackage
,
257 INSTALLTYPE eInstallType
, LPCSTR szCommandLine
)
259 LPWSTR patch_package
= NULL
;
260 LPWSTR install_package
= NULL
;
261 LPWSTR command_line
= NULL
;
262 UINT r
= ERROR_OUTOFMEMORY
;
264 TRACE("%s %s %d %s\n", debugstr_a(szPatchPackage
), debugstr_a(szInstallPackage
),
265 eInstallType
, debugstr_a(szCommandLine
));
267 if (szPatchPackage
&& !(patch_package
= strdupAtoW(szPatchPackage
)))
270 if (szInstallPackage
&& !(install_package
= strdupAtoW(szInstallPackage
)))
273 if (szCommandLine
&& !(command_line
= strdupAtoW(szCommandLine
)))
276 r
= MsiApplyPatchW(patch_package
, install_package
, eInstallType
, command_line
);
279 msi_free(patch_package
);
280 msi_free(install_package
);
281 msi_free(command_line
);
286 static UINT
get_patch_product_codes( LPCWSTR szPatchPackage
, WCHAR
***product_codes
)
288 MSIHANDLE patch
, info
= 0;
291 static WCHAR empty
[] = {0};
294 r
= MsiOpenDatabaseW( szPatchPackage
, MSIDBOPEN_READONLY
, &patch
);
295 if (r
!= ERROR_SUCCESS
)
298 r
= MsiGetSummaryInformationW( patch
, NULL
, 0, &info
);
299 if (r
!= ERROR_SUCCESS
)
303 r
= MsiSummaryInfoGetPropertyW( info
, PID_TEMPLATE
, &type
, NULL
, NULL
, empty
, &size
);
304 if (r
!= ERROR_MORE_DATA
|| !size
|| type
!= VT_LPSTR
)
306 ERR("Failed to read product codes from patch\n");
307 r
= ERROR_FUNCTION_FAILED
;
311 codes
= msi_alloc( ++size
* sizeof(WCHAR
) );
314 r
= ERROR_OUTOFMEMORY
;
318 r
= MsiSummaryInfoGetPropertyW( info
, PID_TEMPLATE
, &type
, NULL
, NULL
, codes
, &size
);
319 if (r
== ERROR_SUCCESS
)
320 *product_codes
= msi_split_string( codes
, ';' );
323 MsiCloseHandle( info
);
324 MsiCloseHandle( patch
);
329 static UINT
MSI_ApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szProductCode
, LPCWSTR szCommandLine
)
331 UINT i
, r
= ERROR_FUNCTION_FAILED
;
333 LPCWSTR cmd_ptr
= szCommandLine
;
334 LPWSTR cmd
, *codes
= NULL
;
335 BOOL succeeded
= FALSE
;
337 static const WCHAR fmt
[] = {'%','s',' ','P','A','T','C','H','=','"','%','s','"',0};
338 static const WCHAR empty
[] = {0};
340 if (!szPatchPackage
|| !szPatchPackage
[0])
341 return ERROR_INVALID_PARAMETER
;
343 if (!szProductCode
&& (r
= get_patch_product_codes( szPatchPackage
, &codes
)))
349 size
= strlenW(cmd_ptr
) + strlenW(fmt
) + strlenW(szPatchPackage
) + 1;
350 cmd
= msi_alloc(size
* sizeof(WCHAR
));
354 return ERROR_OUTOFMEMORY
;
356 sprintfW(cmd
, fmt
, cmd_ptr
, szPatchPackage
);
359 r
= MsiConfigureProductExW(szProductCode
, INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
362 for (i
= 0; codes
[i
]; i
++)
364 r
= MsiConfigureProductExW(codes
[i
], INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
365 if (r
== ERROR_SUCCESS
)
367 TRACE("patch applied\n");
381 UINT WINAPI
MsiApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szInstallPackage
,
382 INSTALLTYPE eInstallType
, LPCWSTR szCommandLine
)
384 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage
), debugstr_w(szInstallPackage
),
385 eInstallType
, debugstr_w(szCommandLine
));
387 if (szInstallPackage
|| eInstallType
== INSTALLTYPE_NETWORK_IMAGE
||
388 eInstallType
== INSTALLTYPE_SINGLE_INSTANCE
)
390 FIXME("Only reading target products from patch\n");
391 return ERROR_CALL_NOT_IMPLEMENTED
;
394 return MSI_ApplyPatchW(szPatchPackage
, NULL
, szCommandLine
);
397 UINT WINAPI
MsiApplyMultiplePatchesA(LPCSTR szPatchPackages
,
398 LPCSTR szProductCode
, LPCSTR szPropertiesList
)
400 LPWSTR patch_packages
= NULL
;
401 LPWSTR product_code
= NULL
;
402 LPWSTR properties_list
= NULL
;
403 UINT r
= ERROR_OUTOFMEMORY
;
405 TRACE("%s %s %s\n", debugstr_a(szPatchPackages
), debugstr_a(szProductCode
),
406 debugstr_a(szPropertiesList
));
408 if (!szPatchPackages
|| !szPatchPackages
[0])
409 return ERROR_INVALID_PARAMETER
;
411 if (!(patch_packages
= strdupAtoW(szPatchPackages
)))
412 return ERROR_OUTOFMEMORY
;
414 if (szProductCode
&& !(product_code
= strdupAtoW(szProductCode
)))
417 if (szPropertiesList
&& !(properties_list
= strdupAtoW(szPropertiesList
)))
420 r
= MsiApplyMultiplePatchesW(patch_packages
, product_code
, properties_list
);
423 msi_free(patch_packages
);
424 msi_free(product_code
);
425 msi_free(properties_list
);
430 UINT WINAPI
MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages
,
431 LPCWSTR szProductCode
, LPCWSTR szPropertiesList
)
433 UINT r
= ERROR_SUCCESS
;
436 TRACE("%s %s %s\n", debugstr_w(szPatchPackages
), debugstr_w(szProductCode
),
437 debugstr_w(szPropertiesList
));
439 if (!szPatchPackages
|| !szPatchPackages
[0])
440 return ERROR_INVALID_PARAMETER
;
442 beg
= end
= szPatchPackages
;
448 while (*beg
== ' ') beg
++;
449 while (*end
&& *end
!= ';') end
++;
452 while (len
&& beg
[len
- 1] == ' ') len
--;
454 if (!len
) return ERROR_INVALID_NAME
;
456 patch
= msi_alloc((len
+ 1) * sizeof(WCHAR
));
458 return ERROR_OUTOFMEMORY
;
460 memcpy(patch
, beg
, len
* sizeof(WCHAR
));
463 r
= MSI_ApplyPatchW(patch
, szProductCode
, szPropertiesList
);
466 if (r
!= ERROR_SUCCESS
)
474 static void free_patchinfo( DWORD count
, MSIPATCHSEQUENCEINFOW
*info
)
477 for (i
= 0; i
< count
; i
++) msi_free( (WCHAR
*)info
[i
].szPatchData
);
481 static MSIPATCHSEQUENCEINFOW
*patchinfoAtoW( DWORD count
, const MSIPATCHSEQUENCEINFOA
*info
)
484 MSIPATCHSEQUENCEINFOW
*ret
;
486 if (!(ret
= msi_alloc( count
* sizeof(MSIPATCHSEQUENCEINFOW
) ))) return NULL
;
487 for (i
= 0; i
< count
; i
++)
489 if (info
[i
].szPatchData
&& !(ret
[i
].szPatchData
= strdupAtoW( info
[i
].szPatchData
)))
491 free_patchinfo( i
, ret
);
494 ret
[i
].ePatchDataType
= info
[i
].ePatchDataType
;
495 ret
[i
].dwOrder
= info
[i
].dwOrder
;
496 ret
[i
].uStatus
= info
[i
].uStatus
;
501 UINT WINAPI
MsiDetermineApplicablePatchesA(LPCSTR szProductPackagePath
,
502 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOA pPatchInfo
)
505 WCHAR
*package_path
= NULL
;
506 MSIPATCHSEQUENCEINFOW
*psi
;
508 TRACE("%s, %u, %p\n", debugstr_a(szProductPackagePath
), cPatchInfo
, pPatchInfo
);
510 if (szProductPackagePath
&& !(package_path
= strdupAtoW( szProductPackagePath
)))
511 return ERROR_OUTOFMEMORY
;
513 if (!(psi
= patchinfoAtoW( cPatchInfo
, pPatchInfo
)))
515 msi_free( package_path
);
516 return ERROR_OUTOFMEMORY
;
518 r
= MsiDetermineApplicablePatchesW( package_path
, cPatchInfo
, psi
);
519 if (r
== ERROR_SUCCESS
)
521 for (i
= 0; i
< cPatchInfo
; i
++)
523 pPatchInfo
[i
].dwOrder
= psi
[i
].dwOrder
;
524 pPatchInfo
[i
].uStatus
= psi
[i
].uStatus
;
527 msi_free( package_path
);
528 free_patchinfo( cPatchInfo
, psi
);
532 static UINT
MSI_ApplicablePatchW( MSIPACKAGE
*package
, LPCWSTR patch
)
535 MSIDATABASE
*patch_db
;
536 UINT r
= ERROR_SUCCESS
;
538 r
= MSI_OpenDatabaseW( patch
, MSIDBOPEN_READONLY
, &patch_db
);
539 if (r
!= ERROR_SUCCESS
)
541 WARN("failed to open patch file %s\n", debugstr_w(patch
));
545 si
= MSI_GetSummaryInformationW( patch_db
->storage
, 0 );
548 msiobj_release( &patch_db
->hdr
);
549 return ERROR_FUNCTION_FAILED
;
552 r
= msi_check_patch_applicable( package
, si
);
553 if (r
!= ERROR_SUCCESS
)
554 TRACE("patch not applicable\n");
556 msiobj_release( &patch_db
->hdr
);
557 msiobj_release( &si
->hdr
);
561 /* IXMLDOMDocument should be set to XPath mode already */
562 static UINT
MSI_ApplicablePatchXML( MSIPACKAGE
*package
, IXMLDOMDocument
*desc
)
564 static const WCHAR queryW
[] = {'M','s','i','P','a','t','c','h','/',
565 'T','a','r','g','e','t','P','r','o','d','u','c','t','/',
566 'T','a','r','g','e','t','P','r','o','d','u','c','t','C','o','d','e',0};
567 UINT r
= ERROR_FUNCTION_FAILED
;
568 IXMLDOMNodeList
*list
;
574 product_code
= msi_dup_property( package
->db
, szProductCode
);
577 /* FIXME: the property ProductCode should be written into the DB somewhere */
578 ERR("no product code to check\n");
579 return ERROR_SUCCESS
;
582 s
= SysAllocString(queryW
);
583 hr
= IXMLDOMDocument_selectNodes( desc
, s
, &list
);
586 return ERROR_INVALID_PATCH_XML
;
588 while (IXMLDOMNodeList_nextNode( list
, &node
) == S_OK
&& r
!= ERROR_SUCCESS
)
590 hr
= IXMLDOMNode_get_text( node
, &s
);
591 IXMLDOMNode_Release( node
);
594 if (!strcmpW( s
, product_code
)) r
= ERROR_SUCCESS
;
598 IXMLDOMNodeList_Release( list
);
600 if (r
!= ERROR_SUCCESS
)
601 TRACE("patch not applicable\n");
603 msi_free( product_code
);
607 static UINT
determine_patch_sequence( MSIPACKAGE
*package
, DWORD count
, MSIPATCHSEQUENCEINFOW
*info
)
609 IXMLDOMDocument
*desc
= NULL
;
613 FIXME("patch ordering not supported\n");
615 for (i
= 0; i
< count
; i
++)
617 switch (info
[i
].ePatchDataType
)
619 case MSIPATCH_DATATYPE_PATCHFILE
:
621 if (MSI_ApplicablePatchW( package
, info
[i
].szPatchData
) != ERROR_SUCCESS
)
623 info
[i
].dwOrder
= ~0u;
624 info
[i
].uStatus
= ERROR_PATCH_TARGET_NOT_FOUND
;
629 info
[i
].uStatus
= ERROR_SUCCESS
;
633 case MSIPATCH_DATATYPE_XMLPATH
:
634 case MSIPATCH_DATATYPE_XMLBLOB
:
642 hr
= CoCreateInstance( &CLSID_DOMDocument30
, NULL
, CLSCTX_INPROC_SERVER
,
643 &IID_IXMLDOMDocument
, (void**)&desc
);
646 ERR("failed to create DOMDocument30 instance, 0x%08x\n", hr
);
647 return ERROR_FUNCTION_FAILED
;
651 s
= SysAllocString( info
[i
].szPatchData
);
652 if (info
[i
].ePatchDataType
== MSIPATCH_DATATYPE_XMLPATH
)
656 V_VT(&src
) = VT_BSTR
;
658 hr
= IXMLDOMDocument_load( desc
, src
, &b
);
661 hr
= IXMLDOMDocument_loadXML( desc
, s
, &b
);
665 ERR("failed to parse patch description\n");
666 IXMLDOMDocument_Release( desc
);
670 if (MSI_ApplicablePatchXML( package
, desc
) != ERROR_SUCCESS
)
672 info
[i
].dwOrder
= ~0u;
673 info
[i
].uStatus
= ERROR_PATCH_TARGET_NOT_FOUND
;
678 info
[i
].uStatus
= ERROR_SUCCESS
;
684 FIXME("unknown patch data type %u\n", info
[i
].ePatchDataType
);
686 info
[i
].uStatus
= ERROR_SUCCESS
;
691 TRACE("szPatchData: %s\n", debugstr_w(info
[i
].szPatchData
));
692 TRACE("ePatchDataType: %u\n", info
[i
].ePatchDataType
);
693 TRACE("dwOrder: %u\n", info
[i
].dwOrder
);
694 TRACE("uStatus: %u\n", info
[i
].uStatus
);
697 if (desc
) IXMLDOMDocument_Release( desc
);
699 return ERROR_SUCCESS
;
702 UINT WINAPI
MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath
,
703 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOW pPatchInfo
)
708 TRACE("%s, %u, %p\n", debugstr_w(szProductPackagePath
), cPatchInfo
, pPatchInfo
);
710 r
= MSI_OpenPackageW( szProductPackagePath
, &package
);
711 if (r
!= ERROR_SUCCESS
)
713 ERR("failed to open package %u\n", r
);
716 r
= determine_patch_sequence( package
, cPatchInfo
, pPatchInfo
);
717 msiobj_release( &package
->hdr
);
721 UINT WINAPI
MsiDeterminePatchSequenceA( LPCSTR product
, LPCSTR usersid
,
722 MSIINSTALLCONTEXT context
, DWORD count
, PMSIPATCHSEQUENCEINFOA patchinfo
)
725 WCHAR
*productW
, *usersidW
= NULL
;
726 MSIPATCHSEQUENCEINFOW
*patchinfoW
;
728 TRACE("%s, %s, %d, %d, %p\n", debugstr_a(product
), debugstr_a(usersid
),
729 context
, count
, patchinfo
);
731 if (!product
) return ERROR_INVALID_PARAMETER
;
732 if (!(productW
= strdupAtoW( product
))) return ERROR_OUTOFMEMORY
;
733 if (usersid
&& !(usersidW
= strdupAtoW( usersid
)))
735 msi_free( productW
);
736 return ERROR_OUTOFMEMORY
;
738 if (!(patchinfoW
= patchinfoAtoW( count
, patchinfo
)))
740 msi_free( productW
);
741 msi_free( usersidW
);
742 return ERROR_OUTOFMEMORY
;
744 r
= MsiDeterminePatchSequenceW( productW
, usersidW
, context
, count
, patchinfoW
);
745 if (r
== ERROR_SUCCESS
)
747 for (i
= 0; i
< count
; i
++)
749 patchinfo
[i
].dwOrder
= patchinfoW
[i
].dwOrder
;
750 patchinfo
[i
].uStatus
= patchinfoW
[i
].uStatus
;
753 msi_free( productW
);
754 msi_free( usersidW
);
755 free_patchinfo( count
, patchinfoW
);
759 static UINT
open_package( const WCHAR
*product
, const WCHAR
*usersid
,
760 MSIINSTALLCONTEXT context
, MSIPACKAGE
**package
)
764 WCHAR
*localpath
, sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
766 r
= MSIREG_OpenInstallProps( product
, context
, usersid
, &props
, FALSE
);
767 if (r
!= ERROR_SUCCESS
) return ERROR_BAD_CONFIGURATION
;
769 if ((localpath
= msi_reg_get_val_str( props
, szLocalPackage
)))
771 strcpyW( sourcepath
, localpath
);
772 msi_free( localpath
);
774 RegCloseKey( props
);
775 if (!localpath
|| GetFileAttributesW( sourcepath
) == INVALID_FILE_ATTRIBUTES
)
777 DWORD sz
= sizeof(sourcepath
);
778 MsiSourceListGetInfoW( product
, usersid
, context
, MSICODE_PRODUCT
,
779 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
780 sz
= sizeof(filename
);
781 MsiSourceListGetInfoW( product
, usersid
, context
, MSICODE_PRODUCT
,
782 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
783 strcatW( sourcepath
, filename
);
785 if (GetFileAttributesW( sourcepath
) == INVALID_FILE_ATTRIBUTES
)
786 return ERROR_INSTALL_SOURCE_ABSENT
;
788 return MSI_OpenPackageW( sourcepath
, package
);
791 UINT WINAPI
MsiDeterminePatchSequenceW( LPCWSTR product
, LPCWSTR usersid
,
792 MSIINSTALLCONTEXT context
, DWORD count
, PMSIPATCHSEQUENCEINFOW patchinfo
)
797 TRACE("%s, %s, %d, %d, %p\n", debugstr_w(product
), debugstr_w(usersid
),
798 context
, count
, patchinfo
);
800 if (!product
) return ERROR_INVALID_PARAMETER
;
801 r
= open_package( product
, usersid
, context
, &package
);
802 if (r
!= ERROR_SUCCESS
) return r
;
804 r
= determine_patch_sequence( package
, count
, patchinfo
);
805 msiobj_release( &package
->hdr
);
809 UINT WINAPI
MsiConfigureProductExW(LPCWSTR szProduct
, int iInstallLevel
,
810 INSTALLSTATE eInstallState
, LPCWSTR szCommandLine
)
812 MSIPACKAGE
* package
= NULL
;
813 MSIINSTALLCONTEXT context
;
816 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
819 static const WCHAR szInstalled
[] = {
820 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
821 static const WCHAR szMaxInstallLevel
[] = {
822 ' ','I','N','S','T','A','L','L','L','E','V','E','L','=','3','2','7','6','7',0};
823 static const WCHAR szRemoveAll
[] = {
824 ' ','R','E','M','O','V','E','=','A','L','L',0};
825 static const WCHAR szMachine
[] = {
826 ' ','A','L','L','U','S','E','R','S','=','1',0};
828 TRACE("%s %d %d %s\n",debugstr_w(szProduct
), iInstallLevel
, eInstallState
,
829 debugstr_w(szCommandLine
));
831 if (!szProduct
|| lstrlenW(szProduct
) != GUID_SIZE
- 1)
832 return ERROR_INVALID_PARAMETER
;
834 if (eInstallState
== INSTALLSTATE_ADVERTISED
||
835 eInstallState
== INSTALLSTATE_SOURCE
)
837 FIXME("State %d not implemented\n", eInstallState
);
838 return ERROR_CALL_NOT_IMPLEMENTED
;
841 r
= msi_locate_product(szProduct
, &context
);
842 if (r
!= ERROR_SUCCESS
)
845 r
= open_package(szProduct
, NULL
, context
, &package
);
846 if (r
!= ERROR_SUCCESS
)
849 sz
= lstrlenW(szInstalled
) + 1;
852 sz
+= lstrlenW(szCommandLine
);
854 if (eInstallState
!= INSTALLSTATE_DEFAULT
)
855 sz
+= lstrlenW(szMaxInstallLevel
);
857 if (eInstallState
== INSTALLSTATE_ABSENT
)
858 sz
+= lstrlenW(szRemoveAll
);
860 if (context
== MSIINSTALLCONTEXT_MACHINE
)
861 sz
+= lstrlenW(szMachine
);
863 commandline
= msi_alloc(sz
* sizeof(WCHAR
));
866 r
= ERROR_OUTOFMEMORY
;
872 lstrcpyW(commandline
,szCommandLine
);
874 if (eInstallState
!= INSTALLSTATE_DEFAULT
)
875 lstrcatW(commandline
, szMaxInstallLevel
);
877 if (eInstallState
== INSTALLSTATE_ABSENT
)
878 lstrcatW(commandline
, szRemoveAll
);
880 if (context
== MSIINSTALLCONTEXT_MACHINE
)
881 lstrcatW(commandline
, szMachine
);
883 sz
= sizeof(sourcepath
);
884 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
885 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
887 sz
= sizeof(filename
);
888 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
889 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
891 strcatW(sourcepath
, filename
);
893 r
= MSI_InstallPackage( package
, sourcepath
, commandline
);
895 msi_free(commandline
);
898 msiobj_release( &package
->hdr
);
903 UINT WINAPI
MsiConfigureProductExA(LPCSTR szProduct
, int iInstallLevel
,
904 INSTALLSTATE eInstallState
, LPCSTR szCommandLine
)
906 LPWSTR szwProduct
= NULL
;
907 LPWSTR szwCommandLine
= NULL
;
908 UINT r
= ERROR_OUTOFMEMORY
;
912 szwProduct
= strdupAtoW( szProduct
);
919 szwCommandLine
= strdupAtoW( szCommandLine
);
924 r
= MsiConfigureProductExW( szwProduct
, iInstallLevel
, eInstallState
,
927 msi_free( szwProduct
);
928 msi_free( szwCommandLine
);
933 UINT WINAPI
MsiConfigureProductA(LPCSTR szProduct
, int iInstallLevel
,
934 INSTALLSTATE eInstallState
)
936 LPWSTR szwProduct
= NULL
;
939 TRACE("%s %d %d\n",debugstr_a(szProduct
), iInstallLevel
, eInstallState
);
943 szwProduct
= strdupAtoW( szProduct
);
945 return ERROR_OUTOFMEMORY
;
948 r
= MsiConfigureProductW( szwProduct
, iInstallLevel
, eInstallState
);
949 msi_free( szwProduct
);
954 UINT WINAPI
MsiConfigureProductW(LPCWSTR szProduct
, int iInstallLevel
,
955 INSTALLSTATE eInstallState
)
957 return MsiConfigureProductExW(szProduct
, iInstallLevel
, eInstallState
, NULL
);
960 UINT WINAPI
MsiGetProductCodeA(LPCSTR szComponent
, LPSTR szBuffer
)
962 LPWSTR szwComponent
= NULL
;
964 WCHAR szwBuffer
[GUID_SIZE
];
966 TRACE("%s %p\n", debugstr_a(szComponent
), szBuffer
);
970 szwComponent
= strdupAtoW( szComponent
);
972 return ERROR_OUTOFMEMORY
;
976 r
= MsiGetProductCodeW( szwComponent
, szwBuffer
);
979 WideCharToMultiByte(CP_ACP
, 0, szwBuffer
, -1, szBuffer
, GUID_SIZE
, NULL
, NULL
);
981 msi_free( szwComponent
);
986 UINT WINAPI
MsiGetProductCodeW(LPCWSTR szComponent
, LPWSTR szBuffer
)
989 HKEY compkey
, prodkey
;
990 WCHAR squished_comp
[GUID_SIZE
];
991 WCHAR squished_prod
[GUID_SIZE
];
992 DWORD sz
= GUID_SIZE
;
994 TRACE("%s %p\n", debugstr_w(szComponent
), szBuffer
);
996 if (!szComponent
|| !*szComponent
)
997 return ERROR_INVALID_PARAMETER
;
999 if (!squash_guid(szComponent
, squished_comp
))
1000 return ERROR_INVALID_PARAMETER
;
1002 if (MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &compkey
, FALSE
) != ERROR_SUCCESS
&&
1003 MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &compkey
, FALSE
) != ERROR_SUCCESS
)
1005 return ERROR_UNKNOWN_COMPONENT
;
1008 rc
= RegEnumValueW(compkey
, 0, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
1009 if (rc
!= ERROR_SUCCESS
)
1011 RegCloseKey(compkey
);
1012 return ERROR_UNKNOWN_COMPONENT
;
1015 /* check simple case, only one product */
1016 rc
= RegEnumValueW(compkey
, 1, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
1017 if (rc
== ERROR_NO_MORE_ITEMS
)
1024 while ((rc
= RegEnumValueW(compkey
, index
, squished_prod
, &sz
,
1025 NULL
, NULL
, NULL
, NULL
)) != ERROR_NO_MORE_ITEMS
)
1029 unsquash_guid(squished_prod
, szBuffer
);
1031 if (MSIREG_OpenProductKey(szBuffer
, NULL
,
1032 MSIINSTALLCONTEXT_USERMANAGED
,
1033 &prodkey
, FALSE
) == ERROR_SUCCESS
||
1034 MSIREG_OpenProductKey(szBuffer
, NULL
,
1035 MSIINSTALLCONTEXT_USERUNMANAGED
,
1036 &prodkey
, FALSE
) == ERROR_SUCCESS
||
1037 MSIREG_OpenProductKey(szBuffer
, NULL
,
1038 MSIINSTALLCONTEXT_MACHINE
,
1039 &prodkey
, FALSE
) == ERROR_SUCCESS
)
1041 RegCloseKey(prodkey
);
1047 rc
= ERROR_INSTALL_FAILURE
;
1050 RegCloseKey(compkey
);
1051 unsquash_guid(squished_prod
, szBuffer
);
1055 static LPWSTR
msi_reg_get_value(HKEY hkey
, LPCWSTR name
, DWORD
*type
)
1061 static const WCHAR format
[] = {'%','d',0};
1063 res
= RegQueryValueExW(hkey
, name
, NULL
, type
, NULL
, NULL
);
1064 if (res
!= ERROR_SUCCESS
)
1067 if (*type
== REG_SZ
)
1068 return msi_reg_get_val_str(hkey
, name
);
1070 if (!msi_reg_get_val_dword(hkey
, name
, &dval
))
1073 sprintfW(temp
, format
, dval
);
1074 return strdupW(temp
);
1077 static UINT
MSI_GetProductInfo(LPCWSTR szProduct
, LPCWSTR szAttribute
,
1078 awstring
*szValue
, LPDWORD pcchValueBuf
)
1080 static WCHAR empty
[] = {0};
1081 static const WCHAR sourcelist
[] = {'S','o','u','r','c','e','L','i','s','t',0};
1082 static const WCHAR display_name
[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
1083 static const WCHAR display_version
[] = {'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1084 static const WCHAR assignment
[] = {'A','s','s','i','g','n','m','e','n','t',0};
1085 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
1086 UINT r
= ERROR_UNKNOWN_PROPERTY
;
1087 HKEY prodkey
, userdata
, source
;
1089 WCHAR squished_pc
[GUID_SIZE
];
1090 WCHAR packagecode
[GUID_SIZE
];
1091 BOOL badconfig
= FALSE
;
1093 DWORD type
= REG_NONE
;
1095 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
1096 debugstr_w(szAttribute
), szValue
, pcchValueBuf
);
1098 if ((szValue
->str
.w
&& !pcchValueBuf
) || !szProduct
|| !szAttribute
)
1099 return ERROR_INVALID_PARAMETER
;
1101 if (!squash_guid(szProduct
, squished_pc
))
1102 return ERROR_INVALID_PARAMETER
;
1104 if ((r
= MSIREG_OpenProductKey(szProduct
, NULL
,
1105 MSIINSTALLCONTEXT_USERMANAGED
,
1106 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
1107 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
1108 MSIINSTALLCONTEXT_USERUNMANAGED
,
1109 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
1110 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
1111 MSIINSTALLCONTEXT_MACHINE
,
1112 &prodkey
, FALSE
)) == ERROR_SUCCESS
)
1114 context
= MSIINSTALLCONTEXT_MACHINE
;
1117 if (!strcmpW( szAttribute
, INSTALLPROPERTY_HELPLINKW
) ||
1118 !strcmpW( szAttribute
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
1119 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLDATEW
) ||
1120 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
1121 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
1122 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
1123 !strcmpW( szAttribute
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
1124 !strcmpW( szAttribute
, INSTALLPROPERTY_PUBLISHERW
) ||
1125 !strcmpW( szAttribute
, INSTALLPROPERTY_URLINFOABOUTW
) ||
1126 !strcmpW( szAttribute
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
1127 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONMINORW
) ||
1128 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONMAJORW
) ||
1129 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
1130 !strcmpW( szAttribute
, INSTALLPROPERTY_PRODUCTIDW
) ||
1131 !strcmpW( szAttribute
, INSTALLPROPERTY_REGCOMPANYW
) ||
1132 !strcmpW( szAttribute
, INSTALLPROPERTY_REGOWNERW
))
1136 r
= ERROR_UNKNOWN_PRODUCT
;
1139 if (MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
))
1141 r
= ERROR_UNKNOWN_PROPERTY
;
1145 if (!strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
1146 szAttribute
= display_name
;
1147 else if (!strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
))
1148 szAttribute
= display_version
;
1150 val
= msi_reg_get_value(userdata
, szAttribute
, &type
);
1153 RegCloseKey(userdata
);
1155 else if (!strcmpW( szAttribute
, INSTALLPROPERTY_INSTANCETYPEW
) ||
1156 !strcmpW( szAttribute
, INSTALLPROPERTY_TRANSFORMSW
) ||
1157 !strcmpW( szAttribute
, INSTALLPROPERTY_LANGUAGEW
) ||
1158 !strcmpW( szAttribute
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
1159 !strcmpW( szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
) ||
1160 !strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGECODEW
) ||
1161 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONW
) ||
1162 !strcmpW( szAttribute
, INSTALLPROPERTY_PRODUCTICONW
) ||
1163 !strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
) ||
1164 !strcmpW( szAttribute
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
1168 r
= ERROR_UNKNOWN_PRODUCT
;
1172 if (!strcmpW( szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
1173 szAttribute
= assignment
;
1175 if (!strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
))
1177 res
= RegOpenKeyW(prodkey
, sourcelist
, &source
);
1178 if (res
!= ERROR_SUCCESS
)
1180 r
= ERROR_UNKNOWN_PRODUCT
;
1184 val
= msi_reg_get_value(source
, szAttribute
, &type
);
1188 RegCloseKey(source
);
1192 val
= msi_reg_get_value(prodkey
, szAttribute
, &type
);
1197 if (val
!= empty
&& type
!= REG_DWORD
&&
1198 !strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGECODEW
))
1200 if (lstrlenW(val
) != SQUISH_GUID_SIZE
- 1)
1204 unsquash_guid(val
, packagecode
);
1206 val
= strdupW(packagecode
);
1213 r
= ERROR_UNKNOWN_PROPERTY
;
1219 int len
= strlenW( val
);
1221 /* If szBuffer (szValue->str) is NULL, there's no need to copy the value
1222 * out. Also, *pcchValueBuf may be uninitialized in this case, so we
1223 * can't rely on its value.
1225 if (szValue
->str
.a
|| szValue
->str
.w
)
1227 DWORD size
= *pcchValueBuf
;
1229 r
= msi_strcpy_to_awstring( val
, len
, szValue
, &size
);
1231 r
= ERROR_MORE_DATA
;
1235 *pcchValueBuf
= len
;
1239 r
= ERROR_BAD_CONFIGURATION
;
1245 RegCloseKey(prodkey
);
1249 UINT WINAPI
MsiGetProductInfoA(LPCSTR szProduct
, LPCSTR szAttribute
,
1250 LPSTR szBuffer
, LPDWORD pcchValueBuf
)
1252 LPWSTR szwProduct
, szwAttribute
= NULL
;
1253 UINT r
= ERROR_OUTOFMEMORY
;
1256 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szAttribute
),
1257 szBuffer
, pcchValueBuf
);
1259 szwProduct
= strdupAtoW( szProduct
);
1260 if( szProduct
&& !szwProduct
)
1263 szwAttribute
= strdupAtoW( szAttribute
);
1264 if( szAttribute
&& !szwAttribute
)
1267 buffer
.unicode
= FALSE
;
1268 buffer
.str
.a
= szBuffer
;
1270 r
= MSI_GetProductInfo( szwProduct
, szwAttribute
,
1271 &buffer
, pcchValueBuf
);
1274 msi_free( szwProduct
);
1275 msi_free( szwAttribute
);
1280 UINT WINAPI
MsiGetProductInfoW(LPCWSTR szProduct
, LPCWSTR szAttribute
,
1281 LPWSTR szBuffer
, LPDWORD pcchValueBuf
)
1285 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szAttribute
),
1286 szBuffer
, pcchValueBuf
);
1288 buffer
.unicode
= TRUE
;
1289 buffer
.str
.w
= szBuffer
;
1291 return MSI_GetProductInfo( szProduct
, szAttribute
,
1292 &buffer
, pcchValueBuf
);
1295 UINT WINAPI
MsiGetProductInfoExA(LPCSTR szProductCode
, LPCSTR szUserSid
,
1296 MSIINSTALLCONTEXT dwContext
, LPCSTR szProperty
,
1297 LPSTR szValue
, LPDWORD pcchValue
)
1299 LPWSTR product
= NULL
;
1300 LPWSTR usersid
= NULL
;
1301 LPWSTR property
= NULL
;
1302 LPWSTR value
= NULL
;
1306 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_a(szProductCode
),
1307 debugstr_a(szUserSid
), dwContext
, debugstr_a(szProperty
),
1308 szValue
, pcchValue
);
1310 if (szValue
&& !pcchValue
)
1311 return ERROR_INVALID_PARAMETER
;
1313 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1314 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1315 if (szProperty
) property
= strdupAtoW(szProperty
);
1317 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1319 if (r
!= ERROR_SUCCESS
)
1322 value
= msi_alloc(++len
* sizeof(WCHAR
));
1325 r
= ERROR_OUTOFMEMORY
;
1329 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1331 if (r
!= ERROR_SUCCESS
)
1337 len
= WideCharToMultiByte(CP_ACP
, 0, value
, -1, NULL
, 0, NULL
, NULL
);
1338 if (*pcchValue
>= len
)
1339 WideCharToMultiByte(CP_ACP
, 0, value
, -1, szValue
, len
, NULL
, NULL
);
1342 r
= ERROR_MORE_DATA
;
1347 if (*pcchValue
<= len
|| !szValue
)
1348 len
= len
* sizeof(WCHAR
) - 1;
1350 *pcchValue
= len
- 1;
1361 static UINT
msi_copy_outval(LPWSTR val
, LPWSTR out
, LPDWORD size
)
1363 UINT r
= ERROR_SUCCESS
;
1366 return ERROR_UNKNOWN_PROPERTY
;
1370 if (strlenW(val
) >= *size
)
1372 r
= ERROR_MORE_DATA
;
1381 *size
= lstrlenW(val
);
1386 UINT WINAPI
MsiGetProductInfoExW(LPCWSTR szProductCode
, LPCWSTR szUserSid
,
1387 MSIINSTALLCONTEXT dwContext
, LPCWSTR szProperty
,
1388 LPWSTR szValue
, LPDWORD pcchValue
)
1390 WCHAR squished_pc
[GUID_SIZE
];
1392 LPCWSTR package
= NULL
;
1393 HKEY props
= NULL
, prod
;
1394 HKEY classes
= NULL
, managed
;
1397 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1399 static const WCHAR five
[] = {'5',0};
1400 static const WCHAR displayname
[] = {
1401 'D','i','s','p','l','a','y','N','a','m','e',0};
1402 static const WCHAR displayversion
[] = {
1403 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1404 static const WCHAR managed_local_package
[] = {
1405 'M','a','n','a','g','e','d','L','o','c','a','l',
1406 'P','a','c','k','a','g','e',0};
1408 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_w(szProductCode
),
1409 debugstr_w(szUserSid
), dwContext
, debugstr_w(szProperty
),
1410 szValue
, pcchValue
);
1412 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1413 return ERROR_INVALID_PARAMETER
;
1415 if (szValue
&& !pcchValue
)
1416 return ERROR_INVALID_PARAMETER
;
1418 if (dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1419 dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1420 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1421 return ERROR_INVALID_PARAMETER
;
1423 if (!szProperty
|| !*szProperty
)
1424 return ERROR_INVALID_PARAMETER
;
1426 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1427 return ERROR_INVALID_PARAMETER
;
1429 /* FIXME: dwContext is provided, no need to search for it */
1430 MSIREG_OpenProductKey(szProductCode
, NULL
,MSIINSTALLCONTEXT_USERMANAGED
,
1432 MSIREG_OpenProductKey(szProductCode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1435 MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
, &props
, FALSE
);
1437 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1439 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1441 if (!props
&& !prod
)
1444 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1446 package
= managed_local_package
;
1448 if (!props
&& !managed
)
1451 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1453 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1454 MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
, &classes
, FALSE
);
1456 if (!props
&& !classes
)
1460 if (!strcmpW( szProperty
, INSTALLPROPERTY_HELPLINKW
) ||
1461 !strcmpW( szProperty
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
1462 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLDATEW
) ||
1463 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
1464 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
1465 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
1466 !strcmpW( szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
1467 !strcmpW( szProperty
, INSTALLPROPERTY_PUBLISHERW
) ||
1468 !strcmpW( szProperty
, INSTALLPROPERTY_URLINFOABOUTW
) ||
1469 !strcmpW( szProperty
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
1470 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONMINORW
) ||
1471 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONMAJORW
) ||
1472 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
1473 !strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTIDW
) ||
1474 !strcmpW( szProperty
, INSTALLPROPERTY_REGCOMPANYW
) ||
1475 !strcmpW( szProperty
, INSTALLPROPERTY_REGOWNERW
) ||
1476 !strcmpW( szProperty
, INSTALLPROPERTY_INSTANCETYPEW
))
1478 val
= msi_reg_get_value(props
, package
, &type
);
1481 if (prod
|| classes
)
1482 r
= ERROR_UNKNOWN_PROPERTY
;
1489 if (!strcmpW( szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
1490 szProperty
= displayname
;
1491 else if (!strcmpW( szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
))
1492 szProperty
= displayversion
;
1494 val
= msi_reg_get_value(props
, szProperty
, &type
);
1496 val
= strdupW(szEmpty
);
1498 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1500 else if (!strcmpW( szProperty
, INSTALLPROPERTY_TRANSFORMSW
) ||
1501 !strcmpW( szProperty
, INSTALLPROPERTY_LANGUAGEW
) ||
1502 !strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
1503 !strcmpW( szProperty
, INSTALLPROPERTY_PACKAGECODEW
) ||
1504 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONW
) ||
1505 !strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTICONW
) ||
1506 !strcmpW( szProperty
, INSTALLPROPERTY_PACKAGENAMEW
) ||
1507 !strcmpW( szProperty
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
1509 if (!prod
&& !classes
)
1512 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1514 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1516 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1519 val
= msi_reg_get_value(hkey
, szProperty
, &type
);
1521 val
= strdupW(szEmpty
);
1523 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1525 else if (!strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTSTATEW
))
1527 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1531 val
= msi_reg_get_value(props
, package
, &type
);
1536 val
= strdupW(five
);
1539 val
= strdupW(szOne
);
1541 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1544 else if (props
&& (val
= msi_reg_get_value(props
, package
, &type
)))
1547 val
= strdupW(five
);
1548 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1552 if (prod
|| managed
)
1553 val
= strdupW(szOne
);
1557 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1559 else if (!strcmpW( szProperty
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
1561 if (!prod
&& !classes
)
1565 val
= strdupW(szEmpty
);
1566 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1569 r
= ERROR_UNKNOWN_PROPERTY
;
1574 RegCloseKey(managed
);
1575 RegCloseKey(classes
);
1581 UINT WINAPI
MsiGetPatchInfoExA(LPCSTR szPatchCode
, LPCSTR szProductCode
,
1582 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1583 LPCSTR szProperty
, LPSTR lpValue
, DWORD
*pcchValue
)
1585 LPWSTR patch
= NULL
, product
= NULL
, usersid
= NULL
;
1586 LPWSTR property
= NULL
, val
= NULL
;
1590 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_a(szPatchCode
),
1591 debugstr_a(szProductCode
), debugstr_a(szUserSid
), dwContext
,
1592 debugstr_a(szProperty
), lpValue
, pcchValue
);
1594 if (lpValue
&& !pcchValue
)
1595 return ERROR_INVALID_PARAMETER
;
1597 if (szPatchCode
) patch
= strdupAtoW(szPatchCode
);
1598 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1599 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1600 if (szProperty
) property
= strdupAtoW(szProperty
);
1603 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1605 if (r
!= ERROR_SUCCESS
)
1608 val
= msi_alloc(++len
* sizeof(WCHAR
));
1611 r
= ERROR_OUTOFMEMORY
;
1615 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1617 if (r
!= ERROR_SUCCESS
|| !pcchValue
)
1621 WideCharToMultiByte(CP_ACP
, 0, val
, -1, lpValue
,
1622 *pcchValue
- 1, NULL
, NULL
);
1624 len
= lstrlenW(val
);
1625 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1629 r
= ERROR_MORE_DATA
;
1630 lpValue
[*pcchValue
- 1] = '\0';
1633 *pcchValue
= len
* sizeof(WCHAR
);
1648 UINT WINAPI
MsiGetPatchInfoExW(LPCWSTR szPatchCode
, LPCWSTR szProductCode
,
1649 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1650 LPCWSTR szProperty
, LPWSTR lpValue
, DWORD
*pcchValue
)
1652 WCHAR squished_pc
[GUID_SIZE
];
1653 WCHAR squished_patch
[GUID_SIZE
];
1654 HKEY udprod
= 0, prod
= 0, props
= 0;
1655 HKEY patch
= 0, patches
= 0;
1656 HKEY udpatch
= 0, datakey
= 0;
1657 HKEY prodpatches
= 0;
1659 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1663 static const WCHAR szManagedPackage
[] = {'M','a','n','a','g','e','d',
1664 'L','o','c','a','l','P','a','c','k','a','g','e',0};
1666 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_w(szPatchCode
),
1667 debugstr_w(szProductCode
), debugstr_w(szUserSid
), dwContext
,
1668 debugstr_w(szProperty
), lpValue
, pcchValue
);
1670 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1671 return ERROR_INVALID_PARAMETER
;
1673 if (!szPatchCode
|| !squash_guid(szPatchCode
, squished_patch
))
1674 return ERROR_INVALID_PARAMETER
;
1677 return ERROR_INVALID_PARAMETER
;
1679 if (lpValue
&& !pcchValue
)
1680 return ERROR_INVALID_PARAMETER
;
1682 if (dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1683 dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1684 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1685 return ERROR_INVALID_PARAMETER
;
1687 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1688 return ERROR_INVALID_PARAMETER
;
1690 if (szUserSid
&& !strcmpW( szUserSid
, szLocalSid
))
1691 return ERROR_INVALID_PARAMETER
;
1693 if (MSIREG_OpenUserDataProductKey(szProductCode
, dwContext
, NULL
,
1694 &udprod
, FALSE
) != ERROR_SUCCESS
)
1697 if (MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
,
1698 &props
, FALSE
) != ERROR_SUCCESS
)
1701 r
= ERROR_UNKNOWN_PATCH
;
1703 res
= RegOpenKeyExW(udprod
, szPatches
, 0, KEY_WOW64_64KEY
|KEY_READ
, &patches
);
1704 if (res
!= ERROR_SUCCESS
)
1707 res
= RegOpenKeyExW(patches
, squished_patch
, 0, KEY_WOW64_64KEY
|KEY_READ
, &patch
);
1708 if (res
!= ERROR_SUCCESS
)
1711 if (!strcmpW( szProperty
, INSTALLPROPERTY_TRANSFORMSW
))
1713 if (MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
,
1714 &prod
, FALSE
) != ERROR_SUCCESS
)
1717 res
= RegOpenKeyExW(prod
, szPatches
, 0, KEY_WOW64_64KEY
|KEY_ALL_ACCESS
, &prodpatches
);
1718 if (res
!= ERROR_SUCCESS
)
1721 datakey
= prodpatches
;
1722 szProperty
= squished_patch
;
1726 if (MSIREG_OpenUserDataPatchKey(szPatchCode
, dwContext
,
1727 &udpatch
, FALSE
) != ERROR_SUCCESS
)
1730 if (!strcmpW( szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1732 if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1733 szProperty
= szManagedPackage
;
1736 else if (!strcmpW( szProperty
, INSTALLPROPERTY_INSTALLDATEW
))
1739 szProperty
= szInstalled
;
1741 else if (!strcmpW( szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1745 else if (!strcmpW( szProperty
, INSTALLPROPERTY_UNINSTALLABLEW
) ||
1746 !strcmpW( szProperty
, INSTALLPROPERTY_PATCHSTATEW
) ||
1747 !strcmpW( szProperty
, INSTALLPROPERTY_DISPLAYNAMEW
) ||
1748 !strcmpW( szProperty
, INSTALLPROPERTY_MOREINFOURLW
))
1754 r
= ERROR_UNKNOWN_PROPERTY
;
1759 val
= msi_reg_get_val_str(datakey
, szProperty
);
1761 val
= strdupW(szEmpty
);
1769 lstrcpynW(lpValue
, val
, *pcchValue
);
1771 len
= lstrlenW(val
);
1772 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1775 r
= ERROR_MORE_DATA
;
1777 *pcchValue
= len
* sizeof(WCHAR
);
1784 RegCloseKey(prodpatches
);
1787 RegCloseKey(patches
);
1788 RegCloseKey(udpatch
);
1790 RegCloseKey(udprod
);
1795 UINT WINAPI
MsiGetPatchInfoA( LPCSTR patch
, LPCSTR attr
, LPSTR buffer
, LPDWORD buflen
)
1797 UINT r
= ERROR_OUTOFMEMORY
;
1799 LPWSTR patchW
= NULL
, attrW
= NULL
, bufferW
= NULL
;
1801 TRACE("%s %s %p %p\n", debugstr_a(patch
), debugstr_a(attr
), buffer
, buflen
);
1803 if (!patch
|| !attr
)
1804 return ERROR_INVALID_PARAMETER
;
1806 if (!(patchW
= strdupAtoW( patch
)))
1809 if (!(attrW
= strdupAtoW( attr
)))
1813 r
= MsiGetPatchInfoW( patchW
, attrW
, NULL
, &size
);
1814 if (r
!= ERROR_SUCCESS
)
1818 if (!(bufferW
= msi_alloc( size
* sizeof(WCHAR
) )))
1820 r
= ERROR_OUTOFMEMORY
;
1824 r
= MsiGetPatchInfoW( patchW
, attrW
, bufferW
, &size
);
1825 if (r
== ERROR_SUCCESS
)
1827 int len
= WideCharToMultiByte( CP_ACP
, 0, bufferW
, -1, NULL
, 0, NULL
, NULL
);
1829 r
= ERROR_MORE_DATA
;
1831 WideCharToMultiByte( CP_ACP
, 0, bufferW
, -1, buffer
, *buflen
, NULL
, NULL
);
1839 msi_free( bufferW
);
1843 UINT WINAPI
MsiGetPatchInfoW( LPCWSTR patch
, LPCWSTR attr
, LPWSTR buffer
, LPDWORD buflen
)
1846 WCHAR product
[GUID_SIZE
];
1849 TRACE("%s %s %p %p\n", debugstr_w(patch
), debugstr_w(attr
), buffer
, buflen
);
1851 if (!patch
|| !attr
)
1852 return ERROR_INVALID_PARAMETER
;
1854 if (strcmpW( INSTALLPROPERTY_LOCALPACKAGEW
, attr
))
1855 return ERROR_UNKNOWN_PROPERTY
;
1860 r
= MsiEnumProductsW( index
, product
);
1861 if (r
!= ERROR_SUCCESS
)
1864 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, attr
, buffer
, buflen
);
1865 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1868 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, attr
, buffer
, buflen
);
1869 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1872 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_MACHINE
, attr
, buffer
, buflen
);
1873 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1879 return ERROR_UNKNOWN_PRODUCT
;
1882 UINT WINAPI
MsiEnableLogA(DWORD dwLogMode
, LPCSTR szLogFile
, DWORD attributes
)
1884 LPWSTR szwLogFile
= NULL
;
1887 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_a(szLogFile
), attributes
);
1891 szwLogFile
= strdupAtoW( szLogFile
);
1893 return ERROR_OUTOFMEMORY
;
1895 r
= MsiEnableLogW( dwLogMode
, szwLogFile
, attributes
);
1896 msi_free( szwLogFile
);
1900 UINT WINAPI
MsiEnableLogW(DWORD dwLogMode
, LPCWSTR szLogFile
, DWORD attributes
)
1902 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_w(szLogFile
), attributes
);
1904 msi_free(gszLogFile
);
1910 if (!(attributes
& INSTALLLOGATTRIBUTES_APPEND
))
1911 DeleteFileW(szLogFile
);
1912 file
= CreateFileW(szLogFile
, GENERIC_WRITE
, FILE_SHARE_WRITE
, NULL
, OPEN_ALWAYS
,
1913 FILE_ATTRIBUTE_NORMAL
, NULL
);
1914 if (file
!= INVALID_HANDLE_VALUE
)
1916 gszLogFile
= strdupW(szLogFile
);
1920 ERR("Unable to enable log %s (%u)\n", debugstr_w(szLogFile
), GetLastError());
1923 return ERROR_SUCCESS
;
1926 UINT WINAPI
MsiEnumComponentCostsA( MSIHANDLE handle
, LPCSTR component
, DWORD index
,
1927 INSTALLSTATE state
, LPSTR drive
, DWORD
*buflen
,
1928 int *cost
, int *temp
)
1932 WCHAR
*driveW
, *componentW
= NULL
;
1934 TRACE("%d, %s, %u, %d, %p, %p, %p %p\n", handle
, debugstr_a(component
), index
,
1935 state
, drive
, buflen
, cost
, temp
);
1937 if (!drive
|| !buflen
) return ERROR_INVALID_PARAMETER
;
1938 if (component
&& !(componentW
= strdupAtoW( component
))) return ERROR_OUTOFMEMORY
;
1941 if (!(driveW
= msi_alloc( len
* sizeof(WCHAR
) )))
1943 msi_free( componentW
);
1944 return ERROR_OUTOFMEMORY
;
1946 r
= MsiEnumComponentCostsW( handle
, componentW
, index
, state
, driveW
, buflen
, cost
, temp
);
1949 WideCharToMultiByte( CP_ACP
, 0, driveW
, -1, drive
, len
, NULL
, NULL
);
1951 msi_free( componentW
);
1956 static UINT
set_drive( WCHAR
*buffer
, WCHAR letter
)
1964 UINT WINAPI
MsiEnumComponentCostsW( MSIHANDLE handle
, LPCWSTR component
, DWORD index
,
1965 INSTALLSTATE state
, LPWSTR drive
, DWORD
*buflen
,
1966 int *cost
, int *temp
)
1968 UINT r
= ERROR_NO_MORE_ITEMS
;
1969 MSICOMPONENT
*comp
= NULL
;
1970 MSIPACKAGE
*package
;
1973 WCHAR path
[MAX_PATH
];
1975 TRACE("%d, %s, %u, %d, %p, %p, %p %p\n", handle
, debugstr_w(component
), index
,
1976 state
, drive
, buflen
, cost
, temp
);
1978 if (!drive
|| !buflen
|| !cost
|| !temp
) return ERROR_INVALID_PARAMETER
;
1979 if (!(package
= msihandle2msiinfo( handle
, MSIHANDLETYPE_PACKAGE
)))
1982 IWineMsiRemotePackage
*remote_package
;
1985 if (!(remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( handle
)))
1986 return ERROR_INVALID_HANDLE
;
1988 if (component
&& !(bname
= SysAllocString( component
)))
1990 IWineMsiRemotePackage_Release( remote_package
);
1991 return ERROR_OUTOFMEMORY
;
1993 hr
= IWineMsiRemotePackage_EnumComponentCosts( remote_package
, bname
, index
, state
, drive
, buflen
, cost
, temp
);
1994 IWineMsiRemotePackage_Release( remote_package
);
1995 SysFreeString( bname
);
1998 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
) return HRESULT_CODE(hr
);
1999 return ERROR_FUNCTION_FAILED
;
2001 return ERROR_SUCCESS
;
2004 if (!msi_get_property_int( package
->db
, szCostingComplete
, 0 ))
2006 msiobj_release( &package
->hdr
);
2007 return ERROR_FUNCTION_NOT_CALLED
;
2009 if (component
&& component
[0] && !(comp
= msi_get_loaded_component( package
, component
)))
2011 msiobj_release( &package
->hdr
);
2012 return ERROR_UNKNOWN_COMPONENT
;
2017 msiobj_release( &package
->hdr
);
2018 return ERROR_MORE_DATA
;
2022 msiobj_release( &package
->hdr
);
2023 return ERROR_NO_MORE_ITEMS
;
2028 GetWindowsDirectoryW( path
, MAX_PATH
);
2029 if (component
&& component
[0])
2031 if (comp
->assembly
&& !comp
->assembly
->application
) *temp
= comp
->Cost
;
2032 if (!comp
->Enabled
|| !comp
->KeyPath
)
2035 *buflen
= set_drive( drive
, path
[0] );
2038 else if ((file
= msi_get_loaded_file( package
, comp
->KeyPath
)))
2040 *cost
= max( 8, comp
->Cost
/ 512 );
2041 *buflen
= set_drive( drive
, file
->TargetPath
[0] );
2045 else if (IStorage_Stat( package
->db
->storage
, &stat
, STATFLAG_NONAME
) == S_OK
)
2047 *temp
= max( 8, stat
.cbSize
.QuadPart
/ 512 );
2048 *buflen
= set_drive( drive
, path
[0] );
2051 msiobj_release( &package
->hdr
);
2055 UINT WINAPI
MsiQueryComponentStateA(LPCSTR szProductCode
,
2056 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
2057 LPCSTR szComponent
, INSTALLSTATE
*pdwState
)
2059 LPWSTR prodcode
= NULL
, usersid
= NULL
, comp
= NULL
;
2062 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode
),
2063 debugstr_a(szUserSid
), dwContext
, debugstr_a(szComponent
), pdwState
);
2065 if (szProductCode
&& !(prodcode
= strdupAtoW(szProductCode
)))
2066 return ERROR_OUTOFMEMORY
;
2068 if (szUserSid
&& !(usersid
= strdupAtoW(szUserSid
)))
2069 return ERROR_OUTOFMEMORY
;
2071 if (szComponent
&& !(comp
= strdupAtoW(szComponent
)))
2072 return ERROR_OUTOFMEMORY
;
2074 r
= MsiQueryComponentStateW(prodcode
, usersid
, dwContext
, comp
, pdwState
);
2083 static BOOL
msi_comp_find_prod_key(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
2088 r
= MSIREG_OpenProductKey(prodcode
, NULL
, context
, &hkey
, FALSE
);
2090 return (r
== ERROR_SUCCESS
);
2093 static BOOL
msi_comp_find_package(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
2101 static const WCHAR local_package
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
2102 static const WCHAR managed_local_package
[] = {
2103 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
2106 r
= MSIREG_OpenInstallProps(prodcode
, context
, NULL
, &hkey
, FALSE
);
2107 if (r
!= ERROR_SUCCESS
)
2110 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
2111 package
= managed_local_package
;
2113 package
= local_package
;
2116 res
= RegQueryValueExW(hkey
, package
, NULL
, NULL
, NULL
, &sz
);
2119 return (res
== ERROR_SUCCESS
);
2122 static UINT
msi_comp_find_prodcode(LPWSTR squished_pc
,
2123 MSIINSTALLCONTEXT context
,
2124 LPCWSTR comp
, LPWSTR val
, DWORD
*sz
)
2130 if (context
== MSIINSTALLCONTEXT_MACHINE
)
2131 r
= MSIREG_OpenUserDataComponentKey(comp
, szLocalSid
, &hkey
, FALSE
);
2133 r
= MSIREG_OpenUserDataComponentKey(comp
, NULL
, &hkey
, FALSE
);
2135 if (r
!= ERROR_SUCCESS
)
2138 res
= RegQueryValueExW(hkey
, squished_pc
, NULL
, NULL
, (BYTE
*)val
, sz
);
2139 if (res
!= ERROR_SUCCESS
)
2146 UINT WINAPI
MsiQueryComponentStateW(LPCWSTR szProductCode
,
2147 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
2148 LPCWSTR szComponent
, INSTALLSTATE
*pdwState
)
2150 WCHAR squished_pc
[GUID_SIZE
];
2154 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode
),
2155 debugstr_w(szUserSid
), dwContext
, debugstr_w(szComponent
), pdwState
);
2157 if (!pdwState
|| !szComponent
)
2158 return ERROR_INVALID_PARAMETER
;
2160 if (!szProductCode
|| !*szProductCode
|| lstrlenW(szProductCode
) != GUID_SIZE
- 1)
2161 return ERROR_INVALID_PARAMETER
;
2163 if (!squash_guid(szProductCode
, squished_pc
))
2164 return ERROR_INVALID_PARAMETER
;
2166 found
= msi_comp_find_prod_key(szProductCode
, dwContext
);
2168 if (!msi_comp_find_package(szProductCode
, dwContext
))
2172 *pdwState
= INSTALLSTATE_UNKNOWN
;
2173 return ERROR_UNKNOWN_COMPONENT
;
2176 return ERROR_UNKNOWN_PRODUCT
;
2179 *pdwState
= INSTALLSTATE_UNKNOWN
;
2182 if (msi_comp_find_prodcode(squished_pc
, dwContext
, szComponent
, NULL
, &sz
))
2183 return ERROR_UNKNOWN_COMPONENT
;
2186 *pdwState
= INSTALLSTATE_NOTUSED
;
2192 if (!(val
= msi_alloc( sz
))) return ERROR_OUTOFMEMORY
;
2193 if ((r
= msi_comp_find_prodcode(squished_pc
, dwContext
, szComponent
, val
, &sz
)))
2199 if (lstrlenW(val
) > 2 &&
2200 val
[0] >= '0' && val
[0] <= '9' && val
[1] >= '0' && val
[1] <= '9' && val
[2] != ':')
2202 *pdwState
= INSTALLSTATE_SOURCE
;
2205 *pdwState
= INSTALLSTATE_LOCAL
;
2209 TRACE("-> %d\n", *pdwState
);
2210 return ERROR_SUCCESS
;
2213 INSTALLSTATE WINAPI
MsiQueryProductStateA(LPCSTR szProduct
)
2215 LPWSTR szwProduct
= NULL
;
2220 szwProduct
= strdupAtoW( szProduct
);
2222 return ERROR_OUTOFMEMORY
;
2224 r
= MsiQueryProductStateW( szwProduct
);
2225 msi_free( szwProduct
);
2229 INSTALLSTATE WINAPI
MsiQueryProductStateW(LPCWSTR szProduct
)
2231 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
2232 INSTALLSTATE state
= INSTALLSTATE_ADVERTISED
;
2233 HKEY prodkey
= 0, userdata
= 0;
2237 TRACE("%s\n", debugstr_w(szProduct
));
2239 if (!szProduct
|| !*szProduct
)
2240 return INSTALLSTATE_INVALIDARG
;
2242 if (lstrlenW(szProduct
) != GUID_SIZE
- 1)
2243 return INSTALLSTATE_INVALIDARG
;
2245 if (szProduct
[0] != '{' || szProduct
[37] != '}')
2246 return INSTALLSTATE_UNKNOWN
;
2248 SetLastError( ERROR_SUCCESS
);
2250 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2251 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
2252 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2253 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
2254 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
2255 &prodkey
, FALSE
) == ERROR_SUCCESS
)
2257 context
= MSIINSTALLCONTEXT_MACHINE
;
2260 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
2261 if (r
!= ERROR_SUCCESS
)
2264 if (!msi_reg_get_val_dword(userdata
, szWindowsInstaller
, &val
))
2268 state
= INSTALLSTATE_DEFAULT
;
2270 state
= INSTALLSTATE_UNKNOWN
;
2275 state
= INSTALLSTATE_UNKNOWN
;
2278 state
= INSTALLSTATE_ABSENT
;
2281 RegCloseKey(prodkey
);
2282 RegCloseKey(userdata
);
2283 TRACE("-> %d\n", state
);
2287 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
2289 INSTALLUILEVEL old
= gUILevel
;
2290 HWND oldwnd
= gUIhwnd
;
2292 TRACE("%08x %p\n", dwUILevel
, phWnd
);
2294 gUILevel
= dwUILevel
;
2303 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
2304 DWORD dwMessageFilter
, LPVOID pvContext
)
2306 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
2308 TRACE("%p %08x %p\n", puiHandler
, dwMessageFilter
, pvContext
);
2310 gUIHandlerA
= puiHandler
;
2312 gUIFilter
= dwMessageFilter
;
2313 gUIContext
= pvContext
;
2318 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
2319 DWORD dwMessageFilter
, LPVOID pvContext
)
2321 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
2323 TRACE("%p %08x %p\n", puiHandler
, dwMessageFilter
, pvContext
);
2326 gUIHandlerW
= puiHandler
;
2327 gUIFilter
= dwMessageFilter
;
2328 gUIContext
= pvContext
;
2333 /******************************************************************
2334 * MsiLoadStringW [MSI.@]
2336 * Loads a string from MSI's string resources.
2340 * handle [I] only -1 is handled currently
2341 * id [I] id of the string to be loaded
2342 * lpBuffer [O] buffer for the string to be written to
2343 * nBufferMax [I] maximum size of the buffer in characters
2344 * lang [I] the preferred language for the string
2348 * If successful, this function returns the language id of the string loaded
2349 * If the function fails, the function returns zero.
2353 * The type of the first parameter is unknown. LoadString's prototype
2354 * suggests that it might be a module handle. I have made it an MSI handle
2355 * for starters, as -1 is an invalid MSI handle, but not an invalid module
2356 * handle. Maybe strings can be stored in an MSI database somehow.
2358 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
2359 int nBufferMax
, LANGID lang
)
2366 TRACE("%d %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
2369 FIXME("don't know how to deal with handle = %08x\n", handle
);
2372 lang
= GetUserDefaultLangID();
2374 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
2378 hResData
= LoadResource( msi_hInstance
, hres
);
2381 p
= LockResource( hResData
);
2385 for (i
= 0; i
< (id
& 0xf); i
++) p
+= *p
+ 1;
2388 if( nBufferMax
<= len
)
2391 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
2392 lpBuffer
[ len
] = 0;
2394 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
2398 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
2399 int nBufferMax
, LANGID lang
)
2405 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
2406 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
2409 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
2410 if( len
<= nBufferMax
)
2411 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
2412 lpBuffer
, nBufferMax
, NULL
, NULL
);
2420 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
2423 char szProduct
[GUID_SIZE
];
2425 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
2427 if (!szComponent
|| !pcchBuf
)
2428 return INSTALLSTATE_INVALIDARG
;
2430 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
2431 return INSTALLSTATE_UNKNOWN
;
2433 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
2436 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
2439 WCHAR szProduct
[GUID_SIZE
];
2441 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
2443 if (!szComponent
|| !pcchBuf
)
2444 return INSTALLSTATE_INVALIDARG
;
2446 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
2447 return INSTALLSTATE_UNKNOWN
;
2449 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
2452 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
2453 WORD wLanguageId
, DWORD f
)
2455 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_a(lpText
), debugstr_a(lpCaption
),
2456 uType
, wLanguageId
, f
);
2457 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
2460 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
2461 WORD wLanguageId
, DWORD f
)
2463 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_w(lpText
), debugstr_w(lpCaption
),
2464 uType
, wLanguageId
, f
);
2465 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
2468 UINT WINAPI
MsiMessageBoxExA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
2469 DWORD unknown
, WORD wLanguageId
, DWORD f
)
2471 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd
, debugstr_a(lpText
),
2472 debugstr_a(lpCaption
), uType
, unknown
, wLanguageId
, f
);
2473 return MessageBoxExA(hWnd
, lpText
, lpCaption
, uType
, wLanguageId
);
2476 UINT WINAPI
MsiMessageBoxExW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
2477 DWORD unknown
, WORD wLanguageId
, DWORD f
)
2479 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd
, debugstr_w(lpText
),
2480 debugstr_w(lpCaption
), uType
, unknown
, wLanguageId
, f
);
2481 return MessageBoxExW(hWnd
, lpText
, lpCaption
, uType
, wLanguageId
);
2484 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
2485 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
2486 LPDWORD pcchPathBuf
)
2488 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName
),
2489 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2491 return ERROR_CALL_NOT_IMPLEMENTED
;
2494 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
2495 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
2496 LPDWORD pcchPathBuf
)
2498 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName
),
2499 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2501 return ERROR_CALL_NOT_IMPLEMENTED
;
2504 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
2505 LPSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2507 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2508 return ERROR_CALL_NOT_IMPLEMENTED
;
2511 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
2512 LPWSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2514 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2515 return ERROR_CALL_NOT_IMPLEMENTED
;
2518 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR path
, DWORD flags
, PCCERT_CONTEXT
*cert
,
2519 LPBYTE hash
, LPDWORD hashlen
)
2522 WCHAR
*pathW
= NULL
;
2524 TRACE("%s %08x %p %p %p\n", debugstr_a(path
), flags
, cert
, hash
, hashlen
);
2526 if (path
&& !(pathW
= strdupAtoW( path
))) return ERROR_OUTOFMEMORY
;
2527 r
= MsiGetFileSignatureInformationW( pathW
, flags
, cert
, hash
, hashlen
);
2532 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR path
, DWORD flags
, PCCERT_CONTEXT
*cert
,
2533 LPBYTE hash
, LPDWORD hashlen
)
2535 static GUID generic_verify_v2
= WINTRUST_ACTION_GENERIC_VERIFY_V2
;
2538 WINTRUST_FILE_INFO info
;
2539 CRYPT_PROVIDER_SGNR
*signer
;
2540 CRYPT_PROVIDER_CERT
*provider
;
2542 TRACE("%s %08x %p %p %p\n", debugstr_w(path
), flags
, cert
, hash
, hashlen
);
2544 if (!path
|| !cert
) return E_INVALIDARG
;
2546 info
.cbStruct
= sizeof(info
);
2547 info
.pcwszFilePath
= path
;
2549 info
.pgKnownSubject
= NULL
;
2551 data
.cbStruct
= sizeof(data
);
2552 data
.pPolicyCallbackData
= NULL
;
2553 data
.pSIPClientData
= NULL
;
2554 data
.dwUIChoice
= WTD_UI_NONE
;
2555 data
.fdwRevocationChecks
= WTD_REVOKE_WHOLECHAIN
;
2556 data
.dwUnionChoice
= WTD_CHOICE_FILE
;
2557 data
.u
.pFile
= &info
;
2558 data
.dwStateAction
= WTD_STATEACTION_VERIFY
;
2559 data
.hWVTStateData
= NULL
;
2560 data
.pwszURLReference
= NULL
;
2561 data
.dwProvFlags
= 0;
2562 data
.dwUIContext
= WTD_UICONTEXT_INSTALL
;
2563 hr
= WinVerifyTrustEx( INVALID_HANDLE_VALUE
, &generic_verify_v2
, &data
);
2565 if (FAILED(hr
)) goto done
;
2567 if (!(signer
= WTHelperGetProvSignerFromChain( data
.hWVTStateData
, 0, FALSE
, 0 )))
2569 hr
= TRUST_E_NOSIGNATURE
;
2574 DWORD len
= signer
->psSigner
->EncryptedHash
.cbData
;
2578 hr
= HRESULT_FROM_WIN32(ERROR_MORE_DATA
);
2581 memcpy( hash
, signer
->psSigner
->EncryptedHash
.pbData
, len
);
2584 if (!(provider
= WTHelperGetProvCertFromChain( signer
, 0 )))
2586 hr
= TRUST_E_PROVIDER_UNKNOWN
;
2589 *cert
= CertDuplicateCertificateContext( provider
->pCert
);
2592 data
.dwStateAction
= WTD_STATEACTION_CLOSE
;
2593 WinVerifyTrustEx( INVALID_HANDLE_VALUE
, &generic_verify_v2
, &data
);
2597 /******************************************************************
2598 * MsiGetProductPropertyA [MSI.@]
2600 UINT WINAPI
MsiGetProductPropertyA(MSIHANDLE hProduct
, LPCSTR szProperty
,
2601 LPSTR szValue
, LPDWORD pccbValue
)
2603 LPWSTR prop
= NULL
, val
= NULL
;
2607 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_a(szProperty
),
2608 szValue
, pccbValue
);
2610 if (szValue
&& !pccbValue
)
2611 return ERROR_INVALID_PARAMETER
;
2613 if (szProperty
) prop
= strdupAtoW(szProperty
);
2616 r
= MsiGetProductPropertyW(hProduct
, prop
, NULL
, &len
);
2617 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2620 if (r
== ERROR_SUCCESS
)
2622 if (szValue
) *szValue
= '\0';
2623 if (pccbValue
) *pccbValue
= 0;
2627 val
= msi_alloc(++len
* sizeof(WCHAR
));
2630 r
= ERROR_OUTOFMEMORY
;
2634 r
= MsiGetProductPropertyW(hProduct
, prop
, val
, &len
);
2635 if (r
!= ERROR_SUCCESS
)
2638 len
= WideCharToMultiByte(CP_ACP
, 0, val
, -1, NULL
, 0, NULL
, NULL
);
2641 WideCharToMultiByte(CP_ACP
, 0, val
, -1, szValue
,
2642 *pccbValue
, NULL
, NULL
);
2646 if (len
> *pccbValue
)
2647 r
= ERROR_MORE_DATA
;
2649 *pccbValue
= len
- 1;
2659 /******************************************************************
2660 * MsiGetProductPropertyW [MSI.@]
2662 UINT WINAPI
MsiGetProductPropertyW(MSIHANDLE hProduct
, LPCWSTR szProperty
,
2663 LPWSTR szValue
, LPDWORD pccbValue
)
2665 MSIPACKAGE
*package
;
2666 MSIQUERY
*view
= NULL
;
2667 MSIRECORD
*rec
= NULL
;
2671 static const WCHAR query
[] = {
2672 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2673 '`','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2674 '`','P','r','o','p','e','r','t','y','`','=','\'','%','s','\'',0};
2676 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_w(szProperty
),
2677 szValue
, pccbValue
);
2680 return ERROR_INVALID_PARAMETER
;
2682 if (szValue
&& !pccbValue
)
2683 return ERROR_INVALID_PARAMETER
;
2685 package
= msihandle2msiinfo(hProduct
, MSIHANDLETYPE_PACKAGE
);
2687 return ERROR_INVALID_HANDLE
;
2689 r
= MSI_OpenQuery(package
->db
, &view
, query
, szProperty
);
2690 if (r
!= ERROR_SUCCESS
)
2693 r
= MSI_ViewExecute(view
, 0);
2694 if (r
!= ERROR_SUCCESS
)
2697 r
= MSI_ViewFetch(view
, &rec
);
2698 if (r
!= ERROR_SUCCESS
)
2701 val
= MSI_RecordGetString(rec
, 2);
2705 if (lstrlenW(val
) >= *pccbValue
)
2707 lstrcpynW(szValue
, val
, *pccbValue
);
2708 *pccbValue
= lstrlenW(val
);
2709 r
= ERROR_MORE_DATA
;
2713 lstrcpyW(szValue
, val
);
2714 *pccbValue
= lstrlenW(val
);
2721 MSI_ViewClose(view
);
2722 msiobj_release(&view
->hdr
);
2723 if (rec
) msiobj_release(&rec
->hdr
);
2728 if (szValue
) *szValue
= '\0';
2729 if (pccbValue
) *pccbValue
= 0;
2733 msiobj_release(&package
->hdr
);
2737 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
2740 LPWSTR szPack
= NULL
;
2742 TRACE("%s\n", debugstr_a(szPackage
) );
2746 szPack
= strdupAtoW( szPackage
);
2748 return ERROR_OUTOFMEMORY
;
2751 r
= MsiVerifyPackageW( szPack
);
2758 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
2763 TRACE("%s\n", debugstr_w(szPackage
) );
2765 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
2766 MsiCloseHandle( handle
);
2771 static INSTALLSTATE
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
2772 awstring
* lpPathBuf
, LPDWORD pcchBuf
)
2774 static const WCHAR wininstaller
[] =
2775 {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
2776 WCHAR squished_pc
[GUID_SIZE
];
2777 WCHAR squished_comp
[GUID_SIZE
];
2783 if (!szProduct
|| !szComponent
)
2784 return INSTALLSTATE_INVALIDARG
;
2786 if (lpPathBuf
->str
.w
&& !pcchBuf
)
2787 return INSTALLSTATE_INVALIDARG
;
2789 if (!squash_guid(szProduct
, squished_pc
) ||
2790 !squash_guid(szComponent
, squished_comp
))
2791 return INSTALLSTATE_INVALIDARG
;
2793 state
= INSTALLSTATE_UNKNOWN
;
2795 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2796 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2798 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2801 state
= INSTALLSTATE_ABSENT
;
2803 if ((MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
, NULL
,
2804 &hkey
, FALSE
) == ERROR_SUCCESS
||
2805 MSIREG_OpenUserDataProductKey(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2806 NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
) &&
2807 msi_reg_get_val_dword(hkey
, wininstaller
, &version
) &&
2808 GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2811 state
= INSTALLSTATE_LOCAL
;
2815 if (state
!= INSTALLSTATE_LOCAL
&&
2816 (MSIREG_OpenProductKey(szProduct
, NULL
,
2817 MSIINSTALLCONTEXT_USERUNMANAGED
,
2818 &hkey
, FALSE
) == ERROR_SUCCESS
||
2819 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
2820 &hkey
, FALSE
) == ERROR_SUCCESS
))
2824 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2825 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2828 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2831 state
= INSTALLSTATE_ABSENT
;
2833 if (GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2834 state
= INSTALLSTATE_LOCAL
;
2839 return INSTALLSTATE_UNKNOWN
;
2841 if (state
== INSTALLSTATE_LOCAL
&& !*path
)
2842 state
= INSTALLSTATE_NOTUSED
;
2844 msi_strcpy_to_awstring(path
, -1, lpPathBuf
, pcchBuf
);
2849 /******************************************************************
2850 * MsiGetComponentPathW [MSI.@]
2852 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
2853 LPWSTR lpPathBuf
, LPDWORD pcchBuf
)
2857 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
2859 path
.unicode
= TRUE
;
2860 path
.str
.w
= lpPathBuf
;
2862 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
2865 /******************************************************************
2866 * MsiGetComponentPathA [MSI.@]
2868 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
2869 LPSTR lpPathBuf
, LPDWORD pcchBuf
)
2871 LPWSTR szwProduct
, szwComponent
= NULL
;
2872 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
2875 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
2877 szwProduct
= strdupAtoW( szProduct
);
2878 if( szProduct
&& !szwProduct
)
2881 szwComponent
= strdupAtoW( szComponent
);
2882 if( szComponent
&& !szwComponent
)
2885 path
.unicode
= FALSE
;
2886 path
.str
.a
= lpPathBuf
;
2888 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
2891 msi_free( szwProduct
);
2892 msi_free( szwComponent
);
2897 static UINT
query_feature_state( const WCHAR
*product
, const WCHAR
*squashed
, const WCHAR
*usersid
,
2898 MSIINSTALLCONTEXT ctx
, const WCHAR
*feature
, INSTALLSTATE
*state
)
2902 WCHAR
*parent
, *components
, *path
;
2904 BOOL missing
= FALSE
, source
= FALSE
;
2905 WCHAR comp
[GUID_SIZE
];
2908 if (ctx
!= MSIINSTALLCONTEXT_MACHINE
) SetLastError( ERROR_SUCCESS
);
2910 if (MSIREG_OpenFeaturesKey( product
, usersid
, ctx
, &hkey
, FALSE
)) return ERROR_UNKNOWN_PRODUCT
;
2912 parent
= msi_reg_get_val_str( hkey
, feature
);
2913 RegCloseKey( hkey
);
2914 if (!parent
) return ERROR_UNKNOWN_FEATURE
;
2916 *state
= (parent
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
2918 if (*state
== INSTALLSTATE_ABSENT
)
2919 return ERROR_SUCCESS
;
2921 r
= MSIREG_OpenUserDataFeaturesKey( product
, usersid
, ctx
, &hkey
, FALSE
);
2922 if (r
!= ERROR_SUCCESS
)
2924 *state
= INSTALLSTATE_ADVERTISED
;
2925 return ERROR_SUCCESS
;
2927 components
= msi_reg_get_val_str( hkey
, feature
);
2928 RegCloseKey( hkey
);
2930 TRACE("buffer = %s\n", debugstr_w(components
));
2934 *state
= INSTALLSTATE_ADVERTISED
;
2935 return ERROR_SUCCESS
;
2937 for (p
= components
; *p
&& *p
!= 2 ; p
+= 20)
2939 if (!decode_base85_guid( p
, &guid
))
2941 if (p
!= components
) break;
2942 msi_free( components
);
2943 *state
= INSTALLSTATE_BADCONFIG
;
2944 return ERROR_BAD_CONFIGURATION
;
2946 StringFromGUID2( &guid
, comp
, GUID_SIZE
);
2947 if (ctx
== MSIINSTALLCONTEXT_MACHINE
)
2948 r
= MSIREG_OpenUserDataComponentKey( comp
, szLocalSid
, &hkey
, FALSE
);
2950 r
= MSIREG_OpenUserDataComponentKey( comp
, usersid
, &hkey
, FALSE
);
2952 if (r
!= ERROR_SUCCESS
)
2954 msi_free( components
);
2955 *state
= INSTALLSTATE_ADVERTISED
;
2956 return ERROR_SUCCESS
;
2958 path
= msi_reg_get_val_str( hkey
, squashed
);
2959 if (!path
) missing
= TRUE
;
2960 else if (strlenW( path
) > 2 &&
2961 path
[0] >= '0' && path
[0] <= '9' &&
2962 path
[1] >= '0' && path
[1] <= '9')
2968 msi_free( components
);
2971 *state
= INSTALLSTATE_ADVERTISED
;
2973 *state
= INSTALLSTATE_SOURCE
;
2975 *state
= INSTALLSTATE_LOCAL
;
2977 TRACE("returning state %d\n", *state
);
2978 return ERROR_SUCCESS
;
2981 UINT WINAPI
MsiQueryFeatureStateExA( LPCSTR product
, LPCSTR usersid
, MSIINSTALLCONTEXT ctx
,
2982 LPCSTR feature
, INSTALLSTATE
*state
)
2985 WCHAR
*productW
= NULL
, *usersidW
= NULL
, *featureW
= NULL
;
2987 if (product
&& !(productW
= strdupAtoW( product
))) return ERROR_OUTOFMEMORY
;
2988 if (usersid
&& !(usersidW
= strdupAtoW( usersid
)))
2990 msi_free( productW
);
2991 return ERROR_OUTOFMEMORY
;
2993 if (feature
&& !(featureW
= strdupAtoW( feature
)))
2995 msi_free( productW
);
2996 msi_free( usersidW
);
2997 return ERROR_OUTOFMEMORY
;
2999 r
= MsiQueryFeatureStateExW( productW
, usersidW
, ctx
, featureW
, state
);
3000 msi_free( productW
);
3001 msi_free( usersidW
);
3002 msi_free( featureW
);
3006 UINT WINAPI
MsiQueryFeatureStateExW( LPCWSTR product
, LPCWSTR usersid
, MSIINSTALLCONTEXT ctx
,
3007 LPCWSTR feature
, INSTALLSTATE
*state
)
3010 if (!squash_guid( product
, squashed
)) return ERROR_INVALID_PARAMETER
;
3011 return query_feature_state( product
, squashed
, usersid
, ctx
, feature
, state
);
3014 /******************************************************************
3015 * MsiQueryFeatureStateA [MSI.@]
3017 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
3019 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
3020 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
3022 szwProduct
= strdupAtoW( szProduct
);
3023 if ( szProduct
&& !szwProduct
)
3026 szwFeature
= strdupAtoW( szFeature
);
3027 if ( szFeature
&& !szwFeature
)
3030 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
3033 msi_free( szwProduct
);
3034 msi_free( szwFeature
);
3039 /******************************************************************
3040 * MsiQueryFeatureStateW [MSI.@]
3042 * Checks the state of a feature
3045 * szProduct [I] Product's GUID string
3046 * szFeature [I] Feature's GUID string
3049 * INSTALLSTATE_LOCAL Feature is installed and usable
3050 * INSTALLSTATE_ABSENT Feature is absent
3051 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
3052 * INSTALLSTATE_UNKNOWN An error occurred
3053 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
3056 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
3062 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
3064 if (!szProduct
|| !szFeature
|| !squash_guid( szProduct
, squashed
))
3065 return INSTALLSTATE_INVALIDARG
;
3067 r
= query_feature_state( szProduct
, squashed
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, szFeature
, &state
);
3068 if (r
== ERROR_SUCCESS
|| r
== ERROR_BAD_CONFIGURATION
) return state
;
3070 r
= query_feature_state( szProduct
, squashed
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, szFeature
, &state
);
3071 if (r
== ERROR_SUCCESS
|| r
== ERROR_BAD_CONFIGURATION
) return state
;
3073 r
= query_feature_state( szProduct
, squashed
, NULL
, MSIINSTALLCONTEXT_MACHINE
, szFeature
, &state
);
3074 if (r
== ERROR_SUCCESS
|| r
== ERROR_BAD_CONFIGURATION
) return state
;
3076 return INSTALLSTATE_UNKNOWN
;
3079 /******************************************************************
3080 * MsiGetFileVersionA [MSI.@]
3082 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
3083 LPDWORD pcchVersionBuf
, LPSTR lpLangBuf
, LPDWORD pcchLangBuf
)
3085 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
3086 UINT ret
= ERROR_OUTOFMEMORY
;
3088 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
3089 (lpLangBuf
&& !pcchLangBuf
))
3090 return ERROR_INVALID_PARAMETER
;
3094 szwFilePath
= strdupAtoW( szFilePath
);
3099 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
3101 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
3102 if( !lpwVersionBuff
)
3106 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
3108 lpwLangBuff
= msi_alloc(*pcchLangBuf
*sizeof(WCHAR
));
3113 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
3114 lpwLangBuff
, pcchLangBuf
);
3116 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwVersionBuff
)
3117 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
3118 lpVersionBuf
, *pcchVersionBuf
+ 1, NULL
, NULL
);
3119 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwLangBuff
)
3120 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
3121 lpLangBuf
, *pcchLangBuf
+ 1, NULL
, NULL
);
3124 msi_free(szwFilePath
);
3125 msi_free(lpwVersionBuff
);
3126 msi_free(lpwLangBuff
);
3131 static UINT
get_file_version( const WCHAR
*path
, WCHAR
*verbuf
, DWORD
*verlen
,
3132 WCHAR
*langbuf
, DWORD
*langlen
)
3134 static const WCHAR szVersionResource
[] = {'\\',0};
3135 static const WCHAR szVersionFormat
[] = {'%','d','.','%','d','.','%','d','.','%','d',0};
3136 static const WCHAR szLangFormat
[] = {'%','d',0};
3137 UINT ret
= ERROR_MORE_DATA
;
3140 VS_FIXEDFILEINFO
*ffi
;
3144 if (!(len
= GetFileVersionInfoSizeW( path
, NULL
)))
3146 error
= GetLastError();
3147 if (error
== ERROR_BAD_PATHNAME
) return ERROR_FILE_NOT_FOUND
;
3148 if (error
== ERROR_RESOURCE_DATA_NOT_FOUND
) return ERROR_FILE_INVALID
;
3151 if (!(version
= msi_alloc( len
))) return ERROR_OUTOFMEMORY
;
3152 if (!GetFileVersionInfoW( path
, 0, len
, version
))
3154 msi_free( version
);
3155 return GetLastError();
3157 if (!verbuf
&& !verlen
&& !langbuf
&& !langlen
)
3159 msi_free( version
);
3160 return ERROR_SUCCESS
;
3164 if (VerQueryValueW( version
, szVersionResource
, (LPVOID
*)&ffi
, &len
) && len
> 0)
3166 sprintfW( tmp
, szVersionFormat
,
3167 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
3168 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
) );
3169 if (verbuf
) lstrcpynW( verbuf
, tmp
, *verlen
);
3170 len
= strlenW( tmp
);
3171 if (*verlen
> len
) ret
= ERROR_SUCCESS
;
3176 if (verbuf
) *verbuf
= 0;
3182 if (VerQueryValueW( version
, szLangResource
, (LPVOID
*)&lang
, &len
) && len
> 0)
3184 sprintfW( tmp
, szLangFormat
, *lang
);
3185 if (langbuf
) lstrcpynW( langbuf
, tmp
, *langlen
);
3186 len
= strlenW( tmp
);
3187 if (*langlen
> len
) ret
= ERROR_SUCCESS
;
3192 if (langbuf
) *langbuf
= 0;
3196 msi_free( version
);
3201 /******************************************************************
3202 * MsiGetFileVersionW [MSI.@]
3204 UINT WINAPI
MsiGetFileVersionW( LPCWSTR path
, LPWSTR verbuf
, LPDWORD verlen
,
3205 LPWSTR langbuf
, LPDWORD langlen
)
3209 TRACE("%s %p %u %p %u\n", debugstr_w(path
), verbuf
, verlen
? *verlen
: 0,
3210 langbuf
, langlen
? *langlen
: 0);
3212 if ((verbuf
&& !verlen
) || (langbuf
&& !langlen
))
3213 return ERROR_INVALID_PARAMETER
;
3215 ret
= get_file_version( path
, verbuf
, verlen
, langbuf
, langlen
);
3216 if (ret
== ERROR_RESOURCE_DATA_NOT_FOUND
&& verlen
)
3219 WCHAR
*version
= msi_font_version_from_file( path
);
3220 if (!version
) return ERROR_FILE_INVALID
;
3221 len
= strlenW( version
);
3222 if (len
>= *verlen
) ret
= ERROR_MORE_DATA
;
3225 strcpyW( verbuf
, version
);
3226 ret
= ERROR_SUCCESS
;
3229 msi_free( version
);
3234 /***********************************************************************
3235 * MsiGetFeatureUsageW [MSI.@]
3237 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3238 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
3240 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
3241 pdwUseCount
, pwDateUsed
);
3242 return ERROR_CALL_NOT_IMPLEMENTED
;
3245 /***********************************************************************
3246 * MsiGetFeatureUsageA [MSI.@]
3248 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
3249 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
3251 LPWSTR prod
= NULL
, feat
= NULL
;
3252 UINT ret
= ERROR_OUTOFMEMORY
;
3254 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3255 pdwUseCount
, pwDateUsed
);
3257 prod
= strdupAtoW( szProduct
);
3258 if (szProduct
&& !prod
)
3261 feat
= strdupAtoW( szFeature
);
3262 if (szFeature
&& !feat
)
3265 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
3274 /***********************************************************************
3275 * MsiUseFeatureExW [MSI.@]
3277 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3278 DWORD dwInstallMode
, DWORD dwReserved
)
3282 TRACE("%s %s %i %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
3283 dwInstallMode
, dwReserved
);
3285 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
3288 return INSTALLSTATE_INVALIDARG
;
3290 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
3292 FIXME("mark product %s feature %s as used\n",
3293 debugstr_w(szProduct
), debugstr_w(szFeature
) );
3299 /***********************************************************************
3300 * MsiUseFeatureExA [MSI.@]
3302 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
3303 DWORD dwInstallMode
, DWORD dwReserved
)
3305 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
3306 LPWSTR prod
= NULL
, feat
= NULL
;
3308 TRACE("%s %s %i %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3309 dwInstallMode
, dwReserved
);
3311 prod
= strdupAtoW( szProduct
);
3312 if (szProduct
&& !prod
)
3315 feat
= strdupAtoW( szFeature
);
3316 if (szFeature
&& !feat
)
3319 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
3328 /***********************************************************************
3329 * MsiUseFeatureW [MSI.@]
3331 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
3333 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
3336 /***********************************************************************
3337 * MsiUseFeatureA [MSI.@]
3339 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
3341 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
3344 /***********************************************************************
3345 * MSI_ProvideQualifiedComponentEx [internal]
3347 static UINT
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
3348 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
3349 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
3350 LPDWORD pcchPathBuf
)
3352 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
3353 feature
[MAX_FEATURE_CHARS
+1];
3359 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
3360 if (rc
!= ERROR_SUCCESS
)
3361 return ERROR_INDEX_ABSENT
;
3363 info
= msi_reg_get_val_str( hkey
, szQualifier
);
3367 return ERROR_INDEX_ABSENT
;
3369 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
3372 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
3374 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
3378 if (rc
!= INSTALLSTATE_LOCAL
)
3379 return ERROR_FILE_NOT_FOUND
;
3381 return ERROR_SUCCESS
;
3384 /***********************************************************************
3385 * MsiProvideQualifiedComponentExW [MSI.@]
3387 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
3388 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
3389 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
3390 LPDWORD pcchPathBuf
)
3394 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_w(szComponent
),
3395 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
3396 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
3398 path
.unicode
= TRUE
;
3399 path
.str
.w
= lpPathBuf
;
3401 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
3402 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
3405 /***********************************************************************
3406 * MsiProvideQualifiedComponentExA [MSI.@]
3408 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
3409 LPCSTR szQualifier
, DWORD dwInstallMode
, LPCSTR szProduct
,
3410 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
3411 LPDWORD pcchPathBuf
)
3413 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
3414 UINT r
= ERROR_OUTOFMEMORY
;
3417 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent
),
3418 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
3419 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
3421 szwComponent
= strdupAtoW( szComponent
);
3422 if (szComponent
&& !szwComponent
)
3425 szwQualifier
= strdupAtoW( szQualifier
);
3426 if (szQualifier
&& !szwQualifier
)
3429 szwProduct
= strdupAtoW( szProduct
);
3430 if (szProduct
&& !szwProduct
)
3433 path
.unicode
= FALSE
;
3434 path
.str
.a
= lpPathBuf
;
3436 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
3437 dwInstallMode
, szwProduct
, Unused1
,
3438 Unused2
, &path
, pcchPathBuf
);
3440 msi_free(szwProduct
);
3441 msi_free(szwComponent
);
3442 msi_free(szwQualifier
);
3447 /***********************************************************************
3448 * MsiProvideQualifiedComponentW [MSI.@]
3450 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
3451 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
3452 LPDWORD pcchPathBuf
)
3454 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
3455 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3458 /***********************************************************************
3459 * MsiProvideQualifiedComponentA [MSI.@]
3461 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
3462 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
3463 LPDWORD pcchPathBuf
)
3465 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
3466 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3469 /***********************************************************************
3470 * MSI_GetUserInfo [internal]
3472 static USERINFOSTATE
MSI_GetUserInfo(LPCWSTR szProduct
,
3473 awstring
*lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3474 awstring
*lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3475 awstring
*lpSerialBuf
, LPDWORD pcchSerialBuf
)
3477 WCHAR squished_pc
[SQUISH_GUID_SIZE
];
3478 LPWSTR user
, org
, serial
;
3479 USERINFOSTATE state
;
3484 TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct
), lpUserNameBuf
,
3485 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
3488 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
3489 return USERINFOSTATE_INVALIDARG
;
3491 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
3492 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3493 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3494 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3495 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
3496 &hkey
, FALSE
) != ERROR_SUCCESS
)
3498 return USERINFOSTATE_UNKNOWN
;
3501 if (MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3502 NULL
, &props
, FALSE
) != ERROR_SUCCESS
&&
3503 MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
3504 NULL
, &props
, FALSE
) != ERROR_SUCCESS
)
3507 return USERINFOSTATE_ABSENT
;
3510 user
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGOWNERW
);
3511 org
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGCOMPANYW
);
3512 serial
= msi_reg_get_val_str(props
, INSTALLPROPERTY_PRODUCTIDW
);
3513 state
= USERINFOSTATE_ABSENT
;
3519 state
= USERINFOSTATE_PRESENT
;
3521 if (pcchUserNameBuf
)
3523 if (lpUserNameBuf
&& !user
)
3525 (*pcchUserNameBuf
)--;
3529 r
= msi_strcpy_to_awstring(user
, -1, lpUserNameBuf
, pcchUserNameBuf
);
3530 if (r
== ERROR_MORE_DATA
)
3532 state
= USERINFOSTATE_MOREDATA
;
3540 if (!orgptr
) orgptr
= szEmpty
;
3542 r
= msi_strcpy_to_awstring(orgptr
, -1, lpOrgNameBuf
, pcchOrgNameBuf
);
3543 if (r
== ERROR_MORE_DATA
)
3545 state
= USERINFOSTATE_MOREDATA
;
3558 r
= msi_strcpy_to_awstring(serial
, -1, lpSerialBuf
, pcchSerialBuf
);
3559 if (r
== ERROR_MORE_DATA
)
3560 state
= USERINFOSTATE_MOREDATA
;
3571 /***********************************************************************
3572 * MsiGetUserInfoW [MSI.@]
3574 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
3575 LPWSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3576 LPWSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3577 LPWSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3579 awstring user
, org
, serial
;
3581 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3582 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3583 (lpSerialBuf
&& !pcchSerialBuf
))
3584 return USERINFOSTATE_INVALIDARG
;
3586 user
.unicode
= TRUE
;
3587 user
.str
.w
= lpUserNameBuf
;
3589 org
.str
.w
= lpOrgNameBuf
;
3590 serial
.unicode
= TRUE
;
3591 serial
.str
.w
= lpSerialBuf
;
3593 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
3594 &org
, pcchOrgNameBuf
,
3595 &serial
, pcchSerialBuf
);
3598 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
3599 LPSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3600 LPSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3601 LPSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3603 awstring user
, org
, serial
;
3607 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3608 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3609 (lpSerialBuf
&& !pcchSerialBuf
))
3610 return USERINFOSTATE_INVALIDARG
;
3612 prod
= strdupAtoW( szProduct
);
3613 if (szProduct
&& !prod
)
3614 return ERROR_OUTOFMEMORY
;
3616 user
.unicode
= FALSE
;
3617 user
.str
.a
= lpUserNameBuf
;
3618 org
.unicode
= FALSE
;
3619 org
.str
.a
= lpOrgNameBuf
;
3620 serial
.unicode
= FALSE
;
3621 serial
.str
.a
= lpSerialBuf
;
3623 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
3624 &org
, pcchOrgNameBuf
,
3625 &serial
, pcchSerialBuf
);
3632 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
3636 MSIPACKAGE
*package
;
3637 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3639 TRACE("(%s)\n",debugstr_w(szProduct
));
3641 rc
= MsiOpenProductW(szProduct
,&handle
);
3642 if (rc
!= ERROR_SUCCESS
)
3643 return ERROR_INVALID_PARAMETER
;
3645 /* MsiCollectUserInfo cannot be called from a custom action. */
3646 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3648 return ERROR_CALL_NOT_IMPLEMENTED
;
3650 rc
= ACTION_PerformUIAction(package
, szFirstRun
, SCRIPT_NONE
);
3651 msiobj_release( &package
->hdr
);
3653 MsiCloseHandle(handle
);
3658 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
3662 MSIPACKAGE
*package
;
3663 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3665 TRACE("(%s)\n",debugstr_a(szProduct
));
3667 rc
= MsiOpenProductA(szProduct
,&handle
);
3668 if (rc
!= ERROR_SUCCESS
)
3669 return ERROR_INVALID_PARAMETER
;
3671 /* MsiCollectUserInfo cannot be called from a custom action. */
3672 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3674 return ERROR_CALL_NOT_IMPLEMENTED
;
3676 rc
= ACTION_PerformUIAction(package
, szFirstRun
, SCRIPT_NONE
);
3677 msiobj_release( &package
->hdr
);
3679 MsiCloseHandle(handle
);
3684 /***********************************************************************
3685 * MsiConfigureFeatureA [MSI.@]
3687 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
3689 LPWSTR prod
, feat
= NULL
;
3690 UINT r
= ERROR_OUTOFMEMORY
;
3692 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
3694 prod
= strdupAtoW( szProduct
);
3695 if (szProduct
&& !prod
)
3698 feat
= strdupAtoW( szFeature
);
3699 if (szFeature
&& !feat
)
3702 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
3711 /***********************************************************************
3712 * MsiConfigureFeatureW [MSI.@]
3714 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
3716 MSIPACKAGE
*package
= NULL
;
3718 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
3721 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
3723 if (!szProduct
|| !szFeature
)
3724 return ERROR_INVALID_PARAMETER
;
3726 switch (eInstallState
)
3728 case INSTALLSTATE_DEFAULT
:
3729 /* FIXME: how do we figure out the default location? */
3730 eInstallState
= INSTALLSTATE_LOCAL
;
3732 case INSTALLSTATE_LOCAL
:
3733 case INSTALLSTATE_SOURCE
:
3734 case INSTALLSTATE_ABSENT
:
3735 case INSTALLSTATE_ADVERTISED
:
3738 return ERROR_INVALID_PARAMETER
;
3741 r
= MSI_OpenProductW( szProduct
, &package
);
3742 if (r
!= ERROR_SUCCESS
)
3745 sz
= sizeof(sourcepath
);
3746 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3747 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3749 sz
= sizeof(filename
);
3750 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3751 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3753 lstrcatW( sourcepath
, filename
);
3755 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
3757 r
= ACTION_PerformUIAction( package
, szCostInitialize
, SCRIPT_NONE
);
3758 if (r
!= ERROR_SUCCESS
)
3761 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
3762 if (r
!= ERROR_SUCCESS
)
3765 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
3768 msiobj_release( &package
->hdr
);
3773 /***********************************************************************
3774 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
3776 * Notes: undocumented
3778 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
3780 WCHAR path
[MAX_PATH
];
3782 TRACE("%d\n", dwReserved
);
3786 FIXME("dwReserved=%d\n", dwReserved
);
3787 return ERROR_INVALID_PARAMETER
;
3790 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
3791 return ERROR_FUNCTION_FAILED
;
3793 lstrcatW(path
, installerW
);
3795 if (!CreateDirectoryW(path
, NULL
) && GetLastError() != ERROR_ALREADY_EXISTS
)
3796 return ERROR_FUNCTION_FAILED
;
3798 return ERROR_SUCCESS
;
3801 /***********************************************************************
3802 * MsiGetShortcutTargetA [MSI.@]
3804 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
3805 LPSTR szProductCode
, LPSTR szFeatureId
,
3806 LPSTR szComponentCode
)
3809 const int len
= MAX_FEATURE_CHARS
+1;
3810 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
3813 target
= strdupAtoW( szShortcutTarget
);
3814 if (szShortcutTarget
&& !target
)
3815 return ERROR_OUTOFMEMORY
;
3819 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
3821 if (r
== ERROR_SUCCESS
)
3823 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
3824 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
3825 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
3830 /***********************************************************************
3831 * MsiGetShortcutTargetW [MSI.@]
3833 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
3834 LPWSTR szProductCode
, LPWSTR szFeatureId
,
3835 LPWSTR szComponentCode
)
3837 IShellLinkDataList
*dl
= NULL
;
3838 IPersistFile
*pf
= NULL
;
3839 LPEXP_DARWIN_LINK darwin
= NULL
;
3842 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
3843 szProductCode
, szFeatureId
, szComponentCode
);
3845 init
= CoInitialize(NULL
);
3847 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
3848 &IID_IPersistFile
, (LPVOID
*) &pf
);
3849 if( SUCCEEDED( r
) )
3851 r
= IPersistFile_Load( pf
, szShortcutTarget
,
3852 STGM_READ
| STGM_SHARE_DENY_WRITE
);
3853 if( SUCCEEDED( r
) )
3855 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
3857 if( SUCCEEDED( r
) )
3859 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
3861 IShellLinkDataList_Release( dl
);
3864 IPersistFile_Release( pf
);
3867 if (SUCCEEDED(init
))
3870 TRACE("darwin = %p\n", darwin
);
3877 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
3878 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
3879 LocalFree( darwin
);
3883 return ERROR_FUNCTION_FAILED
;
3886 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
, DWORD dwReinstallMode
)
3888 static const WCHAR fmtW
[] = {'%','s','=','%','s',' ','%','s','=','%','s',0};
3889 MSIPACKAGE
*package
;
3890 MSIINSTALLCONTEXT context
;
3892 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
], reinstallmode
[11];
3893 WCHAR
*ptr
, *cmdline
;
3896 TRACE("%s, %s, 0x%08x\n", debugstr_w(szProduct
), debugstr_w(szFeature
), dwReinstallMode
);
3898 r
= msi_locate_product( szProduct
, &context
);
3899 if (r
!= ERROR_SUCCESS
)
3902 ptr
= reinstallmode
;
3904 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
3906 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
3908 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
3910 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
3912 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
3914 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
3916 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
3918 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
3920 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
3922 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3926 sz
= sizeof(sourcepath
);
3927 MsiSourceListGetInfoW( szProduct
, NULL
, context
, MSICODE_PRODUCT
,
3928 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3929 sz
= sizeof(filename
);
3930 MsiSourceListGetInfoW( szProduct
, NULL
, context
, MSICODE_PRODUCT
,
3931 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3932 strcatW( sourcepath
, filename
);
3934 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3935 r
= MSI_OpenPackageW( sourcepath
, &package
);
3937 r
= MSI_OpenProductW( szProduct
, &package
);
3939 if (r
!= ERROR_SUCCESS
)
3942 sz
= (strlenW( fmtW
) + strlenW( szReinstallMode
) + strlenW( reinstallmode
)) * sizeof(WCHAR
);
3943 sz
+= (strlenW( szReinstall
) + strlenW( szFeature
)) * sizeof(WCHAR
);
3944 if (!(cmdline
= msi_alloc( sz
)))
3946 msiobj_release( &package
->hdr
);
3947 return ERROR_OUTOFMEMORY
;
3949 sprintfW( cmdline
, fmtW
, szReinstallMode
, reinstallmode
, szReinstall
, szFeature
);
3951 r
= MSI_InstallPackage( package
, sourcepath
, cmdline
);
3952 msiobj_release( &package
->hdr
);
3953 msi_free( cmdline
);
3958 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
3959 DWORD dwReinstallMode
)
3965 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3968 wszProduct
= strdupAtoW(szProduct
);
3969 wszFeature
= strdupAtoW(szFeature
);
3971 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
3973 msi_free(wszProduct
);
3974 msi_free(wszFeature
);
3981 unsigned int buf
[4];
3982 unsigned char in
[64];
3983 unsigned char digest
[16];
3986 extern VOID WINAPI
MD5Init( MD5_CTX
*);
3987 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
3988 extern VOID WINAPI
MD5Final( MD5_CTX
*);
3990 /***********************************************************************
3991 * MsiGetFileHashW [MSI.@]
3993 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
3994 PMSIFILEHASHINFO pHash
)
3996 HANDLE handle
, mapping
;
3999 UINT r
= ERROR_FUNCTION_FAILED
;
4001 TRACE("%s %08x %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
4004 return ERROR_INVALID_PARAMETER
;
4007 return ERROR_PATH_NOT_FOUND
;
4010 return ERROR_INVALID_PARAMETER
;
4012 return ERROR_INVALID_PARAMETER
;
4013 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
4014 return ERROR_INVALID_PARAMETER
;
4016 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
4017 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
4018 if (handle
== INVALID_HANDLE_VALUE
)
4020 WARN("can't open file %u\n", GetLastError());
4021 return ERROR_FILE_NOT_FOUND
;
4023 length
= GetFileSize( handle
, NULL
);
4027 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
4030 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
4036 MD5Update( &ctx
, p
, length
);
4038 UnmapViewOfFile( p
);
4040 memcpy( pHash
->dwData
, ctx
.digest
, sizeof pHash
->dwData
);
4043 CloseHandle( mapping
);
4048 /* Empty file -> set hash to 0 */
4049 memset( pHash
->dwData
, 0, sizeof pHash
->dwData
);
4053 CloseHandle( handle
);
4058 /***********************************************************************
4059 * MsiGetFileHashA [MSI.@]
4061 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
4062 PMSIFILEHASHINFO pHash
)
4067 TRACE("%s %08x %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
4069 file
= strdupAtoW( szFilePath
);
4070 if (szFilePath
&& !file
)
4071 return ERROR_OUTOFMEMORY
;
4073 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
4078 /***********************************************************************
4079 * MsiAdvertiseScriptW [MSI.@]
4081 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
4082 PHKEY phRegData
, BOOL fRemoveItems
)
4084 FIXME("%s %08x %p %d\n",
4085 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
4086 return ERROR_CALL_NOT_IMPLEMENTED
;
4089 /***********************************************************************
4090 * MsiAdvertiseScriptA [MSI.@]
4092 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
4093 PHKEY phRegData
, BOOL fRemoveItems
)
4095 FIXME("%s %08x %p %d\n",
4096 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
4097 return ERROR_CALL_NOT_IMPLEMENTED
;
4100 /***********************************************************************
4101 * MsiIsProductElevatedW [MSI.@]
4103 UINT WINAPI
MsiIsProductElevatedW( LPCWSTR szProduct
, BOOL
*pfElevated
)
4105 FIXME("%s %p - stub\n",
4106 debugstr_w( szProduct
), pfElevated
);
4108 return ERROR_SUCCESS
;
4111 /***********************************************************************
4112 * MsiIsProductElevatedA [MSI.@]
4114 UINT WINAPI
MsiIsProductElevatedA( LPCSTR szProduct
, BOOL
*pfElevated
)
4116 FIXME("%s %p - stub\n",
4117 debugstr_a( szProduct
), pfElevated
);
4119 return ERROR_SUCCESS
;
4122 /***********************************************************************
4123 * MsiSetExternalUIRecord [MSI.@]
4125 UINT WINAPI
MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD handler
,
4126 DWORD filter
, LPVOID context
,
4127 PINSTALLUI_HANDLER_RECORD prev
)
4129 TRACE("%p %08x %p %p\n", handler
, filter
, context
, prev
);
4132 *prev
= gUIHandlerRecord
;
4134 gUIHandlerRecord
= handler
;
4136 gUIContext
= context
;
4138 return ERROR_SUCCESS
;
4141 /***********************************************************************
4142 * MsiInstallMissingComponentA [MSI.@]
4144 UINT WINAPI
MsiInstallMissingComponentA( LPCSTR product
, LPCSTR component
, INSTALLSTATE state
)
4147 WCHAR
*productW
= NULL
, *componentW
= NULL
;
4149 TRACE("%s, %s, %d\n", debugstr_a(product
), debugstr_a(component
), state
);
4151 if (product
&& !(productW
= strdupAtoW( product
)))
4152 return ERROR_OUTOFMEMORY
;
4154 if (component
&& !(componentW
= strdupAtoW( component
)))
4156 msi_free( productW
);
4157 return ERROR_OUTOFMEMORY
;
4160 r
= MsiInstallMissingComponentW( productW
, componentW
, state
);
4161 msi_free( productW
);
4162 msi_free( componentW
);
4166 /***********************************************************************
4167 * MsiInstallMissingComponentW [MSI.@]
4169 UINT WINAPI
MsiInstallMissingComponentW(LPCWSTR szProduct
, LPCWSTR szComponent
, INSTALLSTATE eInstallState
)
4171 FIXME("(%s %s %d\n", debugstr_w(szProduct
), debugstr_w(szComponent
), eInstallState
);
4172 return ERROR_SUCCESS
;
4175 /***********************************************************************
4176 * MsiBeginTransactionA [MSI.@]
4178 UINT WINAPI
MsiBeginTransactionA( LPCSTR name
, DWORD attrs
, MSIHANDLE
*id
, HANDLE
*event
)
4183 FIXME("%s %u %p %p\n", debugstr_a(name
), attrs
, id
, event
);
4185 nameW
= strdupAtoW( name
);
4187 return ERROR_OUTOFMEMORY
;
4189 r
= MsiBeginTransactionW( nameW
, attrs
, id
, event
);
4194 /***********************************************************************
4195 * MsiBeginTransactionW [MSI.@]
4197 UINT WINAPI
MsiBeginTransactionW( LPCWSTR name
, DWORD attrs
, MSIHANDLE
*id
, HANDLE
*event
)
4199 FIXME("%s %u %p %p\n", debugstr_w(name
), attrs
, id
, event
);
4201 *id
= (MSIHANDLE
)0xdeadbeef;
4202 *event
= (HANDLE
)0xdeadbeef;
4204 return ERROR_SUCCESS
;
4207 /***********************************************************************
4208 * MsiEndTransaction [MSI.@]
4210 UINT WINAPI
MsiEndTransaction( DWORD state
)
4212 FIXME("%u\n", state
);
4213 return ERROR_SUCCESS
;
4216 UINT WINAPI
Migrate10CachedPackagesW(void* a
, void* b
, void* c
, DWORD d
)
4218 FIXME("%p,%p,%p,%08x\n", a
, b
, c
, d
);
4219 return ERROR_SUCCESS
;