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 if (msi_strcpy_to_awstring(path
, -1, lpPathBuf
, pcchBuf
) == ERROR_MORE_DATA
)
2845 state
= INSTALLSTATE_MOREDATA
;
2851 /******************************************************************
2852 * MsiGetComponentPathW [MSI.@]
2854 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
2855 LPWSTR lpPathBuf
, LPDWORD pcchBuf
)
2859 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
2861 path
.unicode
= TRUE
;
2862 path
.str
.w
= lpPathBuf
;
2864 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
2867 /******************************************************************
2868 * MsiGetComponentPathA [MSI.@]
2870 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
2871 LPSTR lpPathBuf
, LPDWORD pcchBuf
)
2873 LPWSTR szwProduct
, szwComponent
= NULL
;
2874 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
2877 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
2879 szwProduct
= strdupAtoW( szProduct
);
2880 if( szProduct
&& !szwProduct
)
2883 szwComponent
= strdupAtoW( szComponent
);
2884 if( szComponent
&& !szwComponent
)
2887 path
.unicode
= FALSE
;
2888 path
.str
.a
= lpPathBuf
;
2890 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
2893 msi_free( szwProduct
);
2894 msi_free( szwComponent
);
2899 static UINT
query_feature_state( const WCHAR
*product
, const WCHAR
*squashed
, const WCHAR
*usersid
,
2900 MSIINSTALLCONTEXT ctx
, const WCHAR
*feature
, INSTALLSTATE
*state
)
2904 WCHAR
*parent
, *components
, *path
;
2906 BOOL missing
= FALSE
, source
= FALSE
;
2907 WCHAR comp
[GUID_SIZE
];
2910 if (ctx
!= MSIINSTALLCONTEXT_MACHINE
) SetLastError( ERROR_SUCCESS
);
2912 if (MSIREG_OpenFeaturesKey( product
, usersid
, ctx
, &hkey
, FALSE
)) return ERROR_UNKNOWN_PRODUCT
;
2914 parent
= msi_reg_get_val_str( hkey
, feature
);
2915 RegCloseKey( hkey
);
2916 if (!parent
) return ERROR_UNKNOWN_FEATURE
;
2918 *state
= (parent
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
2920 if (*state
== INSTALLSTATE_ABSENT
)
2921 return ERROR_SUCCESS
;
2923 r
= MSIREG_OpenUserDataFeaturesKey( product
, usersid
, ctx
, &hkey
, FALSE
);
2924 if (r
!= ERROR_SUCCESS
)
2926 *state
= INSTALLSTATE_ADVERTISED
;
2927 return ERROR_SUCCESS
;
2929 components
= msi_reg_get_val_str( hkey
, feature
);
2930 RegCloseKey( hkey
);
2932 TRACE("buffer = %s\n", debugstr_w(components
));
2936 *state
= INSTALLSTATE_ADVERTISED
;
2937 return ERROR_SUCCESS
;
2939 for (p
= components
; *p
&& *p
!= 2 ; p
+= 20)
2941 if (!decode_base85_guid( p
, &guid
))
2943 if (p
!= components
) break;
2944 msi_free( components
);
2945 *state
= INSTALLSTATE_BADCONFIG
;
2946 return ERROR_BAD_CONFIGURATION
;
2948 StringFromGUID2( &guid
, comp
, GUID_SIZE
);
2949 if (ctx
== MSIINSTALLCONTEXT_MACHINE
)
2950 r
= MSIREG_OpenUserDataComponentKey( comp
, szLocalSid
, &hkey
, FALSE
);
2952 r
= MSIREG_OpenUserDataComponentKey( comp
, usersid
, &hkey
, FALSE
);
2954 if (r
!= ERROR_SUCCESS
)
2956 msi_free( components
);
2957 *state
= INSTALLSTATE_ADVERTISED
;
2958 return ERROR_SUCCESS
;
2960 path
= msi_reg_get_val_str( hkey
, squashed
);
2961 if (!path
) missing
= TRUE
;
2962 else if (strlenW( path
) > 2 &&
2963 path
[0] >= '0' && path
[0] <= '9' &&
2964 path
[1] >= '0' && path
[1] <= '9')
2970 msi_free( components
);
2973 *state
= INSTALLSTATE_ADVERTISED
;
2975 *state
= INSTALLSTATE_SOURCE
;
2977 *state
= INSTALLSTATE_LOCAL
;
2979 TRACE("returning state %d\n", *state
);
2980 return ERROR_SUCCESS
;
2983 UINT WINAPI
MsiQueryFeatureStateExA( LPCSTR product
, LPCSTR usersid
, MSIINSTALLCONTEXT ctx
,
2984 LPCSTR feature
, INSTALLSTATE
*state
)
2987 WCHAR
*productW
= NULL
, *usersidW
= NULL
, *featureW
= NULL
;
2989 if (product
&& !(productW
= strdupAtoW( product
))) return ERROR_OUTOFMEMORY
;
2990 if (usersid
&& !(usersidW
= strdupAtoW( usersid
)))
2992 msi_free( productW
);
2993 return ERROR_OUTOFMEMORY
;
2995 if (feature
&& !(featureW
= strdupAtoW( feature
)))
2997 msi_free( productW
);
2998 msi_free( usersidW
);
2999 return ERROR_OUTOFMEMORY
;
3001 r
= MsiQueryFeatureStateExW( productW
, usersidW
, ctx
, featureW
, state
);
3002 msi_free( productW
);
3003 msi_free( usersidW
);
3004 msi_free( featureW
);
3008 UINT WINAPI
MsiQueryFeatureStateExW( LPCWSTR product
, LPCWSTR usersid
, MSIINSTALLCONTEXT ctx
,
3009 LPCWSTR feature
, INSTALLSTATE
*state
)
3012 if (!squash_guid( product
, squashed
)) return ERROR_INVALID_PARAMETER
;
3013 return query_feature_state( product
, squashed
, usersid
, ctx
, feature
, state
);
3016 /******************************************************************
3017 * MsiQueryFeatureStateA [MSI.@]
3019 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
3021 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
3022 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
3024 szwProduct
= strdupAtoW( szProduct
);
3025 if ( szProduct
&& !szwProduct
)
3028 szwFeature
= strdupAtoW( szFeature
);
3029 if ( szFeature
&& !szwFeature
)
3032 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
3035 msi_free( szwProduct
);
3036 msi_free( szwFeature
);
3041 /******************************************************************
3042 * MsiQueryFeatureStateW [MSI.@]
3044 * Checks the state of a feature
3047 * szProduct [I] Product's GUID string
3048 * szFeature [I] Feature's GUID string
3051 * INSTALLSTATE_LOCAL Feature is installed and usable
3052 * INSTALLSTATE_ABSENT Feature is absent
3053 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
3054 * INSTALLSTATE_UNKNOWN An error occurred
3055 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
3058 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
3064 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
3066 if (!szProduct
|| !szFeature
|| !squash_guid( szProduct
, squashed
))
3067 return INSTALLSTATE_INVALIDARG
;
3069 r
= query_feature_state( szProduct
, squashed
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, szFeature
, &state
);
3070 if (r
== ERROR_SUCCESS
|| r
== ERROR_BAD_CONFIGURATION
) return state
;
3072 r
= query_feature_state( szProduct
, squashed
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, szFeature
, &state
);
3073 if (r
== ERROR_SUCCESS
|| r
== ERROR_BAD_CONFIGURATION
) return state
;
3075 r
= query_feature_state( szProduct
, squashed
, NULL
, MSIINSTALLCONTEXT_MACHINE
, szFeature
, &state
);
3076 if (r
== ERROR_SUCCESS
|| r
== ERROR_BAD_CONFIGURATION
) return state
;
3078 return INSTALLSTATE_UNKNOWN
;
3081 /******************************************************************
3082 * MsiGetFileVersionA [MSI.@]
3084 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
3085 LPDWORD pcchVersionBuf
, LPSTR lpLangBuf
, LPDWORD pcchLangBuf
)
3087 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
3088 UINT ret
= ERROR_OUTOFMEMORY
;
3090 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
3091 (lpLangBuf
&& !pcchLangBuf
))
3092 return ERROR_INVALID_PARAMETER
;
3096 szwFilePath
= strdupAtoW( szFilePath
);
3101 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
3103 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
3104 if( !lpwVersionBuff
)
3108 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
3110 lpwLangBuff
= msi_alloc(*pcchLangBuf
*sizeof(WCHAR
));
3115 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
3116 lpwLangBuff
, pcchLangBuf
);
3118 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwVersionBuff
)
3119 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
3120 lpVersionBuf
, *pcchVersionBuf
+ 1, NULL
, NULL
);
3121 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwLangBuff
)
3122 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
3123 lpLangBuf
, *pcchLangBuf
+ 1, NULL
, NULL
);
3126 msi_free(szwFilePath
);
3127 msi_free(lpwVersionBuff
);
3128 msi_free(lpwLangBuff
);
3133 static UINT
get_file_version( const WCHAR
*path
, WCHAR
*verbuf
, DWORD
*verlen
,
3134 WCHAR
*langbuf
, DWORD
*langlen
)
3136 static const WCHAR szVersionResource
[] = {'\\',0};
3137 static const WCHAR szVersionFormat
[] = {'%','d','.','%','d','.','%','d','.','%','d',0};
3138 static const WCHAR szLangFormat
[] = {'%','d',0};
3139 UINT ret
= ERROR_MORE_DATA
;
3142 VS_FIXEDFILEINFO
*ffi
;
3146 if (!(len
= GetFileVersionInfoSizeW( path
, NULL
)))
3148 error
= GetLastError();
3149 if (error
== ERROR_BAD_PATHNAME
) return ERROR_FILE_NOT_FOUND
;
3150 if (error
== ERROR_RESOURCE_DATA_NOT_FOUND
) return ERROR_FILE_INVALID
;
3153 if (!(version
= msi_alloc( len
))) return ERROR_OUTOFMEMORY
;
3154 if (!GetFileVersionInfoW( path
, 0, len
, version
))
3156 msi_free( version
);
3157 return GetLastError();
3159 if (!verbuf
&& !verlen
&& !langbuf
&& !langlen
)
3161 msi_free( version
);
3162 return ERROR_SUCCESS
;
3166 if (VerQueryValueW( version
, szVersionResource
, (LPVOID
*)&ffi
, &len
) && len
> 0)
3168 sprintfW( tmp
, szVersionFormat
,
3169 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
3170 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
) );
3171 if (verbuf
) lstrcpynW( verbuf
, tmp
, *verlen
);
3172 len
= strlenW( tmp
);
3173 if (*verlen
> len
) ret
= ERROR_SUCCESS
;
3178 if (verbuf
) *verbuf
= 0;
3184 if (VerQueryValueW( version
, szLangResource
, (LPVOID
*)&lang
, &len
) && len
> 0)
3186 sprintfW( tmp
, szLangFormat
, *lang
);
3187 if (langbuf
) lstrcpynW( langbuf
, tmp
, *langlen
);
3188 len
= strlenW( tmp
);
3189 if (*langlen
> len
) ret
= ERROR_SUCCESS
;
3194 if (langbuf
) *langbuf
= 0;
3198 msi_free( version
);
3203 /******************************************************************
3204 * MsiGetFileVersionW [MSI.@]
3206 UINT WINAPI
MsiGetFileVersionW( LPCWSTR path
, LPWSTR verbuf
, LPDWORD verlen
,
3207 LPWSTR langbuf
, LPDWORD langlen
)
3211 TRACE("%s %p %u %p %u\n", debugstr_w(path
), verbuf
, verlen
? *verlen
: 0,
3212 langbuf
, langlen
? *langlen
: 0);
3214 if ((verbuf
&& !verlen
) || (langbuf
&& !langlen
))
3215 return ERROR_INVALID_PARAMETER
;
3217 ret
= get_file_version( path
, verbuf
, verlen
, langbuf
, langlen
);
3218 if (ret
== ERROR_RESOURCE_DATA_NOT_FOUND
&& verlen
)
3221 WCHAR
*version
= msi_font_version_from_file( path
);
3222 if (!version
) return ERROR_FILE_INVALID
;
3223 len
= strlenW( version
);
3224 if (len
>= *verlen
) ret
= ERROR_MORE_DATA
;
3227 strcpyW( verbuf
, version
);
3228 ret
= ERROR_SUCCESS
;
3231 msi_free( version
);
3236 /***********************************************************************
3237 * MsiGetFeatureUsageW [MSI.@]
3239 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3240 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
3242 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
3243 pdwUseCount
, pwDateUsed
);
3244 return ERROR_CALL_NOT_IMPLEMENTED
;
3247 /***********************************************************************
3248 * MsiGetFeatureUsageA [MSI.@]
3250 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
3251 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
3253 LPWSTR prod
= NULL
, feat
= NULL
;
3254 UINT ret
= ERROR_OUTOFMEMORY
;
3256 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3257 pdwUseCount
, pwDateUsed
);
3259 prod
= strdupAtoW( szProduct
);
3260 if (szProduct
&& !prod
)
3263 feat
= strdupAtoW( szFeature
);
3264 if (szFeature
&& !feat
)
3267 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
3276 /***********************************************************************
3277 * MsiUseFeatureExW [MSI.@]
3279 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3280 DWORD dwInstallMode
, DWORD dwReserved
)
3284 TRACE("%s %s %i %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
3285 dwInstallMode
, dwReserved
);
3287 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
3290 return INSTALLSTATE_INVALIDARG
;
3292 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
3294 FIXME("mark product %s feature %s as used\n",
3295 debugstr_w(szProduct
), debugstr_w(szFeature
) );
3301 /***********************************************************************
3302 * MsiUseFeatureExA [MSI.@]
3304 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
3305 DWORD dwInstallMode
, DWORD dwReserved
)
3307 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
3308 LPWSTR prod
= NULL
, feat
= NULL
;
3310 TRACE("%s %s %i %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3311 dwInstallMode
, dwReserved
);
3313 prod
= strdupAtoW( szProduct
);
3314 if (szProduct
&& !prod
)
3317 feat
= strdupAtoW( szFeature
);
3318 if (szFeature
&& !feat
)
3321 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
3330 /***********************************************************************
3331 * MsiUseFeatureW [MSI.@]
3333 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
3335 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
3338 /***********************************************************************
3339 * MsiUseFeatureA [MSI.@]
3341 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
3343 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
3346 /***********************************************************************
3347 * MSI_ProvideQualifiedComponentEx [internal]
3349 static UINT
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
3350 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
3351 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
3352 LPDWORD pcchPathBuf
)
3354 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
3355 feature
[MAX_FEATURE_CHARS
+1];
3362 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
3363 if (rc
!= ERROR_SUCCESS
)
3364 return ERROR_INDEX_ABSENT
;
3366 info
= msi_reg_get_val_str( hkey
, szQualifier
);
3370 return ERROR_INDEX_ABSENT
;
3372 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
3375 state
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
3377 state
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
3381 if (state
== INSTALLSTATE_MOREDATA
)
3382 return ERROR_MORE_DATA
;
3384 if (state
!= INSTALLSTATE_LOCAL
)
3385 return ERROR_FILE_NOT_FOUND
;
3387 return ERROR_SUCCESS
;
3390 /***********************************************************************
3391 * MsiProvideQualifiedComponentExW [MSI.@]
3393 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
3394 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
3395 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
3396 LPDWORD pcchPathBuf
)
3400 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_w(szComponent
),
3401 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
3402 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
3404 path
.unicode
= TRUE
;
3405 path
.str
.w
= lpPathBuf
;
3407 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
3408 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
3411 /***********************************************************************
3412 * MsiProvideQualifiedComponentExA [MSI.@]
3414 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
3415 LPCSTR szQualifier
, DWORD dwInstallMode
, LPCSTR szProduct
,
3416 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
3417 LPDWORD pcchPathBuf
)
3419 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
3420 UINT r
= ERROR_OUTOFMEMORY
;
3423 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent
),
3424 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
3425 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
3427 szwComponent
= strdupAtoW( szComponent
);
3428 if (szComponent
&& !szwComponent
)
3431 szwQualifier
= strdupAtoW( szQualifier
);
3432 if (szQualifier
&& !szwQualifier
)
3435 szwProduct
= strdupAtoW( szProduct
);
3436 if (szProduct
&& !szwProduct
)
3439 path
.unicode
= FALSE
;
3440 path
.str
.a
= lpPathBuf
;
3442 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
3443 dwInstallMode
, szwProduct
, Unused1
,
3444 Unused2
, &path
, pcchPathBuf
);
3446 msi_free(szwProduct
);
3447 msi_free(szwComponent
);
3448 msi_free(szwQualifier
);
3453 /***********************************************************************
3454 * MsiProvideQualifiedComponentW [MSI.@]
3456 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
3457 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
3458 LPDWORD pcchPathBuf
)
3460 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
3461 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3464 /***********************************************************************
3465 * MsiProvideQualifiedComponentA [MSI.@]
3467 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
3468 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
3469 LPDWORD pcchPathBuf
)
3471 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
3472 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3475 /***********************************************************************
3476 * MSI_GetUserInfo [internal]
3478 static USERINFOSTATE
MSI_GetUserInfo(LPCWSTR szProduct
,
3479 awstring
*lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3480 awstring
*lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3481 awstring
*lpSerialBuf
, LPDWORD pcchSerialBuf
)
3483 WCHAR squished_pc
[SQUISH_GUID_SIZE
];
3484 LPWSTR user
, org
, serial
;
3485 USERINFOSTATE state
;
3490 TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct
), lpUserNameBuf
,
3491 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
3494 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
3495 return USERINFOSTATE_INVALIDARG
;
3497 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
3498 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3499 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3500 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3501 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
3502 &hkey
, FALSE
) != ERROR_SUCCESS
)
3504 return USERINFOSTATE_UNKNOWN
;
3507 if (MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3508 NULL
, &props
, FALSE
) != ERROR_SUCCESS
&&
3509 MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
3510 NULL
, &props
, FALSE
) != ERROR_SUCCESS
)
3513 return USERINFOSTATE_ABSENT
;
3516 user
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGOWNERW
);
3517 org
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGCOMPANYW
);
3518 serial
= msi_reg_get_val_str(props
, INSTALLPROPERTY_PRODUCTIDW
);
3519 state
= USERINFOSTATE_ABSENT
;
3525 state
= USERINFOSTATE_PRESENT
;
3527 if (pcchUserNameBuf
)
3529 if (lpUserNameBuf
&& !user
)
3531 (*pcchUserNameBuf
)--;
3535 r
= msi_strcpy_to_awstring(user
, -1, lpUserNameBuf
, pcchUserNameBuf
);
3536 if (r
== ERROR_MORE_DATA
)
3538 state
= USERINFOSTATE_MOREDATA
;
3546 if (!orgptr
) orgptr
= szEmpty
;
3548 r
= msi_strcpy_to_awstring(orgptr
, -1, lpOrgNameBuf
, pcchOrgNameBuf
);
3549 if (r
== ERROR_MORE_DATA
)
3551 state
= USERINFOSTATE_MOREDATA
;
3564 r
= msi_strcpy_to_awstring(serial
, -1, lpSerialBuf
, pcchSerialBuf
);
3565 if (r
== ERROR_MORE_DATA
)
3566 state
= USERINFOSTATE_MOREDATA
;
3577 /***********************************************************************
3578 * MsiGetUserInfoW [MSI.@]
3580 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
3581 LPWSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3582 LPWSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3583 LPWSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3585 awstring user
, org
, serial
;
3587 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3588 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3589 (lpSerialBuf
&& !pcchSerialBuf
))
3590 return USERINFOSTATE_INVALIDARG
;
3592 user
.unicode
= TRUE
;
3593 user
.str
.w
= lpUserNameBuf
;
3595 org
.str
.w
= lpOrgNameBuf
;
3596 serial
.unicode
= TRUE
;
3597 serial
.str
.w
= lpSerialBuf
;
3599 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
3600 &org
, pcchOrgNameBuf
,
3601 &serial
, pcchSerialBuf
);
3604 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
3605 LPSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3606 LPSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3607 LPSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3609 awstring user
, org
, serial
;
3613 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3614 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3615 (lpSerialBuf
&& !pcchSerialBuf
))
3616 return USERINFOSTATE_INVALIDARG
;
3618 prod
= strdupAtoW( szProduct
);
3619 if (szProduct
&& !prod
)
3620 return ERROR_OUTOFMEMORY
;
3622 user
.unicode
= FALSE
;
3623 user
.str
.a
= lpUserNameBuf
;
3624 org
.unicode
= FALSE
;
3625 org
.str
.a
= lpOrgNameBuf
;
3626 serial
.unicode
= FALSE
;
3627 serial
.str
.a
= lpSerialBuf
;
3629 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
3630 &org
, pcchOrgNameBuf
,
3631 &serial
, pcchSerialBuf
);
3638 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
3642 MSIPACKAGE
*package
;
3643 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3645 TRACE("(%s)\n",debugstr_w(szProduct
));
3647 rc
= MsiOpenProductW(szProduct
,&handle
);
3648 if (rc
!= ERROR_SUCCESS
)
3649 return ERROR_INVALID_PARAMETER
;
3651 /* MsiCollectUserInfo cannot be called from a custom action. */
3652 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3654 return ERROR_CALL_NOT_IMPLEMENTED
;
3656 rc
= ACTION_PerformUIAction(package
, szFirstRun
, SCRIPT_NONE
);
3657 msiobj_release( &package
->hdr
);
3659 MsiCloseHandle(handle
);
3664 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
3668 MSIPACKAGE
*package
;
3669 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3671 TRACE("(%s)\n",debugstr_a(szProduct
));
3673 rc
= MsiOpenProductA(szProduct
,&handle
);
3674 if (rc
!= ERROR_SUCCESS
)
3675 return ERROR_INVALID_PARAMETER
;
3677 /* MsiCollectUserInfo cannot be called from a custom action. */
3678 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3680 return ERROR_CALL_NOT_IMPLEMENTED
;
3682 rc
= ACTION_PerformUIAction(package
, szFirstRun
, SCRIPT_NONE
);
3683 msiobj_release( &package
->hdr
);
3685 MsiCloseHandle(handle
);
3690 /***********************************************************************
3691 * MsiConfigureFeatureA [MSI.@]
3693 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
3695 LPWSTR prod
, feat
= NULL
;
3696 UINT r
= ERROR_OUTOFMEMORY
;
3698 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
3700 prod
= strdupAtoW( szProduct
);
3701 if (szProduct
&& !prod
)
3704 feat
= strdupAtoW( szFeature
);
3705 if (szFeature
&& !feat
)
3708 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
3717 /***********************************************************************
3718 * MsiConfigureFeatureW [MSI.@]
3720 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
3722 MSIPACKAGE
*package
= NULL
;
3724 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
3727 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
3729 if (!szProduct
|| !szFeature
)
3730 return ERROR_INVALID_PARAMETER
;
3732 switch (eInstallState
)
3734 case INSTALLSTATE_DEFAULT
:
3735 /* FIXME: how do we figure out the default location? */
3736 eInstallState
= INSTALLSTATE_LOCAL
;
3738 case INSTALLSTATE_LOCAL
:
3739 case INSTALLSTATE_SOURCE
:
3740 case INSTALLSTATE_ABSENT
:
3741 case INSTALLSTATE_ADVERTISED
:
3744 return ERROR_INVALID_PARAMETER
;
3747 r
= MSI_OpenProductW( szProduct
, &package
);
3748 if (r
!= ERROR_SUCCESS
)
3751 sz
= sizeof(sourcepath
);
3752 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3753 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3755 sz
= sizeof(filename
);
3756 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3757 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3759 lstrcatW( sourcepath
, filename
);
3761 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
3763 r
= ACTION_PerformUIAction( package
, szCostInitialize
, SCRIPT_NONE
);
3764 if (r
!= ERROR_SUCCESS
)
3767 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
3768 if (r
!= ERROR_SUCCESS
)
3771 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
3774 msiobj_release( &package
->hdr
);
3779 /***********************************************************************
3780 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
3782 * Notes: undocumented
3784 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
3786 WCHAR path
[MAX_PATH
];
3788 TRACE("%d\n", dwReserved
);
3792 FIXME("dwReserved=%d\n", dwReserved
);
3793 return ERROR_INVALID_PARAMETER
;
3796 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
3797 return ERROR_FUNCTION_FAILED
;
3799 lstrcatW(path
, installerW
);
3801 if (!CreateDirectoryW(path
, NULL
) && GetLastError() != ERROR_ALREADY_EXISTS
)
3802 return ERROR_FUNCTION_FAILED
;
3804 return ERROR_SUCCESS
;
3807 /***********************************************************************
3808 * MsiGetShortcutTargetA [MSI.@]
3810 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
3811 LPSTR szProductCode
, LPSTR szFeatureId
,
3812 LPSTR szComponentCode
)
3815 const int len
= MAX_FEATURE_CHARS
+1;
3816 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
3819 target
= strdupAtoW( szShortcutTarget
);
3820 if (szShortcutTarget
&& !target
)
3821 return ERROR_OUTOFMEMORY
;
3825 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
3827 if (r
== ERROR_SUCCESS
)
3829 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
3830 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
3831 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
3836 /***********************************************************************
3837 * MsiGetShortcutTargetW [MSI.@]
3839 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
3840 LPWSTR szProductCode
, LPWSTR szFeatureId
,
3841 LPWSTR szComponentCode
)
3843 IShellLinkDataList
*dl
= NULL
;
3844 IPersistFile
*pf
= NULL
;
3845 LPEXP_DARWIN_LINK darwin
= NULL
;
3848 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
3849 szProductCode
, szFeatureId
, szComponentCode
);
3851 init
= CoInitialize(NULL
);
3853 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
3854 &IID_IPersistFile
, (LPVOID
*) &pf
);
3855 if( SUCCEEDED( r
) )
3857 r
= IPersistFile_Load( pf
, szShortcutTarget
,
3858 STGM_READ
| STGM_SHARE_DENY_WRITE
);
3859 if( SUCCEEDED( r
) )
3861 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
3863 if( SUCCEEDED( r
) )
3865 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
3867 IShellLinkDataList_Release( dl
);
3870 IPersistFile_Release( pf
);
3873 if (SUCCEEDED(init
))
3876 TRACE("darwin = %p\n", darwin
);
3883 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
3884 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
3885 LocalFree( darwin
);
3889 return ERROR_FUNCTION_FAILED
;
3892 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
, DWORD dwReinstallMode
)
3894 static const WCHAR fmtW
[] = {'%','s','=','%','s',' ','%','s','=','%','s',0};
3895 MSIPACKAGE
*package
;
3896 MSIINSTALLCONTEXT context
;
3898 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
], reinstallmode
[11];
3899 WCHAR
*ptr
, *cmdline
;
3902 TRACE("%s, %s, 0x%08x\n", debugstr_w(szProduct
), debugstr_w(szFeature
), dwReinstallMode
);
3904 r
= msi_locate_product( szProduct
, &context
);
3905 if (r
!= ERROR_SUCCESS
)
3908 ptr
= reinstallmode
;
3910 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
3912 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
3914 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
3916 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
3918 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
3920 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
3922 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
3924 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
3926 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
3928 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3932 sz
= sizeof(sourcepath
);
3933 MsiSourceListGetInfoW( szProduct
, NULL
, context
, MSICODE_PRODUCT
,
3934 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3935 sz
= sizeof(filename
);
3936 MsiSourceListGetInfoW( szProduct
, NULL
, context
, MSICODE_PRODUCT
,
3937 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3938 strcatW( sourcepath
, filename
);
3940 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3941 r
= MSI_OpenPackageW( sourcepath
, &package
);
3943 r
= MSI_OpenProductW( szProduct
, &package
);
3945 if (r
!= ERROR_SUCCESS
)
3948 sz
= (strlenW( fmtW
) + strlenW( szReinstallMode
) + strlenW( reinstallmode
)) * sizeof(WCHAR
);
3949 sz
+= (strlenW( szReinstall
) + strlenW( szFeature
)) * sizeof(WCHAR
);
3950 if (!(cmdline
= msi_alloc( sz
)))
3952 msiobj_release( &package
->hdr
);
3953 return ERROR_OUTOFMEMORY
;
3955 sprintfW( cmdline
, fmtW
, szReinstallMode
, reinstallmode
, szReinstall
, szFeature
);
3957 r
= MSI_InstallPackage( package
, sourcepath
, cmdline
);
3958 msiobj_release( &package
->hdr
);
3959 msi_free( cmdline
);
3964 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
3965 DWORD dwReinstallMode
)
3971 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3974 wszProduct
= strdupAtoW(szProduct
);
3975 wszFeature
= strdupAtoW(szFeature
);
3977 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
3979 msi_free(wszProduct
);
3980 msi_free(wszFeature
);
3987 unsigned int buf
[4];
3988 unsigned char in
[64];
3989 unsigned char digest
[16];
3992 extern VOID WINAPI
MD5Init( MD5_CTX
*);
3993 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
3994 extern VOID WINAPI
MD5Final( MD5_CTX
*);
3996 /***********************************************************************
3997 * MsiGetFileHashW [MSI.@]
3999 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
4000 PMSIFILEHASHINFO pHash
)
4002 HANDLE handle
, mapping
;
4005 UINT r
= ERROR_FUNCTION_FAILED
;
4007 TRACE("%s %08x %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
4010 return ERROR_INVALID_PARAMETER
;
4013 return ERROR_PATH_NOT_FOUND
;
4016 return ERROR_INVALID_PARAMETER
;
4018 return ERROR_INVALID_PARAMETER
;
4019 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
4020 return ERROR_INVALID_PARAMETER
;
4022 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
4023 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
4024 if (handle
== INVALID_HANDLE_VALUE
)
4026 WARN("can't open file %u\n", GetLastError());
4027 return ERROR_FILE_NOT_FOUND
;
4029 length
= GetFileSize( handle
, NULL
);
4033 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
4036 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
4042 MD5Update( &ctx
, p
, length
);
4044 UnmapViewOfFile( p
);
4046 memcpy( pHash
->dwData
, ctx
.digest
, sizeof pHash
->dwData
);
4049 CloseHandle( mapping
);
4054 /* Empty file -> set hash to 0 */
4055 memset( pHash
->dwData
, 0, sizeof pHash
->dwData
);
4059 CloseHandle( handle
);
4064 /***********************************************************************
4065 * MsiGetFileHashA [MSI.@]
4067 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
4068 PMSIFILEHASHINFO pHash
)
4073 TRACE("%s %08x %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
4075 file
= strdupAtoW( szFilePath
);
4076 if (szFilePath
&& !file
)
4077 return ERROR_OUTOFMEMORY
;
4079 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
4084 /***********************************************************************
4085 * MsiAdvertiseScriptW [MSI.@]
4087 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
4088 PHKEY phRegData
, BOOL fRemoveItems
)
4090 FIXME("%s %08x %p %d\n",
4091 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
4092 return ERROR_CALL_NOT_IMPLEMENTED
;
4095 /***********************************************************************
4096 * MsiAdvertiseScriptA [MSI.@]
4098 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
4099 PHKEY phRegData
, BOOL fRemoveItems
)
4101 FIXME("%s %08x %p %d\n",
4102 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
4103 return ERROR_CALL_NOT_IMPLEMENTED
;
4106 /***********************************************************************
4107 * MsiIsProductElevatedW [MSI.@]
4109 UINT WINAPI
MsiIsProductElevatedW( LPCWSTR szProduct
, BOOL
*pfElevated
)
4111 FIXME("%s %p - stub\n",
4112 debugstr_w( szProduct
), pfElevated
);
4114 return ERROR_SUCCESS
;
4117 /***********************************************************************
4118 * MsiIsProductElevatedA [MSI.@]
4120 UINT WINAPI
MsiIsProductElevatedA( LPCSTR szProduct
, BOOL
*pfElevated
)
4122 FIXME("%s %p - stub\n",
4123 debugstr_a( szProduct
), pfElevated
);
4125 return ERROR_SUCCESS
;
4128 /***********************************************************************
4129 * MsiSetExternalUIRecord [MSI.@]
4131 UINT WINAPI
MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD handler
,
4132 DWORD filter
, LPVOID context
,
4133 PINSTALLUI_HANDLER_RECORD prev
)
4135 TRACE("%p %08x %p %p\n", handler
, filter
, context
, prev
);
4138 *prev
= gUIHandlerRecord
;
4140 gUIHandlerRecord
= handler
;
4142 gUIContext
= context
;
4144 return ERROR_SUCCESS
;
4147 /***********************************************************************
4148 * MsiInstallMissingComponentA [MSI.@]
4150 UINT WINAPI
MsiInstallMissingComponentA( LPCSTR product
, LPCSTR component
, INSTALLSTATE state
)
4153 WCHAR
*productW
= NULL
, *componentW
= NULL
;
4155 TRACE("%s, %s, %d\n", debugstr_a(product
), debugstr_a(component
), state
);
4157 if (product
&& !(productW
= strdupAtoW( product
)))
4158 return ERROR_OUTOFMEMORY
;
4160 if (component
&& !(componentW
= strdupAtoW( component
)))
4162 msi_free( productW
);
4163 return ERROR_OUTOFMEMORY
;
4166 r
= MsiInstallMissingComponentW( productW
, componentW
, state
);
4167 msi_free( productW
);
4168 msi_free( componentW
);
4172 /***********************************************************************
4173 * MsiInstallMissingComponentW [MSI.@]
4175 UINT WINAPI
MsiInstallMissingComponentW(LPCWSTR szProduct
, LPCWSTR szComponent
, INSTALLSTATE eInstallState
)
4177 FIXME("(%s %s %d\n", debugstr_w(szProduct
), debugstr_w(szComponent
), eInstallState
);
4178 return ERROR_SUCCESS
;
4181 /***********************************************************************
4182 * MsiBeginTransactionA [MSI.@]
4184 UINT WINAPI
MsiBeginTransactionA( LPCSTR name
, DWORD attrs
, MSIHANDLE
*id
, HANDLE
*event
)
4189 FIXME("%s %u %p %p\n", debugstr_a(name
), attrs
, id
, event
);
4191 nameW
= strdupAtoW( name
);
4193 return ERROR_OUTOFMEMORY
;
4195 r
= MsiBeginTransactionW( nameW
, attrs
, id
, event
);
4200 /***********************************************************************
4201 * MsiBeginTransactionW [MSI.@]
4203 UINT WINAPI
MsiBeginTransactionW( LPCWSTR name
, DWORD attrs
, MSIHANDLE
*id
, HANDLE
*event
)
4205 FIXME("%s %u %p %p\n", debugstr_w(name
), attrs
, id
, event
);
4207 *id
= (MSIHANDLE
)0xdeadbeef;
4208 *event
= (HANDLE
)0xdeadbeef;
4210 return ERROR_SUCCESS
;
4213 /***********************************************************************
4214 * MsiEndTransaction [MSI.@]
4216 UINT WINAPI
MsiEndTransaction( DWORD state
)
4218 FIXME("%u\n", state
);
4219 return ERROR_SUCCESS
;
4222 UINT WINAPI
Migrate10CachedPackagesW(void* a
, void* b
, void* c
, DWORD d
)
4224 FIXME("%p,%p,%p,%08x\n", a
, b
, c
, d
);
4225 return ERROR_SUCCESS
;