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
24 #define NONAMELESSUNION
35 #include "msiserver.h"
48 #include "wine/debug.h"
49 #include "wine/unicode.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
53 static const WCHAR installerW
[] = {'\\','I','n','s','t','a','l','l','e','r',0};
55 UINT
msi_locate_product(LPCWSTR szProduct
, MSIINSTALLCONTEXT
*context
)
59 *context
= MSIINSTALLCONTEXT_NONE
;
60 if (!szProduct
) return ERROR_UNKNOWN_PRODUCT
;
62 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
63 &hkey
, FALSE
) == ERROR_SUCCESS
)
64 *context
= MSIINSTALLCONTEXT_USERMANAGED
;
65 else if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
66 &hkey
, FALSE
) == ERROR_SUCCESS
)
67 *context
= MSIINSTALLCONTEXT_MACHINE
;
68 else if (MSIREG_OpenProductKey(szProduct
, NULL
,
69 MSIINSTALLCONTEXT_USERUNMANAGED
,
70 &hkey
, FALSE
) == ERROR_SUCCESS
)
71 *context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
75 if (*context
== MSIINSTALLCONTEXT_NONE
)
76 return ERROR_UNKNOWN_PRODUCT
;
81 UINT WINAPI
MsiOpenProductA(LPCSTR szProduct
, MSIHANDLE
*phProduct
)
84 LPWSTR szwProd
= NULL
;
86 TRACE("%s %p\n",debugstr_a(szProduct
), phProduct
);
90 szwProd
= strdupAtoW( szProduct
);
92 return ERROR_OUTOFMEMORY
;
95 r
= MsiOpenProductW( szwProd
, phProduct
);
102 static UINT
MSI_OpenProductW(LPCWSTR szProduct
, MSIPACKAGE
**package
)
107 MSIINSTALLCONTEXT context
;
109 static const WCHAR managed
[] = {
110 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0};
111 static const WCHAR local
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
113 TRACE("%s %p\n", debugstr_w(szProduct
), package
);
115 r
= msi_locate_product(szProduct
, &context
);
116 if (r
!= ERROR_SUCCESS
)
119 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &props
, FALSE
);
120 if (r
!= ERROR_SUCCESS
)
121 return ERROR_UNKNOWN_PRODUCT
;
123 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
124 path
= msi_reg_get_val_str(props
, managed
);
126 path
= msi_reg_get_val_str(props
, local
);
128 r
= ERROR_UNKNOWN_PRODUCT
;
130 if (!path
|| GetFileAttributesW(path
) == INVALID_FILE_ATTRIBUTES
)
133 if (PathIsRelativeW(path
))
135 r
= ERROR_INSTALL_PACKAGE_OPEN_FAILED
;
139 r
= MSI_OpenPackageW(path
, package
);
147 UINT WINAPI
MsiOpenProductW(LPCWSTR szProduct
, MSIHANDLE
*phProduct
)
149 MSIPACKAGE
*package
= NULL
;
150 WCHAR squished_pc
[GUID_SIZE
];
153 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
154 return ERROR_INVALID_PARAMETER
;
157 return ERROR_INVALID_PARAMETER
;
159 r
= MSI_OpenProductW(szProduct
, &package
);
160 if (r
!= ERROR_SUCCESS
)
163 *phProduct
= alloc_msihandle(&package
->hdr
);
165 r
= ERROR_NOT_ENOUGH_MEMORY
;
167 msiobj_release(&package
->hdr
);
171 UINT WINAPI
MsiAdvertiseProductA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
172 LPCSTR szTransforms
, LANGID lgidLanguage
)
174 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath
),
175 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
), lgidLanguage
);
176 return ERROR_CALL_NOT_IMPLEMENTED
;
179 UINT WINAPI
MsiAdvertiseProductW(LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
180 LPCWSTR szTransforms
, LANGID lgidLanguage
)
182 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath
),
183 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
), lgidLanguage
);
184 return ERROR_CALL_NOT_IMPLEMENTED
;
187 UINT WINAPI
MsiAdvertiseProductExA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
188 LPCSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
190 FIXME("%s %s %s %08x %08x %08x\n", debugstr_a(szPackagePath
),
191 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
),
192 lgidLanguage
, dwPlatform
, dwOptions
);
193 return ERROR_CALL_NOT_IMPLEMENTED
;
196 UINT WINAPI
MsiAdvertiseProductExW( LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
197 LPCWSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
199 FIXME("%s %s %s %08x %08x %08x\n", debugstr_w(szPackagePath
),
200 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
),
201 lgidLanguage
, dwPlatform
, dwOptions
);
202 return ERROR_CALL_NOT_IMPLEMENTED
;
205 UINT WINAPI
MsiInstallProductA(LPCSTR szPackagePath
, LPCSTR szCommandLine
)
207 LPWSTR szwPath
= NULL
, szwCommand
= NULL
;
208 UINT r
= ERROR_OUTOFMEMORY
;
210 TRACE("%s %s\n",debugstr_a(szPackagePath
), debugstr_a(szCommandLine
));
214 szwPath
= strdupAtoW( szPackagePath
);
221 szwCommand
= strdupAtoW( szCommandLine
);
226 r
= MsiInstallProductW( szwPath
, szwCommand
);
230 msi_free( szwCommand
);
235 UINT WINAPI
MsiInstallProductW(LPCWSTR szPackagePath
, LPCWSTR szCommandLine
)
237 MSIPACKAGE
*package
= NULL
;
240 TRACE("%s %s\n",debugstr_w(szPackagePath
), debugstr_w(szCommandLine
));
243 return ERROR_INVALID_PARAMETER
;
246 return ERROR_PATH_NOT_FOUND
;
248 r
= MSI_OpenPackageW( szPackagePath
, &package
);
249 if (r
== ERROR_SUCCESS
)
251 r
= MSI_InstallPackage( package
, szPackagePath
, szCommandLine
);
252 msiobj_release( &package
->hdr
);
258 UINT WINAPI
MsiReinstallProductA(LPCSTR szProduct
, DWORD dwReinstallMode
)
263 TRACE("%s %08x\n", debugstr_a(szProduct
), dwReinstallMode
);
265 wszProduct
= strdupAtoW(szProduct
);
267 rc
= MsiReinstallProductW(wszProduct
, dwReinstallMode
);
269 msi_free(wszProduct
);
273 UINT WINAPI
MsiReinstallProductW(LPCWSTR szProduct
, DWORD dwReinstallMode
)
275 TRACE("%s %08x\n", debugstr_w(szProduct
), dwReinstallMode
);
277 return MsiReinstallFeatureW(szProduct
, szAll
, dwReinstallMode
);
280 UINT WINAPI
MsiApplyPatchA(LPCSTR szPatchPackage
, LPCSTR szInstallPackage
,
281 INSTALLTYPE eInstallType
, LPCSTR szCommandLine
)
283 LPWSTR patch_package
= NULL
;
284 LPWSTR install_package
= NULL
;
285 LPWSTR command_line
= NULL
;
286 UINT r
= ERROR_OUTOFMEMORY
;
288 TRACE("%s %s %d %s\n", debugstr_a(szPatchPackage
), debugstr_a(szInstallPackage
),
289 eInstallType
, debugstr_a(szCommandLine
));
291 if (szPatchPackage
&& !(patch_package
= strdupAtoW(szPatchPackage
)))
294 if (szInstallPackage
&& !(install_package
= strdupAtoW(szInstallPackage
)))
297 if (szCommandLine
&& !(command_line
= strdupAtoW(szCommandLine
)))
300 r
= MsiApplyPatchW(patch_package
, install_package
, eInstallType
, command_line
);
303 msi_free(patch_package
);
304 msi_free(install_package
);
305 msi_free(command_line
);
310 static UINT
get_patch_product_codes( LPCWSTR szPatchPackage
, WCHAR
***product_codes
)
312 MSIHANDLE patch
, info
= 0;
315 static WCHAR empty
[] = {0};
318 r
= MsiOpenDatabaseW( szPatchPackage
, MSIDBOPEN_READONLY
, &patch
);
319 if (r
!= ERROR_SUCCESS
)
322 r
= MsiGetSummaryInformationW( patch
, NULL
, 0, &info
);
323 if (r
!= ERROR_SUCCESS
)
327 r
= MsiSummaryInfoGetPropertyW( info
, PID_TEMPLATE
, &type
, NULL
, NULL
, empty
, &size
);
328 if (r
!= ERROR_MORE_DATA
|| !size
|| type
!= VT_LPSTR
)
330 ERR("Failed to read product codes from patch\n");
331 r
= ERROR_FUNCTION_FAILED
;
335 codes
= msi_alloc( ++size
* sizeof(WCHAR
) );
338 r
= ERROR_OUTOFMEMORY
;
342 r
= MsiSummaryInfoGetPropertyW( info
, PID_TEMPLATE
, &type
, NULL
, NULL
, codes
, &size
);
343 if (r
== ERROR_SUCCESS
)
344 *product_codes
= msi_split_string( codes
, ';' );
347 MsiCloseHandle( info
);
348 MsiCloseHandle( patch
);
353 static UINT
MSI_ApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szProductCode
, LPCWSTR szCommandLine
)
355 UINT i
, r
= ERROR_FUNCTION_FAILED
;
357 LPCWSTR cmd_ptr
= szCommandLine
;
358 LPWSTR cmd
, *codes
= NULL
;
359 BOOL succeeded
= FALSE
;
361 static const WCHAR fmt
[] = {'%','s',' ','P','A','T','C','H','=','"','%','s','"',0};
362 static WCHAR empty
[] = {0};
364 if (!szPatchPackage
|| !szPatchPackage
[0])
365 return ERROR_INVALID_PARAMETER
;
367 if (!szProductCode
&& (r
= get_patch_product_codes( szPatchPackage
, &codes
)))
373 size
= strlenW(cmd_ptr
) + strlenW(fmt
) + strlenW(szPatchPackage
) + 1;
374 cmd
= msi_alloc(size
* sizeof(WCHAR
));
378 return ERROR_OUTOFMEMORY
;
380 sprintfW(cmd
, fmt
, cmd_ptr
, szPatchPackage
);
383 r
= MsiConfigureProductExW(szProductCode
, INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
386 for (i
= 0; codes
[i
]; i
++)
388 r
= MsiConfigureProductExW(codes
[i
], INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
389 if (r
== ERROR_SUCCESS
)
391 TRACE("patch applied\n");
405 UINT WINAPI
MsiApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szInstallPackage
,
406 INSTALLTYPE eInstallType
, LPCWSTR szCommandLine
)
408 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage
), debugstr_w(szInstallPackage
),
409 eInstallType
, debugstr_w(szCommandLine
));
411 if (szInstallPackage
|| eInstallType
== INSTALLTYPE_NETWORK_IMAGE
||
412 eInstallType
== INSTALLTYPE_SINGLE_INSTANCE
)
414 FIXME("Only reading target products from patch\n");
415 return ERROR_CALL_NOT_IMPLEMENTED
;
418 return MSI_ApplyPatchW(szPatchPackage
, NULL
, szCommandLine
);
421 UINT WINAPI
MsiApplyMultiplePatchesA(LPCSTR szPatchPackages
,
422 LPCSTR szProductCode
, LPCSTR szPropertiesList
)
424 LPWSTR patch_packages
= NULL
;
425 LPWSTR product_code
= NULL
;
426 LPWSTR properties_list
= NULL
;
427 UINT r
= ERROR_OUTOFMEMORY
;
429 TRACE("%s %s %s\n", debugstr_a(szPatchPackages
), debugstr_a(szProductCode
),
430 debugstr_a(szPropertiesList
));
432 if (!szPatchPackages
|| !szPatchPackages
[0])
433 return ERROR_INVALID_PARAMETER
;
435 if (!(patch_packages
= strdupAtoW(szPatchPackages
)))
436 return ERROR_OUTOFMEMORY
;
438 if (szProductCode
&& !(product_code
= strdupAtoW(szProductCode
)))
441 if (szPropertiesList
&& !(properties_list
= strdupAtoW(szPropertiesList
)))
444 r
= MsiApplyMultiplePatchesW(patch_packages
, product_code
, properties_list
);
447 msi_free(patch_packages
);
448 msi_free(product_code
);
449 msi_free(properties_list
);
454 UINT WINAPI
MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages
,
455 LPCWSTR szProductCode
, LPCWSTR szPropertiesList
)
457 UINT r
= ERROR_SUCCESS
;
460 TRACE("%s %s %s\n", debugstr_w(szPatchPackages
), debugstr_w(szProductCode
),
461 debugstr_w(szPropertiesList
));
463 if (!szPatchPackages
|| !szPatchPackages
[0])
464 return ERROR_INVALID_PARAMETER
;
466 beg
= end
= szPatchPackages
;
472 while (*beg
== ' ') beg
++;
473 while (*end
&& *end
!= ';') end
++;
476 while (len
&& beg
[len
- 1] == ' ') len
--;
478 if (!len
) return ERROR_INVALID_NAME
;
480 patch
= msi_alloc((len
+ 1) * sizeof(WCHAR
));
482 return ERROR_OUTOFMEMORY
;
484 memcpy(patch
, beg
, len
* sizeof(WCHAR
));
487 r
= MSI_ApplyPatchW(patch
, szProductCode
, szPropertiesList
);
490 if (r
!= ERROR_SUCCESS
)
498 static void free_patchinfo( DWORD count
, MSIPATCHSEQUENCEINFOW
*info
)
501 for (i
= 0; i
< count
; i
++) msi_free( (WCHAR
*)info
[i
].szPatchData
);
505 static MSIPATCHSEQUENCEINFOW
*patchinfoAtoW( DWORD count
, const MSIPATCHSEQUENCEINFOA
*info
)
508 MSIPATCHSEQUENCEINFOW
*ret
;
510 if (!(ret
= msi_alloc( count
* sizeof(MSIPATCHSEQUENCEINFOW
) ))) return NULL
;
511 for (i
= 0; i
< count
; i
++)
513 if (info
[i
].szPatchData
&& !(ret
[i
].szPatchData
= strdupAtoW( info
[i
].szPatchData
)))
515 free_patchinfo( i
, ret
);
518 ret
[i
].ePatchDataType
= info
[i
].ePatchDataType
;
519 ret
[i
].dwOrder
= info
[i
].dwOrder
;
520 ret
[i
].uStatus
= info
[i
].uStatus
;
525 UINT WINAPI
MsiDetermineApplicablePatchesA(LPCSTR szProductPackagePath
,
526 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOA pPatchInfo
)
529 WCHAR
*package_path
= NULL
;
530 MSIPATCHSEQUENCEINFOW
*psi
;
532 TRACE("%s, %u, %p\n", debugstr_a(szProductPackagePath
), cPatchInfo
, pPatchInfo
);
534 if (szProductPackagePath
&& !(package_path
= strdupAtoW( szProductPackagePath
)))
535 return ERROR_OUTOFMEMORY
;
537 if (!(psi
= patchinfoAtoW( cPatchInfo
, pPatchInfo
)))
539 msi_free( package_path
);
540 return ERROR_OUTOFMEMORY
;
542 r
= MsiDetermineApplicablePatchesW( package_path
, cPatchInfo
, psi
);
543 if (r
== ERROR_SUCCESS
)
545 for (i
= 0; i
< cPatchInfo
; i
++)
547 pPatchInfo
[i
].dwOrder
= psi
[i
].dwOrder
;
548 pPatchInfo
[i
].uStatus
= psi
[i
].uStatus
;
551 msi_free( package_path
);
552 free_patchinfo( cPatchInfo
, psi
);
556 static UINT
MSI_ApplicablePatchW( MSIPACKAGE
*package
, LPCWSTR patch
)
559 MSIDATABASE
*patch_db
;
560 UINT r
= ERROR_SUCCESS
;
562 r
= MSI_OpenDatabaseW( patch
, MSIDBOPEN_READONLY
, &patch_db
);
563 if (r
!= ERROR_SUCCESS
)
565 WARN("failed to open patch file %s\n", debugstr_w(patch
));
569 si
= MSI_GetSummaryInformationW( patch_db
->storage
, 0 );
572 msiobj_release( &patch_db
->hdr
);
573 return ERROR_FUNCTION_FAILED
;
576 r
= msi_check_patch_applicable( package
, si
);
577 if (r
!= ERROR_SUCCESS
)
578 TRACE("patch not applicable\n");
580 msiobj_release( &patch_db
->hdr
);
581 msiobj_release( &si
->hdr
);
585 /* IXMLDOMDocument should be set to XPath mode already */
586 static UINT
MSI_ApplicablePatchXML( MSIPACKAGE
*package
, IXMLDOMDocument
*desc
)
588 static const WCHAR queryW
[] = {'M','s','i','P','a','t','c','h','/',
589 'T','a','r','g','e','t','P','r','o','d','u','c','t','/',
590 'T','a','r','g','e','t','P','r','o','d','u','c','t','C','o','d','e',0};
591 UINT r
= ERROR_FUNCTION_FAILED
;
592 IXMLDOMNodeList
*list
;
598 product_code
= msi_dup_property( package
->db
, szProductCode
);
601 /* FIXME: the property ProductCode should be written into the DB somewhere */
602 ERR("no product code to check\n");
603 return ERROR_SUCCESS
;
606 s
= SysAllocString(queryW
);
607 hr
= IXMLDOMDocument_selectNodes( desc
, s
, &list
);
610 return ERROR_INVALID_PATCH_XML
;
612 while (IXMLDOMNodeList_nextNode( list
, &node
) == S_OK
&& r
!= ERROR_SUCCESS
)
614 hr
= IXMLDOMNode_get_text( node
, &s
);
615 IXMLDOMNode_Release( node
);
618 if (!strcmpW( s
, product_code
)) r
= ERROR_SUCCESS
;
622 IXMLDOMNodeList_Release( list
);
624 if (r
!= ERROR_SUCCESS
)
625 TRACE("patch not applicable\n");
627 msi_free( product_code
);
631 static UINT
determine_patch_sequence( MSIPACKAGE
*package
, DWORD count
, MSIPATCHSEQUENCEINFOW
*info
)
633 IXMLDOMDocument
*desc
= NULL
;
637 FIXME("patch ordering not supported\n");
639 for (i
= 0; i
< count
; i
++)
641 switch (info
[i
].ePatchDataType
)
643 case MSIPATCH_DATATYPE_PATCHFILE
:
645 if (MSI_ApplicablePatchW( package
, info
[i
].szPatchData
) != ERROR_SUCCESS
)
647 info
[i
].dwOrder
= ~0u;
648 info
[i
].uStatus
= ERROR_PATCH_TARGET_NOT_FOUND
;
653 info
[i
].uStatus
= ERROR_SUCCESS
;
657 case MSIPATCH_DATATYPE_XMLPATH
:
658 case MSIPATCH_DATATYPE_XMLBLOB
:
666 hr
= CoCreateInstance( &CLSID_DOMDocument30
, NULL
, CLSCTX_INPROC_SERVER
,
667 &IID_IXMLDOMDocument
, (void**)&desc
);
670 ERR("failed to create DOMDocument30 instance, 0x%08x\n", hr
);
671 return ERROR_FUNCTION_FAILED
;
675 s
= SysAllocString( info
[i
].szPatchData
);
676 if (info
[i
].ePatchDataType
== MSIPATCH_DATATYPE_XMLPATH
)
680 V_VT(&src
) = VT_BSTR
;
682 hr
= IXMLDOMDocument_load( desc
, src
, &b
);
685 hr
= IXMLDOMDocument_loadXML( desc
, s
, &b
);
689 ERR("failed to parse patch description\n");
690 IXMLDOMDocument_Release( desc
);
694 if (MSI_ApplicablePatchXML( package
, desc
) != ERROR_SUCCESS
)
696 info
[i
].dwOrder
= ~0u;
697 info
[i
].uStatus
= ERROR_PATCH_TARGET_NOT_FOUND
;
702 info
[i
].uStatus
= ERROR_SUCCESS
;
708 FIXME("unknown patch data type %u\n", info
[i
].ePatchDataType
);
710 info
[i
].uStatus
= ERROR_SUCCESS
;
715 TRACE("szPatchData: %s\n", debugstr_w(info
[i
].szPatchData
));
716 TRACE("ePatchDataType: %u\n", info
[i
].ePatchDataType
);
717 TRACE("dwOrder: %u\n", info
[i
].dwOrder
);
718 TRACE("uStatus: %u\n", info
[i
].uStatus
);
721 if (desc
) IXMLDOMDocument_Release( desc
);
723 return ERROR_SUCCESS
;
726 UINT WINAPI
MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath
,
727 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOW pPatchInfo
)
732 TRACE("%s, %u, %p\n", debugstr_w(szProductPackagePath
), cPatchInfo
, pPatchInfo
);
734 r
= MSI_OpenPackageW( szProductPackagePath
, &package
);
735 if (r
!= ERROR_SUCCESS
)
737 ERR("failed to open package %u\n", r
);
740 r
= determine_patch_sequence( package
, cPatchInfo
, pPatchInfo
);
741 msiobj_release( &package
->hdr
);
745 UINT WINAPI
MsiDeterminePatchSequenceA( LPCSTR product
, LPCSTR usersid
,
746 MSIINSTALLCONTEXT context
, DWORD count
, PMSIPATCHSEQUENCEINFOA patchinfo
)
749 WCHAR
*productW
, *usersidW
= NULL
;
750 MSIPATCHSEQUENCEINFOW
*patchinfoW
;
752 TRACE("%s, %s, %d, %d, %p\n", debugstr_a(product
), debugstr_a(usersid
),
753 context
, count
, patchinfo
);
755 if (!product
) return ERROR_INVALID_PARAMETER
;
756 if (!(productW
= strdupAtoW( product
))) return ERROR_OUTOFMEMORY
;
757 if (usersid
&& !(usersidW
= strdupAtoW( usersid
)))
759 msi_free( productW
);
760 return ERROR_OUTOFMEMORY
;
762 if (!(patchinfoW
= patchinfoAtoW( count
, patchinfo
)))
764 msi_free( productW
);
765 msi_free( usersidW
);
766 return ERROR_OUTOFMEMORY
;
768 r
= MsiDeterminePatchSequenceW( productW
, usersidW
, context
, count
, patchinfoW
);
769 if (r
== ERROR_SUCCESS
)
771 for (i
= 0; i
< count
; i
++)
773 patchinfo
[i
].dwOrder
= patchinfoW
[i
].dwOrder
;
774 patchinfo
[i
].uStatus
= patchinfoW
[i
].uStatus
;
777 msi_free( productW
);
778 msi_free( usersidW
);
779 free_patchinfo( count
, patchinfoW
);
783 static UINT
open_package( const WCHAR
*product
, const WCHAR
*usersid
,
784 MSIINSTALLCONTEXT context
, MSIPACKAGE
**package
)
788 WCHAR
*localpath
, sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
790 r
= MSIREG_OpenInstallProps( product
, context
, usersid
, &props
, FALSE
);
791 if (r
!= ERROR_SUCCESS
) return ERROR_BAD_CONFIGURATION
;
793 if ((localpath
= msi_reg_get_val_str( props
, szLocalPackage
)))
795 strcpyW( sourcepath
, localpath
);
796 msi_free( localpath
);
798 RegCloseKey( props
);
799 if (!localpath
|| GetFileAttributesW( sourcepath
) == INVALID_FILE_ATTRIBUTES
)
801 DWORD sz
= sizeof(sourcepath
);
802 MsiSourceListGetInfoW( product
, usersid
, context
, MSICODE_PRODUCT
,
803 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
804 sz
= sizeof(filename
);
805 MsiSourceListGetInfoW( product
, usersid
, context
, MSICODE_PRODUCT
,
806 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
807 strcatW( sourcepath
, filename
);
809 if (GetFileAttributesW( sourcepath
) == INVALID_FILE_ATTRIBUTES
)
810 return ERROR_INSTALL_SOURCE_ABSENT
;
812 return MSI_OpenPackageW( sourcepath
, package
);
815 UINT WINAPI
MsiDeterminePatchSequenceW( LPCWSTR product
, LPCWSTR usersid
,
816 MSIINSTALLCONTEXT context
, DWORD count
, PMSIPATCHSEQUENCEINFOW patchinfo
)
821 TRACE("%s, %s, %d, %d, %p\n", debugstr_w(product
), debugstr_w(usersid
),
822 context
, count
, patchinfo
);
824 if (!product
) return ERROR_INVALID_PARAMETER
;
825 r
= open_package( product
, usersid
, context
, &package
);
826 if (r
!= ERROR_SUCCESS
) return r
;
828 r
= determine_patch_sequence( package
, count
, patchinfo
);
829 msiobj_release( &package
->hdr
);
833 UINT WINAPI
MsiConfigureProductExW(LPCWSTR szProduct
, int iInstallLevel
,
834 INSTALLSTATE eInstallState
, LPCWSTR szCommandLine
)
836 MSIPACKAGE
* package
= NULL
;
837 MSIINSTALLCONTEXT context
;
840 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
843 static const WCHAR szInstalled
[] = {
844 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
845 static const WCHAR szMaxInstallLevel
[] = {
846 ' ','I','N','S','T','A','L','L','L','E','V','E','L','=','3','2','7','6','7',0};
847 static const WCHAR szRemoveAll
[] = {
848 ' ','R','E','M','O','V','E','=','A','L','L',0};
849 static const WCHAR szMachine
[] = {
850 ' ','A','L','L','U','S','E','R','S','=','1',0};
852 TRACE("%s %d %d %s\n",debugstr_w(szProduct
), iInstallLevel
, eInstallState
,
853 debugstr_w(szCommandLine
));
855 if (!szProduct
|| lstrlenW(szProduct
) != GUID_SIZE
- 1)
856 return ERROR_INVALID_PARAMETER
;
858 if (eInstallState
== INSTALLSTATE_ADVERTISED
||
859 eInstallState
== INSTALLSTATE_SOURCE
)
861 FIXME("State %d not implemented\n", eInstallState
);
862 return ERROR_CALL_NOT_IMPLEMENTED
;
865 r
= msi_locate_product(szProduct
, &context
);
866 if (r
!= ERROR_SUCCESS
)
869 r
= open_package(szProduct
, NULL
, context
, &package
);
870 if (r
!= ERROR_SUCCESS
)
873 sz
= lstrlenW(szInstalled
) + 1;
876 sz
+= lstrlenW(szCommandLine
);
878 if (eInstallState
!= INSTALLSTATE_DEFAULT
)
879 sz
+= lstrlenW(szMaxInstallLevel
);
881 if (eInstallState
== INSTALLSTATE_ABSENT
)
882 sz
+= lstrlenW(szRemoveAll
);
884 if (context
== MSIINSTALLCONTEXT_MACHINE
)
885 sz
+= lstrlenW(szMachine
);
887 commandline
= msi_alloc(sz
* sizeof(WCHAR
));
890 r
= ERROR_OUTOFMEMORY
;
896 lstrcpyW(commandline
,szCommandLine
);
898 if (eInstallState
!= INSTALLSTATE_DEFAULT
)
899 lstrcatW(commandline
, szMaxInstallLevel
);
901 if (eInstallState
== INSTALLSTATE_ABSENT
)
902 lstrcatW(commandline
, szRemoveAll
);
904 if (context
== MSIINSTALLCONTEXT_MACHINE
)
905 lstrcatW(commandline
, szMachine
);
907 sz
= sizeof(sourcepath
);
908 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
909 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
911 sz
= sizeof(filename
);
912 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
913 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
915 strcatW(sourcepath
, filename
);
917 r
= MSI_InstallPackage( package
, sourcepath
, commandline
);
919 msi_free(commandline
);
922 msiobj_release( &package
->hdr
);
927 UINT WINAPI
MsiConfigureProductExA(LPCSTR szProduct
, int iInstallLevel
,
928 INSTALLSTATE eInstallState
, LPCSTR szCommandLine
)
930 LPWSTR szwProduct
= NULL
;
931 LPWSTR szwCommandLine
= NULL
;
932 UINT r
= ERROR_OUTOFMEMORY
;
936 szwProduct
= strdupAtoW( szProduct
);
943 szwCommandLine
= strdupAtoW( szCommandLine
);
948 r
= MsiConfigureProductExW( szwProduct
, iInstallLevel
, eInstallState
,
951 msi_free( szwProduct
);
952 msi_free( szwCommandLine
);
957 UINT WINAPI
MsiConfigureProductA(LPCSTR szProduct
, int iInstallLevel
,
958 INSTALLSTATE eInstallState
)
960 LPWSTR szwProduct
= NULL
;
963 TRACE("%s %d %d\n",debugstr_a(szProduct
), iInstallLevel
, eInstallState
);
967 szwProduct
= strdupAtoW( szProduct
);
969 return ERROR_OUTOFMEMORY
;
972 r
= MsiConfigureProductW( szwProduct
, iInstallLevel
, eInstallState
);
973 msi_free( szwProduct
);
978 UINT WINAPI
MsiConfigureProductW(LPCWSTR szProduct
, int iInstallLevel
,
979 INSTALLSTATE eInstallState
)
981 return MsiConfigureProductExW(szProduct
, iInstallLevel
, eInstallState
, NULL
);
984 UINT WINAPI
MsiGetProductCodeA(LPCSTR szComponent
, LPSTR szBuffer
)
986 LPWSTR szwComponent
= NULL
;
988 WCHAR szwBuffer
[GUID_SIZE
];
990 TRACE("%s %p\n", debugstr_a(szComponent
), szBuffer
);
994 szwComponent
= strdupAtoW( szComponent
);
996 return ERROR_OUTOFMEMORY
;
1000 r
= MsiGetProductCodeW( szwComponent
, szwBuffer
);
1003 WideCharToMultiByte(CP_ACP
, 0, szwBuffer
, -1, szBuffer
, GUID_SIZE
, NULL
, NULL
);
1005 msi_free( szwComponent
);
1010 UINT WINAPI
MsiGetProductCodeW(LPCWSTR szComponent
, LPWSTR szBuffer
)
1013 HKEY compkey
, prodkey
;
1014 WCHAR squished_comp
[GUID_SIZE
];
1015 WCHAR squished_prod
[GUID_SIZE
];
1016 DWORD sz
= GUID_SIZE
;
1018 TRACE("%s %p\n", debugstr_w(szComponent
), szBuffer
);
1020 if (!szComponent
|| !*szComponent
)
1021 return ERROR_INVALID_PARAMETER
;
1023 if (!squash_guid(szComponent
, squished_comp
))
1024 return ERROR_INVALID_PARAMETER
;
1026 if (MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &compkey
, FALSE
) != ERROR_SUCCESS
&&
1027 MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &compkey
, FALSE
) != ERROR_SUCCESS
)
1029 return ERROR_UNKNOWN_COMPONENT
;
1032 rc
= RegEnumValueW(compkey
, 0, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
1033 if (rc
!= ERROR_SUCCESS
)
1035 RegCloseKey(compkey
);
1036 return ERROR_UNKNOWN_COMPONENT
;
1039 /* check simple case, only one product */
1040 rc
= RegEnumValueW(compkey
, 1, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
1041 if (rc
== ERROR_NO_MORE_ITEMS
)
1048 while ((rc
= RegEnumValueW(compkey
, index
, squished_prod
, &sz
,
1049 NULL
, NULL
, NULL
, NULL
)) != ERROR_NO_MORE_ITEMS
)
1053 unsquash_guid(squished_prod
, szBuffer
);
1055 if (MSIREG_OpenProductKey(szBuffer
, NULL
,
1056 MSIINSTALLCONTEXT_USERMANAGED
,
1057 &prodkey
, FALSE
) == ERROR_SUCCESS
||
1058 MSIREG_OpenProductKey(szBuffer
, NULL
,
1059 MSIINSTALLCONTEXT_USERUNMANAGED
,
1060 &prodkey
, FALSE
) == ERROR_SUCCESS
||
1061 MSIREG_OpenProductKey(szBuffer
, NULL
,
1062 MSIINSTALLCONTEXT_MACHINE
,
1063 &prodkey
, FALSE
) == ERROR_SUCCESS
)
1065 RegCloseKey(prodkey
);
1071 rc
= ERROR_INSTALL_FAILURE
;
1074 RegCloseKey(compkey
);
1075 unsquash_guid(squished_prod
, szBuffer
);
1079 static LPWSTR
msi_reg_get_value(HKEY hkey
, LPCWSTR name
, DWORD
*type
)
1085 static const WCHAR format
[] = {'%','d',0};
1087 res
= RegQueryValueExW(hkey
, name
, NULL
, type
, NULL
, NULL
);
1088 if (res
!= ERROR_SUCCESS
)
1091 if (*type
== REG_SZ
)
1092 return msi_reg_get_val_str(hkey
, name
);
1094 if (!msi_reg_get_val_dword(hkey
, name
, &dval
))
1097 sprintfW(temp
, format
, dval
);
1098 return strdupW(temp
);
1101 static UINT
MSI_GetProductInfo(LPCWSTR szProduct
, LPCWSTR szAttribute
,
1102 awstring
*szValue
, LPDWORD pcchValueBuf
)
1104 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
1105 UINT r
= ERROR_UNKNOWN_PROPERTY
;
1106 HKEY prodkey
, userdata
, source
;
1108 WCHAR squished_pc
[GUID_SIZE
];
1109 WCHAR packagecode
[GUID_SIZE
];
1110 BOOL badconfig
= FALSE
;
1112 DWORD type
= REG_NONE
;
1114 static WCHAR empty
[] = {0};
1115 static const WCHAR sourcelist
[] = {
1116 'S','o','u','r','c','e','L','i','s','t',0};
1117 static const WCHAR display_name
[] = {
1118 'D','i','s','p','l','a','y','N','a','m','e',0};
1119 static const WCHAR display_version
[] = {
1120 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1121 static const WCHAR assignment
[] = {
1122 'A','s','s','i','g','n','m','e','n','t',0};
1124 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
1125 debugstr_w(szAttribute
), szValue
, pcchValueBuf
);
1127 if ((szValue
->str
.w
&& !pcchValueBuf
) || !szProduct
|| !szAttribute
)
1128 return ERROR_INVALID_PARAMETER
;
1130 if (!squash_guid(szProduct
, squished_pc
))
1131 return ERROR_INVALID_PARAMETER
;
1133 if ((r
= MSIREG_OpenProductKey(szProduct
, NULL
,
1134 MSIINSTALLCONTEXT_USERMANAGED
,
1135 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
1136 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
1137 MSIINSTALLCONTEXT_USERUNMANAGED
,
1138 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
1139 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
1140 MSIINSTALLCONTEXT_MACHINE
,
1141 &prodkey
, FALSE
)) == ERROR_SUCCESS
)
1143 context
= MSIINSTALLCONTEXT_MACHINE
;
1146 MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
1148 if (!strcmpW( szAttribute
, INSTALLPROPERTY_HELPLINKW
) ||
1149 !strcmpW( szAttribute
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
1150 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLDATEW
) ||
1151 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
1152 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
1153 !strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
1154 !strcmpW( szAttribute
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
1155 !strcmpW( szAttribute
, INSTALLPROPERTY_PUBLISHERW
) ||
1156 !strcmpW( szAttribute
, INSTALLPROPERTY_URLINFOABOUTW
) ||
1157 !strcmpW( szAttribute
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
1158 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONMINORW
) ||
1159 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONMAJORW
) ||
1160 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
1161 !strcmpW( szAttribute
, INSTALLPROPERTY_PRODUCTIDW
) ||
1162 !strcmpW( szAttribute
, INSTALLPROPERTY_REGCOMPANYW
) ||
1163 !strcmpW( szAttribute
, INSTALLPROPERTY_REGOWNERW
))
1167 r
= ERROR_UNKNOWN_PRODUCT
;
1172 return ERROR_UNKNOWN_PROPERTY
;
1174 if (!strcmpW( szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
1175 szAttribute
= display_name
;
1176 else if (!strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
))
1177 szAttribute
= display_version
;
1179 val
= msi_reg_get_value(userdata
, szAttribute
, &type
);
1183 else if (!strcmpW( szAttribute
, INSTALLPROPERTY_INSTANCETYPEW
) ||
1184 !strcmpW( szAttribute
, INSTALLPROPERTY_TRANSFORMSW
) ||
1185 !strcmpW( szAttribute
, INSTALLPROPERTY_LANGUAGEW
) ||
1186 !strcmpW( szAttribute
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
1187 !strcmpW( szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
) ||
1188 !strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGECODEW
) ||
1189 !strcmpW( szAttribute
, INSTALLPROPERTY_VERSIONW
) ||
1190 !strcmpW( szAttribute
, INSTALLPROPERTY_PRODUCTICONW
) ||
1191 !strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
) ||
1192 !strcmpW( szAttribute
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
1196 r
= ERROR_UNKNOWN_PRODUCT
;
1200 if (!strcmpW( szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
1201 szAttribute
= assignment
;
1203 if (!strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
))
1205 res
= RegOpenKeyW(prodkey
, sourcelist
, &source
);
1206 if (res
!= ERROR_SUCCESS
)
1208 r
= ERROR_UNKNOWN_PRODUCT
;
1212 val
= msi_reg_get_value(source
, szAttribute
, &type
);
1216 RegCloseKey(source
);
1220 val
= msi_reg_get_value(prodkey
, szAttribute
, &type
);
1225 if (val
!= empty
&& type
!= REG_DWORD
&&
1226 !strcmpW( szAttribute
, INSTALLPROPERTY_PACKAGECODEW
))
1228 if (lstrlenW(val
) != SQUISH_GUID_SIZE
- 1)
1232 unsquash_guid(val
, packagecode
);
1234 val
= strdupW(packagecode
);
1241 r
= ERROR_UNKNOWN_PROPERTY
;
1247 /* If szBuffer (szValue->str) is NULL, there's no need to copy the value
1248 * out. Also, *pcchValueBuf may be uninitialized in this case, so we
1249 * can't rely on its value.
1251 if (szValue
->str
.a
|| szValue
->str
.w
)
1253 DWORD size
= *pcchValueBuf
;
1254 if (strlenW(val
) < size
)
1255 r
= msi_strcpy_to_awstring(val
, szValue
, &size
);
1258 r
= ERROR_MORE_DATA
;
1263 *pcchValueBuf
= lstrlenW(val
);
1267 r
= ERROR_BAD_CONFIGURATION
;
1273 RegCloseKey(prodkey
);
1274 RegCloseKey(userdata
);
1278 UINT WINAPI
MsiGetProductInfoA(LPCSTR szProduct
, LPCSTR szAttribute
,
1279 LPSTR szBuffer
, LPDWORD pcchValueBuf
)
1281 LPWSTR szwProduct
, szwAttribute
= NULL
;
1282 UINT r
= ERROR_OUTOFMEMORY
;
1285 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szAttribute
),
1286 szBuffer
, pcchValueBuf
);
1288 szwProduct
= strdupAtoW( szProduct
);
1289 if( szProduct
&& !szwProduct
)
1292 szwAttribute
= strdupAtoW( szAttribute
);
1293 if( szAttribute
&& !szwAttribute
)
1296 buffer
.unicode
= FALSE
;
1297 buffer
.str
.a
= szBuffer
;
1299 r
= MSI_GetProductInfo( szwProduct
, szwAttribute
,
1300 &buffer
, pcchValueBuf
);
1303 msi_free( szwProduct
);
1304 msi_free( szwAttribute
);
1309 UINT WINAPI
MsiGetProductInfoW(LPCWSTR szProduct
, LPCWSTR szAttribute
,
1310 LPWSTR szBuffer
, LPDWORD pcchValueBuf
)
1314 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szAttribute
),
1315 szBuffer
, pcchValueBuf
);
1317 buffer
.unicode
= TRUE
;
1318 buffer
.str
.w
= szBuffer
;
1320 return MSI_GetProductInfo( szProduct
, szAttribute
,
1321 &buffer
, pcchValueBuf
);
1324 UINT WINAPI
MsiGetProductInfoExA(LPCSTR szProductCode
, LPCSTR szUserSid
,
1325 MSIINSTALLCONTEXT dwContext
, LPCSTR szProperty
,
1326 LPSTR szValue
, LPDWORD pcchValue
)
1328 LPWSTR product
= NULL
;
1329 LPWSTR usersid
= NULL
;
1330 LPWSTR property
= NULL
;
1331 LPWSTR value
= NULL
;
1335 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_a(szProductCode
),
1336 debugstr_a(szUserSid
), dwContext
, debugstr_a(szProperty
),
1337 szValue
, pcchValue
);
1339 if (szValue
&& !pcchValue
)
1340 return ERROR_INVALID_PARAMETER
;
1342 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1343 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1344 if (szProperty
) property
= strdupAtoW(szProperty
);
1346 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1348 if (r
!= ERROR_SUCCESS
)
1351 value
= msi_alloc(++len
* sizeof(WCHAR
));
1354 r
= ERROR_OUTOFMEMORY
;
1358 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1360 if (r
!= ERROR_SUCCESS
)
1366 len
= WideCharToMultiByte(CP_ACP
, 0, value
, -1, NULL
, 0, NULL
, NULL
);
1367 if (*pcchValue
>= len
)
1368 WideCharToMultiByte(CP_ACP
, 0, value
, -1, szValue
, len
, NULL
, NULL
);
1371 r
= ERROR_MORE_DATA
;
1376 if (*pcchValue
<= len
|| !szValue
)
1377 len
= len
* sizeof(WCHAR
) - 1;
1379 *pcchValue
= len
- 1;
1390 static UINT
msi_copy_outval(LPWSTR val
, LPWSTR out
, LPDWORD size
)
1392 UINT r
= ERROR_SUCCESS
;
1395 return ERROR_UNKNOWN_PROPERTY
;
1399 if (strlenW(val
) >= *size
)
1401 r
= ERROR_MORE_DATA
;
1410 *size
= lstrlenW(val
);
1415 UINT WINAPI
MsiGetProductInfoExW(LPCWSTR szProductCode
, LPCWSTR szUserSid
,
1416 MSIINSTALLCONTEXT dwContext
, LPCWSTR szProperty
,
1417 LPWSTR szValue
, LPDWORD pcchValue
)
1419 WCHAR squished_pc
[GUID_SIZE
];
1421 LPCWSTR package
= NULL
;
1422 HKEY props
= NULL
, prod
;
1423 HKEY classes
= NULL
, managed
;
1426 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1428 static const WCHAR five
[] = {'5',0};
1429 static const WCHAR displayname
[] = {
1430 'D','i','s','p','l','a','y','N','a','m','e',0};
1431 static const WCHAR displayversion
[] = {
1432 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1433 static const WCHAR managed_local_package
[] = {
1434 'M','a','n','a','g','e','d','L','o','c','a','l',
1435 'P','a','c','k','a','g','e',0};
1437 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_w(szProductCode
),
1438 debugstr_w(szUserSid
), dwContext
, debugstr_w(szProperty
),
1439 szValue
, pcchValue
);
1441 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1442 return ERROR_INVALID_PARAMETER
;
1444 if (szValue
&& !pcchValue
)
1445 return ERROR_INVALID_PARAMETER
;
1447 if (dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1448 dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1449 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1450 return ERROR_INVALID_PARAMETER
;
1452 if (!szProperty
|| !*szProperty
)
1453 return ERROR_INVALID_PARAMETER
;
1455 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1456 return ERROR_INVALID_PARAMETER
;
1458 /* FIXME: dwContext is provided, no need to search for it */
1459 MSIREG_OpenProductKey(szProductCode
, NULL
,MSIINSTALLCONTEXT_USERMANAGED
,
1461 MSIREG_OpenProductKey(szProductCode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1464 MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
, &props
, FALSE
);
1466 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1468 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1470 if (!props
&& !prod
)
1473 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1475 package
= managed_local_package
;
1477 if (!props
&& !managed
)
1480 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1482 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1483 MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
, &classes
, FALSE
);
1485 if (!props
&& !classes
)
1489 if (!strcmpW( szProperty
, INSTALLPROPERTY_HELPLINKW
) ||
1490 !strcmpW( szProperty
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
1491 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLDATEW
) ||
1492 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
1493 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
1494 !strcmpW( szProperty
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
1495 !strcmpW( szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
1496 !strcmpW( szProperty
, INSTALLPROPERTY_PUBLISHERW
) ||
1497 !strcmpW( szProperty
, INSTALLPROPERTY_URLINFOABOUTW
) ||
1498 !strcmpW( szProperty
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
1499 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONMINORW
) ||
1500 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONMAJORW
) ||
1501 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
1502 !strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTIDW
) ||
1503 !strcmpW( szProperty
, INSTALLPROPERTY_REGCOMPANYW
) ||
1504 !strcmpW( szProperty
, INSTALLPROPERTY_REGOWNERW
) ||
1505 !strcmpW( szProperty
, INSTALLPROPERTY_INSTANCETYPEW
))
1507 val
= msi_reg_get_value(props
, package
, &type
);
1510 if (prod
|| classes
)
1511 r
= ERROR_UNKNOWN_PROPERTY
;
1518 if (!strcmpW( szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
1519 szProperty
= displayname
;
1520 else if (!strcmpW( szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
))
1521 szProperty
= displayversion
;
1523 val
= msi_reg_get_value(props
, szProperty
, &type
);
1525 val
= strdupW(szEmpty
);
1527 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1529 else if (!strcmpW( szProperty
, INSTALLPROPERTY_TRANSFORMSW
) ||
1530 !strcmpW( szProperty
, INSTALLPROPERTY_LANGUAGEW
) ||
1531 !strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
1532 !strcmpW( szProperty
, INSTALLPROPERTY_PACKAGECODEW
) ||
1533 !strcmpW( szProperty
, INSTALLPROPERTY_VERSIONW
) ||
1534 !strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTICONW
) ||
1535 !strcmpW( szProperty
, INSTALLPROPERTY_PACKAGENAMEW
) ||
1536 !strcmpW( szProperty
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
1538 if (!prod
&& !classes
)
1541 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1543 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1545 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1548 val
= msi_reg_get_value(hkey
, szProperty
, &type
);
1550 val
= strdupW(szEmpty
);
1552 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1554 else if (!strcmpW( szProperty
, INSTALLPROPERTY_PRODUCTSTATEW
))
1556 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1560 val
= msi_reg_get_value(props
, package
, &type
);
1565 val
= strdupW(five
);
1568 val
= strdupW(szOne
);
1570 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1573 else if (props
&& (val
= msi_reg_get_value(props
, package
, &type
)))
1576 val
= strdupW(five
);
1577 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1581 if (prod
|| managed
)
1582 val
= strdupW(szOne
);
1586 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1588 else if (!strcmpW( szProperty
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
1590 if (!prod
&& !classes
)
1594 val
= strdupW(szEmpty
);
1595 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1598 r
= ERROR_UNKNOWN_PROPERTY
;
1603 RegCloseKey(managed
);
1604 RegCloseKey(classes
);
1610 UINT WINAPI
MsiGetPatchInfoExA(LPCSTR szPatchCode
, LPCSTR szProductCode
,
1611 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1612 LPCSTR szProperty
, LPSTR lpValue
, DWORD
*pcchValue
)
1614 LPWSTR patch
= NULL
, product
= NULL
, usersid
= NULL
;
1615 LPWSTR property
= NULL
, val
= NULL
;
1619 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_a(szPatchCode
),
1620 debugstr_a(szProductCode
), debugstr_a(szUserSid
), dwContext
,
1621 debugstr_a(szProperty
), lpValue
, pcchValue
);
1623 if (lpValue
&& !pcchValue
)
1624 return ERROR_INVALID_PARAMETER
;
1626 if (szPatchCode
) patch
= strdupAtoW(szPatchCode
);
1627 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1628 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1629 if (szProperty
) property
= strdupAtoW(szProperty
);
1632 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1634 if (r
!= ERROR_SUCCESS
)
1637 val
= msi_alloc(++len
* sizeof(WCHAR
));
1640 r
= ERROR_OUTOFMEMORY
;
1644 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1646 if (r
!= ERROR_SUCCESS
|| !pcchValue
)
1650 WideCharToMultiByte(CP_ACP
, 0, val
, -1, lpValue
,
1651 *pcchValue
- 1, NULL
, NULL
);
1653 len
= lstrlenW(val
);
1654 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1658 r
= ERROR_MORE_DATA
;
1659 lpValue
[*pcchValue
- 1] = '\0';
1662 *pcchValue
= len
* sizeof(WCHAR
);
1677 UINT WINAPI
MsiGetPatchInfoExW(LPCWSTR szPatchCode
, LPCWSTR szProductCode
,
1678 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1679 LPCWSTR szProperty
, LPWSTR lpValue
, DWORD
*pcchValue
)
1681 WCHAR squished_pc
[GUID_SIZE
];
1682 WCHAR squished_patch
[GUID_SIZE
];
1683 HKEY udprod
= 0, prod
= 0, props
= 0;
1684 HKEY patch
= 0, patches
= 0;
1685 HKEY udpatch
= 0, datakey
= 0;
1686 HKEY prodpatches
= 0;
1688 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1692 static const WCHAR szManagedPackage
[] = {'M','a','n','a','g','e','d',
1693 'L','o','c','a','l','P','a','c','k','a','g','e',0};
1695 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_w(szPatchCode
),
1696 debugstr_w(szProductCode
), debugstr_w(szUserSid
), dwContext
,
1697 debugstr_w(szProperty
), lpValue
, pcchValue
);
1699 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1700 return ERROR_INVALID_PARAMETER
;
1702 if (!szPatchCode
|| !squash_guid(szPatchCode
, squished_patch
))
1703 return ERROR_INVALID_PARAMETER
;
1706 return ERROR_INVALID_PARAMETER
;
1708 if (lpValue
&& !pcchValue
)
1709 return ERROR_INVALID_PARAMETER
;
1711 if (dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1712 dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1713 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1714 return ERROR_INVALID_PARAMETER
;
1716 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1717 return ERROR_INVALID_PARAMETER
;
1719 if (szUserSid
&& !strcmpW( szUserSid
, szLocalSid
))
1720 return ERROR_INVALID_PARAMETER
;
1722 if (MSIREG_OpenUserDataProductKey(szProductCode
, dwContext
, NULL
,
1723 &udprod
, FALSE
) != ERROR_SUCCESS
)
1726 if (MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
,
1727 &props
, FALSE
) != ERROR_SUCCESS
)
1730 r
= ERROR_UNKNOWN_PATCH
;
1732 res
= RegOpenKeyExW(udprod
, szPatches
, 0, KEY_WOW64_64KEY
|KEY_READ
, &patches
);
1733 if (res
!= ERROR_SUCCESS
)
1736 res
= RegOpenKeyExW(patches
, squished_patch
, 0, KEY_WOW64_64KEY
|KEY_READ
, &patch
);
1737 if (res
!= ERROR_SUCCESS
)
1740 if (!strcmpW( szProperty
, INSTALLPROPERTY_TRANSFORMSW
))
1742 if (MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
,
1743 &prod
, FALSE
) != ERROR_SUCCESS
)
1746 res
= RegOpenKeyExW(prod
, szPatches
, 0, KEY_WOW64_64KEY
|KEY_ALL_ACCESS
, &prodpatches
);
1747 if (res
!= ERROR_SUCCESS
)
1750 datakey
= prodpatches
;
1751 szProperty
= squished_patch
;
1755 if (MSIREG_OpenUserDataPatchKey(szPatchCode
, dwContext
,
1756 &udpatch
, FALSE
) != ERROR_SUCCESS
)
1759 if (!strcmpW( szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1761 if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1762 szProperty
= szManagedPackage
;
1765 else if (!strcmpW( szProperty
, INSTALLPROPERTY_INSTALLDATEW
))
1768 szProperty
= szInstalled
;
1770 else if (!strcmpW( szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1774 else if (!strcmpW( szProperty
, INSTALLPROPERTY_UNINSTALLABLEW
) ||
1775 !strcmpW( szProperty
, INSTALLPROPERTY_PATCHSTATEW
) ||
1776 !strcmpW( szProperty
, INSTALLPROPERTY_DISPLAYNAMEW
) ||
1777 !strcmpW( szProperty
, INSTALLPROPERTY_MOREINFOURLW
))
1783 r
= ERROR_UNKNOWN_PROPERTY
;
1788 val
= msi_reg_get_val_str(datakey
, szProperty
);
1790 val
= strdupW(szEmpty
);
1798 lstrcpynW(lpValue
, val
, *pcchValue
);
1800 len
= lstrlenW(val
);
1801 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1804 r
= ERROR_MORE_DATA
;
1806 *pcchValue
= len
* sizeof(WCHAR
);
1813 RegCloseKey(prodpatches
);
1816 RegCloseKey(patches
);
1817 RegCloseKey(udpatch
);
1819 RegCloseKey(udprod
);
1824 UINT WINAPI
MsiGetPatchInfoA( LPCSTR patch
, LPCSTR attr
, LPSTR buffer
, LPDWORD buflen
)
1826 UINT r
= ERROR_OUTOFMEMORY
;
1828 LPWSTR patchW
= NULL
, attrW
= NULL
, bufferW
= NULL
;
1830 TRACE("%s %s %p %p\n", debugstr_a(patch
), debugstr_a(attr
), buffer
, buflen
);
1832 if (!patch
|| !attr
)
1833 return ERROR_INVALID_PARAMETER
;
1835 if (!(patchW
= strdupAtoW( patch
)))
1838 if (!(attrW
= strdupAtoW( attr
)))
1842 r
= MsiGetPatchInfoW( patchW
, attrW
, NULL
, &size
);
1843 if (r
!= ERROR_SUCCESS
)
1847 if (!(bufferW
= msi_alloc( size
* sizeof(WCHAR
) )))
1849 r
= ERROR_OUTOFMEMORY
;
1853 r
= MsiGetPatchInfoW( patchW
, attrW
, bufferW
, &size
);
1854 if (r
== ERROR_SUCCESS
)
1856 int len
= WideCharToMultiByte( CP_ACP
, 0, bufferW
, -1, NULL
, 0, NULL
, NULL
);
1858 r
= ERROR_MORE_DATA
;
1860 WideCharToMultiByte( CP_ACP
, 0, bufferW
, -1, buffer
, *buflen
, NULL
, NULL
);
1868 msi_free( bufferW
);
1872 UINT WINAPI
MsiGetPatchInfoW( LPCWSTR patch
, LPCWSTR attr
, LPWSTR buffer
, LPDWORD buflen
)
1875 WCHAR product
[GUID_SIZE
];
1878 TRACE("%s %s %p %p\n", debugstr_w(patch
), debugstr_w(attr
), buffer
, buflen
);
1880 if (!patch
|| !attr
)
1881 return ERROR_INVALID_PARAMETER
;
1883 if (strcmpW( INSTALLPROPERTY_LOCALPACKAGEW
, attr
))
1884 return ERROR_UNKNOWN_PROPERTY
;
1889 r
= MsiEnumProductsW( index
, product
);
1890 if (r
!= ERROR_SUCCESS
)
1893 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, attr
, buffer
, buflen
);
1894 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1897 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, attr
, buffer
, buflen
);
1898 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1901 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_MACHINE
, attr
, buffer
, buflen
);
1902 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1908 return ERROR_UNKNOWN_PRODUCT
;
1911 UINT WINAPI
MsiEnableLogA(DWORD dwLogMode
, LPCSTR szLogFile
, DWORD attributes
)
1913 LPWSTR szwLogFile
= NULL
;
1916 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_a(szLogFile
), attributes
);
1920 szwLogFile
= strdupAtoW( szLogFile
);
1922 return ERROR_OUTOFMEMORY
;
1924 r
= MsiEnableLogW( dwLogMode
, szwLogFile
, attributes
);
1925 msi_free( szwLogFile
);
1929 UINT WINAPI
MsiEnableLogW(DWORD dwLogMode
, LPCWSTR szLogFile
, DWORD attributes
)
1931 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_w(szLogFile
), attributes
);
1933 msi_free(gszLogFile
);
1939 if (!(attributes
& INSTALLLOGATTRIBUTES_APPEND
))
1940 DeleteFileW(szLogFile
);
1941 file
= CreateFileW(szLogFile
, GENERIC_WRITE
, FILE_SHARE_WRITE
, NULL
, OPEN_ALWAYS
,
1942 FILE_ATTRIBUTE_NORMAL
, NULL
);
1943 if (file
!= INVALID_HANDLE_VALUE
)
1945 gszLogFile
= strdupW(szLogFile
);
1949 ERR("Unable to enable log %s (%u)\n", debugstr_w(szLogFile
), GetLastError());
1952 return ERROR_SUCCESS
;
1955 UINT WINAPI
MsiEnumComponentCostsA( MSIHANDLE handle
, LPCSTR component
, DWORD index
,
1956 INSTALLSTATE state
, LPSTR drive
, DWORD
*buflen
,
1957 int *cost
, int *temp
)
1961 WCHAR
*driveW
, *componentW
= NULL
;
1963 TRACE("%d, %s, %u, %d, %p, %p, %p %p\n", handle
, debugstr_a(component
), index
,
1964 state
, drive
, buflen
, cost
, temp
);
1966 if (!drive
|| !buflen
) return ERROR_INVALID_PARAMETER
;
1967 if (component
&& !(componentW
= strdupAtoW( component
))) return ERROR_OUTOFMEMORY
;
1970 if (!(driveW
= msi_alloc( len
* sizeof(WCHAR
) )))
1972 msi_free( componentW
);
1973 return ERROR_OUTOFMEMORY
;
1975 r
= MsiEnumComponentCostsW( handle
, componentW
, index
, state
, driveW
, buflen
, cost
, temp
);
1978 WideCharToMultiByte( CP_ACP
, 0, driveW
, -1, drive
, len
, NULL
, NULL
);
1980 msi_free( componentW
);
1985 static UINT
set_drive( WCHAR
*buffer
, WCHAR letter
)
1993 UINT WINAPI
MsiEnumComponentCostsW( MSIHANDLE handle
, LPCWSTR component
, DWORD index
,
1994 INSTALLSTATE state
, LPWSTR drive
, DWORD
*buflen
,
1995 int *cost
, int *temp
)
1997 UINT r
= ERROR_NO_MORE_ITEMS
;
1998 MSICOMPONENT
*comp
= NULL
;
1999 MSIPACKAGE
*package
;
2002 WCHAR path
[MAX_PATH
];
2004 TRACE("%d, %s, %u, %d, %p, %p, %p %p\n", handle
, debugstr_w(component
), index
,
2005 state
, drive
, buflen
, cost
, temp
);
2007 if (!drive
|| !buflen
|| !cost
|| !temp
) return ERROR_INVALID_PARAMETER
;
2008 if (!(package
= msihandle2msiinfo( handle
, MSIHANDLETYPE_PACKAGE
)))
2011 IWineMsiRemotePackage
*remote_package
;
2014 if (!(remote_package
= (IWineMsiRemotePackage
*)msi_get_remote( handle
)))
2015 return ERROR_INVALID_HANDLE
;
2017 if (component
&& !(bname
= SysAllocString( component
)))
2019 IWineMsiRemotePackage_Release( remote_package
);
2020 return ERROR_OUTOFMEMORY
;
2022 hr
= IWineMsiRemotePackage_EnumComponentCosts( remote_package
, bname
, index
, state
, drive
, buflen
, cost
, temp
);
2023 IWineMsiRemotePackage_Release( remote_package
);
2024 SysFreeString( bname
);
2027 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
) return HRESULT_CODE(hr
);
2028 return ERROR_FUNCTION_FAILED
;
2030 return ERROR_SUCCESS
;
2033 if (!msi_get_property_int( package
->db
, szCostingComplete
, 0 ))
2035 msiobj_release( &package
->hdr
);
2036 return ERROR_FUNCTION_NOT_CALLED
;
2038 if (component
&& component
[0] && !(comp
= msi_get_loaded_component( package
, component
)))
2040 msiobj_release( &package
->hdr
);
2041 return ERROR_UNKNOWN_COMPONENT
;
2046 msiobj_release( &package
->hdr
);
2047 return ERROR_MORE_DATA
;
2051 msiobj_release( &package
->hdr
);
2052 return ERROR_NO_MORE_ITEMS
;
2057 GetWindowsDirectoryW( path
, MAX_PATH
);
2058 if (component
&& component
[0])
2060 if (comp
->assembly
&& !comp
->assembly
->application
) *temp
= comp
->Cost
;
2061 if (!comp
->Enabled
|| !comp
->KeyPath
)
2064 *buflen
= set_drive( drive
, path
[0] );
2067 else if ((file
= msi_get_loaded_file( package
, comp
->KeyPath
)))
2069 *cost
= max( 8, comp
->Cost
/ 512 );
2070 *buflen
= set_drive( drive
, file
->TargetPath
[0] );
2074 else if (IStorage_Stat( package
->db
->storage
, &stat
, STATFLAG_NONAME
) == S_OK
)
2076 *temp
= max( 8, stat
.cbSize
.QuadPart
/ 512 );
2077 *buflen
= set_drive( drive
, path
[0] );
2080 msiobj_release( &package
->hdr
);
2084 UINT WINAPI
MsiQueryComponentStateA(LPCSTR szProductCode
,
2085 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
2086 LPCSTR szComponent
, INSTALLSTATE
*pdwState
)
2088 LPWSTR prodcode
= NULL
, usersid
= NULL
, comp
= NULL
;
2091 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode
),
2092 debugstr_a(szUserSid
), dwContext
, debugstr_a(szComponent
), pdwState
);
2094 if (szProductCode
&& !(prodcode
= strdupAtoW(szProductCode
)))
2095 return ERROR_OUTOFMEMORY
;
2097 if (szUserSid
&& !(usersid
= strdupAtoW(szUserSid
)))
2098 return ERROR_OUTOFMEMORY
;
2100 if (szComponent
&& !(comp
= strdupAtoW(szComponent
)))
2101 return ERROR_OUTOFMEMORY
;
2103 r
= MsiQueryComponentStateW(prodcode
, usersid
, dwContext
, comp
, pdwState
);
2112 static BOOL
msi_comp_find_prod_key(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
2117 r
= MSIREG_OpenProductKey(prodcode
, NULL
, context
, &hkey
, FALSE
);
2119 return (r
== ERROR_SUCCESS
);
2122 static BOOL
msi_comp_find_package(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
2130 static const WCHAR local_package
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
2131 static const WCHAR managed_local_package
[] = {
2132 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
2135 r
= MSIREG_OpenInstallProps(prodcode
, context
, NULL
, &hkey
, FALSE
);
2136 if (r
!= ERROR_SUCCESS
)
2139 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
2140 package
= managed_local_package
;
2142 package
= local_package
;
2145 res
= RegQueryValueExW(hkey
, package
, NULL
, NULL
, NULL
, &sz
);
2148 return (res
== ERROR_SUCCESS
);
2151 static BOOL
msi_comp_find_prodcode(LPWSTR squished_pc
,
2152 MSIINSTALLCONTEXT context
,
2153 LPCWSTR comp
, LPWSTR val
, DWORD
*sz
)
2159 if (context
== MSIINSTALLCONTEXT_MACHINE
)
2160 r
= MSIREG_OpenUserDataComponentKey(comp
, szLocalSid
, &hkey
, FALSE
);
2162 r
= MSIREG_OpenUserDataComponentKey(comp
, NULL
, &hkey
, FALSE
);
2164 if (r
!= ERROR_SUCCESS
)
2167 res
= RegQueryValueExW(hkey
, squished_pc
, NULL
, NULL
, (BYTE
*)val
, sz
);
2168 if (res
!= ERROR_SUCCESS
)
2175 UINT WINAPI
MsiQueryComponentStateW(LPCWSTR szProductCode
,
2176 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
2177 LPCWSTR szComponent
, INSTALLSTATE
*pdwState
)
2179 WCHAR squished_pc
[GUID_SIZE
];
2180 WCHAR val
[MAX_PATH
];
2184 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode
),
2185 debugstr_w(szUserSid
), dwContext
, debugstr_w(szComponent
), pdwState
);
2187 if (!pdwState
|| !szComponent
)
2188 return ERROR_INVALID_PARAMETER
;
2190 if (!szProductCode
|| !*szProductCode
|| lstrlenW(szProductCode
) != GUID_SIZE
- 1)
2191 return ERROR_INVALID_PARAMETER
;
2193 if (!squash_guid(szProductCode
, squished_pc
))
2194 return ERROR_INVALID_PARAMETER
;
2196 found
= msi_comp_find_prod_key(szProductCode
, dwContext
);
2198 if (!msi_comp_find_package(szProductCode
, dwContext
))
2202 *pdwState
= INSTALLSTATE_UNKNOWN
;
2203 return ERROR_UNKNOWN_COMPONENT
;
2206 return ERROR_UNKNOWN_PRODUCT
;
2209 *pdwState
= INSTALLSTATE_UNKNOWN
;
2212 if (!msi_comp_find_prodcode(squished_pc
, dwContext
, szComponent
, val
, &sz
))
2213 return ERROR_UNKNOWN_COMPONENT
;
2216 *pdwState
= INSTALLSTATE_NOTUSED
;
2219 if (lstrlenW(val
) > 2 &&
2220 val
[0] >= '0' && val
[0] <= '9' && val
[1] >= '0' && val
[1] <= '9')
2222 *pdwState
= INSTALLSTATE_SOURCE
;
2225 *pdwState
= INSTALLSTATE_LOCAL
;
2228 TRACE("-> %d\n", *pdwState
);
2229 return ERROR_SUCCESS
;
2232 INSTALLSTATE WINAPI
MsiQueryProductStateA(LPCSTR szProduct
)
2234 LPWSTR szwProduct
= NULL
;
2239 szwProduct
= strdupAtoW( szProduct
);
2241 return ERROR_OUTOFMEMORY
;
2243 r
= MsiQueryProductStateW( szwProduct
);
2244 msi_free( szwProduct
);
2248 INSTALLSTATE WINAPI
MsiQueryProductStateW(LPCWSTR szProduct
)
2250 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
2251 INSTALLSTATE state
= INSTALLSTATE_ADVERTISED
;
2252 HKEY prodkey
= 0, userdata
= 0;
2256 TRACE("%s\n", debugstr_w(szProduct
));
2258 if (!szProduct
|| !*szProduct
)
2259 return INSTALLSTATE_INVALIDARG
;
2261 if (lstrlenW(szProduct
) != GUID_SIZE
- 1)
2262 return INSTALLSTATE_INVALIDARG
;
2264 if (szProduct
[0] != '{' || szProduct
[37] != '}')
2265 return INSTALLSTATE_UNKNOWN
;
2267 SetLastError( ERROR_SUCCESS
);
2269 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2270 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
2271 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2272 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
2273 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
2274 &prodkey
, FALSE
) == ERROR_SUCCESS
)
2276 context
= MSIINSTALLCONTEXT_MACHINE
;
2279 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
2280 if (r
!= ERROR_SUCCESS
)
2283 if (!msi_reg_get_val_dword(userdata
, szWindowsInstaller
, &val
))
2287 state
= INSTALLSTATE_DEFAULT
;
2289 state
= INSTALLSTATE_UNKNOWN
;
2294 state
= INSTALLSTATE_UNKNOWN
;
2297 state
= INSTALLSTATE_ABSENT
;
2300 RegCloseKey(prodkey
);
2301 RegCloseKey(userdata
);
2302 TRACE("-> %d\n", state
);
2306 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
2308 INSTALLUILEVEL old
= gUILevel
;
2309 HWND oldwnd
= gUIhwnd
;
2311 TRACE("%08x %p\n", dwUILevel
, phWnd
);
2313 gUILevel
= dwUILevel
;
2322 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
2323 DWORD dwMessageFilter
, LPVOID pvContext
)
2325 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
2327 TRACE("%p %08x %p\n", puiHandler
, dwMessageFilter
, pvContext
);
2329 gUIHandlerA
= puiHandler
;
2331 gUIFilter
= dwMessageFilter
;
2332 gUIContext
= pvContext
;
2337 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
2338 DWORD dwMessageFilter
, LPVOID pvContext
)
2340 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
2342 TRACE("%p %08x %p\n", puiHandler
, dwMessageFilter
, pvContext
);
2345 gUIHandlerW
= puiHandler
;
2346 gUIFilter
= dwMessageFilter
;
2347 gUIContext
= pvContext
;
2352 /******************************************************************
2353 * MsiLoadStringW [MSI.@]
2355 * Loads a string from MSI's string resources.
2359 * handle [I] only -1 is handled currently
2360 * id [I] id of the string to be loaded
2361 * lpBuffer [O] buffer for the string to be written to
2362 * nBufferMax [I] maximum size of the buffer in characters
2363 * lang [I] the preferred language for the string
2367 * If successful, this function returns the language id of the string loaded
2368 * If the function fails, the function returns zero.
2372 * The type of the first parameter is unknown. LoadString's prototype
2373 * suggests that it might be a module handle. I have made it an MSI handle
2374 * for starters, as -1 is an invalid MSI handle, but not an invalid module
2375 * handle. Maybe strings can be stored in an MSI database somehow.
2377 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
2378 int nBufferMax
, LANGID lang
)
2385 TRACE("%d %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
2388 FIXME("don't know how to deal with handle = %08x\n", handle
);
2391 lang
= GetUserDefaultLangID();
2393 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
2397 hResData
= LoadResource( msi_hInstance
, hres
);
2400 p
= LockResource( hResData
);
2404 for (i
= 0; i
< (id
& 0xf); i
++) p
+= *p
+ 1;
2407 if( nBufferMax
<= len
)
2410 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
2411 lpBuffer
[ len
] = 0;
2413 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
2417 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
2418 int nBufferMax
, LANGID lang
)
2424 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
2425 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
2428 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
2429 if( len
<= nBufferMax
)
2430 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
2431 lpBuffer
, nBufferMax
, NULL
, NULL
);
2439 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
2442 char szProduct
[GUID_SIZE
];
2444 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
2446 if (!szComponent
|| !pcchBuf
)
2447 return INSTALLSTATE_INVALIDARG
;
2449 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
2450 return INSTALLSTATE_UNKNOWN
;
2452 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
2455 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
2458 WCHAR szProduct
[GUID_SIZE
];
2460 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
2462 if (!szComponent
|| !pcchBuf
)
2463 return INSTALLSTATE_INVALIDARG
;
2465 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
2466 return INSTALLSTATE_UNKNOWN
;
2468 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
2471 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
2472 WORD wLanguageId
, DWORD f
)
2474 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_a(lpText
), debugstr_a(lpCaption
),
2475 uType
, wLanguageId
, f
);
2476 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
2479 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
2480 WORD wLanguageId
, DWORD f
)
2482 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_w(lpText
), debugstr_w(lpCaption
),
2483 uType
, wLanguageId
, f
);
2484 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
2487 UINT WINAPI
MsiMessageBoxExA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
2488 DWORD unknown
, WORD wLanguageId
, DWORD f
)
2490 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd
, debugstr_a(lpText
),
2491 debugstr_a(lpCaption
), uType
, unknown
, wLanguageId
, f
);
2492 return MessageBoxExA(hWnd
, lpText
, lpCaption
, uType
, wLanguageId
);
2495 UINT WINAPI
MsiMessageBoxExW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
2496 DWORD unknown
, WORD wLanguageId
, DWORD f
)
2498 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd
, debugstr_w(lpText
),
2499 debugstr_w(lpCaption
), uType
, unknown
, wLanguageId
, f
);
2500 return MessageBoxExW(hWnd
, lpText
, lpCaption
, uType
, wLanguageId
);
2503 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
2504 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
2505 LPDWORD pcchPathBuf
)
2507 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName
),
2508 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2510 return ERROR_CALL_NOT_IMPLEMENTED
;
2513 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
2514 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
2515 LPDWORD pcchPathBuf
)
2517 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName
),
2518 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2520 return ERROR_CALL_NOT_IMPLEMENTED
;
2523 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
2524 LPSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2526 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2527 return ERROR_CALL_NOT_IMPLEMENTED
;
2530 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
2531 LPWSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2533 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2534 return ERROR_CALL_NOT_IMPLEMENTED
;
2537 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR path
, DWORD flags
, PCCERT_CONTEXT
*cert
,
2538 LPBYTE hash
, LPDWORD hashlen
)
2541 WCHAR
*pathW
= NULL
;
2543 TRACE("%s %08x %p %p %p\n", debugstr_a(path
), flags
, cert
, hash
, hashlen
);
2545 if (path
&& !(pathW
= strdupAtoW( path
))) return ERROR_OUTOFMEMORY
;
2546 r
= MsiGetFileSignatureInformationW( pathW
, flags
, cert
, hash
, hashlen
);
2551 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR path
, DWORD flags
, PCCERT_CONTEXT
*cert
,
2552 LPBYTE hash
, LPDWORD hashlen
)
2554 static GUID generic_verify_v2
= WINTRUST_ACTION_GENERIC_VERIFY_V2
;
2557 WINTRUST_FILE_INFO info
;
2558 CRYPT_PROVIDER_SGNR
*signer
;
2559 CRYPT_PROVIDER_CERT
*provider
;
2561 TRACE("%s %08x %p %p %p\n", debugstr_w(path
), flags
, cert
, hash
, hashlen
);
2563 if (!path
|| !cert
) return E_INVALIDARG
;
2565 info
.cbStruct
= sizeof(info
);
2566 info
.pcwszFilePath
= path
;
2568 info
.pgKnownSubject
= NULL
;
2570 data
.cbStruct
= sizeof(data
);
2571 data
.pPolicyCallbackData
= NULL
;
2572 data
.pSIPClientData
= NULL
;
2573 data
.dwUIChoice
= WTD_UI_NONE
;
2574 data
.fdwRevocationChecks
= WTD_REVOKE_WHOLECHAIN
;
2575 data
.dwUnionChoice
= WTD_CHOICE_FILE
;
2576 data
.u
.pFile
= &info
;
2577 data
.dwStateAction
= WTD_STATEACTION_VERIFY
;
2578 data
.hWVTStateData
= NULL
;
2579 data
.pwszURLReference
= NULL
;
2580 data
.dwProvFlags
= 0;
2581 data
.dwUIContext
= WTD_UICONTEXT_INSTALL
;
2582 hr
= WinVerifyTrustEx( INVALID_HANDLE_VALUE
, &generic_verify_v2
, &data
);
2584 if (FAILED(hr
)) goto done
;
2586 if (!(signer
= WTHelperGetProvSignerFromChain( data
.hWVTStateData
, 0, FALSE
, 0 )))
2588 hr
= TRUST_E_NOSIGNATURE
;
2593 DWORD len
= signer
->psSigner
->EncryptedHash
.cbData
;
2597 hr
= HRESULT_FROM_WIN32(ERROR_MORE_DATA
);
2600 memcpy( hash
, signer
->psSigner
->EncryptedHash
.pbData
, len
);
2603 if (!(provider
= WTHelperGetProvCertFromChain( signer
, 0 )))
2605 hr
= TRUST_E_PROVIDER_UNKNOWN
;
2608 *cert
= CertDuplicateCertificateContext( provider
->pCert
);
2611 data
.dwStateAction
= WTD_STATEACTION_CLOSE
;
2612 WinVerifyTrustEx( INVALID_HANDLE_VALUE
, &generic_verify_v2
, &data
);
2616 /******************************************************************
2617 * MsiGetProductPropertyA [MSI.@]
2619 UINT WINAPI
MsiGetProductPropertyA(MSIHANDLE hProduct
, LPCSTR szProperty
,
2620 LPSTR szValue
, LPDWORD pccbValue
)
2622 LPWSTR prop
= NULL
, val
= NULL
;
2626 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_a(szProperty
),
2627 szValue
, pccbValue
);
2629 if (szValue
&& !pccbValue
)
2630 return ERROR_INVALID_PARAMETER
;
2632 if (szProperty
) prop
= strdupAtoW(szProperty
);
2635 r
= MsiGetProductPropertyW(hProduct
, prop
, NULL
, &len
);
2636 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2639 if (r
== ERROR_SUCCESS
)
2641 if (szValue
) *szValue
= '\0';
2642 if (pccbValue
) *pccbValue
= 0;
2646 val
= msi_alloc(++len
* sizeof(WCHAR
));
2649 r
= ERROR_OUTOFMEMORY
;
2653 r
= MsiGetProductPropertyW(hProduct
, prop
, val
, &len
);
2654 if (r
!= ERROR_SUCCESS
)
2657 len
= WideCharToMultiByte(CP_ACP
, 0, val
, -1, NULL
, 0, NULL
, NULL
);
2660 WideCharToMultiByte(CP_ACP
, 0, val
, -1, szValue
,
2661 *pccbValue
, NULL
, NULL
);
2665 if (len
> *pccbValue
)
2666 r
= ERROR_MORE_DATA
;
2668 *pccbValue
= len
- 1;
2678 /******************************************************************
2679 * MsiGetProductPropertyW [MSI.@]
2681 UINT WINAPI
MsiGetProductPropertyW(MSIHANDLE hProduct
, LPCWSTR szProperty
,
2682 LPWSTR szValue
, LPDWORD pccbValue
)
2684 MSIPACKAGE
*package
;
2685 MSIQUERY
*view
= NULL
;
2686 MSIRECORD
*rec
= NULL
;
2690 static const WCHAR query
[] = {
2691 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2692 '`','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2693 '`','P','r','o','p','e','r','t','y','`','=','\'','%','s','\'',0};
2695 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_w(szProperty
),
2696 szValue
, pccbValue
);
2699 return ERROR_INVALID_PARAMETER
;
2701 if (szValue
&& !pccbValue
)
2702 return ERROR_INVALID_PARAMETER
;
2704 package
= msihandle2msiinfo(hProduct
, MSIHANDLETYPE_PACKAGE
);
2706 return ERROR_INVALID_HANDLE
;
2708 r
= MSI_OpenQuery(package
->db
, &view
, query
, szProperty
);
2709 if (r
!= ERROR_SUCCESS
)
2712 r
= MSI_ViewExecute(view
, 0);
2713 if (r
!= ERROR_SUCCESS
)
2716 r
= MSI_ViewFetch(view
, &rec
);
2717 if (r
!= ERROR_SUCCESS
)
2720 val
= MSI_RecordGetString(rec
, 2);
2724 if (lstrlenW(val
) >= *pccbValue
)
2726 lstrcpynW(szValue
, val
, *pccbValue
);
2727 *pccbValue
= lstrlenW(val
);
2728 r
= ERROR_MORE_DATA
;
2732 lstrcpyW(szValue
, val
);
2733 *pccbValue
= lstrlenW(val
);
2740 MSI_ViewClose(view
);
2741 msiobj_release(&view
->hdr
);
2742 if (rec
) msiobj_release(&rec
->hdr
);
2747 if (szValue
) *szValue
= '\0';
2748 if (pccbValue
) *pccbValue
= 0;
2752 msiobj_release(&package
->hdr
);
2756 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
2759 LPWSTR szPack
= NULL
;
2761 TRACE("%s\n", debugstr_a(szPackage
) );
2765 szPack
= strdupAtoW( szPackage
);
2767 return ERROR_OUTOFMEMORY
;
2770 r
= MsiVerifyPackageW( szPack
);
2777 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
2782 TRACE("%s\n", debugstr_w(szPackage
) );
2784 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
2785 MsiCloseHandle( handle
);
2790 static INSTALLSTATE
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
2791 awstring
* lpPathBuf
, LPDWORD pcchBuf
)
2793 static const WCHAR wininstaller
[] =
2794 {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
2795 WCHAR squished_pc
[GUID_SIZE
];
2796 WCHAR squished_comp
[GUID_SIZE
];
2802 if (!szProduct
|| !szComponent
)
2803 return INSTALLSTATE_INVALIDARG
;
2805 if (lpPathBuf
->str
.w
&& !pcchBuf
)
2806 return INSTALLSTATE_INVALIDARG
;
2808 if (!squash_guid(szProduct
, squished_pc
) ||
2809 !squash_guid(szComponent
, squished_comp
))
2810 return INSTALLSTATE_INVALIDARG
;
2812 state
= INSTALLSTATE_UNKNOWN
;
2814 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2815 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2817 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2820 state
= INSTALLSTATE_ABSENT
;
2822 if ((MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
, NULL
,
2823 &hkey
, FALSE
) == ERROR_SUCCESS
||
2824 MSIREG_OpenUserDataProductKey(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2825 NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
) &&
2826 msi_reg_get_val_dword(hkey
, wininstaller
, &version
) &&
2827 GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2830 state
= INSTALLSTATE_LOCAL
;
2834 if (state
!= INSTALLSTATE_LOCAL
&&
2835 (MSIREG_OpenProductKey(szProduct
, NULL
,
2836 MSIINSTALLCONTEXT_USERUNMANAGED
,
2837 &hkey
, FALSE
) == ERROR_SUCCESS
||
2838 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
2839 &hkey
, FALSE
) == ERROR_SUCCESS
))
2843 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2844 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2847 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2850 state
= INSTALLSTATE_ABSENT
;
2852 if (GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2853 state
= INSTALLSTATE_LOCAL
;
2858 return INSTALLSTATE_UNKNOWN
;
2860 if (state
== INSTALLSTATE_LOCAL
&& !*path
)
2861 state
= INSTALLSTATE_NOTUSED
;
2863 msi_strcpy_to_awstring(path
, lpPathBuf
, pcchBuf
);
2868 /******************************************************************
2869 * MsiGetComponentPathW [MSI.@]
2871 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
2872 LPWSTR lpPathBuf
, LPDWORD pcchBuf
)
2876 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
2878 path
.unicode
= TRUE
;
2879 path
.str
.w
= lpPathBuf
;
2881 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
2884 /******************************************************************
2885 * MsiGetComponentPathA [MSI.@]
2887 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
2888 LPSTR lpPathBuf
, LPDWORD pcchBuf
)
2890 LPWSTR szwProduct
, szwComponent
= NULL
;
2891 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
2894 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
2896 szwProduct
= strdupAtoW( szProduct
);
2897 if( szProduct
&& !szwProduct
)
2900 szwComponent
= strdupAtoW( szComponent
);
2901 if( szComponent
&& !szwComponent
)
2904 path
.unicode
= FALSE
;
2905 path
.str
.a
= lpPathBuf
;
2907 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
2910 msi_free( szwProduct
);
2911 msi_free( szwComponent
);
2916 /******************************************************************
2917 * MsiQueryFeatureStateA [MSI.@]
2919 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
2921 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
2922 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
2924 szwProduct
= strdupAtoW( szProduct
);
2925 if ( szProduct
&& !szwProduct
)
2928 szwFeature
= strdupAtoW( szFeature
);
2929 if ( szFeature
&& !szwFeature
)
2932 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
2935 msi_free( szwProduct
);
2936 msi_free( szwFeature
);
2941 /******************************************************************
2942 * MsiQueryFeatureStateW [MSI.@]
2944 * Checks the state of a feature
2947 * szProduct [I] Product's GUID string
2948 * szFeature [I] Feature's GUID string
2951 * INSTALLSTATE_LOCAL Feature is installed and usable
2952 * INSTALLSTATE_ABSENT Feature is absent
2953 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
2954 * INSTALLSTATE_UNKNOWN An error occurred
2955 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
2958 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
2960 WCHAR squishProduct
[33], comp
[GUID_SIZE
];
2962 LPWSTR components
, p
, parent_feature
, path
;
2966 BOOL missing
= FALSE
;
2967 BOOL machine
= FALSE
;
2968 BOOL source
= FALSE
;
2970 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
2972 if (!szProduct
|| !szFeature
)
2973 return INSTALLSTATE_INVALIDARG
;
2975 if (!squash_guid( szProduct
, squishProduct
))
2976 return INSTALLSTATE_INVALIDARG
;
2978 SetLastError( ERROR_SUCCESS
);
2980 if (MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_USERMANAGED
,
2981 &hkey
, FALSE
) != ERROR_SUCCESS
&&
2982 MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2983 &hkey
, FALSE
) != ERROR_SUCCESS
)
2985 rc
= MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
2987 if (rc
!= ERROR_SUCCESS
)
2988 return INSTALLSTATE_UNKNOWN
;
2993 parent_feature
= msi_reg_get_val_str( hkey
, szFeature
);
2996 if (!parent_feature
)
2997 return INSTALLSTATE_UNKNOWN
;
2999 r
= (parent_feature
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
3000 msi_free(parent_feature
);
3001 if (r
== INSTALLSTATE_ABSENT
)
3005 rc
= MSIREG_OpenUserDataFeaturesKey(szProduct
,
3006 MSIINSTALLCONTEXT_MACHINE
,
3009 rc
= MSIREG_OpenUserDataFeaturesKey(szProduct
,
3010 MSIINSTALLCONTEXT_USERUNMANAGED
,
3013 if (rc
!= ERROR_SUCCESS
)
3014 return INSTALLSTATE_ADVERTISED
;
3016 components
= msi_reg_get_val_str( hkey
, szFeature
);
3019 TRACE("rc = %d buffer = %s\n", rc
, debugstr_w(components
));
3022 return INSTALLSTATE_ADVERTISED
;
3024 for( p
= components
; *p
&& *p
!= 2 ; p
+= 20)
3026 if (!decode_base85_guid( p
, &guid
))
3028 if (p
!= components
)
3031 msi_free(components
);
3032 return INSTALLSTATE_BADCONFIG
;
3035 StringFromGUID2(&guid
, comp
, GUID_SIZE
);
3038 rc
= MSIREG_OpenUserDataComponentKey(comp
, szLocalSid
, &hkey
, FALSE
);
3040 rc
= MSIREG_OpenUserDataComponentKey(comp
, NULL
, &hkey
, FALSE
);
3042 if (rc
!= ERROR_SUCCESS
)
3044 msi_free(components
);
3045 return INSTALLSTATE_ADVERTISED
;
3048 path
= msi_reg_get_val_str(hkey
, squishProduct
);
3051 else if (lstrlenW(path
) > 2 &&
3052 path
[0] >= '0' && path
[0] <= '9' &&
3053 path
[1] >= '0' && path
[1] <= '9')
3060 msi_free(components
);
3063 r
= INSTALLSTATE_ADVERTISED
;
3065 r
= INSTALLSTATE_SOURCE
;
3067 r
= INSTALLSTATE_LOCAL
;
3069 TRACE("-> %d\n", r
);
3073 /******************************************************************
3074 * MsiGetFileVersionA [MSI.@]
3076 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
3077 LPDWORD pcchVersionBuf
, LPSTR lpLangBuf
, LPDWORD pcchLangBuf
)
3079 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
3080 UINT ret
= ERROR_OUTOFMEMORY
;
3082 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
3083 (lpLangBuf
&& !pcchLangBuf
))
3084 return ERROR_INVALID_PARAMETER
;
3088 szwFilePath
= strdupAtoW( szFilePath
);
3093 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
3095 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
3096 if( !lpwVersionBuff
)
3100 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
3102 lpwLangBuff
= msi_alloc(*pcchLangBuf
*sizeof(WCHAR
));
3107 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
3108 lpwLangBuff
, pcchLangBuf
);
3110 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwVersionBuff
)
3111 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
3112 lpVersionBuf
, *pcchVersionBuf
+ 1, NULL
, NULL
);
3113 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwLangBuff
)
3114 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
3115 lpLangBuf
, *pcchLangBuf
+ 1, NULL
, NULL
);
3118 msi_free(szwFilePath
);
3119 msi_free(lpwVersionBuff
);
3120 msi_free(lpwLangBuff
);
3125 static UINT
get_file_version( const WCHAR
*path
, WCHAR
*verbuf
, DWORD
*verlen
,
3126 WCHAR
*langbuf
, DWORD
*langlen
)
3128 static const WCHAR szVersionResource
[] = {'\\',0};
3129 static const WCHAR szVersionFormat
[] = {
3130 '%','d','.','%','d','.','%','d','.','%','d',0};
3131 static const WCHAR szLangResource
[] = {
3132 '\\','V','a','r','F','i','l','e','I','n','f','o','\\',
3133 'T','r','a','n','s','l','a','t','i','o','n',0};
3134 static const WCHAR szLangFormat
[] = {'%','d',0};
3135 UINT ret
= ERROR_SUCCESS
;
3138 VS_FIXEDFILEINFO
*ffi
;
3142 if (!(len
= GetFileVersionInfoSizeW( path
, NULL
)))
3144 error
= GetLastError();
3145 if (error
== ERROR_BAD_PATHNAME
) return ERROR_FILE_NOT_FOUND
;
3148 if (!(version
= msi_alloc( len
))) return ERROR_OUTOFMEMORY
;
3149 if (!GetFileVersionInfoW( path
, 0, len
, version
))
3151 msi_free( version
);
3152 return GetLastError();
3156 if (VerQueryValueW( version
, szVersionResource
, (LPVOID
*)&ffi
, &len
) && len
> 0)
3158 sprintfW( tmp
, szVersionFormat
,
3159 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
3160 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
) );
3161 if (verbuf
) lstrcpynW( verbuf
, tmp
, *verlen
);
3162 len
= strlenW( tmp
);
3163 if (len
>= *verlen
) ret
= ERROR_MORE_DATA
;
3168 if (verbuf
) *verbuf
= 0;
3174 if (VerQueryValueW( version
, szLangResource
, (LPVOID
*)&lang
, &len
) && len
> 0)
3176 sprintfW( tmp
, szLangFormat
, *lang
);
3177 if (langbuf
) lstrcpynW( langbuf
, tmp
, *langlen
);
3178 len
= strlenW( tmp
);
3179 if (len
>= *langlen
) ret
= ERROR_MORE_DATA
;
3184 if (langbuf
) *langbuf
= 0;
3188 msi_free( version
);
3193 /******************************************************************
3194 * MsiGetFileVersionW [MSI.@]
3196 UINT WINAPI
MsiGetFileVersionW( LPCWSTR path
, LPWSTR verbuf
, LPDWORD verlen
,
3197 LPWSTR langbuf
, LPDWORD langlen
)
3201 TRACE("%s %p %u %p %u\n", debugstr_w(path
), verbuf
, verlen
? *verlen
: 0,
3202 langbuf
, langlen
? *langlen
: 0);
3204 if ((verbuf
&& !verlen
) || (langbuf
&& !langlen
))
3205 return ERROR_INVALID_PARAMETER
;
3207 ret
= get_file_version( path
, verbuf
, verlen
, langbuf
, langlen
);
3208 if (ret
== ERROR_RESOURCE_DATA_NOT_FOUND
&& verlen
)
3211 WCHAR
*version
= msi_font_version_from_file( path
);
3212 if (!version
) return ERROR_FILE_INVALID
;
3213 len
= strlenW( version
);
3214 if (len
>= *verlen
) ret
= ERROR_MORE_DATA
;
3217 strcpyW( verbuf
, version
);
3218 ret
= ERROR_SUCCESS
;
3221 msi_free( version
);
3226 /***********************************************************************
3227 * MsiGetFeatureUsageW [MSI.@]
3229 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3230 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
3232 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
3233 pdwUseCount
, pwDateUsed
);
3234 return ERROR_CALL_NOT_IMPLEMENTED
;
3237 /***********************************************************************
3238 * MsiGetFeatureUsageA [MSI.@]
3240 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
3241 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
3243 LPWSTR prod
= NULL
, feat
= NULL
;
3244 UINT ret
= ERROR_OUTOFMEMORY
;
3246 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3247 pdwUseCount
, pwDateUsed
);
3249 prod
= strdupAtoW( szProduct
);
3250 if (szProduct
&& !prod
)
3253 feat
= strdupAtoW( szFeature
);
3254 if (szFeature
&& !feat
)
3257 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
3266 /***********************************************************************
3267 * MsiUseFeatureExW [MSI.@]
3269 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3270 DWORD dwInstallMode
, DWORD dwReserved
)
3274 TRACE("%s %s %i %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
3275 dwInstallMode
, dwReserved
);
3277 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
3280 return INSTALLSTATE_INVALIDARG
;
3282 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
3284 FIXME("mark product %s feature %s as used\n",
3285 debugstr_w(szProduct
), debugstr_w(szFeature
) );
3291 /***********************************************************************
3292 * MsiUseFeatureExA [MSI.@]
3294 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
3295 DWORD dwInstallMode
, DWORD dwReserved
)
3297 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
3298 LPWSTR prod
= NULL
, feat
= NULL
;
3300 TRACE("%s %s %i %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3301 dwInstallMode
, dwReserved
);
3303 prod
= strdupAtoW( szProduct
);
3304 if (szProduct
&& !prod
)
3307 feat
= strdupAtoW( szFeature
);
3308 if (szFeature
&& !feat
)
3311 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
3320 /***********************************************************************
3321 * MsiUseFeatureW [MSI.@]
3323 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
3325 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
3328 /***********************************************************************
3329 * MsiUseFeatureA [MSI.@]
3331 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
3333 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
3336 /***********************************************************************
3337 * MSI_ProvideQualifiedComponentEx [internal]
3339 static UINT
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
3340 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
3341 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
3342 LPDWORD pcchPathBuf
)
3344 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
3345 feature
[MAX_FEATURE_CHARS
+1];
3351 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
3352 if (rc
!= ERROR_SUCCESS
)
3353 return ERROR_INDEX_ABSENT
;
3355 info
= msi_reg_get_val_str( hkey
, szQualifier
);
3359 return ERROR_INDEX_ABSENT
;
3361 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
3364 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
3366 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
3370 if (rc
!= INSTALLSTATE_LOCAL
)
3371 return ERROR_FILE_NOT_FOUND
;
3373 return ERROR_SUCCESS
;
3376 /***********************************************************************
3377 * MsiProvideQualifiedComponentExW [MSI.@]
3379 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
3380 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
3381 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
3382 LPDWORD pcchPathBuf
)
3386 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_w(szComponent
),
3387 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
3388 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
3390 path
.unicode
= TRUE
;
3391 path
.str
.w
= lpPathBuf
;
3393 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
3394 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
3397 /***********************************************************************
3398 * MsiProvideQualifiedComponentExA [MSI.@]
3400 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
3401 LPCSTR szQualifier
, DWORD dwInstallMode
, LPCSTR szProduct
,
3402 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
3403 LPDWORD pcchPathBuf
)
3405 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
3406 UINT r
= ERROR_OUTOFMEMORY
;
3409 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent
),
3410 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
3411 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
3413 szwComponent
= strdupAtoW( szComponent
);
3414 if (szComponent
&& !szwComponent
)
3417 szwQualifier
= strdupAtoW( szQualifier
);
3418 if (szQualifier
&& !szwQualifier
)
3421 szwProduct
= strdupAtoW( szProduct
);
3422 if (szProduct
&& !szwProduct
)
3425 path
.unicode
= FALSE
;
3426 path
.str
.a
= lpPathBuf
;
3428 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
3429 dwInstallMode
, szwProduct
, Unused1
,
3430 Unused2
, &path
, pcchPathBuf
);
3432 msi_free(szwProduct
);
3433 msi_free(szwComponent
);
3434 msi_free(szwQualifier
);
3439 /***********************************************************************
3440 * MsiProvideQualifiedComponentW [MSI.@]
3442 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
3443 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
3444 LPDWORD pcchPathBuf
)
3446 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
3447 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3450 /***********************************************************************
3451 * MsiProvideQualifiedComponentA [MSI.@]
3453 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
3454 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
3455 LPDWORD pcchPathBuf
)
3457 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
3458 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3461 /***********************************************************************
3462 * MSI_GetUserInfo [internal]
3464 static USERINFOSTATE
MSI_GetUserInfo(LPCWSTR szProduct
,
3465 awstring
*lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3466 awstring
*lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3467 awstring
*lpSerialBuf
, LPDWORD pcchSerialBuf
)
3469 WCHAR squished_pc
[SQUISH_GUID_SIZE
];
3470 LPWSTR user
, org
, serial
;
3471 USERINFOSTATE state
;
3476 TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct
), lpUserNameBuf
,
3477 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
3480 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
3481 return USERINFOSTATE_INVALIDARG
;
3483 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
3484 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3485 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3486 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3487 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
3488 &hkey
, FALSE
) != ERROR_SUCCESS
)
3490 return USERINFOSTATE_UNKNOWN
;
3493 if (MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3494 NULL
, &props
, FALSE
) != ERROR_SUCCESS
&&
3495 MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
3496 NULL
, &props
, FALSE
) != ERROR_SUCCESS
)
3499 return USERINFOSTATE_ABSENT
;
3502 user
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGOWNERW
);
3503 org
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGCOMPANYW
);
3504 serial
= msi_reg_get_val_str(props
, INSTALLPROPERTY_PRODUCTIDW
);
3505 state
= USERINFOSTATE_ABSENT
;
3511 state
= USERINFOSTATE_PRESENT
;
3513 if (pcchUserNameBuf
)
3515 if (lpUserNameBuf
&& !user
)
3517 (*pcchUserNameBuf
)--;
3521 r
= msi_strcpy_to_awstring(user
, lpUserNameBuf
, pcchUserNameBuf
);
3522 if (r
== ERROR_MORE_DATA
)
3524 state
= USERINFOSTATE_MOREDATA
;
3532 if (!orgptr
) orgptr
= szEmpty
;
3534 r
= msi_strcpy_to_awstring(orgptr
, lpOrgNameBuf
, pcchOrgNameBuf
);
3535 if (r
== ERROR_MORE_DATA
)
3537 state
= USERINFOSTATE_MOREDATA
;
3550 r
= msi_strcpy_to_awstring(serial
, lpSerialBuf
, pcchSerialBuf
);
3551 if (r
== ERROR_MORE_DATA
)
3552 state
= USERINFOSTATE_MOREDATA
;
3563 /***********************************************************************
3564 * MsiGetUserInfoW [MSI.@]
3566 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
3567 LPWSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3568 LPWSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3569 LPWSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3571 awstring user
, org
, serial
;
3573 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3574 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3575 (lpSerialBuf
&& !pcchSerialBuf
))
3576 return USERINFOSTATE_INVALIDARG
;
3578 user
.unicode
= TRUE
;
3579 user
.str
.w
= lpUserNameBuf
;
3581 org
.str
.w
= lpOrgNameBuf
;
3582 serial
.unicode
= TRUE
;
3583 serial
.str
.w
= lpSerialBuf
;
3585 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
3586 &org
, pcchOrgNameBuf
,
3587 &serial
, pcchSerialBuf
);
3590 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
3591 LPSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3592 LPSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3593 LPSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3595 awstring user
, org
, serial
;
3599 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3600 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3601 (lpSerialBuf
&& !pcchSerialBuf
))
3602 return USERINFOSTATE_INVALIDARG
;
3604 prod
= strdupAtoW( szProduct
);
3605 if (szProduct
&& !prod
)
3606 return ERROR_OUTOFMEMORY
;
3608 user
.unicode
= FALSE
;
3609 user
.str
.a
= lpUserNameBuf
;
3610 org
.unicode
= FALSE
;
3611 org
.str
.a
= lpOrgNameBuf
;
3612 serial
.unicode
= FALSE
;
3613 serial
.str
.a
= lpSerialBuf
;
3615 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
3616 &org
, pcchOrgNameBuf
,
3617 &serial
, pcchSerialBuf
);
3624 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
3628 MSIPACKAGE
*package
;
3629 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3631 TRACE("(%s)\n",debugstr_w(szProduct
));
3633 rc
= MsiOpenProductW(szProduct
,&handle
);
3634 if (rc
!= ERROR_SUCCESS
)
3635 return ERROR_INVALID_PARAMETER
;
3637 /* MsiCollectUserInfo cannot be called from a custom action. */
3638 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3640 return ERROR_CALL_NOT_IMPLEMENTED
;
3642 rc
= ACTION_PerformUIAction(package
, szFirstRun
, SCRIPT_NONE
);
3643 msiobj_release( &package
->hdr
);
3645 MsiCloseHandle(handle
);
3650 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
3654 MSIPACKAGE
*package
;
3655 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3657 TRACE("(%s)\n",debugstr_a(szProduct
));
3659 rc
= MsiOpenProductA(szProduct
,&handle
);
3660 if (rc
!= ERROR_SUCCESS
)
3661 return ERROR_INVALID_PARAMETER
;
3663 /* MsiCollectUserInfo cannot be called from a custom action. */
3664 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3666 return ERROR_CALL_NOT_IMPLEMENTED
;
3668 rc
= ACTION_PerformUIAction(package
, szFirstRun
, SCRIPT_NONE
);
3669 msiobj_release( &package
->hdr
);
3671 MsiCloseHandle(handle
);
3676 /***********************************************************************
3677 * MsiConfigureFeatureA [MSI.@]
3679 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
3681 LPWSTR prod
, feat
= NULL
;
3682 UINT r
= ERROR_OUTOFMEMORY
;
3684 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
3686 prod
= strdupAtoW( szProduct
);
3687 if (szProduct
&& !prod
)
3690 feat
= strdupAtoW( szFeature
);
3691 if (szFeature
&& !feat
)
3694 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
3703 /***********************************************************************
3704 * MsiConfigureFeatureW [MSI.@]
3706 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
3708 MSIPACKAGE
*package
= NULL
;
3710 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
3713 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
3715 if (!szProduct
|| !szFeature
)
3716 return ERROR_INVALID_PARAMETER
;
3718 switch (eInstallState
)
3720 case INSTALLSTATE_DEFAULT
:
3721 /* FIXME: how do we figure out the default location? */
3722 eInstallState
= INSTALLSTATE_LOCAL
;
3724 case INSTALLSTATE_LOCAL
:
3725 case INSTALLSTATE_SOURCE
:
3726 case INSTALLSTATE_ABSENT
:
3727 case INSTALLSTATE_ADVERTISED
:
3730 return ERROR_INVALID_PARAMETER
;
3733 r
= MSI_OpenProductW( szProduct
, &package
);
3734 if (r
!= ERROR_SUCCESS
)
3737 sz
= sizeof(sourcepath
);
3738 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3739 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3741 sz
= sizeof(filename
);
3742 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3743 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3745 lstrcatW( sourcepath
, filename
);
3747 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
3749 r
= ACTION_PerformUIAction( package
, szCostInitialize
, SCRIPT_NONE
);
3750 if (r
!= ERROR_SUCCESS
)
3753 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
3754 if (r
!= ERROR_SUCCESS
)
3757 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
3760 msiobj_release( &package
->hdr
);
3765 /***********************************************************************
3766 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
3768 * Notes: undocumented
3770 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
3772 WCHAR path
[MAX_PATH
];
3774 TRACE("%d\n", dwReserved
);
3778 FIXME("dwReserved=%d\n", dwReserved
);
3779 return ERROR_INVALID_PARAMETER
;
3782 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
3783 return ERROR_FUNCTION_FAILED
;
3785 lstrcatW(path
, installerW
);
3787 if (!CreateDirectoryW(path
, NULL
))
3788 return ERROR_FUNCTION_FAILED
;
3790 return ERROR_SUCCESS
;
3793 /***********************************************************************
3794 * MsiGetShortcutTargetA [MSI.@]
3796 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
3797 LPSTR szProductCode
, LPSTR szFeatureId
,
3798 LPSTR szComponentCode
)
3801 const int len
= MAX_FEATURE_CHARS
+1;
3802 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
3805 target
= strdupAtoW( szShortcutTarget
);
3806 if (szShortcutTarget
&& !target
)
3807 return ERROR_OUTOFMEMORY
;
3811 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
3813 if (r
== ERROR_SUCCESS
)
3815 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
3816 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
3817 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
3822 /***********************************************************************
3823 * MsiGetShortcutTargetW [MSI.@]
3825 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
3826 LPWSTR szProductCode
, LPWSTR szFeatureId
,
3827 LPWSTR szComponentCode
)
3829 IShellLinkDataList
*dl
= NULL
;
3830 IPersistFile
*pf
= NULL
;
3831 LPEXP_DARWIN_LINK darwin
= NULL
;
3834 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
3835 szProductCode
, szFeatureId
, szComponentCode
);
3837 init
= CoInitialize(NULL
);
3839 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
3840 &IID_IPersistFile
, (LPVOID
*) &pf
);
3841 if( SUCCEEDED( r
) )
3843 r
= IPersistFile_Load( pf
, szShortcutTarget
,
3844 STGM_READ
| STGM_SHARE_DENY_WRITE
);
3845 if( SUCCEEDED( r
) )
3847 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
3849 if( SUCCEEDED( r
) )
3851 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
3853 IShellLinkDataList_Release( dl
);
3856 IPersistFile_Release( pf
);
3859 if (SUCCEEDED(init
))
3862 TRACE("darwin = %p\n", darwin
);
3869 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
3870 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
3871 LocalFree( darwin
);
3875 return ERROR_FUNCTION_FAILED
;
3878 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
, DWORD dwReinstallMode
)
3880 static const WCHAR fmtW
[] = {'%','s','=','%','s',' ','%','s','=','%','s',0};
3881 MSIPACKAGE
*package
;
3882 MSIINSTALLCONTEXT context
;
3884 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
], reinstallmode
[11];
3885 WCHAR
*ptr
, *cmdline
;
3888 TRACE("%s, %s, 0x%08x\n", debugstr_w(szProduct
), debugstr_w(szFeature
), dwReinstallMode
);
3890 r
= msi_locate_product( szProduct
, &context
);
3891 if (r
!= ERROR_SUCCESS
)
3894 ptr
= reinstallmode
;
3896 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
3898 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
3900 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
3902 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
3904 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
3906 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
3908 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
3910 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
3912 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
3914 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3918 sz
= sizeof(sourcepath
);
3919 MsiSourceListGetInfoW( szProduct
, NULL
, context
, MSICODE_PRODUCT
,
3920 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3921 sz
= sizeof(filename
);
3922 MsiSourceListGetInfoW( szProduct
, NULL
, context
, MSICODE_PRODUCT
,
3923 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3924 strcatW( sourcepath
, filename
);
3926 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3927 r
= MSI_OpenPackageW( sourcepath
, &package
);
3929 r
= MSI_OpenProductW( szProduct
, &package
);
3931 if (r
!= ERROR_SUCCESS
)
3934 sz
= (strlenW( fmtW
) + strlenW( szReinstallMode
) + strlenW( reinstallmode
)) * sizeof(WCHAR
);
3935 sz
+= (strlenW( szReinstall
) + strlenW( szFeature
)) * sizeof(WCHAR
);
3936 if (!(cmdline
= msi_alloc( sz
)))
3938 msiobj_release( &package
->hdr
);
3939 return ERROR_OUTOFMEMORY
;
3941 sprintfW( cmdline
, fmtW
, szReinstallMode
, reinstallmode
, szReinstall
, szFeature
);
3943 r
= MSI_InstallPackage( package
, sourcepath
, cmdline
);
3944 msiobj_release( &package
->hdr
);
3945 msi_free( cmdline
);
3950 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
3951 DWORD dwReinstallMode
)
3957 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3960 wszProduct
= strdupAtoW(szProduct
);
3961 wszFeature
= strdupAtoW(szFeature
);
3963 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
3965 msi_free(wszProduct
);
3966 msi_free(wszFeature
);
3973 unsigned int buf
[4];
3974 unsigned char in
[64];
3975 unsigned char digest
[16];
3978 extern VOID WINAPI
MD5Init( MD5_CTX
*);
3979 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
3980 extern VOID WINAPI
MD5Final( MD5_CTX
*);
3982 /***********************************************************************
3983 * MsiGetFileHashW [MSI.@]
3985 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
3986 PMSIFILEHASHINFO pHash
)
3988 HANDLE handle
, mapping
;
3991 UINT r
= ERROR_FUNCTION_FAILED
;
3993 TRACE("%s %08x %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
3996 return ERROR_INVALID_PARAMETER
;
3999 return ERROR_PATH_NOT_FOUND
;
4002 return ERROR_INVALID_PARAMETER
;
4004 return ERROR_INVALID_PARAMETER
;
4005 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
4006 return ERROR_INVALID_PARAMETER
;
4008 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
4009 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
4010 if (handle
== INVALID_HANDLE_VALUE
)
4012 WARN("can't open file %u\n", GetLastError());
4013 return ERROR_FILE_NOT_FOUND
;
4015 length
= GetFileSize( handle
, NULL
);
4019 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
4022 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
4028 MD5Update( &ctx
, p
, length
);
4030 UnmapViewOfFile( p
);
4032 memcpy( pHash
->dwData
, ctx
.digest
, sizeof pHash
->dwData
);
4035 CloseHandle( mapping
);
4040 /* Empty file -> set hash to 0 */
4041 memset( pHash
->dwData
, 0, sizeof pHash
->dwData
);
4045 CloseHandle( handle
);
4050 /***********************************************************************
4051 * MsiGetFileHashA [MSI.@]
4053 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
4054 PMSIFILEHASHINFO pHash
)
4059 TRACE("%s %08x %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
4061 file
= strdupAtoW( szFilePath
);
4062 if (szFilePath
&& !file
)
4063 return ERROR_OUTOFMEMORY
;
4065 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
4070 /***********************************************************************
4071 * MsiAdvertiseScriptW [MSI.@]
4073 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
4074 PHKEY phRegData
, BOOL fRemoveItems
)
4076 FIXME("%s %08x %p %d\n",
4077 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
4078 return ERROR_CALL_NOT_IMPLEMENTED
;
4081 /***********************************************************************
4082 * MsiAdvertiseScriptA [MSI.@]
4084 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
4085 PHKEY phRegData
, BOOL fRemoveItems
)
4087 FIXME("%s %08x %p %d\n",
4088 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
4089 return ERROR_CALL_NOT_IMPLEMENTED
;
4092 /***********************************************************************
4093 * MsiIsProductElevatedW [MSI.@]
4095 UINT WINAPI
MsiIsProductElevatedW( LPCWSTR szProduct
, BOOL
*pfElevated
)
4097 FIXME("%s %p - stub\n",
4098 debugstr_w( szProduct
), pfElevated
);
4100 return ERROR_SUCCESS
;
4103 /***********************************************************************
4104 * MsiIsProductElevatedA [MSI.@]
4106 UINT WINAPI
MsiIsProductElevatedA( LPCSTR szProduct
, BOOL
*pfElevated
)
4108 FIXME("%s %p - stub\n",
4109 debugstr_a( szProduct
), pfElevated
);
4111 return ERROR_SUCCESS
;
4114 /***********************************************************************
4115 * MsiSetExternalUIRecord [MSI.@]
4117 UINT WINAPI
MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD handler
,
4118 DWORD filter
, LPVOID context
,
4119 PINSTALLUI_HANDLER_RECORD prev
)
4121 TRACE("%p %08x %p %p\n", handler
, filter
, context
, prev
);
4124 *prev
= gUIHandlerRecord
;
4126 gUIHandlerRecord
= handler
;
4128 gUIContext
= context
;
4130 return ERROR_SUCCESS
;
4133 /***********************************************************************
4134 * MsiInstallMissingComponentA [MSI.@]
4136 UINT WINAPI
MsiInstallMissingComponentA( LPCSTR product
, LPCSTR component
, INSTALLSTATE state
)
4139 WCHAR
*productW
= NULL
, *componentW
= NULL
;
4141 TRACE("%s, %s, %d\n", debugstr_a(product
), debugstr_a(component
), state
);
4143 if (product
&& !(productW
= strdupAtoW( product
)))
4144 return ERROR_OUTOFMEMORY
;
4146 if (component
&& !(componentW
= strdupAtoW( component
)))
4148 msi_free( productW
);
4149 return ERROR_OUTOFMEMORY
;
4152 r
= MsiInstallMissingComponentW( productW
, componentW
, state
);
4153 msi_free( productW
);
4154 msi_free( componentW
);
4158 /***********************************************************************
4159 * MsiInstallMissingComponentW [MSI.@]
4161 UINT WINAPI
MsiInstallMissingComponentW(LPCWSTR szProduct
, LPCWSTR szComponent
, INSTALLSTATE eInstallState
)
4163 FIXME("(%s %s %d\n", debugstr_w(szProduct
), debugstr_w(szComponent
), eInstallState
);
4164 return ERROR_SUCCESS
;
4167 /***********************************************************************
4168 * MsiBeginTransactionA [MSI.@]
4170 UINT WINAPI
MsiBeginTransactionA( LPCSTR name
, DWORD attrs
, MSIHANDLE
*id
, HANDLE
*event
)
4175 FIXME("%s %u %p %p\n", debugstr_a(name
), attrs
, id
, event
);
4177 nameW
= strdupAtoW( name
);
4179 return ERROR_OUTOFMEMORY
;
4181 r
= MsiBeginTransactionW( nameW
, attrs
, id
, event
);
4186 /***********************************************************************
4187 * MsiBeginTransactionW [MSI.@]
4189 UINT WINAPI
MsiBeginTransactionW( LPCWSTR name
, DWORD attrs
, MSIHANDLE
*id
, HANDLE
*event
)
4191 FIXME("%s %u %p %p\n", debugstr_w(name
), attrs
, id
, event
);
4193 *id
= (MSIHANDLE
)0xdeadbeef;
4194 *event
= (HANDLE
)0xdeadbeef;
4196 return ERROR_SUCCESS
;
4199 /***********************************************************************
4200 * MsiEndTransaction [MSI.@]
4202 UINT WINAPI
MsiEndTransaction( DWORD state
)
4204 FIXME("%u\n", state
);
4205 return ERROR_SUCCESS
;