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
31 #include "wine/debug.h"
42 #include "wine/unicode.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
46 static const WCHAR installerW
[] = {'\\','I','n','s','t','a','l','l','e','r',0};
48 static UINT
msi_locate_product(LPCWSTR szProduct
, MSIINSTALLCONTEXT
*context
)
52 *context
= MSIINSTALLCONTEXT_NONE
;
54 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
55 &hkey
, FALSE
) == ERROR_SUCCESS
)
56 *context
= MSIINSTALLCONTEXT_USERMANAGED
;
57 else if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
58 &hkey
, FALSE
) == ERROR_SUCCESS
)
59 *context
= MSIINSTALLCONTEXT_MACHINE
;
60 else if (MSIREG_OpenProductKey(szProduct
, NULL
,
61 MSIINSTALLCONTEXT_USERUNMANAGED
,
62 &hkey
, FALSE
) == ERROR_SUCCESS
)
63 *context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
67 if (*context
== MSIINSTALLCONTEXT_NONE
)
68 return ERROR_UNKNOWN_PRODUCT
;
73 UINT WINAPI
MsiOpenProductA(LPCSTR szProduct
, MSIHANDLE
*phProduct
)
76 LPWSTR szwProd
= NULL
;
78 TRACE("%s %p\n",debugstr_a(szProduct
), phProduct
);
82 szwProd
= strdupAtoW( szProduct
);
84 return ERROR_OUTOFMEMORY
;
87 r
= MsiOpenProductW( szwProd
, phProduct
);
94 static UINT
MSI_OpenProductW(LPCWSTR szProduct
, MSIPACKAGE
**package
)
99 MSIINSTALLCONTEXT context
;
101 static const WCHAR managed
[] = {
102 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0};
103 static const WCHAR local
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
105 TRACE("%s %p\n", debugstr_w(szProduct
), package
);
107 r
= msi_locate_product(szProduct
, &context
);
108 if (r
!= ERROR_SUCCESS
)
111 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &props
, FALSE
);
112 if (r
!= ERROR_SUCCESS
)
113 return ERROR_UNKNOWN_PRODUCT
;
115 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
116 path
= msi_reg_get_val_str(props
, managed
);
118 path
= msi_reg_get_val_str(props
, local
);
120 r
= ERROR_UNKNOWN_PRODUCT
;
122 if (!path
|| GetFileAttributesW(path
) == INVALID_FILE_ATTRIBUTES
)
125 if (PathIsRelativeW(path
))
127 r
= ERROR_INSTALL_PACKAGE_OPEN_FAILED
;
131 r
= MSI_OpenPackageW(path
, package
);
139 UINT WINAPI
MsiOpenProductW(LPCWSTR szProduct
, MSIHANDLE
*phProduct
)
141 MSIPACKAGE
*package
= NULL
;
142 WCHAR squished_pc
[GUID_SIZE
];
145 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
146 return ERROR_INVALID_PARAMETER
;
149 return ERROR_INVALID_PARAMETER
;
151 r
= MSI_OpenProductW(szProduct
, &package
);
152 if (r
!= ERROR_SUCCESS
)
155 *phProduct
= alloc_msihandle(&package
->hdr
);
157 r
= ERROR_NOT_ENOUGH_MEMORY
;
159 msiobj_release(&package
->hdr
);
163 UINT WINAPI
MsiAdvertiseProductA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
164 LPCSTR szTransforms
, LANGID lgidLanguage
)
166 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath
),
167 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
), lgidLanguage
);
168 return ERROR_CALL_NOT_IMPLEMENTED
;
171 UINT WINAPI
MsiAdvertiseProductW(LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
172 LPCWSTR szTransforms
, LANGID lgidLanguage
)
174 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath
),
175 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
), lgidLanguage
);
176 return ERROR_CALL_NOT_IMPLEMENTED
;
179 UINT WINAPI
MsiAdvertiseProductExA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
180 LPCSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
182 FIXME("%s %s %s %08x %08x %08x\n", debugstr_a(szPackagePath
),
183 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
),
184 lgidLanguage
, dwPlatform
, dwOptions
);
185 return ERROR_CALL_NOT_IMPLEMENTED
;
188 UINT WINAPI
MsiAdvertiseProductExW( LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
189 LPCWSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
191 FIXME("%s %s %s %08x %08x %08x\n", debugstr_w(szPackagePath
),
192 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
),
193 lgidLanguage
, dwPlatform
, dwOptions
);
194 return ERROR_CALL_NOT_IMPLEMENTED
;
197 UINT WINAPI
MsiInstallProductA(LPCSTR szPackagePath
, LPCSTR szCommandLine
)
199 LPWSTR szwPath
= NULL
, szwCommand
= NULL
;
200 UINT r
= ERROR_OUTOFMEMORY
;
202 TRACE("%s %s\n",debugstr_a(szPackagePath
), debugstr_a(szCommandLine
));
206 szwPath
= strdupAtoW( szPackagePath
);
213 szwCommand
= strdupAtoW( szCommandLine
);
218 r
= MsiInstallProductW( szwPath
, szwCommand
);
222 msi_free( szwCommand
);
227 UINT WINAPI
MsiInstallProductW(LPCWSTR szPackagePath
, LPCWSTR szCommandLine
)
229 MSIPACKAGE
*package
= NULL
;
232 TRACE("%s %s\n",debugstr_w(szPackagePath
), debugstr_w(szCommandLine
));
235 return ERROR_INVALID_PARAMETER
;
238 return ERROR_PATH_NOT_FOUND
;
240 r
= MSI_OpenPackageW( szPackagePath
, &package
);
241 if (r
== ERROR_SUCCESS
)
243 r
= MSI_InstallPackage( package
, szPackagePath
, szCommandLine
);
244 msiobj_release( &package
->hdr
);
250 UINT WINAPI
MsiReinstallProductA(LPCSTR szProduct
, DWORD dwReinstallMode
)
255 TRACE("%s %08x\n", debugstr_a(szProduct
), dwReinstallMode
);
257 wszProduct
= strdupAtoW(szProduct
);
259 rc
= MsiReinstallProductW(wszProduct
, dwReinstallMode
);
261 msi_free(wszProduct
);
265 UINT WINAPI
MsiReinstallProductW(LPCWSTR szProduct
, DWORD dwReinstallMode
)
267 static const WCHAR szAll
[] = {'A','L','L',0};
269 TRACE("%s %08x\n", debugstr_w(szProduct
), dwReinstallMode
);
271 return MsiReinstallFeatureW(szProduct
, szAll
, dwReinstallMode
);
274 UINT WINAPI
MsiApplyPatchA(LPCSTR szPatchPackage
, LPCSTR szInstallPackage
,
275 INSTALLTYPE eInstallType
, LPCSTR szCommandLine
)
277 LPWSTR patch_package
= NULL
;
278 LPWSTR install_package
= NULL
;
279 LPWSTR command_line
= NULL
;
280 UINT r
= ERROR_OUTOFMEMORY
;
282 TRACE("%s %s %d %s\n", debugstr_a(szPatchPackage
), debugstr_a(szInstallPackage
),
283 eInstallType
, debugstr_a(szCommandLine
));
285 if (szPatchPackage
&& !(patch_package
= strdupAtoW(szPatchPackage
)))
288 if (szInstallPackage
&& !(install_package
= strdupAtoW(szInstallPackage
)))
291 if (szCommandLine
&& !(command_line
= strdupAtoW(szCommandLine
)))
294 r
= MsiApplyPatchW(patch_package
, install_package
, eInstallType
, command_line
);
297 msi_free(patch_package
);
298 msi_free(install_package
);
299 msi_free(command_line
);
304 static UINT
MSI_ApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szProductCode
, LPCWSTR szCommandLine
)
306 MSIHANDLE patch
, info
;
309 LPCWSTR cmd_ptr
= szCommandLine
;
310 LPCWSTR product_code
= szProductCode
;
312 LPWSTR cmd
= NULL
, codes
= NULL
;
314 static const WCHAR space
[] = {' ',0};
315 static const WCHAR patcheq
[] = {'P','A','T','C','H','=',0};
316 static WCHAR empty
[] = {0};
320 r
= MsiOpenDatabaseW(szPatchPackage
, MSIDBOPEN_READONLY
, &patch
);
321 if (r
!= ERROR_SUCCESS
)
324 r
= MsiGetSummaryInformationW(patch
, NULL
, 0, &info
);
325 if (r
!= ERROR_SUCCESS
)
328 r
= MsiSummaryInfoGetPropertyW(info
, PID_TEMPLATE
, &type
, NULL
, NULL
, empty
, &size
);
329 if (r
!= ERROR_MORE_DATA
|| !size
|| type
!= VT_LPSTR
)
331 ERR("Failed to read product codes from patch\n");
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
)
346 product_code
= codes
;
352 size
= lstrlenW(cmd_ptr
) + lstrlenW(patcheq
) + lstrlenW(szPatchPackage
) + 1;
353 cmd
= msi_alloc(size
* sizeof(WCHAR
));
356 r
= ERROR_OUTOFMEMORY
;
360 lstrcpyW(cmd
, cmd_ptr
);
361 if (szCommandLine
) lstrcatW(cmd
, space
);
362 lstrcatW(cmd
, patcheq
);
363 lstrcatW(cmd
, szPatchPackage
);
366 while ((end
= strchrW(beg
, '}')))
370 r
= MsiConfigureProductExW(beg
, INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
371 if (r
!= ERROR_SUCCESS
)
381 MsiCloseHandle(info
);
382 MsiCloseHandle(patch
);
387 UINT WINAPI
MsiApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szInstallPackage
,
388 INSTALLTYPE eInstallType
, LPCWSTR szCommandLine
)
390 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage
), debugstr_w(szInstallPackage
),
391 eInstallType
, debugstr_w(szCommandLine
));
393 if (szInstallPackage
|| eInstallType
== INSTALLTYPE_NETWORK_IMAGE
||
394 eInstallType
== INSTALLTYPE_SINGLE_INSTANCE
)
396 FIXME("Only reading target products from patch\n");
397 return ERROR_CALL_NOT_IMPLEMENTED
;
400 return MSI_ApplyPatchW(szPatchPackage
, NULL
, szCommandLine
);
403 UINT WINAPI
MsiApplyMultiplePatchesA(LPCSTR szPatchPackages
,
404 LPCSTR szProductCode
, LPCSTR szPropertiesList
)
406 LPWSTR patch_packages
= NULL
;
407 LPWSTR product_code
= NULL
;
408 LPWSTR properties_list
= NULL
;
409 UINT r
= ERROR_OUTOFMEMORY
;
411 TRACE("%s %s %s\n", debugstr_a(szPatchPackages
), debugstr_a(szProductCode
),
412 debugstr_a(szPropertiesList
));
414 if (!szPatchPackages
|| !szPatchPackages
[0])
415 return ERROR_INVALID_PARAMETER
;
417 if (!(patch_packages
= strdupAtoW(szPatchPackages
)))
418 return ERROR_OUTOFMEMORY
;
420 if (szProductCode
&& !(product_code
= strdupAtoW(szProductCode
)))
423 if (szPropertiesList
&& !(properties_list
= strdupAtoW(szPropertiesList
)))
426 r
= MsiApplyMultiplePatchesW(patch_packages
, product_code
, properties_list
);
429 msi_free(patch_packages
);
430 msi_free(product_code
);
431 msi_free(properties_list
);
436 UINT WINAPI
MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages
,
437 LPCWSTR szProductCode
, LPCWSTR szPropertiesList
)
439 UINT r
= ERROR_SUCCESS
;
442 TRACE("%s %s %s\n", debugstr_w(szPatchPackages
), debugstr_w(szProductCode
),
443 debugstr_w(szPropertiesList
));
445 if (!szPatchPackages
|| !szPatchPackages
[0])
446 return ERROR_INVALID_PARAMETER
;
448 beg
= end
= szPatchPackages
;
454 while (*beg
== ' ') beg
++;
455 while (*end
&& *end
!= ';') end
++;
458 while (len
&& beg
[len
- 1] == ' ') len
--;
460 if (!len
) return ERROR_INVALID_NAME
;
462 patch
= msi_alloc((len
+ 1) * sizeof(WCHAR
));
464 return ERROR_OUTOFMEMORY
;
466 memcpy(patch
, beg
, len
* sizeof(WCHAR
));
469 r
= MSI_ApplyPatchW(patch
, szProductCode
, szPropertiesList
);
472 if (r
!= ERROR_SUCCESS
)
480 UINT WINAPI
MsiDetermineApplicablePatchesA(LPCSTR szProductPackagePath
,
481 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOA pPatchInfo
)
483 FIXME("(%s, %d, %p): stub!\n", debugstr_a(szProductPackagePath
),
484 cPatchInfo
, pPatchInfo
);
486 return ERROR_CALL_NOT_IMPLEMENTED
;
489 UINT WINAPI
MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath
,
490 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOW pPatchInfo
)
492 FIXME("(%s, %d, %p): stub!\n", debugstr_w(szProductPackagePath
),
493 cPatchInfo
, pPatchInfo
);
495 return ERROR_CALL_NOT_IMPLEMENTED
;
498 UINT WINAPI
MsiDeterminePatchSequenceA(LPCSTR szProductCode
, LPCSTR szUserSid
,
499 MSIINSTALLCONTEXT dwContext
, DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOA pPatchInfo
)
501 FIXME("(%s, %s, %d, %d, %p): stub!\n", debugstr_a(szProductCode
),
502 debugstr_a(szUserSid
), dwContext
, cPatchInfo
, pPatchInfo
);
504 return ERROR_CALL_NOT_IMPLEMENTED
;
507 UINT WINAPI
MsiDeterminePatchSequenceW(LPCWSTR szProductCode
, LPCWSTR szUserSid
,
508 MSIINSTALLCONTEXT dwContext
, DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOW pPatchInfo
)
510 FIXME("(%s, %s, %d, %d, %p): stub!\n", debugstr_w(szProductCode
),
511 debugstr_w(szUserSid
), dwContext
, cPatchInfo
, pPatchInfo
);
513 return ERROR_CALL_NOT_IMPLEMENTED
;
516 static UINT
msi_open_package(LPCWSTR product
, MSIINSTALLCONTEXT context
,
517 MSIPACKAGE
**package
)
523 WCHAR sourcepath
[MAX_PATH
];
524 WCHAR filename
[MAX_PATH
];
526 static const WCHAR szLocalPackage
[] = {
527 'L','o','c','a','l','P','a','c','k','a','g','e',0};
530 r
= MSIREG_OpenInstallProps(product
, context
, NULL
, &props
, FALSE
);
531 if (r
!= ERROR_SUCCESS
)
532 return ERROR_BAD_CONFIGURATION
;
534 localpack
= msi_reg_get_val_str(props
, szLocalPackage
);
537 lstrcpyW(sourcepath
, localpack
);
541 if (!localpack
|| GetFileAttributesW(sourcepath
) == INVALID_FILE_ATTRIBUTES
)
543 sz
= sizeof(sourcepath
);
544 MsiSourceListGetInfoW(product
, NULL
, context
, MSICODE_PRODUCT
,
545 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
547 sz
= sizeof(filename
);
548 MsiSourceListGetInfoW(product
, NULL
, context
, MSICODE_PRODUCT
,
549 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
551 lstrcatW(sourcepath
, filename
);
554 if (GetFileAttributesW(sourcepath
) == INVALID_FILE_ATTRIBUTES
)
555 return ERROR_INSTALL_SOURCE_ABSENT
;
557 return MSI_OpenPackageW(sourcepath
, package
);
560 UINT WINAPI
MsiConfigureProductExW(LPCWSTR szProduct
, int iInstallLevel
,
561 INSTALLSTATE eInstallState
, LPCWSTR szCommandLine
)
563 MSIPACKAGE
* package
= NULL
;
564 MSIINSTALLCONTEXT context
;
567 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
570 static const WCHAR szInstalled
[] = {
571 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
572 static const WCHAR szRemoveAll
[] = {
573 ' ','R','E','M','O','V','E','=','A','L','L',0};
574 static const WCHAR szMachine
[] = {
575 ' ','A','L','L','U','S','E','R','S','=','1',0};
577 TRACE("%s %d %d %s\n",debugstr_w(szProduct
), iInstallLevel
, eInstallState
,
578 debugstr_w(szCommandLine
));
580 if (!szProduct
|| lstrlenW(szProduct
) != GUID_SIZE
- 1)
581 return ERROR_INVALID_PARAMETER
;
583 if (eInstallState
== INSTALLSTATE_ADVERTISED
||
584 eInstallState
== INSTALLSTATE_SOURCE
)
586 FIXME("State %d not implemented\n", eInstallState
);
587 return ERROR_CALL_NOT_IMPLEMENTED
;
590 r
= msi_locate_product(szProduct
, &context
);
591 if (r
!= ERROR_SUCCESS
)
594 r
= msi_open_package(szProduct
, context
, &package
);
595 if (r
!= ERROR_SUCCESS
)
598 sz
= lstrlenW(szInstalled
) + 1;
601 sz
+= lstrlenW(szCommandLine
);
603 if (eInstallState
== INSTALLSTATE_ABSENT
)
604 sz
+= lstrlenW(szRemoveAll
);
606 if (context
== MSIINSTALLCONTEXT_MACHINE
)
607 sz
+= lstrlenW(szMachine
);
609 commandline
= msi_alloc(sz
* sizeof(WCHAR
));
612 r
= ERROR_OUTOFMEMORY
;
618 lstrcpyW(commandline
,szCommandLine
);
620 if (MsiQueryProductStateW(szProduct
) != INSTALLSTATE_UNKNOWN
)
621 lstrcatW(commandline
,szInstalled
);
623 if (eInstallState
== INSTALLSTATE_ABSENT
)
624 lstrcatW(commandline
, szRemoveAll
);
626 if (context
== MSIINSTALLCONTEXT_MACHINE
)
627 lstrcatW(commandline
, szMachine
);
629 sz
= sizeof(sourcepath
);
630 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
631 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
633 sz
= sizeof(filename
);
634 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
635 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
637 strcatW(sourcepath
, filename
);
639 r
= MSI_InstallPackage( package
, sourcepath
, commandline
);
641 msi_free(commandline
);
644 msiobj_release( &package
->hdr
);
649 UINT WINAPI
MsiConfigureProductExA(LPCSTR szProduct
, int iInstallLevel
,
650 INSTALLSTATE eInstallState
, LPCSTR szCommandLine
)
652 LPWSTR szwProduct
= NULL
;
653 LPWSTR szwCommandLine
= NULL
;
654 UINT r
= ERROR_OUTOFMEMORY
;
658 szwProduct
= strdupAtoW( szProduct
);
665 szwCommandLine
= strdupAtoW( szCommandLine
);
670 r
= MsiConfigureProductExW( szwProduct
, iInstallLevel
, eInstallState
,
673 msi_free( szwProduct
);
674 msi_free( szwCommandLine
);
679 UINT WINAPI
MsiConfigureProductA(LPCSTR szProduct
, int iInstallLevel
,
680 INSTALLSTATE eInstallState
)
682 LPWSTR szwProduct
= NULL
;
685 TRACE("%s %d %d\n",debugstr_a(szProduct
), iInstallLevel
, eInstallState
);
689 szwProduct
= strdupAtoW( szProduct
);
691 return ERROR_OUTOFMEMORY
;
694 r
= MsiConfigureProductW( szwProduct
, iInstallLevel
, eInstallState
);
695 msi_free( szwProduct
);
700 UINT WINAPI
MsiConfigureProductW(LPCWSTR szProduct
, int iInstallLevel
,
701 INSTALLSTATE eInstallState
)
703 return MsiConfigureProductExW(szProduct
, iInstallLevel
, eInstallState
, NULL
);
706 UINT WINAPI
MsiGetProductCodeA(LPCSTR szComponent
, LPSTR szBuffer
)
708 LPWSTR szwComponent
= NULL
;
710 WCHAR szwBuffer
[GUID_SIZE
];
712 TRACE("%s %s\n",debugstr_a(szComponent
), debugstr_a(szBuffer
));
716 szwComponent
= strdupAtoW( szComponent
);
718 return ERROR_OUTOFMEMORY
;
722 r
= MsiGetProductCodeW( szwComponent
, szwBuffer
);
725 WideCharToMultiByte(CP_ACP
, 0, szwBuffer
, -1, szBuffer
, GUID_SIZE
, NULL
, NULL
);
727 msi_free( szwComponent
);
732 UINT WINAPI
MsiGetProductCodeW(LPCWSTR szComponent
, LPWSTR szBuffer
)
735 HKEY compkey
, prodkey
;
736 WCHAR squished_comp
[GUID_SIZE
];
737 WCHAR squished_prod
[GUID_SIZE
];
738 DWORD sz
= GUID_SIZE
;
740 TRACE("%s %p\n", debugstr_w(szComponent
), szBuffer
);
742 if (!szComponent
|| !*szComponent
)
743 return ERROR_INVALID_PARAMETER
;
745 if (!squash_guid(szComponent
, squished_comp
))
746 return ERROR_INVALID_PARAMETER
;
748 if (MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &compkey
, FALSE
) != ERROR_SUCCESS
&&
749 MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &compkey
, FALSE
) != ERROR_SUCCESS
)
751 return ERROR_UNKNOWN_COMPONENT
;
754 rc
= RegEnumValueW(compkey
, 0, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
755 if (rc
!= ERROR_SUCCESS
)
757 RegCloseKey(compkey
);
758 return ERROR_UNKNOWN_COMPONENT
;
761 /* check simple case, only one product */
762 rc
= RegEnumValueW(compkey
, 1, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
763 if (rc
== ERROR_NO_MORE_ITEMS
)
770 while ((rc
= RegEnumValueW(compkey
, index
, squished_prod
, &sz
,
771 NULL
, NULL
, NULL
, NULL
)) != ERROR_NO_MORE_ITEMS
)
775 unsquash_guid(squished_prod
, szBuffer
);
777 if (MSIREG_OpenProductKey(szBuffer
, NULL
,
778 MSIINSTALLCONTEXT_USERMANAGED
,
779 &prodkey
, FALSE
) == ERROR_SUCCESS
||
780 MSIREG_OpenProductKey(szBuffer
, NULL
,
781 MSIINSTALLCONTEXT_USERUNMANAGED
,
782 &prodkey
, FALSE
) == ERROR_SUCCESS
||
783 MSIREG_OpenProductKey(szBuffer
, NULL
,
784 MSIINSTALLCONTEXT_MACHINE
,
785 &prodkey
, FALSE
) == ERROR_SUCCESS
)
787 RegCloseKey(prodkey
);
793 rc
= ERROR_INSTALL_FAILURE
;
796 RegCloseKey(compkey
);
797 unsquash_guid(squished_prod
, szBuffer
);
801 static LPWSTR
msi_reg_get_value(HKEY hkey
, LPCWSTR name
, DWORD
*type
)
807 static const WCHAR format
[] = {'%','d',0};
809 res
= RegQueryValueExW(hkey
, name
, NULL
, type
, NULL
, NULL
);
810 if (res
!= ERROR_SUCCESS
)
814 return msi_reg_get_val_str(hkey
, name
);
816 if (!msi_reg_get_val_dword(hkey
, name
, &dval
))
819 sprintfW(temp
, format
, dval
);
820 return strdupW(temp
);
823 static UINT
MSI_GetProductInfo(LPCWSTR szProduct
, LPCWSTR szAttribute
,
824 awstring
*szValue
, LPDWORD pcchValueBuf
)
826 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
827 UINT r
= ERROR_UNKNOWN_PROPERTY
;
828 HKEY prodkey
, userdata
, source
;
830 WCHAR squished_pc
[GUID_SIZE
];
831 WCHAR packagecode
[GUID_SIZE
];
832 BOOL badconfig
= FALSE
;
834 DWORD save
, type
= REG_NONE
;
836 static WCHAR empty
[] = {0};
837 static const WCHAR sourcelist
[] = {
838 'S','o','u','r','c','e','L','i','s','t',0};
839 static const WCHAR display_name
[] = {
840 'D','i','s','p','l','a','y','N','a','m','e',0};
841 static const WCHAR display_version
[] = {
842 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
843 static const WCHAR assignment
[] = {
844 'A','s','s','i','g','n','m','e','n','t',0};
846 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
847 debugstr_w(szAttribute
), szValue
, pcchValueBuf
);
849 if ((szValue
->str
.w
&& !pcchValueBuf
) || !szProduct
|| !szAttribute
)
850 return ERROR_INVALID_PARAMETER
;
852 if (!squash_guid(szProduct
, squished_pc
))
853 return ERROR_INVALID_PARAMETER
;
855 if ((r
= MSIREG_OpenProductKey(szProduct
, NULL
,
856 MSIINSTALLCONTEXT_USERMANAGED
,
857 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
858 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
859 MSIINSTALLCONTEXT_USERUNMANAGED
,
860 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
861 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
862 MSIINSTALLCONTEXT_MACHINE
,
863 &prodkey
, FALSE
)) == ERROR_SUCCESS
)
865 context
= MSIINSTALLCONTEXT_MACHINE
;
868 MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
870 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_HELPLINKW
) ||
871 !lstrcmpW(szAttribute
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
872 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLDATEW
) ||
873 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
874 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
875 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
876 !lstrcmpW(szAttribute
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
877 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PUBLISHERW
) ||
878 !lstrcmpW(szAttribute
, INSTALLPROPERTY_URLINFOABOUTW
) ||
879 !lstrcmpW(szAttribute
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
880 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONMINORW
) ||
881 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONMAJORW
) ||
882 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
883 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTIDW
) ||
884 !lstrcmpW(szAttribute
, INSTALLPROPERTY_REGCOMPANYW
) ||
885 !lstrcmpW(szAttribute
, INSTALLPROPERTY_REGOWNERW
))
889 r
= ERROR_UNKNOWN_PRODUCT
;
894 return ERROR_UNKNOWN_PROPERTY
;
896 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
897 szAttribute
= display_name
;
898 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
))
899 szAttribute
= display_version
;
901 val
= msi_reg_get_value(userdata
, szAttribute
, &type
);
905 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTANCETYPEW
) ||
906 !lstrcmpW(szAttribute
, INSTALLPROPERTY_TRANSFORMSW
) ||
907 !lstrcmpW(szAttribute
, INSTALLPROPERTY_LANGUAGEW
) ||
908 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
909 !lstrcmpW(szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
) ||
910 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGECODEW
) ||
911 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONW
) ||
912 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTICONW
) ||
913 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
) ||
914 !lstrcmpW(szAttribute
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
918 r
= ERROR_UNKNOWN_PRODUCT
;
922 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
923 szAttribute
= assignment
;
925 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
))
927 res
= RegOpenKeyW(prodkey
, sourcelist
, &source
);
928 if (res
!= ERROR_SUCCESS
)
930 r
= ERROR_UNKNOWN_PRODUCT
;
934 val
= msi_reg_get_value(source
, szAttribute
, &type
);
942 val
= msi_reg_get_value(prodkey
, szAttribute
, &type
);
947 if (val
!= empty
&& type
!= REG_DWORD
&&
948 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGECODEW
))
950 if (lstrlenW(val
) != SQUISH_GUID_SIZE
- 1)
954 unsquash_guid(val
, packagecode
);
956 val
= strdupW(packagecode
);
963 r
= ERROR_UNKNOWN_PROPERTY
;
969 save
= *pcchValueBuf
;
971 if (strlenW(val
) < *pcchValueBuf
)
972 r
= msi_strcpy_to_awstring(val
, szValue
, pcchValueBuf
);
973 else if (szValue
->str
.a
|| szValue
->str
.w
)
977 *pcchValueBuf
= lstrlenW(val
);
978 else if (r
== ERROR_SUCCESS
)
980 *pcchValueBuf
= save
;
981 r
= ERROR_BAD_CONFIGURATION
;
985 r
= ERROR_BAD_CONFIGURATION
;
991 RegCloseKey(prodkey
);
992 RegCloseKey(userdata
);
996 UINT WINAPI
MsiGetProductInfoA(LPCSTR szProduct
, LPCSTR szAttribute
,
997 LPSTR szBuffer
, LPDWORD pcchValueBuf
)
999 LPWSTR szwProduct
, szwAttribute
= NULL
;
1000 UINT r
= ERROR_OUTOFMEMORY
;
1003 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szAttribute
),
1004 szBuffer
, pcchValueBuf
);
1006 szwProduct
= strdupAtoW( szProduct
);
1007 if( szProduct
&& !szwProduct
)
1010 szwAttribute
= strdupAtoW( szAttribute
);
1011 if( szAttribute
&& !szwAttribute
)
1014 buffer
.unicode
= FALSE
;
1015 buffer
.str
.a
= szBuffer
;
1017 r
= MSI_GetProductInfo( szwProduct
, szwAttribute
,
1018 &buffer
, pcchValueBuf
);
1021 msi_free( szwProduct
);
1022 msi_free( szwAttribute
);
1027 UINT WINAPI
MsiGetProductInfoW(LPCWSTR szProduct
, LPCWSTR szAttribute
,
1028 LPWSTR szBuffer
, LPDWORD pcchValueBuf
)
1032 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szAttribute
),
1033 szBuffer
, pcchValueBuf
);
1035 buffer
.unicode
= TRUE
;
1036 buffer
.str
.w
= szBuffer
;
1038 return MSI_GetProductInfo( szProduct
, szAttribute
,
1039 &buffer
, pcchValueBuf
);
1042 UINT WINAPI
MsiGetProductInfoExA(LPCSTR szProductCode
, LPCSTR szUserSid
,
1043 MSIINSTALLCONTEXT dwContext
, LPCSTR szProperty
,
1044 LPSTR szValue
, LPDWORD pcchValue
)
1046 LPWSTR product
= NULL
;
1047 LPWSTR usersid
= NULL
;
1048 LPWSTR property
= NULL
;
1049 LPWSTR value
= NULL
;
1053 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_a(szProductCode
),
1054 debugstr_a(szUserSid
), dwContext
, debugstr_a(szProperty
),
1055 szValue
, pcchValue
);
1057 if (szValue
&& !pcchValue
)
1058 return ERROR_INVALID_PARAMETER
;
1060 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1061 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1062 if (szProperty
) property
= strdupAtoW(szProperty
);
1064 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1066 if (r
!= ERROR_SUCCESS
)
1069 value
= msi_alloc(++len
* sizeof(WCHAR
));
1072 r
= ERROR_OUTOFMEMORY
;
1076 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1078 if (r
!= ERROR_SUCCESS
)
1084 len
= WideCharToMultiByte(CP_ACP
, 0, value
, -1, NULL
, 0, NULL
, NULL
);
1085 if (*pcchValue
>= len
)
1086 WideCharToMultiByte(CP_ACP
, 0, value
, -1, szValue
, len
, NULL
, NULL
);
1089 r
= ERROR_MORE_DATA
;
1094 if (*pcchValue
<= len
|| !szValue
)
1095 len
= len
* sizeof(WCHAR
) - 1;
1097 *pcchValue
= len
- 1;
1108 static UINT
msi_copy_outval(LPWSTR val
, LPWSTR out
, LPDWORD size
)
1113 return ERROR_UNKNOWN_PROPERTY
;
1117 if (strlenW(val
) >= *size
)
1119 r
= ERROR_MORE_DATA
;
1128 *size
= lstrlenW(val
);
1130 return ERROR_SUCCESS
;
1133 UINT WINAPI
MsiGetProductInfoExW(LPCWSTR szProductCode
, LPCWSTR szUserSid
,
1134 MSIINSTALLCONTEXT dwContext
, LPCWSTR szProperty
,
1135 LPWSTR szValue
, LPDWORD pcchValue
)
1137 WCHAR squished_pc
[GUID_SIZE
];
1139 LPCWSTR package
= NULL
;
1140 HKEY props
= NULL
, prod
;
1141 HKEY classes
= NULL
, managed
;
1144 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1146 static const WCHAR one
[] = {'1',0};
1147 static const WCHAR five
[] = {'5',0};
1148 static const WCHAR empty
[] = {0};
1149 static const WCHAR displayname
[] = {
1150 'D','i','s','p','l','a','y','N','a','m','e',0};
1151 static const WCHAR displayversion
[] = {
1152 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1153 static const WCHAR managed_local_package
[] = {
1154 'M','a','n','a','g','e','d','L','o','c','a','l',
1155 'P','a','c','k','a','g','e',0};
1157 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_w(szProductCode
),
1158 debugstr_w(szUserSid
), dwContext
, debugstr_w(szProperty
),
1159 szValue
, pcchValue
);
1161 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1162 return ERROR_INVALID_PARAMETER
;
1164 if (szValue
&& !pcchValue
)
1165 return ERROR_INVALID_PARAMETER
;
1167 if (dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1168 dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1169 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1170 return ERROR_INVALID_PARAMETER
;
1172 if (!szProperty
|| !*szProperty
)
1173 return ERROR_INVALID_PARAMETER
;
1175 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1176 return ERROR_INVALID_PARAMETER
;
1178 /* FIXME: dwContext is provided, no need to search for it */
1179 MSIREG_OpenProductKey(szProductCode
, NULL
,MSIINSTALLCONTEXT_USERMANAGED
,
1181 MSIREG_OpenProductKey(szProductCode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1184 MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
, &props
, FALSE
);
1186 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1188 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1190 if (!props
&& !prod
)
1193 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1195 package
= managed_local_package
;
1197 if (!props
&& !managed
)
1200 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1202 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1203 MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
, &classes
, FALSE
);
1205 if (!props
&& !classes
)
1209 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_HELPLINKW
) ||
1210 !lstrcmpW(szProperty
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
1211 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLDATEW
) ||
1212 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
1213 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
1214 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
1215 !lstrcmpW(szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
1216 !lstrcmpW(szProperty
, INSTALLPROPERTY_PUBLISHERW
) ||
1217 !lstrcmpW(szProperty
, INSTALLPROPERTY_URLINFOABOUTW
) ||
1218 !lstrcmpW(szProperty
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
1219 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONMINORW
) ||
1220 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONMAJORW
) ||
1221 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
1222 !lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTIDW
) ||
1223 !lstrcmpW(szProperty
, INSTALLPROPERTY_REGCOMPANYW
) ||
1224 !lstrcmpW(szProperty
, INSTALLPROPERTY_REGOWNERW
) ||
1225 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTANCETYPEW
))
1227 val
= msi_reg_get_value(props
, package
, &type
);
1230 if (prod
|| classes
)
1231 r
= ERROR_UNKNOWN_PROPERTY
;
1238 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
1239 szProperty
= displayname
;
1240 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
))
1241 szProperty
= displayversion
;
1243 val
= msi_reg_get_value(props
, szProperty
, &type
);
1245 val
= strdupW(empty
);
1247 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1249 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_TRANSFORMSW
) ||
1250 !lstrcmpW(szProperty
, INSTALLPROPERTY_LANGUAGEW
) ||
1251 !lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
1252 !lstrcmpW(szProperty
, INSTALLPROPERTY_PACKAGECODEW
) ||
1253 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONW
) ||
1254 !lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTICONW
) ||
1255 !lstrcmpW(szProperty
, INSTALLPROPERTY_PACKAGENAMEW
) ||
1256 !lstrcmpW(szProperty
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
1258 if (!prod
&& !classes
)
1261 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1263 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1265 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1268 val
= msi_reg_get_value(hkey
, szProperty
, &type
);
1270 val
= strdupW(empty
);
1272 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1274 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTSTATEW
))
1276 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1280 val
= msi_reg_get_value(props
, package
, &type
);
1285 val
= strdupW(five
);
1290 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1293 else if (props
&& (val
= msi_reg_get_value(props
, package
, &type
)))
1296 val
= strdupW(five
);
1297 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1301 if (prod
|| managed
)
1306 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1308 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
1310 if (!prod
&& !classes
)
1314 val
= strdupW(empty
);
1315 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1318 r
= ERROR_UNKNOWN_PROPERTY
;
1323 RegCloseKey(managed
);
1324 RegCloseKey(classes
);
1330 UINT WINAPI
MsiGetPatchInfoExA(LPCSTR szPatchCode
, LPCSTR szProductCode
,
1331 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1332 LPCSTR szProperty
, LPSTR lpValue
, DWORD
*pcchValue
)
1334 LPWSTR patch
= NULL
, product
= NULL
, usersid
= NULL
;
1335 LPWSTR property
= NULL
, val
= NULL
;
1339 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_a(szPatchCode
),
1340 debugstr_a(szProductCode
), debugstr_a(szUserSid
), dwContext
,
1341 debugstr_a(szProperty
), lpValue
, pcchValue
);
1343 if (lpValue
&& !pcchValue
)
1344 return ERROR_INVALID_PARAMETER
;
1346 if (szPatchCode
) patch
= strdupAtoW(szPatchCode
);
1347 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1348 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1349 if (szProperty
) property
= strdupAtoW(szProperty
);
1352 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1354 if (r
!= ERROR_SUCCESS
)
1357 val
= msi_alloc(++len
* sizeof(WCHAR
));
1360 r
= ERROR_OUTOFMEMORY
;
1364 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1366 if (r
!= ERROR_SUCCESS
|| !pcchValue
)
1370 WideCharToMultiByte(CP_ACP
, 0, val
, -1, lpValue
,
1371 *pcchValue
- 1, NULL
, NULL
);
1373 len
= lstrlenW(val
);
1374 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1378 r
= ERROR_MORE_DATA
;
1379 lpValue
[*pcchValue
- 1] = '\0';
1382 *pcchValue
= len
* sizeof(WCHAR
);
1397 UINT WINAPI
MsiGetPatchInfoExW(LPCWSTR szPatchCode
, LPCWSTR szProductCode
,
1398 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1399 LPCWSTR szProperty
, LPWSTR lpValue
, DWORD
*pcchValue
)
1401 WCHAR squished_pc
[GUID_SIZE
];
1402 WCHAR squished_patch
[GUID_SIZE
];
1403 HKEY udprod
= 0, prod
= 0, props
= 0;
1404 HKEY patch
= 0, patches
= 0;
1405 HKEY udpatch
= 0, datakey
= 0;
1406 HKEY prodpatches
= 0;
1408 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1412 static const WCHAR szEmpty
[] = {0};
1413 static const WCHAR szPatches
[] = {'P','a','t','c','h','e','s',0};
1414 static const WCHAR szInstalled
[] = {'I','n','s','t','a','l','l','e','d',0};
1415 static const WCHAR szManagedPackage
[] = {'M','a','n','a','g','e','d',
1416 'L','o','c','a','l','P','a','c','k','a','g','e',0};
1418 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_w(szPatchCode
),
1419 debugstr_w(szProductCode
), debugstr_w(szUserSid
), dwContext
,
1420 debugstr_w(szProperty
), lpValue
, pcchValue
);
1422 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1423 return ERROR_INVALID_PARAMETER
;
1425 if (!szPatchCode
|| !squash_guid(szPatchCode
, squished_patch
))
1426 return ERROR_INVALID_PARAMETER
;
1429 return ERROR_INVALID_PARAMETER
;
1431 if (lpValue
&& !pcchValue
)
1432 return ERROR_INVALID_PARAMETER
;
1434 if (dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1435 dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1436 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1437 return ERROR_INVALID_PARAMETER
;
1439 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1440 return ERROR_INVALID_PARAMETER
;
1442 if (!lstrcmpW(szUserSid
, szLocalSid
))
1443 return ERROR_INVALID_PARAMETER
;
1445 if (MSIREG_OpenUserDataProductKey(szProductCode
, dwContext
, NULL
,
1446 &udprod
, FALSE
) != ERROR_SUCCESS
)
1449 if (MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
,
1450 &props
, FALSE
) != ERROR_SUCCESS
)
1453 r
= ERROR_UNKNOWN_PATCH
;
1455 res
= RegOpenKeyExW(udprod
, szPatches
, 0, KEY_READ
, &patches
);
1456 if (res
!= ERROR_SUCCESS
)
1459 res
= RegOpenKeyExW(patches
, squished_patch
, 0, KEY_READ
, &patch
);
1460 if (res
!= ERROR_SUCCESS
)
1463 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_TRANSFORMSW
))
1465 if (MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
,
1466 &prod
, FALSE
) != ERROR_SUCCESS
)
1469 res
= RegOpenKeyExW(prod
, szPatches
, 0, KEY_ALL_ACCESS
, &prodpatches
);
1470 if (res
!= ERROR_SUCCESS
)
1473 datakey
= prodpatches
;
1474 szProperty
= squished_patch
;
1478 if (MSIREG_OpenUserDataPatchKey(szPatchCode
, dwContext
,
1479 &udpatch
, FALSE
) != ERROR_SUCCESS
)
1482 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1484 if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1485 szProperty
= szManagedPackage
;
1488 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLDATEW
))
1491 szProperty
= szInstalled
;
1493 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1497 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_UNINSTALLABLEW
) ||
1498 !lstrcmpW(szProperty
, INSTALLPROPERTY_PATCHSTATEW
) ||
1499 !lstrcmpW(szProperty
, INSTALLPROPERTY_DISPLAYNAMEW
) ||
1500 !lstrcmpW(szProperty
, INSTALLPROPERTY_MOREINFOURLW
))
1506 r
= ERROR_UNKNOWN_PROPERTY
;
1511 val
= msi_reg_get_val_str(datakey
, szProperty
);
1513 val
= strdupW(szEmpty
);
1521 lstrcpynW(lpValue
, val
, *pcchValue
);
1523 len
= lstrlenW(val
);
1524 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1527 r
= ERROR_MORE_DATA
;
1529 *pcchValue
= len
* sizeof(WCHAR
);
1536 RegCloseKey(prodpatches
);
1539 RegCloseKey(patches
);
1540 RegCloseKey(udpatch
);
1542 RegCloseKey(udprod
);
1547 UINT WINAPI
MsiEnableLogA(DWORD dwLogMode
, LPCSTR szLogFile
, DWORD attributes
)
1549 LPWSTR szwLogFile
= NULL
;
1552 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_a(szLogFile
), attributes
);
1556 szwLogFile
= strdupAtoW( szLogFile
);
1558 return ERROR_OUTOFMEMORY
;
1560 r
= MsiEnableLogW( dwLogMode
, szwLogFile
, attributes
);
1561 msi_free( szwLogFile
);
1565 UINT WINAPI
MsiEnableLogW(DWORD dwLogMode
, LPCWSTR szLogFile
, DWORD attributes
)
1567 HANDLE file
= INVALID_HANDLE_VALUE
;
1569 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_w(szLogFile
), attributes
);
1573 lstrcpyW(gszLogFile
,szLogFile
);
1574 if (!(attributes
& INSTALLLOGATTRIBUTES_APPEND
))
1575 DeleteFileW(szLogFile
);
1576 file
= CreateFileW(szLogFile
, GENERIC_WRITE
, 0, NULL
, OPEN_ALWAYS
,
1577 FILE_ATTRIBUTE_NORMAL
, NULL
);
1578 if (file
!= INVALID_HANDLE_VALUE
)
1581 ERR("Unable to enable log %s\n",debugstr_w(szLogFile
));
1584 gszLogFile
[0] = '\0';
1586 return ERROR_SUCCESS
;
1589 UINT WINAPI
MsiEnumComponentCostsW(MSIHANDLE hInstall
, LPCWSTR szComponent
,
1590 DWORD dwIndex
, INSTALLSTATE iState
,
1591 LPWSTR lpDriveBuf
, DWORD
*pcchDriveBuf
,
1592 int *piCost
, int *pTempCost
)
1594 FIXME("(%d, %s, %d, %d, %p, %p, %p %p): stub!\n", hInstall
,
1595 debugstr_w(szComponent
), dwIndex
, iState
, lpDriveBuf
,
1596 pcchDriveBuf
, piCost
, pTempCost
);
1598 return ERROR_NO_MORE_ITEMS
;
1601 UINT WINAPI
MsiQueryComponentStateA(LPCSTR szProductCode
,
1602 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1603 LPCSTR szComponent
, INSTALLSTATE
*pdwState
)
1605 LPWSTR prodcode
= NULL
, usersid
= NULL
, comp
= NULL
;
1608 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode
),
1609 debugstr_a(szUserSid
), dwContext
, debugstr_a(szComponent
), pdwState
);
1611 if (szProductCode
&& !(prodcode
= strdupAtoW(szProductCode
)))
1612 return ERROR_OUTOFMEMORY
;
1614 if (szUserSid
&& !(usersid
= strdupAtoW(szUserSid
)))
1615 return ERROR_OUTOFMEMORY
;
1617 if (szComponent
&& !(comp
= strdupAtoW(szComponent
)))
1618 return ERROR_OUTOFMEMORY
;
1620 r
= MsiQueryComponentStateW(prodcode
, usersid
, dwContext
, comp
, pdwState
);
1629 static BOOL
msi_comp_find_prod_key(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
1634 r
= MSIREG_OpenProductKey(prodcode
, NULL
, context
, &hkey
, FALSE
);
1636 return (r
== ERROR_SUCCESS
);
1639 static BOOL
msi_comp_find_package(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
1647 static const WCHAR local_package
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
1648 static const WCHAR managed_local_package
[] = {
1649 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
1652 r
= MSIREG_OpenInstallProps(prodcode
, context
, NULL
, &hkey
, FALSE
);
1653 if (r
!= ERROR_SUCCESS
)
1656 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
1657 package
= managed_local_package
;
1659 package
= local_package
;
1662 res
= RegQueryValueExW(hkey
, package
, NULL
, NULL
, NULL
, &sz
);
1665 return (res
== ERROR_SUCCESS
);
1668 static BOOL
msi_comp_find_prodcode(LPWSTR squished_pc
,
1669 MSIINSTALLCONTEXT context
,
1670 LPCWSTR comp
, LPWSTR val
, DWORD
*sz
)
1676 if (context
== MSIINSTALLCONTEXT_MACHINE
)
1677 r
= MSIREG_OpenUserDataComponentKey(comp
, szLocalSid
, &hkey
, FALSE
);
1679 r
= MSIREG_OpenUserDataComponentKey(comp
, NULL
, &hkey
, FALSE
);
1681 if (r
!= ERROR_SUCCESS
)
1684 res
= RegQueryValueExW(hkey
, squished_pc
, NULL
, NULL
, (BYTE
*)val
, sz
);
1685 if (res
!= ERROR_SUCCESS
)
1692 UINT WINAPI
MsiQueryComponentStateW(LPCWSTR szProductCode
,
1693 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1694 LPCWSTR szComponent
, INSTALLSTATE
*pdwState
)
1696 WCHAR squished_pc
[GUID_SIZE
];
1697 WCHAR val
[MAX_PATH
];
1701 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode
),
1702 debugstr_w(szUserSid
), dwContext
, debugstr_w(szComponent
), pdwState
);
1704 if (!pdwState
|| !szComponent
)
1705 return ERROR_INVALID_PARAMETER
;
1707 if (!szProductCode
|| !*szProductCode
|| lstrlenW(szProductCode
) != GUID_SIZE
- 1)
1708 return ERROR_INVALID_PARAMETER
;
1710 if (!squash_guid(szProductCode
, squished_pc
))
1711 return ERROR_INVALID_PARAMETER
;
1713 found
= msi_comp_find_prod_key(szProductCode
, dwContext
);
1715 if (!msi_comp_find_package(szProductCode
, dwContext
))
1719 *pdwState
= INSTALLSTATE_UNKNOWN
;
1720 return ERROR_UNKNOWN_COMPONENT
;
1723 return ERROR_UNKNOWN_PRODUCT
;
1726 *pdwState
= INSTALLSTATE_UNKNOWN
;
1729 if (!msi_comp_find_prodcode(squished_pc
, dwContext
, szComponent
, val
, &sz
))
1730 return ERROR_UNKNOWN_COMPONENT
;
1733 *pdwState
= INSTALLSTATE_NOTUSED
;
1736 if (lstrlenW(val
) > 2 &&
1737 val
[0] >= '0' && val
[0] <= '9' && val
[1] >= '0' && val
[1] <= '9')
1739 *pdwState
= INSTALLSTATE_SOURCE
;
1742 *pdwState
= INSTALLSTATE_LOCAL
;
1745 return ERROR_SUCCESS
;
1748 INSTALLSTATE WINAPI
MsiQueryProductStateA(LPCSTR szProduct
)
1750 LPWSTR szwProduct
= NULL
;
1755 szwProduct
= strdupAtoW( szProduct
);
1757 return ERROR_OUTOFMEMORY
;
1759 r
= MsiQueryProductStateW( szwProduct
);
1760 msi_free( szwProduct
);
1764 INSTALLSTATE WINAPI
MsiQueryProductStateW(LPCWSTR szProduct
)
1766 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
1767 INSTALLSTATE state
= INSTALLSTATE_ADVERTISED
;
1768 HKEY prodkey
= 0, userdata
= 0;
1772 static const WCHAR szWindowsInstaller
[] = {
1773 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
1775 TRACE("%s\n", debugstr_w(szProduct
));
1777 if (!szProduct
|| !*szProduct
)
1778 return INSTALLSTATE_INVALIDARG
;
1780 if (lstrlenW(szProduct
) != GUID_SIZE
- 1)
1781 return INSTALLSTATE_INVALIDARG
;
1783 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1784 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
1785 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1786 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
1787 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
1788 &prodkey
, FALSE
) == ERROR_SUCCESS
)
1790 context
= MSIINSTALLCONTEXT_MACHINE
;
1793 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
1794 if (r
!= ERROR_SUCCESS
)
1797 if (!msi_reg_get_val_dword(userdata
, szWindowsInstaller
, &val
))
1801 state
= INSTALLSTATE_DEFAULT
;
1803 state
= INSTALLSTATE_UNKNOWN
;
1808 state
= INSTALLSTATE_UNKNOWN
;
1811 state
= INSTALLSTATE_ABSENT
;
1814 RegCloseKey(prodkey
);
1815 RegCloseKey(userdata
);
1819 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
1821 INSTALLUILEVEL old
= gUILevel
;
1822 HWND oldwnd
= gUIhwnd
;
1824 TRACE("%08x %p\n", dwUILevel
, phWnd
);
1826 gUILevel
= dwUILevel
;
1835 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
1836 DWORD dwMessageFilter
, LPVOID pvContext
)
1838 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
1840 TRACE("%p %x %p\n",puiHandler
, dwMessageFilter
,pvContext
);
1841 gUIHandlerA
= puiHandler
;
1842 gUIFilter
= dwMessageFilter
;
1843 gUIContext
= pvContext
;
1848 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
1849 DWORD dwMessageFilter
, LPVOID pvContext
)
1851 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
1853 TRACE("%p %x %p\n",puiHandler
,dwMessageFilter
,pvContext
);
1854 gUIHandlerW
= puiHandler
;
1855 gUIFilter
= dwMessageFilter
;
1856 gUIContext
= pvContext
;
1861 /******************************************************************
1862 * MsiLoadStringW [MSI.@]
1864 * Loads a string from MSI's string resources.
1868 * handle [I] only -1 is handled currently
1869 * id [I] id of the string to be loaded
1870 * lpBuffer [O] buffer for the string to be written to
1871 * nBufferMax [I] maximum size of the buffer in characters
1872 * lang [I] the preferred language for the string
1876 * If successful, this function returns the language id of the string loaded
1877 * If the function fails, the function returns zero.
1881 * The type of the first parameter is unknown. LoadString's prototype
1882 * suggests that it might be a module handle. I have made it an MSI handle
1883 * for starters, as -1 is an invalid MSI handle, but not an invalid module
1884 * handle. Maybe strings can be stored in an MSI database somehow.
1886 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
1887 int nBufferMax
, LANGID lang
)
1894 TRACE("%d %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
1897 FIXME("don't know how to deal with handle = %08x\n", handle
);
1900 lang
= GetUserDefaultLangID();
1902 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
1906 hResData
= LoadResource( msi_hInstance
, hres
);
1909 p
= LockResource( hResData
);
1913 for (i
= 0; i
< (id
&0xf); i
++)
1917 if( nBufferMax
<= len
)
1920 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
1921 lpBuffer
[ len
] = 0;
1923 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
1928 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
1929 int nBufferMax
, LANGID lang
)
1935 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
1936 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
1939 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
1940 if( len
<= nBufferMax
)
1941 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
1942 lpBuffer
, nBufferMax
, NULL
, NULL
);
1950 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
1953 char szProduct
[GUID_SIZE
];
1955 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
1957 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
1958 return INSTALLSTATE_UNKNOWN
;
1960 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
1963 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
1966 WCHAR szProduct
[GUID_SIZE
];
1968 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
1970 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
1971 return INSTALLSTATE_UNKNOWN
;
1973 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
1976 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
1977 WORD wLanguageId
, DWORD f
)
1979 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_a(lpText
), debugstr_a(lpCaption
),
1980 uType
, wLanguageId
, f
);
1981 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
1984 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
1985 WORD wLanguageId
, DWORD f
)
1987 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_w(lpText
), debugstr_w(lpCaption
),
1988 uType
, wLanguageId
, f
);
1989 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
1992 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
1993 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
1994 LPDWORD pcchPathBuf
)
1996 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName
),
1997 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
1999 return ERROR_CALL_NOT_IMPLEMENTED
;
2002 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
2003 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
2004 LPDWORD pcchPathBuf
)
2006 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName
),
2007 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2009 return ERROR_CALL_NOT_IMPLEMENTED
;
2012 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
2013 LPSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2015 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2016 return ERROR_CALL_NOT_IMPLEMENTED
;
2019 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
2020 LPWSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2022 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2023 return ERROR_CALL_NOT_IMPLEMENTED
;
2026 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath
,
2027 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, LPBYTE pbHashData
,
2028 LPDWORD pcbHashData
)
2030 FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath
), dwFlags
,
2031 ppcCertContext
, pbHashData
, pcbHashData
);
2032 return ERROR_CALL_NOT_IMPLEMENTED
;
2035 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath
,
2036 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, LPBYTE pbHashData
,
2037 LPDWORD pcbHashData
)
2039 FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath
), dwFlags
,
2040 ppcCertContext
, pbHashData
, pcbHashData
);
2041 return ERROR_CALL_NOT_IMPLEMENTED
;
2044 /******************************************************************
2045 * MsiGetProductPropertyA [MSI.@]
2047 UINT WINAPI
MsiGetProductPropertyA(MSIHANDLE hProduct
, LPCSTR szProperty
,
2048 LPSTR szValue
, LPDWORD pccbValue
)
2050 LPWSTR prop
= NULL
, val
= NULL
;
2054 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_a(szProperty
),
2055 szValue
, pccbValue
);
2057 if (szValue
&& !pccbValue
)
2058 return ERROR_INVALID_PARAMETER
;
2060 if (szProperty
) prop
= strdupAtoW(szProperty
);
2063 r
= MsiGetProductPropertyW(hProduct
, prop
, NULL
, &len
);
2064 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2067 if (r
== ERROR_SUCCESS
)
2069 if (szValue
) *szValue
= '\0';
2070 if (pccbValue
) *pccbValue
= 0;
2074 val
= msi_alloc(++len
* sizeof(WCHAR
));
2077 r
= ERROR_OUTOFMEMORY
;
2081 r
= MsiGetProductPropertyW(hProduct
, prop
, val
, &len
);
2082 if (r
!= ERROR_SUCCESS
)
2085 len
= WideCharToMultiByte(CP_ACP
, 0, val
, -1, NULL
, 0, NULL
, NULL
);
2088 WideCharToMultiByte(CP_ACP
, 0, val
, -1, szValue
,
2089 *pccbValue
, NULL
, NULL
);
2093 if (len
> *pccbValue
)
2094 r
= ERROR_MORE_DATA
;
2096 *pccbValue
= len
- 1;
2106 /******************************************************************
2107 * MsiGetProductPropertyW [MSI.@]
2109 UINT WINAPI
MsiGetProductPropertyW(MSIHANDLE hProduct
, LPCWSTR szProperty
,
2110 LPWSTR szValue
, LPDWORD pccbValue
)
2112 MSIPACKAGE
*package
;
2113 MSIQUERY
*view
= NULL
;
2114 MSIRECORD
*rec
= NULL
;
2118 static const WCHAR query
[] = {
2119 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2120 '`','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2121 '`','P','r','o','p','e','r','t','y','`','=','\'','%','s','\'',0};
2123 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_w(szProperty
),
2124 szValue
, pccbValue
);
2127 return ERROR_INVALID_PARAMETER
;
2129 if (szValue
&& !pccbValue
)
2130 return ERROR_INVALID_PARAMETER
;
2132 package
= msihandle2msiinfo(hProduct
, MSIHANDLETYPE_PACKAGE
);
2134 return ERROR_INVALID_HANDLE
;
2136 r
= MSI_OpenQuery(package
->db
, &view
, query
, szProperty
);
2137 if (r
!= ERROR_SUCCESS
)
2140 r
= MSI_ViewExecute(view
, 0);
2141 if (r
!= ERROR_SUCCESS
)
2144 r
= MSI_ViewFetch(view
, &rec
);
2145 if (r
!= ERROR_SUCCESS
)
2148 val
= MSI_RecordGetString(rec
, 2);
2152 if (lstrlenW(val
) >= *pccbValue
)
2154 lstrcpynW(szValue
, val
, *pccbValue
);
2155 *pccbValue
= lstrlenW(val
);
2156 r
= ERROR_MORE_DATA
;
2160 lstrcpyW(szValue
, val
);
2161 *pccbValue
= lstrlenW(val
);
2168 MSI_ViewClose(view
);
2169 msiobj_release(&view
->hdr
);
2170 if (rec
) msiobj_release(&rec
->hdr
);
2175 if (szValue
) *szValue
= '\0';
2176 if (pccbValue
) *pccbValue
= 0;
2183 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
2186 LPWSTR szPack
= NULL
;
2188 TRACE("%s\n", debugstr_a(szPackage
) );
2192 szPack
= strdupAtoW( szPackage
);
2194 return ERROR_OUTOFMEMORY
;
2197 r
= MsiVerifyPackageW( szPack
);
2204 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
2209 TRACE("%s\n", debugstr_w(szPackage
) );
2211 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
2212 MsiCloseHandle( handle
);
2217 static INSTALLSTATE
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
2218 awstring
* lpPathBuf
, LPDWORD pcchBuf
)
2220 WCHAR squished_pc
[GUID_SIZE
];
2221 WCHAR squished_comp
[GUID_SIZE
];
2227 static const WCHAR wininstaller
[] = {
2228 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
2230 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
2231 debugstr_w(szComponent
), lpPathBuf
->str
.w
, pcchBuf
);
2233 if (!szProduct
|| !szComponent
)
2234 return INSTALLSTATE_INVALIDARG
;
2236 if (lpPathBuf
->str
.w
&& !pcchBuf
)
2237 return INSTALLSTATE_INVALIDARG
;
2239 if (!squash_guid(szProduct
, squished_pc
) ||
2240 !squash_guid(szComponent
, squished_comp
))
2241 return INSTALLSTATE_INVALIDARG
;
2243 state
= INSTALLSTATE_UNKNOWN
;
2245 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2246 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2248 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2251 state
= INSTALLSTATE_ABSENT
;
2253 if ((MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
, NULL
,
2254 &hkey
, FALSE
) == ERROR_SUCCESS
||
2255 MSIREG_OpenUserDataProductKey(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2256 NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
) &&
2257 msi_reg_get_val_dword(hkey
, wininstaller
, &version
) &&
2258 GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2261 state
= INSTALLSTATE_LOCAL
;
2265 if (state
!= INSTALLSTATE_LOCAL
&&
2266 (MSIREG_OpenProductKey(szProduct
, NULL
,
2267 MSIINSTALLCONTEXT_USERUNMANAGED
,
2268 &hkey
, FALSE
) == ERROR_SUCCESS
||
2269 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
2270 &hkey
, FALSE
) == ERROR_SUCCESS
))
2274 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2275 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2278 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2281 state
= INSTALLSTATE_ABSENT
;
2283 if (GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2284 state
= INSTALLSTATE_LOCAL
;
2289 return INSTALLSTATE_UNKNOWN
;
2291 if (state
== INSTALLSTATE_LOCAL
&& !*path
)
2292 state
= INSTALLSTATE_NOTUSED
;
2294 msi_strcpy_to_awstring(path
, lpPathBuf
, pcchBuf
);
2299 /******************************************************************
2300 * MsiGetComponentPathW [MSI.@]
2302 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
2303 LPWSTR lpPathBuf
, LPDWORD pcchBuf
)
2307 path
.unicode
= TRUE
;
2308 path
.str
.w
= lpPathBuf
;
2310 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
2313 /******************************************************************
2314 * MsiGetComponentPathA [MSI.@]
2316 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
2317 LPSTR lpPathBuf
, LPDWORD pcchBuf
)
2319 LPWSTR szwProduct
, szwComponent
= NULL
;
2320 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
2323 szwProduct
= strdupAtoW( szProduct
);
2324 if( szProduct
&& !szwProduct
)
2327 szwComponent
= strdupAtoW( szComponent
);
2328 if( szComponent
&& !szwComponent
)
2331 path
.unicode
= FALSE
;
2332 path
.str
.a
= lpPathBuf
;
2334 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
2337 msi_free( szwProduct
);
2338 msi_free( szwComponent
);
2343 /******************************************************************
2344 * MsiQueryFeatureStateA [MSI.@]
2346 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
2348 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
2349 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
2351 szwProduct
= strdupAtoW( szProduct
);
2352 if ( szProduct
&& !szwProduct
)
2355 szwFeature
= strdupAtoW( szFeature
);
2356 if ( szFeature
&& !szwFeature
)
2359 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
2362 msi_free( szwProduct
);
2363 msi_free( szwFeature
);
2368 /******************************************************************
2369 * MsiQueryFeatureStateW [MSI.@]
2371 * Checks the state of a feature
2374 * szProduct [I] Product's GUID string
2375 * szFeature [I] Feature's GUID string
2378 * INSTALLSTATE_LOCAL Feature is installed and usable
2379 * INSTALLSTATE_ABSENT Feature is absent
2380 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
2381 * INSTALLSTATE_UNKNOWN An error occurred
2382 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
2385 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
2387 WCHAR squishProduct
[33], comp
[GUID_SIZE
];
2389 LPWSTR components
, p
, parent_feature
, path
;
2393 BOOL missing
= FALSE
;
2394 BOOL machine
= FALSE
;
2395 BOOL source
= FALSE
;
2397 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
2399 if (!szProduct
|| !szFeature
)
2400 return INSTALLSTATE_INVALIDARG
;
2402 if (!squash_guid( szProduct
, squishProduct
))
2403 return INSTALLSTATE_INVALIDARG
;
2405 if (MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_USERMANAGED
,
2406 &hkey
, FALSE
) != ERROR_SUCCESS
&&
2407 MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2408 &hkey
, FALSE
) != ERROR_SUCCESS
)
2410 rc
= MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
2412 if (rc
!= ERROR_SUCCESS
)
2413 return INSTALLSTATE_UNKNOWN
;
2418 parent_feature
= msi_reg_get_val_str( hkey
, szFeature
);
2421 if (!parent_feature
)
2422 return INSTALLSTATE_UNKNOWN
;
2424 r
= (parent_feature
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
2425 msi_free(parent_feature
);
2426 if (r
== INSTALLSTATE_ABSENT
)
2430 rc
= MSIREG_OpenUserDataFeaturesKey(szProduct
,
2431 MSIINSTALLCONTEXT_MACHINE
,
2434 rc
= MSIREG_OpenUserDataFeaturesKey(szProduct
,
2435 MSIINSTALLCONTEXT_USERUNMANAGED
,
2438 if (rc
!= ERROR_SUCCESS
)
2439 return INSTALLSTATE_ADVERTISED
;
2441 components
= msi_reg_get_val_str( hkey
, szFeature
);
2444 TRACE("rc = %d buffer = %s\n", rc
, debugstr_w(components
));
2447 return INSTALLSTATE_ADVERTISED
;
2449 for( p
= components
; *p
&& *p
!= 2 ; p
+= 20)
2451 if (!decode_base85_guid( p
, &guid
))
2453 if (p
!= components
)
2456 msi_free(components
);
2457 return INSTALLSTATE_BADCONFIG
;
2460 StringFromGUID2(&guid
, comp
, GUID_SIZE
);
2463 rc
= MSIREG_OpenUserDataComponentKey(comp
, szLocalSid
, &hkey
, FALSE
);
2465 rc
= MSIREG_OpenUserDataComponentKey(comp
, NULL
, &hkey
, FALSE
);
2467 if (rc
!= ERROR_SUCCESS
)
2469 msi_free(components
);
2470 return INSTALLSTATE_ADVERTISED
;
2473 path
= msi_reg_get_val_str(hkey
, squishProduct
);
2476 else if (lstrlenW(path
) > 2 &&
2477 path
[0] >= '0' && path
[0] <= '9' &&
2478 path
[1] >= '0' && path
[1] <= '9')
2486 TRACE("%s %s -> %d\n", debugstr_w(szProduct
), debugstr_w(szFeature
), r
);
2487 msi_free(components
);
2490 return INSTALLSTATE_ADVERTISED
;
2493 return INSTALLSTATE_SOURCE
;
2495 return INSTALLSTATE_LOCAL
;
2498 /******************************************************************
2499 * MsiGetFileVersionA [MSI.@]
2501 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
2502 LPDWORD pcchVersionBuf
, LPSTR lpLangBuf
, LPDWORD pcchLangBuf
)
2504 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
2505 UINT ret
= ERROR_OUTOFMEMORY
;
2507 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
2508 (lpLangBuf
&& !pcchLangBuf
))
2509 return ERROR_INVALID_PARAMETER
;
2513 szwFilePath
= strdupAtoW( szFilePath
);
2518 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
2520 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
2521 if( !lpwVersionBuff
)
2525 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
2527 lpwLangBuff
= msi_alloc(*pcchLangBuf
*sizeof(WCHAR
));
2532 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
2533 lpwLangBuff
, pcchLangBuf
);
2535 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwVersionBuff
)
2536 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
2537 lpVersionBuf
, *pcchVersionBuf
+ 1, NULL
, NULL
);
2538 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwLangBuff
)
2539 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
2540 lpLangBuf
, *pcchLangBuf
+ 1, NULL
, NULL
);
2543 msi_free(szwFilePath
);
2544 msi_free(lpwVersionBuff
);
2545 msi_free(lpwLangBuff
);
2550 /******************************************************************
2551 * MsiGetFileVersionW [MSI.@]
2553 UINT WINAPI
MsiGetFileVersionW(LPCWSTR szFilePath
, LPWSTR lpVersionBuf
,
2554 LPDWORD pcchVersionBuf
, LPWSTR lpLangBuf
, LPDWORD pcchLangBuf
)
2556 static const WCHAR szVersionResource
[] = {'\\',0};
2557 static const WCHAR szVersionFormat
[] = {
2558 '%','d','.','%','d','.','%','d','.','%','d',0};
2559 static const WCHAR szLangResource
[] = {
2560 '\\','V','a','r','F','i','l','e','I','n','f','o','\\',
2561 'T','r','a','n','s','l','a','t','i','o','n',0};
2562 static const WCHAR szLangFormat
[] = {'%','d',0};
2564 DWORD dwVerLen
, gle
;
2565 LPVOID lpVer
= NULL
;
2566 VS_FIXEDFILEINFO
*ffi
;
2571 TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath
),
2572 lpVersionBuf
, pcchVersionBuf
?*pcchVersionBuf
:0,
2573 lpLangBuf
, pcchLangBuf
?*pcchLangBuf
:0);
2575 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
2576 (lpLangBuf
&& !pcchLangBuf
))
2577 return ERROR_INVALID_PARAMETER
;
2579 dwVerLen
= GetFileVersionInfoSizeW(szFilePath
, NULL
);
2582 gle
= GetLastError();
2583 if (gle
== ERROR_BAD_PATHNAME
)
2584 return ERROR_FILE_NOT_FOUND
;
2585 else if (gle
== ERROR_RESOURCE_DATA_NOT_FOUND
)
2586 return ERROR_FILE_INVALID
;
2591 lpVer
= msi_alloc(dwVerLen
);
2594 ret
= ERROR_OUTOFMEMORY
;
2598 if( !GetFileVersionInfoW(szFilePath
, 0, dwVerLen
, lpVer
) )
2600 ret
= GetLastError();
2606 if( VerQueryValueW(lpVer
, szVersionResource
, (LPVOID
*)&ffi
, &puLen
) &&
2609 wsprintfW(tmp
, szVersionFormat
,
2610 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
2611 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
));
2612 if (lpVersionBuf
) lstrcpynW(lpVersionBuf
, tmp
, *pcchVersionBuf
);
2614 if (strlenW(tmp
) >= *pcchVersionBuf
)
2615 ret
= ERROR_MORE_DATA
;
2617 *pcchVersionBuf
= lstrlenW(tmp
);
2621 if (lpVersionBuf
) *lpVersionBuf
= 0;
2622 *pcchVersionBuf
= 0;
2628 if (VerQueryValueW(lpVer
, szLangResource
, (LPVOID
*)&lang
, &puLen
) &&
2631 wsprintfW(tmp
, szLangFormat
, *lang
);
2632 if (lpLangBuf
) lstrcpynW(lpLangBuf
, tmp
, *pcchLangBuf
);
2634 if (strlenW(tmp
) >= *pcchLangBuf
)
2635 ret
= ERROR_MORE_DATA
;
2637 *pcchLangBuf
= lstrlenW(tmp
);
2641 if (lpLangBuf
) *lpLangBuf
= 0;
2651 /***********************************************************************
2652 * MsiGetFeatureUsageW [MSI.@]
2654 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
2655 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
2657 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
2658 pdwUseCount
, pwDateUsed
);
2659 return ERROR_CALL_NOT_IMPLEMENTED
;
2662 /***********************************************************************
2663 * MsiGetFeatureUsageA [MSI.@]
2665 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
2666 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
2668 LPWSTR prod
= NULL
, feat
= NULL
;
2669 UINT ret
= ERROR_OUTOFMEMORY
;
2671 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
2672 pdwUseCount
, pwDateUsed
);
2674 prod
= strdupAtoW( szProduct
);
2675 if (szProduct
&& !prod
)
2678 feat
= strdupAtoW( szFeature
);
2679 if (szFeature
&& !feat
)
2682 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
2691 /***********************************************************************
2692 * MsiUseFeatureExW [MSI.@]
2694 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
2695 DWORD dwInstallMode
, DWORD dwReserved
)
2699 TRACE("%s %s %i %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
2700 dwInstallMode
, dwReserved
);
2702 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
2705 return INSTALLSTATE_INVALIDARG
;
2707 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
2709 FIXME("mark product %s feature %s as used\n",
2710 debugstr_w(szProduct
), debugstr_w(szFeature
) );
2716 /***********************************************************************
2717 * MsiUseFeatureExA [MSI.@]
2719 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
2720 DWORD dwInstallMode
, DWORD dwReserved
)
2722 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
2723 LPWSTR prod
= NULL
, feat
= NULL
;
2725 TRACE("%s %s %i %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
2726 dwInstallMode
, dwReserved
);
2728 prod
= strdupAtoW( szProduct
);
2729 if (szProduct
&& !prod
)
2732 feat
= strdupAtoW( szFeature
);
2733 if (szFeature
&& !feat
)
2736 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
2745 /***********************************************************************
2746 * MsiUseFeatureW [MSI.@]
2748 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
2750 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
2753 /***********************************************************************
2754 * MsiUseFeatureA [MSI.@]
2756 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
2758 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
2761 /***********************************************************************
2762 * MSI_ProvideQualifiedComponentEx [internal]
2764 static UINT
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
2765 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
2766 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
2767 LPDWORD pcchPathBuf
)
2769 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
2770 feature
[MAX_FEATURE_CHARS
+1];
2776 TRACE("%s %s %i %s %i %i %p %p\n", debugstr_w(szComponent
),
2777 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
2778 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
2780 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
2781 if (rc
!= ERROR_SUCCESS
)
2782 return ERROR_INDEX_ABSENT
;
2784 info
= msi_reg_get_val_str( hkey
, szQualifier
);
2788 return ERROR_INDEX_ABSENT
;
2790 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
2793 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
2795 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
2799 if (rc
!= INSTALLSTATE_LOCAL
)
2800 return ERROR_FILE_NOT_FOUND
;
2802 return ERROR_SUCCESS
;
2805 /***********************************************************************
2806 * MsiProvideQualifiedComponentExW [MSI.@]
2808 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
2809 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
2810 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
2811 LPDWORD pcchPathBuf
)
2815 path
.unicode
= TRUE
;
2816 path
.str
.w
= lpPathBuf
;
2818 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
2819 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
2822 /***********************************************************************
2823 * MsiProvideQualifiedComponentExA [MSI.@]
2825 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
2826 LPCSTR szQualifier
, DWORD dwInstallMode
, LPCSTR szProduct
,
2827 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
2828 LPDWORD pcchPathBuf
)
2830 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
2831 UINT r
= ERROR_OUTOFMEMORY
;
2834 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent
),
2835 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
2836 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
2838 szwComponent
= strdupAtoW( szComponent
);
2839 if (szComponent
&& !szwComponent
)
2842 szwQualifier
= strdupAtoW( szQualifier
);
2843 if (szQualifier
&& !szwQualifier
)
2846 szwProduct
= strdupAtoW( szProduct
);
2847 if (szProduct
&& !szwProduct
)
2850 path
.unicode
= FALSE
;
2851 path
.str
.a
= lpPathBuf
;
2853 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
2854 dwInstallMode
, szwProduct
, Unused1
,
2855 Unused2
, &path
, pcchPathBuf
);
2857 msi_free(szwProduct
);
2858 msi_free(szwComponent
);
2859 msi_free(szwQualifier
);
2864 /***********************************************************************
2865 * MsiProvideQualifiedComponentW [MSI.@]
2867 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
2868 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
2869 LPDWORD pcchPathBuf
)
2871 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
2872 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
2875 /***********************************************************************
2876 * MsiProvideQualifiedComponentA [MSI.@]
2878 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
2879 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
2880 LPDWORD pcchPathBuf
)
2882 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
2883 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
2886 /***********************************************************************
2887 * MSI_GetUserInfo [internal]
2889 static USERINFOSTATE
MSI_GetUserInfo(LPCWSTR szProduct
,
2890 awstring
*lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
2891 awstring
*lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
2892 awstring
*lpSerialBuf
, LPDWORD pcchSerialBuf
)
2894 WCHAR squished_pc
[SQUISH_GUID_SIZE
];
2895 LPWSTR user
, org
, serial
;
2896 USERINFOSTATE state
;
2901 static const WCHAR szEmpty
[] = {0};
2903 TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct
), lpUserNameBuf
,
2904 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
2907 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
2908 return USERINFOSTATE_INVALIDARG
;
2910 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2911 &hkey
, FALSE
) != ERROR_SUCCESS
&&
2912 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2913 &hkey
, FALSE
) != ERROR_SUCCESS
&&
2914 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
2915 &hkey
, FALSE
) != ERROR_SUCCESS
)
2917 return USERINFOSTATE_UNKNOWN
;
2920 if (MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2921 NULL
, &props
, FALSE
) != ERROR_SUCCESS
&&
2922 MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
2923 NULL
, &props
, FALSE
) != ERROR_SUCCESS
)
2926 return USERINFOSTATE_ABSENT
;
2929 user
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGOWNERW
);
2930 org
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGCOMPANYW
);
2931 serial
= msi_reg_get_val_str(props
, INSTALLPROPERTY_PRODUCTIDW
);
2932 state
= USERINFOSTATE_ABSENT
;
2938 state
= USERINFOSTATE_PRESENT
;
2940 if (pcchUserNameBuf
)
2942 if (lpUserNameBuf
&& !user
)
2944 (*pcchUserNameBuf
)--;
2948 r
= msi_strcpy_to_awstring(user
, lpUserNameBuf
, pcchUserNameBuf
);
2949 if (r
== ERROR_MORE_DATA
)
2951 state
= USERINFOSTATE_MOREDATA
;
2959 if (!orgptr
) orgptr
= szEmpty
;
2961 r
= msi_strcpy_to_awstring(orgptr
, lpOrgNameBuf
, pcchOrgNameBuf
);
2962 if (r
== ERROR_MORE_DATA
)
2964 state
= USERINFOSTATE_MOREDATA
;
2977 r
= msi_strcpy_to_awstring(serial
, lpSerialBuf
, pcchSerialBuf
);
2978 if (r
== ERROR_MORE_DATA
)
2979 state
= USERINFOSTATE_MOREDATA
;
2990 /***********************************************************************
2991 * MsiGetUserInfoW [MSI.@]
2993 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
2994 LPWSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
2995 LPWSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
2996 LPWSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
2998 awstring user
, org
, serial
;
3000 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3001 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3002 (lpSerialBuf
&& !pcchSerialBuf
))
3003 return USERINFOSTATE_INVALIDARG
;
3005 user
.unicode
= TRUE
;
3006 user
.str
.w
= lpUserNameBuf
;
3008 org
.str
.w
= lpOrgNameBuf
;
3009 serial
.unicode
= TRUE
;
3010 serial
.str
.w
= lpSerialBuf
;
3012 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
3013 &org
, pcchOrgNameBuf
,
3014 &serial
, pcchSerialBuf
);
3017 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
3018 LPSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3019 LPSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3020 LPSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3022 awstring user
, org
, serial
;
3026 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3027 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3028 (lpSerialBuf
&& !pcchSerialBuf
))
3029 return USERINFOSTATE_INVALIDARG
;
3031 prod
= strdupAtoW( szProduct
);
3032 if (szProduct
&& !prod
)
3033 return ERROR_OUTOFMEMORY
;
3035 user
.unicode
= FALSE
;
3036 user
.str
.a
= lpUserNameBuf
;
3037 org
.unicode
= FALSE
;
3038 org
.str
.a
= lpOrgNameBuf
;
3039 serial
.unicode
= FALSE
;
3040 serial
.str
.a
= lpSerialBuf
;
3042 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
3043 &org
, pcchOrgNameBuf
,
3044 &serial
, pcchSerialBuf
);
3051 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
3055 MSIPACKAGE
*package
;
3056 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3058 TRACE("(%s)\n",debugstr_w(szProduct
));
3060 rc
= MsiOpenProductW(szProduct
,&handle
);
3061 if (rc
!= ERROR_SUCCESS
)
3062 return ERROR_INVALID_PARAMETER
;
3064 /* MsiCollectUserInfo cannot be called from a custom action. */
3065 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3067 return ERROR_CALL_NOT_IMPLEMENTED
;
3069 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
3070 msiobj_release( &package
->hdr
);
3072 MsiCloseHandle(handle
);
3077 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
3081 MSIPACKAGE
*package
;
3082 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3084 TRACE("(%s)\n",debugstr_a(szProduct
));
3086 rc
= MsiOpenProductA(szProduct
,&handle
);
3087 if (rc
!= ERROR_SUCCESS
)
3088 return ERROR_INVALID_PARAMETER
;
3090 /* MsiCollectUserInfo cannot be called from a custom action. */
3091 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3093 return ERROR_CALL_NOT_IMPLEMENTED
;
3095 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
3096 msiobj_release( &package
->hdr
);
3098 MsiCloseHandle(handle
);
3103 /***********************************************************************
3104 * MsiConfigureFeatureA [MSI.@]
3106 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
3108 LPWSTR prod
, feat
= NULL
;
3109 UINT r
= ERROR_OUTOFMEMORY
;
3111 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
3113 prod
= strdupAtoW( szProduct
);
3114 if (szProduct
&& !prod
)
3117 feat
= strdupAtoW( szFeature
);
3118 if (szFeature
&& !feat
)
3121 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
3130 /***********************************************************************
3131 * MsiConfigureFeatureW [MSI.@]
3133 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
3135 static const WCHAR szCostInit
[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
3136 MSIPACKAGE
*package
= NULL
;
3138 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
3141 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
3143 if (!szProduct
|| !szFeature
)
3144 return ERROR_INVALID_PARAMETER
;
3146 switch (eInstallState
)
3148 case INSTALLSTATE_DEFAULT
:
3149 /* FIXME: how do we figure out the default location? */
3150 eInstallState
= INSTALLSTATE_LOCAL
;
3152 case INSTALLSTATE_LOCAL
:
3153 case INSTALLSTATE_SOURCE
:
3154 case INSTALLSTATE_ABSENT
:
3155 case INSTALLSTATE_ADVERTISED
:
3158 return ERROR_INVALID_PARAMETER
;
3161 r
= MSI_OpenProductW( szProduct
, &package
);
3162 if (r
!= ERROR_SUCCESS
)
3165 sz
= sizeof(sourcepath
);
3166 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3167 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3169 sz
= sizeof(filename
);
3170 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3171 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3173 lstrcatW( sourcepath
, filename
);
3175 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
3177 r
= ACTION_PerformUIAction( package
, szCostInit
, -1 );
3178 if (r
!= ERROR_SUCCESS
)
3181 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
3182 if (r
!= ERROR_SUCCESS
)
3185 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
3188 msiobj_release( &package
->hdr
);
3193 /***********************************************************************
3194 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
3196 * Notes: undocumented
3198 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
3200 WCHAR path
[MAX_PATH
];
3202 TRACE("%d\n", dwReserved
);
3206 FIXME("dwReserved=%d\n", dwReserved
);
3207 return ERROR_INVALID_PARAMETER
;
3210 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
3211 return ERROR_FUNCTION_FAILED
;
3213 lstrcatW(path
, installerW
);
3215 if (!CreateDirectoryW(path
, NULL
))
3216 return ERROR_FUNCTION_FAILED
;
3218 return ERROR_SUCCESS
;
3221 /***********************************************************************
3222 * MsiGetShortcutTargetA [MSI.@]
3224 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
3225 LPSTR szProductCode
, LPSTR szFeatureId
,
3226 LPSTR szComponentCode
)
3229 const int len
= MAX_FEATURE_CHARS
+1;
3230 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
3233 target
= strdupAtoW( szShortcutTarget
);
3234 if (szShortcutTarget
&& !target
)
3235 return ERROR_OUTOFMEMORY
;
3239 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
3241 if (r
== ERROR_SUCCESS
)
3243 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
3244 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
3245 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
3250 /***********************************************************************
3251 * MsiGetShortcutTargetW [MSI.@]
3253 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
3254 LPWSTR szProductCode
, LPWSTR szFeatureId
,
3255 LPWSTR szComponentCode
)
3257 IShellLinkDataList
*dl
= NULL
;
3258 IPersistFile
*pf
= NULL
;
3259 LPEXP_DARWIN_LINK darwin
= NULL
;
3262 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
3263 szProductCode
, szFeatureId
, szComponentCode
);
3265 init
= CoInitialize(NULL
);
3267 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
3268 &IID_IPersistFile
, (LPVOID
*) &pf
);
3269 if( SUCCEEDED( r
) )
3271 r
= IPersistFile_Load( pf
, szShortcutTarget
,
3272 STGM_READ
| STGM_SHARE_DENY_WRITE
);
3273 if( SUCCEEDED( r
) )
3275 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
3277 if( SUCCEEDED( r
) )
3279 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
3281 IShellLinkDataList_Release( dl
);
3284 IPersistFile_Release( pf
);
3287 if (SUCCEEDED(init
))
3290 TRACE("darwin = %p\n", darwin
);
3297 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
3298 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
3299 LocalFree( darwin
);
3303 return ERROR_FUNCTION_FAILED
;
3306 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3307 DWORD dwReinstallMode
)
3309 MSIPACKAGE
* package
= NULL
;
3311 WCHAR sourcepath
[MAX_PATH
];
3312 WCHAR filename
[MAX_PATH
];
3313 static const WCHAR szLogVerbose
[] = {
3314 ' ','L','O','G','V','E','R','B','O','S','E',0 };
3315 static const WCHAR szInstalled
[] = { 'I','n','s','t','a','l','l','e','d',0};
3316 static const WCHAR szReinstall
[] = {'R','E','I','N','S','T','A','L','L',0};
3317 static const WCHAR szReinstallMode
[] = {'R','E','I','N','S','T','A','L','L','M','O','D','E',0};
3318 static const WCHAR szOne
[] = {'1',0};
3319 WCHAR reinstallmode
[11];
3323 FIXME("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
3326 ptr
= reinstallmode
;
3328 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
3330 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
3332 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
3334 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
3336 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
3338 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
3340 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
3342 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
3344 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
3346 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3350 sz
= sizeof(sourcepath
);
3351 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3352 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3354 sz
= sizeof(filename
);
3355 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3356 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3358 lstrcatW( sourcepath
, filename
);
3360 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3361 r
= MSI_OpenPackageW( sourcepath
, &package
);
3363 r
= MSI_OpenProductW( szProduct
, &package
);
3365 if (r
!= ERROR_SUCCESS
)
3368 MSI_SetPropertyW( package
, szReinstallMode
, reinstallmode
);
3369 MSI_SetPropertyW( package
, szInstalled
, szOne
);
3370 MSI_SetPropertyW( package
, szLogVerbose
, szOne
);
3371 MSI_SetPropertyW( package
, szReinstall
, szFeature
);
3373 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
3375 msiobj_release( &package
->hdr
);
3380 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
3381 DWORD dwReinstallMode
)
3387 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3390 wszProduct
= strdupAtoW(szProduct
);
3391 wszFeature
= strdupAtoW(szFeature
);
3393 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
3395 msi_free(wszProduct
);
3396 msi_free(wszFeature
);
3403 unsigned int buf
[4];
3404 unsigned char in
[64];
3405 unsigned char digest
[16];
3408 extern VOID WINAPI
MD5Init( MD5_CTX
*);
3409 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
3410 extern VOID WINAPI
MD5Final( MD5_CTX
*);
3412 /***********************************************************************
3413 * MsiGetFileHashW [MSI.@]
3415 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
3416 PMSIFILEHASHINFO pHash
)
3418 HANDLE handle
, mapping
;
3421 UINT r
= ERROR_FUNCTION_FAILED
;
3423 TRACE("%s %08x %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
3426 return ERROR_INVALID_PARAMETER
;
3429 return ERROR_PATH_NOT_FOUND
;
3432 return ERROR_INVALID_PARAMETER
;
3434 return ERROR_INVALID_PARAMETER
;
3435 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
3436 return ERROR_INVALID_PARAMETER
;
3438 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
3439 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
3440 if (handle
== INVALID_HANDLE_VALUE
)
3441 return ERROR_FILE_NOT_FOUND
;
3443 length
= GetFileSize( handle
, NULL
);
3445 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
3448 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
3454 MD5Update( &ctx
, p
, length
);
3456 UnmapViewOfFile( p
);
3458 memcpy( pHash
->dwData
, ctx
.digest
, sizeof pHash
->dwData
);
3461 CloseHandle( mapping
);
3463 CloseHandle( handle
);
3468 /***********************************************************************
3469 * MsiGetFileHashA [MSI.@]
3471 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
3472 PMSIFILEHASHINFO pHash
)
3477 TRACE("%s %08x %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
3479 file
= strdupAtoW( szFilePath
);
3480 if (szFilePath
&& !file
)
3481 return ERROR_OUTOFMEMORY
;
3483 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
3488 /***********************************************************************
3489 * MsiAdvertiseScriptW [MSI.@]
3491 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
3492 PHKEY phRegData
, BOOL fRemoveItems
)
3494 FIXME("%s %08x %p %d\n",
3495 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
3496 return ERROR_CALL_NOT_IMPLEMENTED
;
3499 /***********************************************************************
3500 * MsiAdvertiseScriptA [MSI.@]
3502 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
3503 PHKEY phRegData
, BOOL fRemoveItems
)
3505 FIXME("%s %08x %p %d\n",
3506 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
3507 return ERROR_CALL_NOT_IMPLEMENTED
;
3510 /***********************************************************************
3511 * MsiIsProductElevatedW [MSI.@]
3513 UINT WINAPI
MsiIsProductElevatedW( LPCWSTR szProduct
, BOOL
*pfElevated
)
3515 FIXME("%s %p - stub\n",
3516 debugstr_w( szProduct
), pfElevated
);
3518 return ERROR_SUCCESS
;
3521 /***********************************************************************
3522 * MsiIsProductElevatedA [MSI.@]
3524 UINT WINAPI
MsiIsProductElevatedA( LPCSTR szProduct
, BOOL
*pfElevated
)
3526 FIXME("%s %p - stub\n",
3527 debugstr_a( szProduct
), pfElevated
);
3529 return ERROR_SUCCESS
;
3532 /***********************************************************************
3533 * MsiSetExternalUIRecord [MSI.@]
3535 UINT WINAPI
MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD puiHandler
,
3536 DWORD dwMessageFilter
, LPVOID pvContext
,
3537 PINSTALLUI_HANDLER_RECORD ppuiPrevHandler
)
3539 FIXME("%p %08x %p %p\n", puiHandler
, dwMessageFilter
,pvContext
,
3541 return ERROR_CALL_NOT_IMPLEMENTED
;
3544 /***********************************************************************
3545 * MsiInstallMissingComponentW [MSI.@]
3547 UINT WINAPI
MsiInstallMissingComponentW(LPCWSTR szProduct
, LPCWSTR szComponent
, INSTALLSTATE eInstallState
)
3549 FIXME("(%s %s %d\n", debugstr_w(szProduct
), debugstr_w(szComponent
), eInstallState
);
3550 return ERROR_SUCCESS
;