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_OpenLocalManagedProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS)
55 *context = MSIINSTALLCONTEXT_USERMANAGED;
56 else if (MSIREG_OpenLocalClassesProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS)
57 *context = MSIINSTALLCONTEXT_MACHINE;
58 else if (MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS)
59 *context = MSIINSTALLCONTEXT_USERUNMANAGED;
63 if (*context == MSIINSTALLCONTEXT_NONE)
64 return ERROR_UNKNOWN_PRODUCT;
69 UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
72 LPWSTR szwProd = NULL;
74 TRACE("%s %p\n",debugstr_a(szProduct), phProduct);
78 szwProd = strdupAtoW( szProduct );
80 return ERROR_OUTOFMEMORY;
83 r = MsiOpenProductW( szwProd, phProduct );
90 static UINT MSI_OpenProductW(LPCWSTR szProduct, MSIPACKAGE **package)
95 MSIINSTALLCONTEXT context;
97 static const WCHAR managed[] = {
98 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0};
99 static const WCHAR local[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
101 TRACE("%s %p\n", debugstr_w(szProduct), package);
103 r = msi_locate_product(szProduct, &context);
104 if (r != ERROR_SUCCESS)
107 if (context == MSIINSTALLCONTEXT_MACHINE)
108 r = MSIREG_OpenLocalSystemInstallProps(szProduct, &props, FALSE);
109 else if (context == MSIINSTALLCONTEXT_USERMANAGED ||
110 context == MSIINSTALLCONTEXT_USERUNMANAGED)
111 r = MSIREG_OpenCurrentUserInstallProps(szProduct, &props, FALSE);
113 if (r != ERROR_SUCCESS)
114 return ERROR_UNKNOWN_PRODUCT;
116 if (context == MSIINSTALLCONTEXT_USERMANAGED)
117 path = msi_reg_get_val_str(props, managed);
119 path = msi_reg_get_val_str(props, local);
121 r = ERROR_UNKNOWN_PRODUCT;
123 if (!path || GetFileAttributesW(path) == INVALID_FILE_ATTRIBUTES)
126 if (PathIsRelativeW(path))
128 r = ERROR_INSTALL_PACKAGE_OPEN_FAILED;
132 r = MSI_OpenPackageW(path, package);
140 UINT WINAPI MsiOpenProductW(LPCWSTR szProduct, MSIHANDLE *phProduct)
142 MSIPACKAGE *package = NULL;
143 WCHAR squished_pc[GUID_SIZE];
146 if (!szProduct || !squash_guid(szProduct, squished_pc))
147 return ERROR_INVALID_PARAMETER;
150 return ERROR_INVALID_PARAMETER;
152 r = MSI_OpenProductW(szProduct, &package);
153 if (r != ERROR_SUCCESS)
156 *phProduct = alloc_msihandle(&package->hdr);
158 r = ERROR_NOT_ENOUGH_MEMORY;
160 msiobj_release(&package->hdr);
164 UINT WINAPI MsiAdvertiseProductA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
165 LPCSTR szTransforms, LANGID lgidLanguage)
167 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath),
168 debugstr_a(szScriptfilePath), debugstr_a(szTransforms), lgidLanguage);
169 return ERROR_CALL_NOT_IMPLEMENTED;
172 UINT WINAPI MsiAdvertiseProductW(LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
173 LPCWSTR szTransforms, LANGID lgidLanguage)
175 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath),
176 debugstr_w(szScriptfilePath), debugstr_w(szTransforms), lgidLanguage);
177 return ERROR_CALL_NOT_IMPLEMENTED;
180 UINT WINAPI MsiAdvertiseProductExA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
181 LPCSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
183 FIXME("%s %s %s %08x %08x %08x\n", debugstr_a(szPackagePath),
184 debugstr_a(szScriptfilePath), debugstr_a(szTransforms),
185 lgidLanguage, dwPlatform, dwOptions);
186 return ERROR_CALL_NOT_IMPLEMENTED;
189 UINT WINAPI MsiAdvertiseProductExW( LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
190 LPCWSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
192 FIXME("%s %s %s %08x %08x %08x\n", debugstr_w(szPackagePath),
193 debugstr_w(szScriptfilePath), debugstr_w(szTransforms),
194 lgidLanguage, dwPlatform, dwOptions);
195 return ERROR_CALL_NOT_IMPLEMENTED;
198 UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
200 LPWSTR szwPath = NULL, szwCommand = NULL;
201 UINT r = ERROR_OUTOFMEMORY;
203 TRACE("%s %s\n",debugstr_a(szPackagePath), debugstr_a(szCommandLine));
207 szwPath = strdupAtoW( szPackagePath );
214 szwCommand = strdupAtoW( szCommandLine );
219 r = MsiInstallProductW( szwPath, szwCommand );
223 msi_free( szwCommand );
228 UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
230 MSIPACKAGE *package = NULL;
233 TRACE("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
235 r = MSI_OpenPackageW( szPackagePath, &package );
236 if (r == ERROR_SUCCESS)
238 r = MSI_InstallPackage( package, szPackagePath, szCommandLine );
239 msiobj_release( &package->hdr );
245 UINT WINAPI MsiReinstallProductA(LPCSTR szProduct, DWORD dwReinstallMode)
247 FIXME("%s %08x\n", debugstr_a(szProduct), dwReinstallMode);
248 return ERROR_CALL_NOT_IMPLEMENTED;
251 UINT WINAPI MsiReinstallProductW(LPCWSTR szProduct, DWORD dwReinstallMode)
253 FIXME("%s %08x\n", debugstr_w(szProduct), dwReinstallMode);
254 return ERROR_CALL_NOT_IMPLEMENTED;
257 UINT WINAPI MsiApplyPatchA(LPCSTR szPatchPackage, LPCSTR szInstallPackage,
258 INSTALLTYPE eInstallType, LPCSTR szCommandLine)
260 LPWSTR patch_package = NULL;
261 LPWSTR install_package = NULL;
262 LPWSTR command_line = NULL;
263 UINT r = ERROR_OUTOFMEMORY;
265 TRACE("%s %s %d %s\n", debugstr_a(szPatchPackage), debugstr_a(szInstallPackage),
266 eInstallType, debugstr_a(szCommandLine));
268 if (szPatchPackage && !(patch_package = strdupAtoW(szPatchPackage)))
271 if (szInstallPackage && !(install_package = strdupAtoW(szInstallPackage)))
274 if (szCommandLine && !(command_line = strdupAtoW(szCommandLine)))
277 r = MsiApplyPatchW(patch_package, install_package, eInstallType, command_line);
280 msi_free(patch_package);
281 msi_free(install_package);
282 msi_free(command_line);
287 UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage,
288 INSTALLTYPE eInstallType, LPCWSTR szCommandLine)
290 MSIHANDLE patch, info;
293 LPCWSTR cmd_ptr = szCommandLine;
295 LPWSTR cmd = NULL, codes = NULL;
297 static const WCHAR space[] = {' ',0};
298 static const WCHAR patcheq[] = {'P','A','T','C','H','=',0};
299 static WCHAR empty[] = {0};
301 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage), debugstr_w(szInstallPackage),
302 eInstallType, debugstr_w(szCommandLine));
304 if (szInstallPackage || eInstallType == INSTALLTYPE_NETWORK_IMAGE ||
305 eInstallType == INSTALLTYPE_SINGLE_INSTANCE)
307 FIXME("Only reading target products from patch\n");
308 return ERROR_CALL_NOT_IMPLEMENTED;
311 r = MsiOpenDatabaseW(szPatchPackage, MSIDBOPEN_READONLY, &patch);
312 if (r != ERROR_SUCCESS)
315 r = MsiGetSummaryInformationW(patch, NULL, 0, &info);
316 if (r != ERROR_SUCCESS)
319 r = MsiSummaryInfoGetPropertyW(info, PID_TEMPLATE, &type, NULL, NULL, empty, &size);
320 if (r != ERROR_MORE_DATA || !size || type != VT_LPSTR)
322 ERR("Failed to read product codes from patch\n");
326 codes = msi_alloc(++size * sizeof(WCHAR));
329 r = ERROR_OUTOFMEMORY;
333 r = MsiSummaryInfoGetPropertyW(info, PID_TEMPLATE, &type, NULL, NULL, codes, &size);
334 if (r != ERROR_SUCCESS)
340 size = lstrlenW(cmd_ptr) + lstrlenW(patcheq) + lstrlenW(szPatchPackage) + 1;
341 cmd = msi_alloc(size * sizeof(WCHAR));
344 r = ERROR_OUTOFMEMORY;
348 lstrcpyW(cmd, cmd_ptr);
349 if (szCommandLine) lstrcatW(cmd, space);
350 lstrcatW(cmd, patcheq);
351 lstrcatW(cmd, szPatchPackage);
354 while ((end = strchrW(beg, '}')))
358 r = MsiConfigureProductExW(beg, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
359 if (r != ERROR_SUCCESS)
369 MsiCloseHandle(info);
370 MsiCloseHandle(patch);
375 UINT WINAPI MsiDetermineApplicablePatchesA(LPCSTR szProductPackagePath,
376 DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOA pPatchInfo)
378 FIXME("(%s, %d, %p): stub!\n", debugstr_a(szProductPackagePath),
379 cPatchInfo, pPatchInfo);
381 return ERROR_CALL_NOT_IMPLEMENTED;
384 UINT WINAPI MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath,
385 DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOW pPatchInfo)
387 FIXME("(%s, %d, %p): stub!\n", debugstr_w(szProductPackagePath),
388 cPatchInfo, pPatchInfo);
390 return ERROR_CALL_NOT_IMPLEMENTED;
393 static UINT msi_open_package(LPCWSTR product, MSIINSTALLCONTEXT context,
394 MSIPACKAGE **package)
400 WCHAR sourcepath[MAX_PATH];
401 WCHAR filename[MAX_PATH];
403 static const WCHAR szLocalPackage[] = {
404 'L','o','c','a','l','P','a','c','k','a','g','e',0};
406 if (context == MSIINSTALLCONTEXT_MACHINE)
407 r = MSIREG_OpenLocalSystemInstallProps(product, &props, FALSE);
409 r = MSIREG_OpenCurrentUserInstallProps(product, &props, FALSE);
411 if (r != ERROR_SUCCESS)
412 return ERROR_BAD_CONFIGURATION;
414 localpack = msi_reg_get_val_str(props, szLocalPackage);
417 lstrcpyW(sourcepath, localpack);
421 if (!localpack || GetFileAttributesW(sourcepath) == INVALID_FILE_ATTRIBUTES)
423 sz = sizeof(sourcepath);
424 MsiSourceListGetInfoW(product, NULL, context, MSICODE_PRODUCT,
425 INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
427 sz = sizeof(filename);
428 MsiSourceListGetInfoW(product, NULL, context, MSICODE_PRODUCT,
429 INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
431 lstrcatW(sourcepath, filename);
434 if (GetFileAttributesW(sourcepath) == INVALID_FILE_ATTRIBUTES)
435 return ERROR_INSTALL_SOURCE_ABSENT;
437 return MSI_OpenPackageW(sourcepath, package);
440 UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
441 INSTALLSTATE eInstallState, LPCWSTR szCommandLine)
443 MSIPACKAGE* package = NULL;
444 MSIINSTALLCONTEXT context;
447 WCHAR sourcepath[MAX_PATH];
450 static const WCHAR szInstalled[] = {
451 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
452 static const WCHAR szRemoveAll[] = {
453 ' ','R','E','M','O','V','E','=','A','L','L',0};
454 static const WCHAR szMachine[] = {
455 ' ','A','L','L','U','S','E','R','S','=','1',0};
457 TRACE("%s %d %d %s\n",debugstr_w(szProduct), iInstallLevel, eInstallState,
458 debugstr_w(szCommandLine));
460 if (!szProduct || lstrlenW(szProduct) != GUID_SIZE - 1)
461 return ERROR_INVALID_PARAMETER;
463 if (eInstallState == INSTALLSTATE_ADVERTISED ||
464 eInstallState == INSTALLSTATE_SOURCE)
466 FIXME("State %d not implemented\n", eInstallState);
467 return ERROR_CALL_NOT_IMPLEMENTED;
470 r = msi_locate_product(szProduct, &context);
471 if (r != ERROR_SUCCESS)
474 r = msi_open_package(szProduct, context, &package);
475 if (r != ERROR_SUCCESS)
478 sz = lstrlenW(szInstalled) + 1;
481 sz += lstrlenW(szCommandLine);
483 if (eInstallState == INSTALLSTATE_ABSENT)
484 sz += lstrlenW(szRemoveAll);
486 if (context == MSIINSTALLCONTEXT_MACHINE)
487 sz += lstrlenW(szMachine);
489 commandline = msi_alloc(sz * sizeof(WCHAR));
492 r = ERROR_OUTOFMEMORY;
498 lstrcpyW(commandline,szCommandLine);
500 if (MsiQueryProductStateW(szProduct) != INSTALLSTATE_UNKNOWN)
501 lstrcatW(commandline,szInstalled);
503 if (eInstallState == INSTALLSTATE_ABSENT)
504 lstrcatW(commandline, szRemoveAll);
506 if (context == MSIINSTALLCONTEXT_MACHINE)
507 lstrcatW(commandline, szMachine);
509 r = MSI_InstallPackage( package, sourcepath, commandline );
511 msi_free(commandline);
514 msiobj_release( &package->hdr );
519 UINT WINAPI MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel,
520 INSTALLSTATE eInstallState, LPCSTR szCommandLine)
522 LPWSTR szwProduct = NULL;
523 LPWSTR szwCommandLine = NULL;
524 UINT r = ERROR_OUTOFMEMORY;
528 szwProduct = strdupAtoW( szProduct );
535 szwCommandLine = strdupAtoW( szCommandLine );
540 r = MsiConfigureProductExW( szwProduct, iInstallLevel, eInstallState,
543 msi_free( szwProduct );
544 msi_free( szwCommandLine);
549 UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel,
550 INSTALLSTATE eInstallState)
552 LPWSTR szwProduct = NULL;
555 TRACE("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
559 szwProduct = strdupAtoW( szProduct );
561 return ERROR_OUTOFMEMORY;
564 r = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
565 msi_free( szwProduct );
570 UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel,
571 INSTALLSTATE eInstallState)
573 return MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, NULL);
576 UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer)
578 LPWSTR szwComponent = NULL;
580 WCHAR szwBuffer[GUID_SIZE];
582 TRACE("%s %s\n",debugstr_a(szComponent), debugstr_a(szBuffer));
586 szwComponent = strdupAtoW( szComponent );
588 return ERROR_OUTOFMEMORY;
592 r = MsiGetProductCodeW( szwComponent, szwBuffer );
595 WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, GUID_SIZE, NULL, NULL);
597 msi_free( szwComponent );
602 UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
605 HKEY compkey, prodkey;
606 WCHAR squished_comp[GUID_SIZE];
607 WCHAR squished_prod[GUID_SIZE];
608 DWORD sz = GUID_SIZE;
610 TRACE("%s %p\n", debugstr_w(szComponent), szBuffer);
612 if (!szComponent || !*szComponent)
613 return ERROR_INVALID_PARAMETER;
615 if (!squash_guid(szComponent, squished_comp))
616 return ERROR_INVALID_PARAMETER;
618 if (MSIREG_OpenUserDataComponentKey(szComponent, &compkey, FALSE) != ERROR_SUCCESS &&
619 MSIREG_OpenLocalSystemComponentKey(szComponent, &compkey, FALSE) != ERROR_SUCCESS)
621 return ERROR_UNKNOWN_COMPONENT;
624 rc = RegEnumValueW(compkey, 0, squished_prod, &sz, NULL, NULL, NULL, NULL);
625 if (rc != ERROR_SUCCESS)
627 RegCloseKey(compkey);
628 return ERROR_UNKNOWN_COMPONENT;
631 /* check simple case, only one product */
632 rc = RegEnumValueW(compkey, 1, squished_prod, &sz, NULL, NULL, NULL, NULL);
633 if (rc == ERROR_NO_MORE_ITEMS)
640 while ((rc = RegEnumValueW(compkey, index, squished_prod, &sz,
641 NULL, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS)
645 unsquash_guid(squished_prod, szBuffer);
647 if (MSIREG_OpenLocalManagedProductKey(szBuffer, &prodkey, FALSE) == ERROR_SUCCESS ||
648 MSIREG_OpenUserProductsKey(szBuffer, &prodkey, FALSE) == ERROR_SUCCESS ||
649 MSIREG_OpenLocalClassesProductKey(szBuffer, &prodkey, FALSE) == ERROR_SUCCESS)
651 RegCloseKey(prodkey);
657 rc = ERROR_INSTALL_FAILURE;
660 RegCloseKey(compkey);
661 unsquash_guid(squished_prod, szBuffer);
665 static LPWSTR msi_reg_get_value(HKEY hkey, LPCWSTR name, DWORD *type)
671 static const WCHAR format[] = {'%','d',0};
673 res = RegQueryValueExW(hkey, name, NULL, type, NULL, NULL);
674 if (res != ERROR_SUCCESS)
678 return msi_reg_get_val_str(hkey, name);
680 if (!msi_reg_get_val_dword(hkey, name, &dval))
683 sprintfW(temp, format, dval);
684 return strdupW(temp);
687 static UINT WINAPI MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
688 awstring *szValue, LPDWORD pcchValueBuf)
690 UINT r = ERROR_UNKNOWN_PROPERTY;
691 HKEY prodkey, userdata, source;
693 WCHAR squished_pc[GUID_SIZE];
694 WCHAR packagecode[GUID_SIZE];
695 BOOL classes = FALSE;
696 BOOL badconfig = FALSE;
698 DWORD save, type = REG_NONE;
700 static WCHAR empty[] = {0};
701 static const WCHAR sourcelist[] = {
702 'S','o','u','r','c','e','L','i','s','t',0};
703 static const WCHAR display_name[] = {
704 'D','i','s','p','l','a','y','N','a','m','e',0};
705 static const WCHAR display_version[] = {
706 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
707 static const WCHAR assignment[] = {
708 'A','s','s','i','g','n','m','e','n','t',0};
710 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
711 debugstr_w(szAttribute), szValue, pcchValueBuf);
713 if ((szValue->str.w && !pcchValueBuf) || !szProduct || !szAttribute)
714 return ERROR_INVALID_PARAMETER;
716 if (!squash_guid(szProduct, squished_pc))
717 return ERROR_INVALID_PARAMETER;
719 r = MSIREG_OpenLocalManagedProductKey(szProduct, &prodkey, FALSE);
720 if (r != ERROR_SUCCESS)
722 r = MSIREG_OpenUserProductsKey(szProduct, &prodkey, FALSE);
723 if (r != ERROR_SUCCESS)
725 r = MSIREG_OpenLocalClassesProductKey(szProduct, &prodkey, FALSE);
726 if (r == ERROR_SUCCESS)
732 MSIREG_OpenLocalSystemProductKey(szProduct, &userdata, FALSE);
734 MSIREG_OpenCurrentUserInstallProps(szProduct, &userdata, FALSE);
736 if (!lstrcmpW(szAttribute, INSTALLPROPERTY_HELPLINKW) ||
737 !lstrcmpW(szAttribute, INSTALLPROPERTY_HELPTELEPHONEW) ||
738 !lstrcmpW(szAttribute, INSTALLPROPERTY_INSTALLDATEW) ||
739 !lstrcmpW(szAttribute, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW) ||
740 !lstrcmpW(szAttribute, INSTALLPROPERTY_INSTALLLOCATIONW) ||
741 !lstrcmpW(szAttribute, INSTALLPROPERTY_INSTALLSOURCEW) ||
742 !lstrcmpW(szAttribute, INSTALLPROPERTY_LOCALPACKAGEW) ||
743 !lstrcmpW(szAttribute, INSTALLPROPERTY_PUBLISHERW) ||
744 !lstrcmpW(szAttribute, INSTALLPROPERTY_URLINFOABOUTW) ||
745 !lstrcmpW(szAttribute, INSTALLPROPERTY_URLUPDATEINFOW) ||
746 !lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONMINORW) ||
747 !lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONMAJORW) ||
748 !lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONSTRINGW) ||
749 !lstrcmpW(szAttribute, INSTALLPROPERTY_PRODUCTIDW) ||
750 !lstrcmpW(szAttribute, INSTALLPROPERTY_REGCOMPANYW) ||
751 !lstrcmpW(szAttribute, INSTALLPROPERTY_REGOWNERW))
755 r = ERROR_UNKNOWN_PRODUCT;
760 return ERROR_UNKNOWN_PROPERTY;
762 if (!lstrcmpW(szAttribute, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW))
763 szAttribute = display_name;
764 else if (!lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONSTRINGW))
765 szAttribute = display_version;
767 val = msi_reg_get_value(userdata, szAttribute, &type);
771 else if (!lstrcmpW(szAttribute, INSTALLPROPERTY_INSTANCETYPEW) ||
772 !lstrcmpW(szAttribute, INSTALLPROPERTY_TRANSFORMSW) ||
773 !lstrcmpW(szAttribute, INSTALLPROPERTY_LANGUAGEW) ||
774 !lstrcmpW(szAttribute, INSTALLPROPERTY_PRODUCTNAMEW) ||
775 !lstrcmpW(szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW) ||
776 !lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGECODEW) ||
777 !lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONW) ||
778 !lstrcmpW(szAttribute, INSTALLPROPERTY_PRODUCTICONW) ||
779 !lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGENAMEW) ||
780 !lstrcmpW(szAttribute, INSTALLPROPERTY_AUTHORIZED_LUA_APPW))
784 r = ERROR_UNKNOWN_PRODUCT;
788 if (!lstrcmpW(szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW))
789 szAttribute = assignment;
791 if (!lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGENAMEW))
793 res = RegOpenKeyW(prodkey, sourcelist, &source);
794 if (res == ERROR_SUCCESS)
795 val = msi_reg_get_value(source, szAttribute, &type);
801 val = msi_reg_get_value(prodkey, szAttribute, &type);
806 if (val != empty && type != REG_DWORD &&
807 !lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGECODEW))
809 if (lstrlenW(val) != SQUISH_GUID_SIZE - 1)
813 unsquash_guid(val, packagecode);
815 val = strdupW(packagecode);
822 r = ERROR_UNKNOWN_PROPERTY;
828 save = *pcchValueBuf;
830 if (lstrlenW(val) < *pcchValueBuf)
831 r = msi_strcpy_to_awstring(val, szValue, pcchValueBuf);
832 else if (szValue->str.a || szValue->str.w)
836 *pcchValueBuf = lstrlenW(val);
837 else if (r == ERROR_SUCCESS)
839 *pcchValueBuf = save;
840 r = ERROR_BAD_CONFIGURATION;
844 r = ERROR_BAD_CONFIGURATION;
850 RegCloseKey(prodkey);
851 RegCloseKey(userdata);
855 UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
856 LPSTR szBuffer, LPDWORD pcchValueBuf)
858 LPWSTR szwProduct, szwAttribute = NULL;
859 UINT r = ERROR_OUTOFMEMORY;
862 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
863 szBuffer, pcchValueBuf);
865 szwProduct = strdupAtoW( szProduct );
866 if( szProduct && !szwProduct )
869 szwAttribute = strdupAtoW( szAttribute );
870 if( szAttribute && !szwAttribute )
873 buffer.unicode = FALSE;
874 buffer.str.a = szBuffer;
876 r = MSI_GetProductInfo( szwProduct, szwAttribute,
877 &buffer, pcchValueBuf );
880 msi_free( szwProduct );
881 msi_free( szwAttribute );
886 UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
887 LPWSTR szBuffer, LPDWORD pcchValueBuf)
891 TRACE("%s %s %p %p\n", debugstr_w(szProduct), debugstr_w(szAttribute),
892 szBuffer, pcchValueBuf);
894 buffer.unicode = TRUE;
895 buffer.str.w = szBuffer;
897 return MSI_GetProductInfo( szProduct, szAttribute,
898 &buffer, pcchValueBuf );
901 UINT WINAPI MsiGetProductInfoExA(LPCSTR szProductCode, LPCSTR szUserSid,
902 MSIINSTALLCONTEXT dwContext, LPCSTR szProperty,
903 LPSTR szValue, LPDWORD pcchValue)
905 LPWSTR product = NULL;
906 LPWSTR usersid = NULL;
907 LPWSTR property = NULL;
912 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_a(szProductCode),
913 debugstr_a(szUserSid), dwContext, debugstr_a(szProperty),
916 if (szValue && !pcchValue)
917 return ERROR_INVALID_PARAMETER;
919 if (szProductCode) product = strdupAtoW(szProductCode);
920 if (szUserSid) usersid = strdupAtoW(szUserSid);
921 if (szProperty) property = strdupAtoW(szProperty);
923 r = MsiGetProductInfoExW(product, usersid, dwContext, property,
925 if (r != ERROR_SUCCESS)
928 value = msi_alloc(++len * sizeof(WCHAR));
931 r = ERROR_OUTOFMEMORY;
935 r = MsiGetProductInfoExW(product, usersid, dwContext, property,
937 if (r != ERROR_SUCCESS)
943 len = WideCharToMultiByte(CP_ACP, 0, value, -1, NULL, 0, NULL, NULL);
944 if (*pcchValue >= len)
945 WideCharToMultiByte(CP_ACP, 0, value, -1, szValue, len, NULL, NULL);
953 if (*pcchValue <= len || !szValue)
954 len = len * sizeof(WCHAR) - 1;
956 *pcchValue = len - 1;
967 static UINT msi_copy_outval(LPWSTR val, LPWSTR out, LPDWORD size)
972 return ERROR_UNKNOWN_PROPERTY;
976 if (lstrlenW(val) >= *size)
987 *size = lstrlenW(val);
989 return ERROR_SUCCESS;
992 UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
993 MSIINSTALLCONTEXT dwContext, LPCWSTR szProperty,
994 LPWSTR szValue, LPDWORD pcchValue)
996 WCHAR squished_pc[GUID_SIZE];
998 LPCWSTR package = NULL;
999 HKEY props = NULL, prod;
1000 HKEY classes = NULL, managed;
1003 UINT r = ERROR_UNKNOWN_PRODUCT;
1005 static const WCHAR one[] = {'1',0};
1006 static const WCHAR five[] = {'5',0};
1007 static const WCHAR empty[] = {0};
1008 static const WCHAR displayname[] = {
1009 'D','i','s','p','l','a','y','N','a','m','e',0};
1010 static const WCHAR displayversion[] = {
1011 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1012 static const WCHAR managed_local_package[] = {
1013 'M','a','n','a','g','e','d','L','o','c','a','l',
1014 'P','a','c','k','a','g','e',0};
1016 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_w(szProductCode),
1017 debugstr_w(szUserSid), dwContext, debugstr_w(szProperty),
1018 szValue, pcchValue);
1020 if (!szProductCode || !squash_guid(szProductCode, squished_pc))
1021 return ERROR_INVALID_PARAMETER;
1023 if (szValue && !pcchValue)
1024 return ERROR_INVALID_PARAMETER;
1026 if (dwContext != MSIINSTALLCONTEXT_USERUNMANAGED &&
1027 dwContext != MSIINSTALLCONTEXT_USERMANAGED &&
1028 dwContext != MSIINSTALLCONTEXT_MACHINE)
1029 return ERROR_INVALID_PARAMETER;
1031 if (!szProperty || !*szProperty)
1032 return ERROR_INVALID_PARAMETER;
1034 if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
1035 return ERROR_INVALID_PARAMETER;
1037 MSIREG_OpenLocalManagedProductKey(szProductCode, &managed, FALSE);
1038 MSIREG_OpenUserProductsKey(szProductCode, &prod, FALSE);
1040 if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
1042 package = INSTALLPROPERTY_LOCALPACKAGEW;
1043 MSIREG_OpenCurrentUserInstallProps(szProductCode, &props, FALSE);
1045 if (!props && !prod)
1048 else if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
1050 package = managed_local_package;
1051 MSIREG_OpenCurrentUserInstallProps(szProductCode, &props, FALSE);
1053 if (!props && !managed)
1056 else if (dwContext == MSIINSTALLCONTEXT_MACHINE)
1058 package = INSTALLPROPERTY_LOCALPACKAGEW;
1059 MSIREG_OpenLocalSystemProductKey(szProductCode, &props, FALSE);
1060 MSIREG_OpenLocalClassesProductKey(szProductCode, &classes, FALSE);
1062 if (!props && !classes)
1066 if (!lstrcmpW(szProperty, INSTALLPROPERTY_HELPLINKW) ||
1067 !lstrcmpW(szProperty, INSTALLPROPERTY_HELPTELEPHONEW) ||
1068 !lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLDATEW) ||
1069 !lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW) ||
1070 !lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLLOCATIONW) ||
1071 !lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLSOURCEW) ||
1072 !lstrcmpW(szProperty, INSTALLPROPERTY_LOCALPACKAGEW) ||
1073 !lstrcmpW(szProperty, INSTALLPROPERTY_PUBLISHERW) ||
1074 !lstrcmpW(szProperty, INSTALLPROPERTY_URLINFOABOUTW) ||
1075 !lstrcmpW(szProperty, INSTALLPROPERTY_URLUPDATEINFOW) ||
1076 !lstrcmpW(szProperty, INSTALLPROPERTY_VERSIONMINORW) ||
1077 !lstrcmpW(szProperty, INSTALLPROPERTY_VERSIONMAJORW) ||
1078 !lstrcmpW(szProperty, INSTALLPROPERTY_VERSIONSTRINGW) ||
1079 !lstrcmpW(szProperty, INSTALLPROPERTY_PRODUCTIDW) ||
1080 !lstrcmpW(szProperty, INSTALLPROPERTY_REGCOMPANYW) ||
1081 !lstrcmpW(szProperty, INSTALLPROPERTY_REGOWNERW) ||
1082 !lstrcmpW(szProperty, INSTALLPROPERTY_INSTANCETYPEW))
1084 val = msi_reg_get_value(props, package, &type);
1087 if (prod || classes)
1088 r = ERROR_UNKNOWN_PROPERTY;
1095 if (!lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW))
1096 szProperty = displayname;
1097 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_VERSIONSTRINGW))
1098 szProperty = displayversion;
1100 val = msi_reg_get_value(props, szProperty, &type);
1102 val = strdupW(empty);
1104 r = msi_copy_outval(val, szValue, pcchValue);
1106 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_TRANSFORMSW) ||
1107 !lstrcmpW(szProperty, INSTALLPROPERTY_LANGUAGEW) ||
1108 !lstrcmpW(szProperty, INSTALLPROPERTY_PRODUCTNAMEW) ||
1109 !lstrcmpW(szProperty, INSTALLPROPERTY_PACKAGECODEW) ||
1110 !lstrcmpW(szProperty, INSTALLPROPERTY_VERSIONW) ||
1111 !lstrcmpW(szProperty, INSTALLPROPERTY_PRODUCTICONW) ||
1112 !lstrcmpW(szProperty, INSTALLPROPERTY_PACKAGENAMEW) ||
1113 !lstrcmpW(szProperty, INSTALLPROPERTY_AUTHORIZED_LUA_APPW))
1115 if (!prod && !classes)
1118 if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
1120 else if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
1122 else if (dwContext == MSIINSTALLCONTEXT_MACHINE)
1125 val = msi_reg_get_value(hkey, szProperty, &type);
1127 val = strdupW(empty);
1129 r = msi_copy_outval(val, szValue, pcchValue);
1131 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_PRODUCTSTATEW))
1133 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
1137 val = msi_reg_get_value(props, package, &type);
1142 val = strdupW(five);
1147 r = msi_copy_outval(val, szValue, pcchValue);
1150 else if (props && (val = msi_reg_get_value(props, package, &type)))
1153 val = strdupW(five);
1154 r = msi_copy_outval(val, szValue, pcchValue);
1158 if (prod || managed)
1163 r = msi_copy_outval(val, szValue, pcchValue);
1165 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_ASSIGNMENTTYPEW))
1167 if (!prod && !classes)
1171 val = strdupW(empty);
1172 r = msi_copy_outval(val, szValue, pcchValue);
1175 r = ERROR_UNKNOWN_PROPERTY;
1180 RegCloseKey(managed);
1181 RegCloseKey(classes);
1187 UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
1189 LPWSTR szwLogFile = NULL;
1192 TRACE("%08x %s %08x\n", dwLogMode, debugstr_a(szLogFile), attributes);
1196 szwLogFile = strdupAtoW( szLogFile );
1198 return ERROR_OUTOFMEMORY;
1200 r = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
1201 msi_free( szwLogFile );
1205 UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
1207 HANDLE file = INVALID_HANDLE_VALUE;
1209 TRACE("%08x %s %08x\n", dwLogMode, debugstr_w(szLogFile), attributes);
1213 lstrcpyW(gszLogFile,szLogFile);
1214 if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
1215 DeleteFileW(szLogFile);
1216 file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
1217 FILE_ATTRIBUTE_NORMAL, NULL);
1218 if (file != INVALID_HANDLE_VALUE)
1221 ERR("Unable to enable log %s\n",debugstr_w(szLogFile));
1224 gszLogFile[0] = '\0';
1226 return ERROR_SUCCESS;
1229 UINT WINAPI MsiEnumComponentCostsW(MSIHANDLE hInstall, LPCWSTR szComponent,
1230 DWORD dwIndex, INSTALLSTATE iState,
1231 LPWSTR lpDriveBuf, DWORD *pcchDriveBuf,
1232 int *piCost, int *pTempCost)
1234 FIXME("(%ld, %s, %d, %d, %p, %p, %p %p): stub!\n", hInstall,
1235 debugstr_w(szComponent), dwIndex, iState, lpDriveBuf,
1236 pcchDriveBuf, piCost, pTempCost);
1238 return ERROR_NO_MORE_ITEMS;
1241 UINT WINAPI MsiQueryComponentStateA(LPCSTR szProductCode,
1242 LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext,
1243 LPCSTR szComponent, INSTALLSTATE *pdwState)
1245 LPWSTR prodcode = NULL, usersid = NULL, comp = NULL;
1248 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode),
1249 debugstr_a(szUserSid), dwContext, debugstr_a(szComponent), pdwState);
1251 if (szProductCode && !(prodcode = strdupAtoW(szProductCode)))
1252 return ERROR_OUTOFMEMORY;
1254 if (szUserSid && !(usersid = strdupAtoW(szUserSid)))
1255 return ERROR_OUTOFMEMORY;
1257 if (szComponent && !(comp = strdupAtoW(szComponent)))
1258 return ERROR_OUTOFMEMORY;
1260 r = MsiQueryComponentStateW(prodcode, usersid, dwContext, comp, pdwState);
1269 static BOOL msi_comp_find_prod_key(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
1274 if (context == MSIINSTALLCONTEXT_MACHINE)
1275 r = MSIREG_OpenLocalClassesProductKey(prodcode, &hkey, FALSE);
1276 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
1277 r = MSIREG_OpenUserProductsKey(prodcode, &hkey, FALSE);
1279 r = MSIREG_OpenLocalManagedProductKey(prodcode, &hkey, FALSE);
1282 return (r == ERROR_SUCCESS);
1285 static BOOL msi_comp_find_package(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
1293 static const WCHAR local_package[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
1294 static const WCHAR managed_local_package[] = {
1295 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
1298 if (context == MSIINSTALLCONTEXT_MACHINE)
1299 r = MSIREG_OpenLocalSystemProductKey(prodcode, &hkey, FALSE);
1301 r = MSIREG_OpenCurrentUserInstallProps(prodcode, &hkey, FALSE);
1303 if (r != ERROR_SUCCESS)
1306 if (context == MSIINSTALLCONTEXT_USERMANAGED)
1307 package = managed_local_package;
1309 package = local_package;
1312 res = RegQueryValueExW(hkey, package, NULL, NULL, NULL, &sz);
1315 return (res == ERROR_SUCCESS);
1318 static BOOL msi_comp_find_prodcode(LPWSTR squished_pc,
1319 MSIINSTALLCONTEXT context,
1320 LPCWSTR comp, LPWSTR val, DWORD *sz)
1326 if (context == MSIINSTALLCONTEXT_MACHINE)
1327 r = MSIREG_OpenLocalSystemComponentKey(comp, &hkey, FALSE);
1329 r = MSIREG_OpenUserDataComponentKey(comp, &hkey, FALSE);
1331 if (r != ERROR_SUCCESS)
1334 res = RegQueryValueExW(hkey, squished_pc, NULL, NULL, (BYTE *)val, sz);
1335 if (res != ERROR_SUCCESS)
1342 UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode,
1343 LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext,
1344 LPCWSTR szComponent, INSTALLSTATE *pdwState)
1346 WCHAR squished_pc[GUID_SIZE];
1347 WCHAR val[MAX_PATH];
1351 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode),
1352 debugstr_w(szUserSid), dwContext, debugstr_w(szComponent), pdwState);
1355 return ERROR_INVALID_PARAMETER;
1357 if (!szProductCode || !*szProductCode || lstrlenW(szProductCode) != GUID_SIZE - 1)
1358 return ERROR_INVALID_PARAMETER;
1360 if (!squash_guid(szProductCode, squished_pc))
1361 return ERROR_INVALID_PARAMETER;
1363 found = msi_comp_find_prod_key(szProductCode, dwContext);
1365 if (!msi_comp_find_package(szProductCode, dwContext))
1369 *pdwState = INSTALLSTATE_UNKNOWN;
1370 return ERROR_UNKNOWN_COMPONENT;
1373 return ERROR_UNKNOWN_PRODUCT;
1376 *pdwState = INSTALLSTATE_UNKNOWN;
1379 if (!msi_comp_find_prodcode(squished_pc, dwContext, szComponent, val, &sz))
1380 return ERROR_UNKNOWN_COMPONENT;
1383 *pdwState = INSTALLSTATE_NOTUSED;
1386 if (lstrlenW(val) > 2 &&
1387 val[0] >= '0' && val[0] <= '9' && val[1] >= '0' && val[1] <= '9')
1389 *pdwState = INSTALLSTATE_SOURCE;
1392 *pdwState = INSTALLSTATE_LOCAL;
1395 return ERROR_SUCCESS;
1398 INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
1400 LPWSTR szwProduct = NULL;
1405 szwProduct = strdupAtoW( szProduct );
1407 return ERROR_OUTOFMEMORY;
1409 r = MsiQueryProductStateW( szwProduct );
1410 msi_free( szwProduct );
1414 INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
1416 INSTALLSTATE state = INSTALLSTATE_ADVERTISED;
1417 HKEY prodkey = 0, userdata = 0;
1422 static const WCHAR szWindowsInstaller[] = {
1423 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
1425 TRACE("%s\n", debugstr_w(szProduct));
1427 if (!szProduct || !*szProduct)
1428 return INSTALLSTATE_INVALIDARG;
1430 if (lstrlenW(szProduct) != GUID_SIZE - 1)
1431 return INSTALLSTATE_INVALIDARG;
1433 r = MSIREG_OpenLocalManagedProductKey(szProduct, &prodkey, FALSE);
1434 if (r != ERROR_SUCCESS)
1436 r = MSIREG_OpenUserProductsKey(szProduct, &prodkey, FALSE);
1437 if (r != ERROR_SUCCESS)
1439 r = MSIREG_OpenLocalClassesProductKey(szProduct, &prodkey, FALSE);
1440 if (r == ERROR_SUCCESS)
1447 r = MSIREG_OpenCurrentUserInstallProps(szProduct, &userdata, FALSE);
1448 if (r != ERROR_SUCCESS)
1453 r = MSIREG_OpenLocalSystemInstallProps(szProduct, &userdata, FALSE);
1454 if (r != ERROR_SUCCESS)
1458 if (!msi_reg_get_val_dword(userdata, szWindowsInstaller, &val))
1462 state = INSTALLSTATE_DEFAULT;
1464 state = INSTALLSTATE_UNKNOWN;
1469 state = INSTALLSTATE_UNKNOWN;
1472 state = INSTALLSTATE_ABSENT;
1475 RegCloseKey(prodkey);
1476 RegCloseKey(userdata);
1480 INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
1482 INSTALLUILEVEL old = gUILevel;
1483 HWND oldwnd = gUIhwnd;
1485 TRACE("%08x %p\n", dwUILevel, phWnd);
1487 gUILevel = dwUILevel;
1496 INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
1497 DWORD dwMessageFilter, LPVOID pvContext)
1499 INSTALLUI_HANDLERA prev = gUIHandlerA;
1501 TRACE("%p %x %p\n",puiHandler, dwMessageFilter,pvContext);
1502 gUIHandlerA = puiHandler;
1503 gUIFilter = dwMessageFilter;
1504 gUIContext = pvContext;
1509 INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler,
1510 DWORD dwMessageFilter, LPVOID pvContext)
1512 INSTALLUI_HANDLERW prev = gUIHandlerW;
1514 TRACE("%p %x %p\n",puiHandler,dwMessageFilter,pvContext);
1515 gUIHandlerW = puiHandler;
1516 gUIFilter = dwMessageFilter;
1517 gUIContext = pvContext;
1522 /******************************************************************
1523 * MsiLoadStringW [MSI.@]
1525 * Loads a string from MSI's string resources.
1529 * handle [I] only -1 is handled currently
1530 * id [I] id of the string to be loaded
1531 * lpBuffer [O] buffer for the string to be written to
1532 * nBufferMax [I] maximum size of the buffer in characters
1533 * lang [I] the preferred language for the string
1537 * If successful, this function returns the language id of the string loaded
1538 * If the function fails, the function returns zero.
1542 * The type of the first parameter is unknown. LoadString's prototype
1543 * suggests that it might be a module handle. I have made it an MSI handle
1544 * for starters, as -1 is an invalid MSI handle, but not an invalid module
1545 * handle. Maybe strings can be stored in an MSI database somehow.
1547 LANGID WINAPI MsiLoadStringW( MSIHANDLE handle, UINT id, LPWSTR lpBuffer,
1548 int nBufferMax, LANGID lang )
1555 TRACE("%ld %u %p %d %d\n", handle, id, lpBuffer, nBufferMax, lang);
1558 FIXME("don't know how to deal with handle = %08lx\n", handle);
1561 lang = GetUserDefaultLangID();
1563 hres = FindResourceExW( msi_hInstance, (LPCWSTR) RT_STRING,
1567 hResData = LoadResource( msi_hInstance, hres );
1570 p = LockResource( hResData );
1574 for (i = 0; i < (id&0xf); i++)
1578 if( nBufferMax <= len )
1581 memcpy( lpBuffer, p+1, len * sizeof(WCHAR));
1582 lpBuffer[ len ] = 0;
1584 TRACE("found -> %s\n", debugstr_w(lpBuffer));
1589 LANGID WINAPI MsiLoadStringA( MSIHANDLE handle, UINT id, LPSTR lpBuffer,
1590 int nBufferMax, LANGID lang )
1596 bufW = msi_alloc(nBufferMax*sizeof(WCHAR));
1597 r = MsiLoadStringW(handle, id, bufW, nBufferMax, lang);
1600 len = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL, NULL );
1601 if( len <= nBufferMax )
1602 WideCharToMultiByte( CP_ACP, 0, bufW, -1,
1603 lpBuffer, nBufferMax, NULL, NULL );
1611 INSTALLSTATE WINAPI MsiLocateComponentA(LPCSTR szComponent, LPSTR lpPathBuf,
1614 char szProduct[GUID_SIZE];
1616 TRACE("%s %p %p\n", debugstr_a(szComponent), lpPathBuf, pcchBuf);
1618 if (MsiGetProductCodeA( szComponent, szProduct ) != ERROR_SUCCESS)
1619 return INSTALLSTATE_UNKNOWN;
1621 return MsiGetComponentPathA( szProduct, szComponent, lpPathBuf, pcchBuf );
1624 INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPWSTR lpPathBuf,
1627 WCHAR szProduct[GUID_SIZE];
1629 TRACE("%s %p %p\n", debugstr_w(szComponent), lpPathBuf, pcchBuf);
1631 if (MsiGetProductCodeW( szComponent, szProduct ) != ERROR_SUCCESS)
1632 return INSTALLSTATE_UNKNOWN;
1634 return MsiGetComponentPathW( szProduct, szComponent, lpPathBuf, pcchBuf );
1637 UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
1638 WORD wLanguageId, DWORD f)
1640 FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_a(lpText), debugstr_a(lpCaption),
1641 uType, wLanguageId, f);
1642 return MessageBoxExA(hWnd,lpText,lpCaption,uType,wLanguageId);
1645 UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
1646 WORD wLanguageId, DWORD f)
1648 FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_w(lpText), debugstr_w(lpCaption),
1649 uType, wLanguageId, f);
1650 return MessageBoxExW(hWnd,lpText,lpCaption,uType,wLanguageId);
1653 UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
1654 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
1655 LPDWORD pcchPathBuf )
1657 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName),
1658 debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
1660 return ERROR_CALL_NOT_IMPLEMENTED;
1663 UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
1664 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
1665 LPDWORD pcchPathBuf )
1667 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName),
1668 debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
1670 return ERROR_CALL_NOT_IMPLEMENTED;
1673 UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor,
1674 LPSTR szPath, LPDWORD pcchPath, LPDWORD pcchArgs )
1676 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
1677 return ERROR_CALL_NOT_IMPLEMENTED;
1680 UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor,
1681 LPWSTR szPath, LPDWORD pcchPath, LPDWORD pcchArgs )
1683 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
1684 return ERROR_CALL_NOT_IMPLEMENTED;
1687 HRESULT WINAPI MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath,
1688 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, LPBYTE pbHashData,
1689 LPDWORD pcbHashData)
1691 FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath), dwFlags,
1692 ppcCertContext, pbHashData, pcbHashData);
1693 return ERROR_CALL_NOT_IMPLEMENTED;
1696 HRESULT WINAPI MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath,
1697 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, LPBYTE pbHashData,
1698 LPDWORD pcbHashData)
1700 FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath), dwFlags,
1701 ppcCertContext, pbHashData, pcbHashData);
1702 return ERROR_CALL_NOT_IMPLEMENTED;
1705 UINT WINAPI MsiGetProductPropertyA( MSIHANDLE hProduct, LPCSTR szProperty,
1706 LPSTR szValue, LPDWORD pccbValue )
1708 FIXME("%ld %s %p %p\n", hProduct, debugstr_a(szProperty), szValue, pccbValue);
1709 return ERROR_CALL_NOT_IMPLEMENTED;
1712 UINT WINAPI MsiGetProductPropertyW( MSIHANDLE hProduct, LPCWSTR szProperty,
1713 LPWSTR szValue, LPDWORD pccbValue )
1715 FIXME("%ld %s %p %p\n", hProduct, debugstr_w(szProperty), szValue, pccbValue);
1716 return ERROR_CALL_NOT_IMPLEMENTED;
1719 UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
1722 LPWSTR szPack = NULL;
1724 TRACE("%s\n", debugstr_a(szPackage) );
1728 szPack = strdupAtoW( szPackage );
1730 return ERROR_OUTOFMEMORY;
1733 r = MsiVerifyPackageW( szPack );
1740 UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
1745 TRACE("%s\n", debugstr_w(szPackage) );
1747 r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
1748 MsiCloseHandle( handle );
1753 static INSTALLSTATE WINAPI MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
1754 awstring* lpPathBuf, LPDWORD pcchBuf)
1756 WCHAR squished_pc[GUID_SIZE];
1757 WCHAR squished_comp[GUID_SIZE];
1763 static const WCHAR wininstaller[] = {
1764 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
1766 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
1767 debugstr_w(szComponent), lpPathBuf->str.w, pcchBuf);
1769 if (!szProduct || !szComponent)
1770 return INSTALLSTATE_INVALIDARG;
1772 if (lpPathBuf->str.w && !pcchBuf)
1773 return INSTALLSTATE_INVALIDARG;
1775 if (!squash_guid(szProduct, squished_pc) ||
1776 !squash_guid(szComponent, squished_comp))
1777 return INSTALLSTATE_INVALIDARG;
1779 state = INSTALLSTATE_UNKNOWN;
1781 if (MSIREG_OpenLocalSystemComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS ||
1782 MSIREG_OpenUserDataComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS)
1784 path = msi_reg_get_val_str(hkey, squished_pc);
1787 state = INSTALLSTATE_ABSENT;
1789 if ((MSIREG_OpenLocalSystemProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS ||
1790 MSIREG_OpenUserDataProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS) &&
1791 msi_reg_get_val_dword(hkey, wininstaller, &version) &&
1792 GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
1795 state = INSTALLSTATE_LOCAL;
1799 if (state != INSTALLSTATE_LOCAL &&
1800 (MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS ||
1801 MSIREG_OpenLocalClassesProductKey(szProduct, &hkey, FALSE) == ERROR_SUCCESS))
1805 if (MSIREG_OpenLocalSystemComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS ||
1806 MSIREG_OpenUserDataComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS)
1809 path = msi_reg_get_val_str(hkey, squished_pc);
1812 state = INSTALLSTATE_ABSENT;
1814 if (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
1815 state = INSTALLSTATE_LOCAL;
1820 return INSTALLSTATE_UNKNOWN;
1822 if (state == INSTALLSTATE_LOCAL && !*path)
1823 state = INSTALLSTATE_NOTUSED;
1825 msi_strcpy_to_awstring(path, lpPathBuf, pcchBuf);
1830 /******************************************************************
1831 * MsiGetComponentPathW [MSI.@]
1833 INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
1834 LPWSTR lpPathBuf, LPDWORD pcchBuf)
1838 path.unicode = TRUE;
1839 path.str.w = lpPathBuf;
1841 return MSI_GetComponentPath( szProduct, szComponent, &path, pcchBuf );
1844 /******************************************************************
1845 * MsiGetComponentPathA [MSI.@]
1847 INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
1848 LPSTR lpPathBuf, LPDWORD pcchBuf)
1850 LPWSTR szwProduct, szwComponent = NULL;
1851 INSTALLSTATE r = INSTALLSTATE_UNKNOWN;
1854 szwProduct = strdupAtoW( szProduct );
1855 if( szProduct && !szwProduct)
1858 szwComponent = strdupAtoW( szComponent );
1859 if( szComponent && !szwComponent )
1862 path.unicode = FALSE;
1863 path.str.a = lpPathBuf;
1865 r = MSI_GetComponentPath( szwProduct, szwComponent, &path, pcchBuf );
1868 msi_free( szwProduct );
1869 msi_free( szwComponent );
1874 /******************************************************************
1875 * MsiQueryFeatureStateA [MSI.@]
1877 INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
1879 LPWSTR szwProduct = NULL, szwFeature= NULL;
1880 INSTALLSTATE rc = INSTALLSTATE_UNKNOWN;
1882 szwProduct = strdupAtoW( szProduct );
1883 if ( szProduct && !szwProduct )
1886 szwFeature = strdupAtoW( szFeature );
1887 if ( szFeature && !szwFeature )
1890 rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
1893 msi_free( szwProduct);
1894 msi_free( szwFeature);
1899 /******************************************************************
1900 * MsiQueryFeatureStateW [MSI.@]
1902 * Checks the state of a feature
1905 * szProduct [I] Product's GUID string
1906 * szFeature [I] Feature's GUID string
1909 * INSTALLSTATE_LOCAL Feature is installed and usable
1910 * INSTALLSTATE_ABSENT Feature is absent
1911 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
1912 * INSTALLSTATE_UNKNOWN An error occurred
1913 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
1916 INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
1918 WCHAR squishProduct[33], comp[GUID_SIZE];
1920 LPWSTR components, p, parent_feature, path;
1924 BOOL missing = FALSE;
1925 BOOL machine = FALSE;
1926 BOOL source = FALSE;
1928 TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
1930 if (!szProduct || !szFeature)
1931 return INSTALLSTATE_INVALIDARG;
1933 if (!squash_guid( szProduct, squishProduct ))
1934 return INSTALLSTATE_INVALIDARG;
1936 if (MSIREG_OpenManagedFeaturesKey(szProduct, &hkey, FALSE) != ERROR_SUCCESS &&
1937 MSIREG_OpenUserFeaturesKey(szProduct, &hkey, FALSE) != ERROR_SUCCESS)
1939 rc = MSIREG_OpenLocalClassesFeaturesKey(szProduct, &hkey, FALSE);
1940 if (rc != ERROR_SUCCESS)
1941 return INSTALLSTATE_UNKNOWN;
1946 parent_feature = msi_reg_get_val_str( hkey, szFeature );
1949 if (!parent_feature)
1950 return INSTALLSTATE_UNKNOWN;
1952 r = (parent_feature[0] == 6) ? INSTALLSTATE_ABSENT : INSTALLSTATE_LOCAL;
1953 msi_free(parent_feature);
1954 if (r == INSTALLSTATE_ABSENT)
1958 rc = MSIREG_OpenLocalUserDataFeaturesKey(szProduct, &hkey, FALSE);
1960 rc = MSIREG_OpenUserDataFeaturesKey(szProduct, &hkey, FALSE);
1962 if (rc != ERROR_SUCCESS)
1963 return INSTALLSTATE_ADVERTISED;
1965 components = msi_reg_get_val_str( hkey, szFeature );
1968 TRACE("rc = %d buffer = %s\n", rc, debugstr_w(components));
1971 return INSTALLSTATE_ADVERTISED;
1973 for( p = components; *p && *p != 2 ; p += 20)
1975 if (!decode_base85_guid( p, &guid ))
1977 if (p != components)
1980 msi_free(components);
1981 return INSTALLSTATE_BADCONFIG;
1984 StringFromGUID2(&guid, comp, GUID_SIZE);
1987 rc = MSIREG_OpenLocalUserDataComponentKey(comp, &hkey, FALSE);
1989 rc = MSIREG_OpenUserDataComponentKey(comp, &hkey, FALSE);
1991 if (rc != ERROR_SUCCESS)
1993 msi_free(components);
1994 return INSTALLSTATE_ADVERTISED;
1997 path = msi_reg_get_val_str(hkey, squishProduct);
2000 else if (lstrlenW(path) > 2 &&
2001 path[0] >= '0' && path[0] <= '9' &&
2002 path[1] >= '0' && path[1] <= '9')
2010 TRACE("%s %s -> %d\n", debugstr_w(szProduct), debugstr_w(szFeature), r);
2011 msi_free(components);
2014 return INSTALLSTATE_ADVERTISED;
2017 return INSTALLSTATE_SOURCE;
2019 return INSTALLSTATE_LOCAL;
2022 /******************************************************************
2023 * MsiGetFileVersionA [MSI.@]
2025 UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
2026 LPDWORD pcchVersionBuf, LPSTR lpLangBuf, LPDWORD pcchLangBuf)
2028 LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
2029 UINT ret = ERROR_OUTOFMEMORY;
2031 if ((lpVersionBuf && !pcchVersionBuf) ||
2032 (lpLangBuf && !pcchLangBuf))
2033 return ERROR_INVALID_PARAMETER;
2037 szwFilePath = strdupAtoW( szFilePath );
2042 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
2044 lpwVersionBuff = msi_alloc(*pcchVersionBuf*sizeof(WCHAR));
2045 if( !lpwVersionBuff )
2049 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
2051 lpwLangBuff = msi_alloc(*pcchLangBuf*sizeof(WCHAR));
2056 ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
2057 lpwLangBuff, pcchLangBuf);
2059 if( (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) && lpwVersionBuff )
2060 WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
2061 lpVersionBuf, *pcchVersionBuf + 1, NULL, NULL);
2062 if( (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) && lpwLangBuff )
2063 WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
2064 lpLangBuf, *pcchLangBuf + 1, NULL, NULL);
2067 msi_free(szwFilePath);
2068 msi_free(lpwVersionBuff);
2069 msi_free(lpwLangBuff);
2074 /******************************************************************
2075 * MsiGetFileVersionW [MSI.@]
2077 UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
2078 LPDWORD pcchVersionBuf, LPWSTR lpLangBuf, LPDWORD pcchLangBuf)
2080 static const WCHAR szVersionResource[] = {'\\',0};
2081 static const WCHAR szVersionFormat[] = {
2082 '%','d','.','%','d','.','%','d','.','%','d',0};
2083 static const WCHAR szLangResource[] = {
2084 '\\','V','a','r','F','i','l','e','I','n','f','o','\\',
2085 'T','r','a','n','s','l','a','t','i','o','n',0};
2086 static const WCHAR szLangFormat[] = {'%','d',0};
2088 DWORD dwVerLen, gle;
2089 LPVOID lpVer = NULL;
2090 VS_FIXEDFILEINFO *ffi;
2095 TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath),
2096 lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
2097 lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
2099 if ((lpVersionBuf && !pcchVersionBuf) ||
2100 (lpLangBuf && !pcchLangBuf))
2101 return ERROR_INVALID_PARAMETER;
2103 dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL);
2106 gle = GetLastError();
2107 if (gle == ERROR_BAD_PATHNAME)
2108 return ERROR_FILE_NOT_FOUND;
2109 else if (gle == ERROR_RESOURCE_DATA_NOT_FOUND)
2110 return ERROR_FILE_INVALID;
2115 lpVer = msi_alloc(dwVerLen);
2118 ret = ERROR_OUTOFMEMORY;
2122 if( !GetFileVersionInfoW(szFilePath, 0, dwVerLen, lpVer) )
2124 ret = GetLastError();
2130 if( VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) &&
2133 wsprintfW(tmp, szVersionFormat,
2134 HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
2135 HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
2136 if (lpVersionBuf) lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
2138 if (lstrlenW(tmp) >= *pcchVersionBuf)
2139 ret = ERROR_MORE_DATA;
2141 *pcchVersionBuf = lstrlenW(tmp);
2145 if (lpVersionBuf) *lpVersionBuf = 0;
2146 *pcchVersionBuf = 0;
2152 if (VerQueryValueW(lpVer, szLangResource, (LPVOID*)&lang, &puLen) &&
2155 wsprintfW(tmp, szLangFormat, *lang);
2156 if (lpLangBuf) lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
2158 if (lstrlenW(tmp) >= *pcchLangBuf)
2159 ret = ERROR_MORE_DATA;
2161 *pcchLangBuf = lstrlenW(tmp);
2165 if (lpLangBuf) *lpLangBuf = 0;
2175 /***********************************************************************
2176 * MsiGetFeatureUsageW [MSI.@]
2178 UINT WINAPI MsiGetFeatureUsageW( LPCWSTR szProduct, LPCWSTR szFeature,
2179 LPDWORD pdwUseCount, LPWORD pwDateUsed )
2181 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szFeature),
2182 pdwUseCount, pwDateUsed);
2183 return ERROR_CALL_NOT_IMPLEMENTED;
2186 /***********************************************************************
2187 * MsiGetFeatureUsageA [MSI.@]
2189 UINT WINAPI MsiGetFeatureUsageA( LPCSTR szProduct, LPCSTR szFeature,
2190 LPDWORD pdwUseCount, LPWORD pwDateUsed )
2192 LPWSTR prod = NULL, feat = NULL;
2193 UINT ret = ERROR_OUTOFMEMORY;
2195 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szFeature),
2196 pdwUseCount, pwDateUsed);
2198 prod = strdupAtoW( szProduct );
2199 if (szProduct && !prod)
2202 feat = strdupAtoW( szFeature );
2203 if (szFeature && !feat)
2206 ret = MsiGetFeatureUsageW( prod, feat, pdwUseCount, pwDateUsed );
2215 /***********************************************************************
2216 * MsiUseFeatureExW [MSI.@]
2218 INSTALLSTATE WINAPI MsiUseFeatureExW( LPCWSTR szProduct, LPCWSTR szFeature,
2219 DWORD dwInstallMode, DWORD dwReserved )
2223 TRACE("%s %s %i %i\n", debugstr_w(szProduct), debugstr_w(szFeature),
2224 dwInstallMode, dwReserved);
2226 state = MsiQueryFeatureStateW( szProduct, szFeature );
2229 return INSTALLSTATE_INVALIDARG;
2231 if (state == INSTALLSTATE_LOCAL && dwInstallMode != INSTALLMODE_NODETECTION)
2233 FIXME("mark product %s feature %s as used\n",
2234 debugstr_w(szProduct), debugstr_w(szFeature) );
2240 /***********************************************************************
2241 * MsiUseFeatureExA [MSI.@]
2243 INSTALLSTATE WINAPI MsiUseFeatureExA( LPCSTR szProduct, LPCSTR szFeature,
2244 DWORD dwInstallMode, DWORD dwReserved )
2246 INSTALLSTATE ret = INSTALLSTATE_UNKNOWN;
2247 LPWSTR prod = NULL, feat = NULL;
2249 TRACE("%s %s %i %i\n", debugstr_a(szProduct), debugstr_a(szFeature),
2250 dwInstallMode, dwReserved);
2252 prod = strdupAtoW( szProduct );
2253 if (szProduct && !prod)
2256 feat = strdupAtoW( szFeature );
2257 if (szFeature && !feat)
2260 ret = MsiUseFeatureExW( prod, feat, dwInstallMode, dwReserved );
2269 /***********************************************************************
2270 * MsiUseFeatureW [MSI.@]
2272 INSTALLSTATE WINAPI MsiUseFeatureW( LPCWSTR szProduct, LPCWSTR szFeature )
2274 return MsiUseFeatureExW(szProduct, szFeature, 0, 0);
2277 /***********************************************************************
2278 * MsiUseFeatureA [MSI.@]
2280 INSTALLSTATE WINAPI MsiUseFeatureA( LPCSTR szProduct, LPCSTR szFeature )
2282 return MsiUseFeatureExA(szProduct, szFeature, 0, 0);
2285 /***********************************************************************
2286 * MSI_ProvideQualifiedComponentEx [internal]
2288 static UINT WINAPI MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent,
2289 LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct,
2290 DWORD Unused1, DWORD Unused2, awstring *lpPathBuf,
2291 LPDWORD pcchPathBuf)
2293 WCHAR product[MAX_FEATURE_CHARS+1], component[MAX_FEATURE_CHARS+1],
2294 feature[MAX_FEATURE_CHARS+1];
2300 TRACE("%s %s %i %s %i %i %p %p\n", debugstr_w(szComponent),
2301 debugstr_w(szQualifier), dwInstallMode, debugstr_w(szProduct),
2302 Unused1, Unused2, lpPathBuf, pcchPathBuf);
2304 rc = MSIREG_OpenUserComponentsKey(szComponent, &hkey, FALSE);
2305 if (rc != ERROR_SUCCESS)
2306 return ERROR_INDEX_ABSENT;
2308 info = msi_reg_get_val_str( hkey, szQualifier );
2312 return ERROR_INDEX_ABSENT;
2314 MsiDecomposeDescriptorW(info, product, feature, component, &sz);
2317 rc = MSI_GetComponentPath(product, component, lpPathBuf, pcchPathBuf);
2319 rc = MSI_GetComponentPath(szProduct, component, lpPathBuf, pcchPathBuf);
2323 if (rc != INSTALLSTATE_LOCAL)
2324 return ERROR_FILE_NOT_FOUND;
2326 return ERROR_SUCCESS;
2329 /***********************************************************************
2330 * MsiProvideQualifiedComponentExW [MSI.@]
2332 UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
2333 LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct,
2334 DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
2335 LPDWORD pcchPathBuf)
2339 path.unicode = TRUE;
2340 path.str.w = lpPathBuf;
2342 return MSI_ProvideQualifiedComponentEx(szComponent, szQualifier,
2343 dwInstallMode, szProduct, Unused1, Unused2, &path, pcchPathBuf);
2346 /***********************************************************************
2347 * MsiProvideQualifiedComponentExA [MSI.@]
2349 UINT WINAPI MsiProvideQualifiedComponentExA(LPCSTR szComponent,
2350 LPCSTR szQualifier, DWORD dwInstallMode, LPCSTR szProduct,
2351 DWORD Unused1, DWORD Unused2, LPSTR lpPathBuf,
2352 LPDWORD pcchPathBuf)
2354 LPWSTR szwComponent, szwQualifier = NULL, szwProduct = NULL;
2355 UINT r = ERROR_OUTOFMEMORY;
2358 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent),
2359 debugstr_a(szQualifier), dwInstallMode, debugstr_a(szProduct),
2360 Unused1, Unused2, lpPathBuf, pcchPathBuf);
2362 szwComponent = strdupAtoW( szComponent );
2363 if (szComponent && !szwComponent)
2366 szwQualifier = strdupAtoW( szQualifier );
2367 if (szQualifier && !szwQualifier)
2370 szwProduct = strdupAtoW( szProduct );
2371 if (szProduct && !szwProduct)
2374 path.unicode = FALSE;
2375 path.str.a = lpPathBuf;
2377 r = MSI_ProvideQualifiedComponentEx(szwComponent, szwQualifier,
2378 dwInstallMode, szwProduct, Unused1,
2379 Unused2, &path, pcchPathBuf);
2381 msi_free(szwProduct);
2382 msi_free(szwComponent);
2383 msi_free(szwQualifier);
2388 /***********************************************************************
2389 * MsiProvideQualifiedComponentW [MSI.@]
2391 UINT WINAPI MsiProvideQualifiedComponentW( LPCWSTR szComponent,
2392 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf,
2393 LPDWORD pcchPathBuf)
2395 return MsiProvideQualifiedComponentExW(szComponent, szQualifier,
2396 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
2399 /***********************************************************************
2400 * MsiProvideQualifiedComponentA [MSI.@]
2402 UINT WINAPI MsiProvideQualifiedComponentA( LPCSTR szComponent,
2403 LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf,
2404 LPDWORD pcchPathBuf)
2406 return MsiProvideQualifiedComponentExA(szComponent, szQualifier,
2407 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
2410 /***********************************************************************
2411 * MSI_GetUserInfo [internal]
2413 static USERINFOSTATE WINAPI MSI_GetUserInfo(LPCWSTR szProduct,
2414 awstring *lpUserNameBuf, LPDWORD pcchUserNameBuf,
2415 awstring *lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
2416 awstring *lpSerialBuf, LPDWORD pcchSerialBuf)
2418 WCHAR squished_pc[SQUISH_GUID_SIZE];
2419 LPWSTR user, org, serial;
2420 USERINFOSTATE state;
2425 static const WCHAR szEmpty[] = {0};
2427 TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct), lpUserNameBuf,
2428 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
2431 if (!szProduct || !squash_guid(szProduct, squished_pc))
2432 return USERINFOSTATE_INVALIDARG;
2434 if (MSIREG_OpenLocalManagedProductKey(szProduct, &hkey, FALSE) != ERROR_SUCCESS &&
2435 MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE) != ERROR_SUCCESS &&
2436 MSIREG_OpenLocalClassesProductKey(szProduct, &hkey, FALSE) != ERROR_SUCCESS)
2438 return USERINFOSTATE_UNKNOWN;
2441 if (MSIREG_OpenCurrentUserInstallProps(szProduct, &props, FALSE) != ERROR_SUCCESS &&
2442 MSIREG_OpenLocalSystemInstallProps(szProduct, &props, FALSE) != ERROR_SUCCESS)
2445 return USERINFOSTATE_ABSENT;
2448 user = msi_reg_get_val_str(props, INSTALLPROPERTY_REGOWNERW);
2449 org = msi_reg_get_val_str(props, INSTALLPROPERTY_REGCOMPANYW);
2450 serial = msi_reg_get_val_str(props, INSTALLPROPERTY_PRODUCTIDW);
2451 state = USERINFOSTATE_ABSENT;
2457 state = USERINFOSTATE_PRESENT;
2459 if (pcchUserNameBuf)
2461 if (lpUserNameBuf && !user)
2463 (*pcchUserNameBuf)--;
2467 r = msi_strcpy_to_awstring(user, lpUserNameBuf, pcchUserNameBuf);
2468 if (r == ERROR_MORE_DATA)
2470 state = USERINFOSTATE_MOREDATA;
2478 if (!orgptr) orgptr = szEmpty;
2480 r = msi_strcpy_to_awstring(orgptr, lpOrgNameBuf, pcchOrgNameBuf);
2481 if (r == ERROR_MORE_DATA)
2483 state = USERINFOSTATE_MOREDATA;
2496 r = msi_strcpy_to_awstring(serial, lpSerialBuf, pcchSerialBuf);
2497 if (r == ERROR_MORE_DATA)
2498 state = USERINFOSTATE_MOREDATA;
2509 /***********************************************************************
2510 * MsiGetUserInfoW [MSI.@]
2512 USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct,
2513 LPWSTR lpUserNameBuf, LPDWORD pcchUserNameBuf,
2514 LPWSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
2515 LPWSTR lpSerialBuf, LPDWORD pcchSerialBuf)
2517 awstring user, org, serial;
2519 if ((lpUserNameBuf && !pcchUserNameBuf) ||
2520 (lpOrgNameBuf && !pcchOrgNameBuf) ||
2521 (lpSerialBuf && !pcchSerialBuf))
2522 return USERINFOSTATE_INVALIDARG;
2524 user.unicode = TRUE;
2525 user.str.w = lpUserNameBuf;
2527 org.str.w = lpOrgNameBuf;
2528 serial.unicode = TRUE;
2529 serial.str.w = lpSerialBuf;
2531 return MSI_GetUserInfo( szProduct, &user, pcchUserNameBuf,
2532 &org, pcchOrgNameBuf,
2533 &serial, pcchSerialBuf );
2536 USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct,
2537 LPSTR lpUserNameBuf, LPDWORD pcchUserNameBuf,
2538 LPSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
2539 LPSTR lpSerialBuf, LPDWORD pcchSerialBuf)
2541 awstring user, org, serial;
2545 if ((lpUserNameBuf && !pcchUserNameBuf) ||
2546 (lpOrgNameBuf && !pcchOrgNameBuf) ||
2547 (lpSerialBuf && !pcchSerialBuf))
2548 return USERINFOSTATE_INVALIDARG;
2550 prod = strdupAtoW( szProduct );
2551 if (szProduct && !prod)
2552 return ERROR_OUTOFMEMORY;
2554 user.unicode = FALSE;
2555 user.str.a = lpUserNameBuf;
2556 org.unicode = FALSE;
2557 org.str.a = lpOrgNameBuf;
2558 serial.unicode = FALSE;
2559 serial.str.a = lpSerialBuf;
2561 r = MSI_GetUserInfo( prod, &user, pcchUserNameBuf,
2562 &org, pcchOrgNameBuf,
2563 &serial, pcchSerialBuf );
2570 UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
2574 MSIPACKAGE *package;
2575 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
2577 TRACE("(%s)\n",debugstr_w(szProduct));
2579 rc = MsiOpenProductW(szProduct,&handle);
2580 if (rc != ERROR_SUCCESS)
2581 return ERROR_INVALID_PARAMETER;
2583 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
2584 rc = ACTION_PerformUIAction(package, szFirstRun, -1);
2585 msiobj_release( &package->hdr );
2587 MsiCloseHandle(handle);
2592 UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct)
2596 MSIPACKAGE *package;
2597 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
2599 TRACE("(%s)\n",debugstr_a(szProduct));
2601 rc = MsiOpenProductA(szProduct,&handle);
2602 if (rc != ERROR_SUCCESS)
2603 return ERROR_INVALID_PARAMETER;
2605 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
2606 rc = ACTION_PerformUIAction(package, szFirstRun, -1);
2607 msiobj_release( &package->hdr );
2609 MsiCloseHandle(handle);
2614 /***********************************************************************
2615 * MsiConfigureFeatureA [MSI.@]
2617 UINT WINAPI MsiConfigureFeatureA(LPCSTR szProduct, LPCSTR szFeature, INSTALLSTATE eInstallState)
2619 LPWSTR prod, feat = NULL;
2620 UINT r = ERROR_OUTOFMEMORY;
2622 TRACE("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature), eInstallState);
2624 prod = strdupAtoW( szProduct );
2625 if (szProduct && !prod)
2628 feat = strdupAtoW( szFeature );
2629 if (szFeature && !feat)
2632 r = MsiConfigureFeatureW(prod, feat, eInstallState);
2641 /***********************************************************************
2642 * MsiConfigureFeatureW [MSI.@]
2644 UINT WINAPI MsiConfigureFeatureW(LPCWSTR szProduct, LPCWSTR szFeature, INSTALLSTATE eInstallState)
2646 static const WCHAR szCostInit[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
2647 MSIPACKAGE *package = NULL;
2649 WCHAR sourcepath[MAX_PATH], filename[MAX_PATH];
2652 TRACE("%s %s %i\n", debugstr_w(szProduct), debugstr_w(szFeature), eInstallState);
2654 if (!szProduct || !szFeature)
2655 return ERROR_INVALID_PARAMETER;
2657 switch (eInstallState)
2659 case INSTALLSTATE_DEFAULT:
2660 /* FIXME: how do we figure out the default location? */
2661 eInstallState = INSTALLSTATE_LOCAL;
2663 case INSTALLSTATE_LOCAL:
2664 case INSTALLSTATE_SOURCE:
2665 case INSTALLSTATE_ABSENT:
2666 case INSTALLSTATE_ADVERTISED:
2669 return ERROR_INVALID_PARAMETER;
2672 r = MSI_OpenProductW( szProduct, &package );
2673 if (r != ERROR_SUCCESS)
2676 sz = sizeof(sourcepath);
2677 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2678 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
2680 sz = sizeof(filename);
2681 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2682 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
2684 lstrcatW( sourcepath, filename );
2686 MsiSetInternalUI( INSTALLUILEVEL_BASIC, NULL );
2688 r = ACTION_PerformUIAction( package, szCostInit, -1 );
2689 if (r != ERROR_SUCCESS)
2692 r = MSI_SetFeatureStateW( package, szFeature, eInstallState);
2693 if (r != ERROR_SUCCESS)
2696 r = MSI_InstallPackage( package, sourcepath, NULL );
2699 msiobj_release( &package->hdr );
2704 /***********************************************************************
2705 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
2707 * Notes: undocumented
2709 UINT WINAPI MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved)
2711 WCHAR path[MAX_PATH];
2713 TRACE("%d\n", dwReserved);
2717 FIXME("dwReserved=%d\n", dwReserved);
2718 return ERROR_INVALID_PARAMETER;
2721 if (!GetWindowsDirectoryW(path, MAX_PATH))
2722 return ERROR_FUNCTION_FAILED;
2724 lstrcatW(path, installerW);
2726 if (!CreateDirectoryW(path, NULL))
2727 return ERROR_FUNCTION_FAILED;
2729 return ERROR_SUCCESS;
2732 /***********************************************************************
2733 * MsiGetShortcutTargetA [MSI.@]
2735 UINT WINAPI MsiGetShortcutTargetA( LPCSTR szShortcutTarget,
2736 LPSTR szProductCode, LPSTR szFeatureId,
2737 LPSTR szComponentCode )
2740 const int len = MAX_FEATURE_CHARS+1;
2741 WCHAR product[MAX_FEATURE_CHARS+1], feature[MAX_FEATURE_CHARS+1], component[MAX_FEATURE_CHARS+1];
2744 target = strdupAtoW( szShortcutTarget );
2745 if (szShortcutTarget && !target )
2746 return ERROR_OUTOFMEMORY;
2750 r = MsiGetShortcutTargetW( target, product, feature, component );
2752 if (r == ERROR_SUCCESS)
2754 WideCharToMultiByte( CP_ACP, 0, product, -1, szProductCode, len, NULL, NULL );
2755 WideCharToMultiByte( CP_ACP, 0, feature, -1, szFeatureId, len, NULL, NULL );
2756 WideCharToMultiByte( CP_ACP, 0, component, -1, szComponentCode, len, NULL, NULL );
2761 /***********************************************************************
2762 * MsiGetShortcutTargetW [MSI.@]
2764 UINT WINAPI MsiGetShortcutTargetW( LPCWSTR szShortcutTarget,
2765 LPWSTR szProductCode, LPWSTR szFeatureId,
2766 LPWSTR szComponentCode )
2768 IShellLinkDataList *dl = NULL;
2769 IPersistFile *pf = NULL;
2770 LPEXP_DARWIN_LINK darwin = NULL;
2773 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget),
2774 szProductCode, szFeatureId, szComponentCode );
2776 init = CoInitialize(NULL);
2778 r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
2779 &IID_IPersistFile, (LPVOID*) &pf );
2780 if( SUCCEEDED( r ) )
2782 r = IPersistFile_Load( pf, szShortcutTarget,
2783 STGM_READ | STGM_SHARE_DENY_WRITE );
2784 if( SUCCEEDED( r ) )
2786 r = IPersistFile_QueryInterface( pf, &IID_IShellLinkDataList,
2788 if( SUCCEEDED( r ) )
2790 IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG,
2792 IShellLinkDataList_Release( dl );
2795 IPersistFile_Release( pf );
2798 if (SUCCEEDED(init))
2801 TRACE("darwin = %p\n", darwin);
2808 ret = MsiDecomposeDescriptorW( darwin->szwDarwinID,
2809 szProductCode, szFeatureId, szComponentCode, &sz );
2810 LocalFree( darwin );
2814 return ERROR_FUNCTION_FAILED;
2817 UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature,
2818 DWORD dwReinstallMode )
2820 MSIPACKAGE* package = NULL;
2822 WCHAR sourcepath[MAX_PATH];
2823 WCHAR filename[MAX_PATH];
2824 static const WCHAR szLogVerbose[] = {
2825 ' ','L','O','G','V','E','R','B','O','S','E',0 };
2826 static const WCHAR szInstalled[] = { 'I','n','s','t','a','l','l','e','d',0};
2827 static const WCHAR szReinstall[] = {'R','E','I','N','S','T','A','L','L',0};
2828 static const WCHAR szReinstallMode[] = {'R','E','I','N','S','T','A','L','L','M','O','D','E',0};
2829 static const WCHAR szOne[] = {'1',0};
2830 WCHAR reinstallmode[11];
2834 FIXME("%s %s %i\n", debugstr_w(szProduct), debugstr_w(szFeature),
2837 ptr = reinstallmode;
2839 if (dwReinstallMode & REINSTALLMODE_FILEMISSING)
2841 if (dwReinstallMode & REINSTALLMODE_FILEOLDERVERSION)
2843 if (dwReinstallMode & REINSTALLMODE_FILEEQUALVERSION)
2845 if (dwReinstallMode & REINSTALLMODE_FILEEXACT)
2847 if (dwReinstallMode & REINSTALLMODE_FILEVERIFY)
2849 if (dwReinstallMode & REINSTALLMODE_FILEREPLACE)
2851 if (dwReinstallMode & REINSTALLMODE_USERDATA)
2853 if (dwReinstallMode & REINSTALLMODE_MACHINEDATA)
2855 if (dwReinstallMode & REINSTALLMODE_SHORTCUT)
2857 if (dwReinstallMode & REINSTALLMODE_PACKAGE)
2861 sz = sizeof(sourcepath);
2862 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2863 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
2865 sz = sizeof(filename);
2866 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2867 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
2869 lstrcatW( sourcepath, filename );
2871 if (dwReinstallMode & REINSTALLMODE_PACKAGE)
2872 r = MSI_OpenPackageW( sourcepath, &package );
2874 r = MSI_OpenProductW( szProduct, &package );
2876 if (r != ERROR_SUCCESS)
2879 MSI_SetPropertyW( package, szReinstallMode, reinstallmode );
2880 MSI_SetPropertyW( package, szInstalled, szOne );
2881 MSI_SetPropertyW( package, szLogVerbose, szOne );
2882 MSI_SetPropertyW( package, szReinstall, szFeature );
2884 r = MSI_InstallPackage( package, sourcepath, NULL );
2886 msiobj_release( &package->hdr );
2891 UINT WINAPI MsiReinstallFeatureA( LPCSTR szProduct, LPCSTR szFeature,
2892 DWORD dwReinstallMode )
2898 TRACE("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature),
2901 wszProduct = strdupAtoW(szProduct);
2902 wszFeature = strdupAtoW(szFeature);
2904 rc = MsiReinstallFeatureW(wszProduct, wszFeature, dwReinstallMode);
2906 msi_free(wszProduct);
2907 msi_free(wszFeature);
2914 unsigned int buf[4];
2915 unsigned char in[64];
2916 unsigned char digest[16];
2919 extern VOID WINAPI MD5Init( MD5_CTX *);
2920 extern VOID WINAPI MD5Update( MD5_CTX *, const unsigned char *, unsigned int );
2921 extern VOID WINAPI MD5Final( MD5_CTX *);
2923 /***********************************************************************
2924 * MsiGetFileHashW [MSI.@]
2926 UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
2927 PMSIFILEHASHINFO pHash )
2929 HANDLE handle, mapping;
2932 UINT r = ERROR_FUNCTION_FAILED;
2934 TRACE("%s %08x %p\n", debugstr_w(szFilePath), dwOptions, pHash );
2937 return ERROR_INVALID_PARAMETER;
2940 return ERROR_PATH_NOT_FOUND;
2943 return ERROR_INVALID_PARAMETER;
2945 return ERROR_INVALID_PARAMETER;
2946 if (pHash->dwFileHashInfoSize < sizeof *pHash)
2947 return ERROR_INVALID_PARAMETER;
2949 handle = CreateFileW( szFilePath, GENERIC_READ,
2950 FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL );
2951 if (handle == INVALID_HANDLE_VALUE)
2952 return ERROR_FILE_NOT_FOUND;
2954 length = GetFileSize( handle, NULL );
2956 mapping = CreateFileMappingW( handle, NULL, PAGE_READONLY, 0, 0, NULL );
2959 p = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, length );
2965 MD5Update( &ctx, p, length );
2967 UnmapViewOfFile( p );
2969 memcpy( pHash->dwData, ctx.digest, sizeof pHash->dwData );
2972 CloseHandle( mapping );
2974 CloseHandle( handle );
2979 /***********************************************************************
2980 * MsiGetFileHashA [MSI.@]
2982 UINT WINAPI MsiGetFileHashA( LPCSTR szFilePath, DWORD dwOptions,
2983 PMSIFILEHASHINFO pHash )
2988 TRACE("%s %08x %p\n", debugstr_a(szFilePath), dwOptions, pHash );
2990 file = strdupAtoW( szFilePath );
2991 if (szFilePath && !file)
2992 return ERROR_OUTOFMEMORY;
2994 r = MsiGetFileHashW( file, dwOptions, pHash );
2999 /***********************************************************************
3000 * MsiAdvertiseScriptW [MSI.@]
3002 UINT WINAPI MsiAdvertiseScriptW( LPCWSTR szScriptFile, DWORD dwFlags,
3003 PHKEY phRegData, BOOL fRemoveItems )
3005 FIXME("%s %08x %p %d\n",
3006 debugstr_w( szScriptFile ), dwFlags, phRegData, fRemoveItems );
3007 return ERROR_CALL_NOT_IMPLEMENTED;
3010 /***********************************************************************
3011 * MsiAdvertiseScriptA [MSI.@]
3013 UINT WINAPI MsiAdvertiseScriptA( LPCSTR szScriptFile, DWORD dwFlags,
3014 PHKEY phRegData, BOOL fRemoveItems )
3016 FIXME("%s %08x %p %d\n",
3017 debugstr_a( szScriptFile ), dwFlags, phRegData, fRemoveItems );
3018 return ERROR_CALL_NOT_IMPLEMENTED;
3021 /***********************************************************************
3022 * MsiIsProductElevatedW [MSI.@]
3024 UINT WINAPI MsiIsProductElevatedW( LPCWSTR szProduct, BOOL *pfElevated )
3026 FIXME("%s %p - stub\n",
3027 debugstr_w( szProduct ), pfElevated );
3029 return ERROR_SUCCESS;
3032 /***********************************************************************
3033 * MsiIsProductElevatedA [MSI.@]
3035 UINT WINAPI MsiIsProductElevatedA( LPCSTR szProduct, BOOL *pfElevated )
3037 FIXME("%s %p - stub\n",
3038 debugstr_a( szProduct ), pfElevated );
3040 return ERROR_SUCCESS;
3043 /***********************************************************************
3044 * MsiSetExternalUIRecord [MSI.@]
3046 UINT WINAPI MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD puiHandler,
3047 DWORD dwMessageFilter, LPVOID pvContext,
3048 PINSTALLUI_HANDLER_RECORD ppuiPrevHandler)
3050 FIXME("%p %08x %p %p\n", puiHandler, dwMessageFilter ,pvContext,
3052 return ERROR_CALL_NOT_IMPLEMENTED;
3055 /***********************************************************************
3056 * MsiInstallMissingComponentW [MSI.@]
3058 UINT WINAPI MsiInstallMissingComponentW(LPCWSTR szProduct, LPCWSTR szComponent, INSTALLSTATE eInstallState)
3060 FIXME("(%s %s %d\n", debugstr_w(szProduct), debugstr_w(szComponent), eInstallState);
3061 return ERROR_SUCCESS;