2003-08-13 03:27:48 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
2005-01-24 12:22:00 +01:00
|
|
|
* Copyright 2002,2003,2004,2005 Mike McCormack for CodeWeavers
|
2003-08-13 03:27:48 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-08-13 03:27:48 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
2003-09-27 04:24:31 +02:00
|
|
|
#include "winnls.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "msi.h"
|
2007-06-15 23:08:37 +02:00
|
|
|
#include "msidefs.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "msiquery.h"
|
2003-09-02 01:57:06 +02:00
|
|
|
#include "wincrypt.h"
|
2004-09-06 23:25:48 +02:00
|
|
|
#include "winver.h"
|
2005-01-24 12:22:00 +01:00
|
|
|
#include "winuser.h"
|
2005-10-29 12:28:30 +02:00
|
|
|
#include "shlobj.h"
|
|
|
|
#include "shobjidl.h"
|
|
|
|
#include "objidl.h"
|
2011-03-30 12:31:35 +02:00
|
|
|
#include "wintrust.h"
|
|
|
|
#include "softpub.h"
|
|
|
|
|
2018-04-16 03:52:10 +02:00
|
|
|
#include "msipriv.h"
|
|
|
|
#include "winemsi.h"
|
|
|
|
|
2012-01-17 20:07:11 +01:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "msxml2.h"
|
|
|
|
|
2011-03-30 12:31:35 +02:00
|
|
|
#include "wine/debug.h"
|
2018-09-08 03:17:22 +02:00
|
|
|
#include "wine/exception.h"
|
2005-04-20 14:50:05 +02:00
|
|
|
#include "wine/unicode.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2005-05-11 14:01:12 +02:00
|
|
|
static const WCHAR installerW[] = {'\\','I','n','s','t','a','l','l','e','r',0};
|
|
|
|
|
2011-08-23 14:41:43 +02:00
|
|
|
UINT msi_locate_product(LPCWSTR szProduct, MSIINSTALLCONTEXT *context)
|
2008-07-29 01:48:13 +02:00
|
|
|
{
|
|
|
|
HKEY hkey = NULL;
|
|
|
|
|
|
|
|
*context = MSIINSTALLCONTEXT_NONE;
|
2011-08-23 14:42:15 +02:00
|
|
|
if (!szProduct) return ERROR_UNKNOWN_PRODUCT;
|
2008-07-29 01:48:13 +02:00
|
|
|
|
2009-03-22 22:30:16 +01:00
|
|
|
if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&hkey, FALSE) == ERROR_SUCCESS)
|
2008-07-31 07:42:07 +02:00
|
|
|
*context = MSIINSTALLCONTEXT_USERMANAGED;
|
2009-03-22 22:30:16 +01:00
|
|
|
else if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
|
2008-11-04 05:16:43 +01:00
|
|
|
&hkey, FALSE) == ERROR_SUCCESS)
|
2008-07-29 01:48:13 +02:00
|
|
|
*context = MSIINSTALLCONTEXT_MACHINE;
|
2009-03-22 22:30:16 +01:00
|
|
|
else if (MSIREG_OpenProductKey(szProduct, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERUNMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&hkey, FALSE) == ERROR_SUCCESS)
|
2008-07-31 07:42:07 +02:00
|
|
|
*context = MSIINSTALLCONTEXT_USERUNMANAGED;
|
2008-07-29 01:48:13 +02:00
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
2008-07-31 07:42:07 +02:00
|
|
|
|
|
|
|
if (*context == MSIINSTALLCONTEXT_NONE)
|
|
|
|
return ERROR_UNKNOWN_PRODUCT;
|
|
|
|
|
2008-07-29 01:48:13 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2003-08-13 03:27:48 +02:00
|
|
|
UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
|
|
|
|
{
|
2005-03-29 13:28:57 +02:00
|
|
|
UINT r;
|
2003-10-30 23:47:42 +01:00
|
|
|
LPWSTR szwProd = NULL;
|
|
|
|
|
|
|
|
TRACE("%s %p\n",debugstr_a(szProduct), phProduct);
|
|
|
|
|
|
|
|
if( szProduct )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwProd = strdupAtoW( szProduct );
|
|
|
|
if( !szwProd )
|
|
|
|
return ERROR_OUTOFMEMORY;
|
2003-10-30 23:47:42 +01:00
|
|
|
}
|
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
r = MsiOpenProductW( szwProd, phProduct );
|
2003-10-30 23:47:42 +01:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwProd );
|
2003-10-30 23:47:42 +01:00
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2008-07-31 07:42:07 +02:00
|
|
|
static UINT MSI_OpenProductW(LPCWSTR szProduct, MSIPACKAGE **package)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2003-11-05 01:34:51 +01:00
|
|
|
UINT r;
|
2008-07-31 07:42:07 +02:00
|
|
|
HKEY props;
|
|
|
|
LPWSTR path;
|
|
|
|
MSIINSTALLCONTEXT context;
|
2003-11-05 01:34:51 +01:00
|
|
|
|
2008-07-31 07:42:07 +02:00
|
|
|
static const WCHAR managed[] = {
|
|
|
|
'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0};
|
|
|
|
static const WCHAR local[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
|
2003-11-05 01:34:51 +01:00
|
|
|
|
2008-07-31 07:42:07 +02:00
|
|
|
TRACE("%s %p\n", debugstr_w(szProduct), package);
|
2003-11-05 01:34:51 +01:00
|
|
|
|
2008-07-31 07:42:07 +02:00
|
|
|
r = msi_locate_product(szProduct, &context);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
2003-11-05 01:34:51 +01:00
|
|
|
|
2008-12-15 04:07:14 +01:00
|
|
|
r = MSIREG_OpenInstallProps(szProduct, context, NULL, &props, FALSE);
|
2008-07-31 07:42:07 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return ERROR_UNKNOWN_PRODUCT;
|
2003-11-05 01:34:51 +01:00
|
|
|
|
2008-07-31 07:42:07 +02:00
|
|
|
if (context == MSIINSTALLCONTEXT_USERMANAGED)
|
|
|
|
path = msi_reg_get_val_str(props, managed);
|
|
|
|
else
|
|
|
|
path = msi_reg_get_val_str(props, local);
|
|
|
|
|
|
|
|
r = ERROR_UNKNOWN_PRODUCT;
|
|
|
|
|
|
|
|
if (!path || GetFileAttributesW(path) == INVALID_FILE_ATTRIBUTES)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (PathIsRelativeW(path))
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2008-07-31 07:42:07 +02:00
|
|
|
r = ERROR_INSTALL_PACKAGE_OPEN_FAILED;
|
|
|
|
goto done;
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
2003-11-05 01:34:51 +01:00
|
|
|
|
2018-06-21 21:48:56 +02:00
|
|
|
r = MSI_OpenPackageW(path, 0, package);
|
2003-11-05 01:34:51 +01:00
|
|
|
|
2008-07-31 07:42:07 +02:00
|
|
|
done:
|
|
|
|
RegCloseKey(props);
|
|
|
|
msi_free(path);
|
2003-11-05 01:34:51 +01:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2008-07-31 07:42:07 +02:00
|
|
|
UINT WINAPI MsiOpenProductW(LPCWSTR szProduct, MSIHANDLE *phProduct)
|
2005-09-28 12:13:18 +02:00
|
|
|
{
|
2008-07-31 07:42:07 +02:00
|
|
|
MSIPACKAGE *package = NULL;
|
2016-11-04 13:28:07 +01:00
|
|
|
WCHAR squashed_pc[SQUASHED_GUID_SIZE];
|
2008-07-31 07:42:07 +02:00
|
|
|
UINT r;
|
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
if (!szProduct || !squash_guid( szProduct, squashed_pc ))
|
2008-07-31 07:42:07 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (!phProduct)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
r = MSI_OpenProductW(szProduct, &package);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
*phProduct = alloc_msihandle(&package->hdr);
|
|
|
|
if (!*phProduct)
|
|
|
|
r = ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
|
|
|
|
msiobj_release(&package->hdr);
|
|
|
|
return r;
|
2005-09-28 12:13:18 +02:00
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiAdvertiseProductA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
|
|
|
|
LPCSTR szTransforms, LANGID lgidLanguage)
|
2003-09-02 01:57:06 +02:00
|
|
|
{
|
2005-01-24 12:22:00 +01:00
|
|
|
FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath),
|
|
|
|
debugstr_a(szScriptfilePath), debugstr_a(szTransforms), lgidLanguage);
|
2003-09-02 01:57:06 +02:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiAdvertiseProductW(LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
|
|
|
|
LPCWSTR szTransforms, LANGID lgidLanguage)
|
2003-09-02 01:57:06 +02:00
|
|
|
{
|
2005-01-24 12:22:00 +01:00
|
|
|
FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath),
|
|
|
|
debugstr_w(szScriptfilePath), debugstr_w(szTransforms), lgidLanguage);
|
2003-09-02 01:57:06 +02:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiAdvertiseProductExA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
|
|
|
|
LPCSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
|
2003-09-02 01:57:06 +02:00
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("%s %s %s %08x %08x %08x\n", debugstr_a(szPackagePath),
|
2005-01-24 12:22:00 +01:00
|
|
|
debugstr_a(szScriptfilePath), debugstr_a(szTransforms),
|
|
|
|
lgidLanguage, dwPlatform, dwOptions);
|
2003-09-02 01:57:06 +02:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiAdvertiseProductExW( LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
|
|
|
|
LPCWSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
|
2003-09-02 01:57:06 +02:00
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("%s %s %s %08x %08x %08x\n", debugstr_w(szPackagePath),
|
2005-01-24 12:22:00 +01:00
|
|
|
debugstr_w(szScriptfilePath), debugstr_w(szTransforms),
|
|
|
|
lgidLanguage, dwPlatform, dwOptions);
|
2003-09-02 01:57:06 +02:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2003-08-13 03:27:48 +02:00
|
|
|
UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
|
|
|
|
{
|
|
|
|
LPWSTR szwPath = NULL, szwCommand = NULL;
|
2005-03-29 13:28:57 +02:00
|
|
|
UINT r = ERROR_OUTOFMEMORY;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
TRACE("%s %s\n",debugstr_a(szPackagePath), debugstr_a(szCommandLine));
|
|
|
|
|
|
|
|
if( szPackagePath )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwPath = strdupAtoW( szPackagePath );
|
2003-09-27 04:24:31 +02:00
|
|
|
if( !szwPath )
|
|
|
|
goto end;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if( szCommandLine )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwCommand = strdupAtoW( szCommandLine );
|
2003-09-27 04:24:31 +02:00
|
|
|
if( !szwCommand )
|
|
|
|
goto end;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2003-08-13 03:27:48 +02:00
|
|
|
r = MsiInstallProductW( szwPath, szwCommand );
|
|
|
|
|
|
|
|
end:
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwPath );
|
|
|
|
msi_free( szwCommand );
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
|
|
|
|
{
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIPACKAGE *package = NULL;
|
2018-06-21 21:48:56 +02:00
|
|
|
const WCHAR *reinstallmode;
|
|
|
|
DWORD options = 0;
|
|
|
|
UINT r, len;
|
2004-06-28 22:34:35 +02:00
|
|
|
|
2006-07-21 07:04:09 +02:00
|
|
|
TRACE("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2009-03-22 22:31:35 +01:00
|
|
|
if (!szPackagePath)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (!*szPackagePath)
|
|
|
|
return ERROR_PATH_NOT_FOUND;
|
|
|
|
|
2018-06-21 21:48:56 +02:00
|
|
|
reinstallmode = msi_get_command_line_option(szCommandLine, szReinstallMode, &len);
|
|
|
|
if (reinstallmode)
|
|
|
|
{
|
|
|
|
while (len > 0)
|
|
|
|
{
|
|
|
|
if (reinstallmode[--len] == 'v' || reinstallmode[len] == 'V')
|
|
|
|
{
|
|
|
|
options |= WINE_OPENPACKAGEFLAGS_RECACHE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MSI_OpenPackageW( szPackagePath, options, &package );
|
2005-09-28 12:13:18 +02:00
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
2005-09-30 12:32:41 +02:00
|
|
|
r = MSI_InstallPackage( package, szPackagePath, szCommandLine );
|
2005-09-28 12:13:18 +02:00
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
}
|
2005-06-28 21:14:30 +02:00
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2004-07-19 23:19:45 +02:00
|
|
|
UINT WINAPI MsiReinstallProductA(LPCSTR szProduct, DWORD dwReinstallMode)
|
|
|
|
{
|
2009-03-24 10:25:34 +01:00
|
|
|
LPWSTR wszProduct;
|
|
|
|
UINT rc;
|
|
|
|
|
|
|
|
TRACE("%s %08x\n", debugstr_a(szProduct), dwReinstallMode);
|
|
|
|
|
|
|
|
wszProduct = strdupAtoW(szProduct);
|
|
|
|
|
|
|
|
rc = MsiReinstallProductW(wszProduct, dwReinstallMode);
|
|
|
|
|
|
|
|
msi_free(wszProduct);
|
|
|
|
return rc;
|
2004-07-19 23:19:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiReinstallProductW(LPCWSTR szProduct, DWORD dwReinstallMode)
|
|
|
|
{
|
2009-03-24 10:25:34 +01:00
|
|
|
TRACE("%s %08x\n", debugstr_w(szProduct), dwReinstallMode);
|
|
|
|
|
|
|
|
return MsiReinstallFeatureW(szProduct, szAll, dwReinstallMode);
|
2004-07-19 23:19:45 +02:00
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiApplyPatchA(LPCSTR szPatchPackage, LPCSTR szInstallPackage,
|
|
|
|
INSTALLTYPE eInstallType, LPCSTR szCommandLine)
|
2004-07-29 04:39:20 +02:00
|
|
|
{
|
2007-06-15 23:04:04 +02:00
|
|
|
LPWSTR patch_package = NULL;
|
|
|
|
LPWSTR install_package = NULL;
|
|
|
|
LPWSTR command_line = NULL;
|
|
|
|
UINT r = ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
TRACE("%s %s %d %s\n", debugstr_a(szPatchPackage), debugstr_a(szInstallPackage),
|
2005-01-24 12:22:00 +01:00
|
|
|
eInstallType, debugstr_a(szCommandLine));
|
2007-06-15 23:04:04 +02:00
|
|
|
|
|
|
|
if (szPatchPackage && !(patch_package = strdupAtoW(szPatchPackage)))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (szInstallPackage && !(install_package = strdupAtoW(szInstallPackage)))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (szCommandLine && !(command_line = strdupAtoW(szCommandLine)))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = MsiApplyPatchW(patch_package, install_package, eInstallType, command_line);
|
|
|
|
|
|
|
|
done:
|
|
|
|
msi_free(patch_package);
|
|
|
|
msi_free(install_package);
|
|
|
|
msi_free(command_line);
|
|
|
|
|
|
|
|
return r;
|
2004-07-29 04:39:20 +02:00
|
|
|
}
|
|
|
|
|
2011-01-12 14:04:28 +01:00
|
|
|
static UINT get_patch_product_codes( LPCWSTR szPatchPackage, WCHAR ***product_codes )
|
2010-05-31 12:11:34 +02:00
|
|
|
{
|
|
|
|
MSIHANDLE patch, info = 0;
|
|
|
|
UINT r, type;
|
|
|
|
DWORD size;
|
|
|
|
static WCHAR empty[] = {0};
|
2011-01-27 11:56:39 +01:00
|
|
|
WCHAR *codes = NULL;
|
2010-05-31 12:11:34 +02:00
|
|
|
|
|
|
|
r = MsiOpenDatabaseW( szPatchPackage, MSIDBOPEN_READONLY, &patch );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MsiGetSummaryInformationW( patch, NULL, 0, &info );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
r = MsiSummaryInfoGetPropertyW( info, PID_TEMPLATE, &type, NULL, NULL, empty, &size );
|
|
|
|
if (r != ERROR_MORE_DATA || !size || type != VT_LPSTR)
|
|
|
|
{
|
|
|
|
ERR("Failed to read product codes from patch\n");
|
|
|
|
r = ERROR_FUNCTION_FAILED;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
codes = msi_alloc( ++size * sizeof(WCHAR) );
|
|
|
|
if (!codes)
|
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MsiSummaryInfoGetPropertyW( info, PID_TEMPLATE, &type, NULL, NULL, codes, &size );
|
2011-01-12 14:04:28 +01:00
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
*product_codes = msi_split_string( codes, ';' );
|
2010-05-31 12:11:34 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
MsiCloseHandle( info );
|
|
|
|
MsiCloseHandle( patch );
|
2011-01-12 14:04:28 +01:00
|
|
|
msi_free( codes );
|
2010-05-31 12:11:34 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2009-05-01 15:06:53 +02:00
|
|
|
static UINT MSI_ApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szProductCode, LPCWSTR szCommandLine)
|
2004-07-29 04:39:20 +02:00
|
|
|
{
|
2011-10-13 15:26:15 +02:00
|
|
|
UINT i, r = ERROR_FUNCTION_FAILED;
|
2010-05-31 12:11:34 +02:00
|
|
|
DWORD size;
|
2010-05-01 17:49:14 +02:00
|
|
|
LPCWSTR cmd_ptr = szCommandLine;
|
2011-01-12 14:04:28 +01:00
|
|
|
LPWSTR cmd, *codes = NULL;
|
2010-04-21 11:39:34 +02:00
|
|
|
BOOL succeeded = FALSE;
|
2007-06-15 23:08:37 +02:00
|
|
|
|
2010-11-11 10:45:05 +01:00
|
|
|
static const WCHAR fmt[] = {'%','s',' ','P','A','T','C','H','=','"','%','s','"',0};
|
2013-12-17 22:17:37 +01:00
|
|
|
static const WCHAR empty[] = {0};
|
2007-06-15 23:08:37 +02:00
|
|
|
|
2009-05-06 15:57:22 +02:00
|
|
|
if (!szPatchPackage || !szPatchPackage[0])
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2010-05-31 12:11:34 +02:00
|
|
|
if (!szProductCode && (r = get_patch_product_codes( szPatchPackage, &codes )))
|
|
|
|
return r;
|
2007-06-15 23:08:37 +02:00
|
|
|
|
|
|
|
if (!szCommandLine)
|
|
|
|
cmd_ptr = empty;
|
|
|
|
|
2010-11-11 10:45:05 +01:00
|
|
|
size = strlenW(cmd_ptr) + strlenW(fmt) + strlenW(szPatchPackage) + 1;
|
2007-06-15 23:08:37 +02:00
|
|
|
cmd = msi_alloc(size * sizeof(WCHAR));
|
|
|
|
if (!cmd)
|
|
|
|
{
|
2010-05-31 12:11:34 +02:00
|
|
|
msi_free(codes);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
2007-06-15 23:08:37 +02:00
|
|
|
}
|
2010-11-11 10:45:05 +01:00
|
|
|
sprintfW(cmd, fmt, cmd_ptr, szPatchPackage);
|
2007-06-15 23:08:37 +02:00
|
|
|
|
2010-05-04 09:07:23 +02:00
|
|
|
if (szProductCode)
|
|
|
|
r = MsiConfigureProductExW(szProductCode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
|
|
|
|
else
|
2007-06-15 23:08:37 +02:00
|
|
|
{
|
2011-01-12 14:04:28 +01:00
|
|
|
for (i = 0; codes[i]; i++)
|
2010-04-21 11:39:34 +02:00
|
|
|
{
|
2011-01-12 14:04:28 +01:00
|
|
|
r = MsiConfigureProductExW(codes[i], INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
|
2010-05-04 09:07:23 +02:00
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
TRACE("patch applied\n");
|
|
|
|
succeeded = TRUE;
|
|
|
|
}
|
2010-04-21 11:39:34 +02:00
|
|
|
}
|
2010-05-04 09:07:23 +02:00
|
|
|
|
|
|
|
if (succeeded)
|
|
|
|
r = ERROR_SUCCESS;
|
2007-06-15 23:08:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
msi_free(cmd);
|
|
|
|
msi_free(codes);
|
|
|
|
return r;
|
2004-07-29 04:39:20 +02:00
|
|
|
}
|
|
|
|
|
2009-05-01 15:06:53 +02:00
|
|
|
UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage,
|
|
|
|
INSTALLTYPE eInstallType, LPCWSTR szCommandLine)
|
|
|
|
{
|
|
|
|
TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage), debugstr_w(szInstallPackage),
|
|
|
|
eInstallType, debugstr_w(szCommandLine));
|
|
|
|
|
|
|
|
if (szInstallPackage || eInstallType == INSTALLTYPE_NETWORK_IMAGE ||
|
|
|
|
eInstallType == INSTALLTYPE_SINGLE_INSTANCE)
|
|
|
|
{
|
|
|
|
FIXME("Only reading target products from patch\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MSI_ApplyPatchW(szPatchPackage, NULL, szCommandLine);
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiApplyMultiplePatchesA(LPCSTR szPatchPackages,
|
|
|
|
LPCSTR szProductCode, LPCSTR szPropertiesList)
|
|
|
|
{
|
|
|
|
LPWSTR patch_packages = NULL;
|
|
|
|
LPWSTR product_code = NULL;
|
|
|
|
LPWSTR properties_list = NULL;
|
|
|
|
UINT r = ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
TRACE("%s %s %s\n", debugstr_a(szPatchPackages), debugstr_a(szProductCode),
|
|
|
|
debugstr_a(szPropertiesList));
|
|
|
|
|
|
|
|
if (!szPatchPackages || !szPatchPackages[0])
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (!(patch_packages = strdupAtoW(szPatchPackages)))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (szProductCode && !(product_code = strdupAtoW(szProductCode)))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (szPropertiesList && !(properties_list = strdupAtoW(szPropertiesList)))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = MsiApplyMultiplePatchesW(patch_packages, product_code, properties_list);
|
|
|
|
|
|
|
|
done:
|
|
|
|
msi_free(patch_packages);
|
|
|
|
msi_free(product_code);
|
|
|
|
msi_free(properties_list);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages,
|
|
|
|
LPCWSTR szProductCode, LPCWSTR szPropertiesList)
|
|
|
|
{
|
|
|
|
UINT r = ERROR_SUCCESS;
|
|
|
|
LPCWSTR beg, end;
|
|
|
|
|
|
|
|
TRACE("%s %s %s\n", debugstr_w(szPatchPackages), debugstr_w(szProductCode),
|
|
|
|
debugstr_w(szPropertiesList));
|
|
|
|
|
|
|
|
if (!szPatchPackages || !szPatchPackages[0])
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
beg = end = szPatchPackages;
|
|
|
|
while (*beg)
|
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
LPWSTR patch;
|
|
|
|
|
|
|
|
while (*beg == ' ') beg++;
|
|
|
|
while (*end && *end != ';') end++;
|
|
|
|
|
|
|
|
len = end - beg;
|
|
|
|
while (len && beg[len - 1] == ' ') len--;
|
|
|
|
|
|
|
|
if (!len) return ERROR_INVALID_NAME;
|
|
|
|
|
|
|
|
patch = msi_alloc((len + 1) * sizeof(WCHAR));
|
|
|
|
if (!patch)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
memcpy(patch, beg, len * sizeof(WCHAR));
|
|
|
|
patch[len] = '\0';
|
|
|
|
|
|
|
|
r = MSI_ApplyPatchW(patch, szProductCode, szPropertiesList);
|
|
|
|
msi_free(patch);
|
|
|
|
|
2015-04-10 12:57:40 +02:00
|
|
|
if (r != ERROR_SUCCESS || !*end)
|
2009-05-01 15:06:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
beg = ++end;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
static void free_patchinfo( DWORD count, MSIPATCHSEQUENCEINFOW *info )
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
for (i = 0; i < count; i++) msi_free( (WCHAR *)info[i].szPatchData );
|
|
|
|
msi_free( info );
|
|
|
|
}
|
|
|
|
|
|
|
|
static MSIPATCHSEQUENCEINFOW *patchinfoAtoW( DWORD count, const MSIPATCHSEQUENCEINFOA *info )
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
MSIPATCHSEQUENCEINFOW *ret;
|
|
|
|
|
|
|
|
if (!(ret = msi_alloc( count * sizeof(MSIPATCHSEQUENCEINFOW) ))) return NULL;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (info[i].szPatchData && !(ret[i].szPatchData = strdupAtoW( info[i].szPatchData )))
|
|
|
|
{
|
|
|
|
free_patchinfo( i, ret );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ret[i].ePatchDataType = info[i].ePatchDataType;
|
|
|
|
ret[i].dwOrder = info[i].dwOrder;
|
|
|
|
ret[i].uStatus = info[i].uStatus;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-10-09 06:07:19 +02:00
|
|
|
UINT WINAPI MsiDetermineApplicablePatchesA(LPCSTR szProductPackagePath,
|
|
|
|
DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOA pPatchInfo)
|
|
|
|
{
|
2010-05-05 14:37:24 +02:00
|
|
|
UINT i, r;
|
|
|
|
WCHAR *package_path = NULL;
|
|
|
|
MSIPATCHSEQUENCEINFOW *psi;
|
2008-10-09 06:07:19 +02:00
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
TRACE("%s, %u, %p\n", debugstr_a(szProductPackagePath), cPatchInfo, pPatchInfo);
|
2010-05-05 14:37:24 +02:00
|
|
|
|
|
|
|
if (szProductPackagePath && !(package_path = strdupAtoW( szProductPackagePath )))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
if (!(psi = patchinfoAtoW( cPatchInfo, pPatchInfo )))
|
2010-05-05 14:37:24 +02:00
|
|
|
{
|
|
|
|
msi_free( package_path );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
r = MsiDetermineApplicablePatchesW( package_path, cPatchInfo, psi );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
for (i = 0; i < cPatchInfo; i++)
|
|
|
|
{
|
|
|
|
pPatchInfo[i].dwOrder = psi[i].dwOrder;
|
|
|
|
pPatchInfo[i].uStatus = psi[i].uStatus;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
msi_free( package_path );
|
2011-07-07 09:22:34 +02:00
|
|
|
free_patchinfo( cPatchInfo, psi );
|
2010-05-05 14:37:24 +02:00
|
|
|
return r;
|
2008-10-09 06:07:19 +02:00
|
|
|
}
|
|
|
|
|
2009-09-02 11:44:17 +02:00
|
|
|
static UINT MSI_ApplicablePatchW( MSIPACKAGE *package, LPCWSTR patch )
|
|
|
|
{
|
|
|
|
MSISUMMARYINFO *si;
|
|
|
|
MSIDATABASE *patch_db;
|
2015-03-16 10:55:58 +01:00
|
|
|
UINT r;
|
2009-09-02 11:44:17 +02:00
|
|
|
|
|
|
|
r = MSI_OpenDatabaseW( patch, MSIDBOPEN_READONLY, &patch_db );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("failed to open patch file %s\n", debugstr_w(patch));
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
r = msi_get_suminfo( patch_db->storage, 0, &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
2009-09-02 11:44:17 +02:00
|
|
|
{
|
2010-05-25 12:18:32 +02:00
|
|
|
msiobj_release( &patch_db->hdr );
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2009-09-02 11:44:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
r = msi_check_patch_applicable( package, si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
TRACE("patch not applicable\n");
|
|
|
|
|
|
|
|
msiobj_release( &patch_db->hdr );
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2012-01-17 20:07:11 +01:00
|
|
|
/* IXMLDOMDocument should be set to XPath mode already */
|
|
|
|
static UINT MSI_ApplicablePatchXML( MSIPACKAGE *package, IXMLDOMDocument *desc )
|
|
|
|
{
|
|
|
|
static const WCHAR queryW[] = {'M','s','i','P','a','t','c','h','/',
|
|
|
|
'T','a','r','g','e','t','P','r','o','d','u','c','t','/',
|
|
|
|
'T','a','r','g','e','t','P','r','o','d','u','c','t','C','o','d','e',0};
|
|
|
|
UINT r = ERROR_FUNCTION_FAILED;
|
|
|
|
IXMLDOMNodeList *list;
|
|
|
|
LPWSTR product_code;
|
|
|
|
IXMLDOMNode *node;
|
|
|
|
HRESULT hr;
|
|
|
|
BSTR s;
|
|
|
|
|
|
|
|
product_code = msi_dup_property( package->db, szProductCode );
|
|
|
|
if (!product_code)
|
|
|
|
{
|
|
|
|
/* FIXME: the property ProductCode should be written into the DB somewhere */
|
|
|
|
ERR("no product code to check\n");
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = SysAllocString(queryW);
|
|
|
|
hr = IXMLDOMDocument_selectNodes( desc, s, &list );
|
|
|
|
SysFreeString(s);
|
|
|
|
if (hr != S_OK)
|
|
|
|
return ERROR_INVALID_PATCH_XML;
|
|
|
|
|
|
|
|
while (IXMLDOMNodeList_nextNode( list, &node ) == S_OK && r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
hr = IXMLDOMNode_get_text( node, &s );
|
|
|
|
IXMLDOMNode_Release( node );
|
2012-02-06 13:05:14 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
if (!strcmpW( s, product_code )) r = ERROR_SUCCESS;
|
|
|
|
SysFreeString( s );
|
|
|
|
}
|
2012-01-17 20:07:11 +01:00
|
|
|
}
|
|
|
|
IXMLDOMNodeList_Release( list );
|
|
|
|
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
TRACE("patch not applicable\n");
|
|
|
|
|
|
|
|
msi_free( product_code );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
static UINT determine_patch_sequence( MSIPACKAGE *package, DWORD count, MSIPATCHSEQUENCEINFOW *info )
|
2008-10-09 06:07:19 +02:00
|
|
|
{
|
2012-01-17 20:07:11 +01:00
|
|
|
IXMLDOMDocument *desc = NULL;
|
2011-07-07 09:22:34 +02:00
|
|
|
DWORD i;
|
2009-09-02 11:44:17 +02:00
|
|
|
|
2012-01-17 20:07:11 +01:00
|
|
|
if (count > 1)
|
|
|
|
FIXME("patch ordering not supported\n");
|
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
for (i = 0; i < count; i++)
|
2009-09-02 11:44:17 +02:00
|
|
|
{
|
2011-07-07 09:22:34 +02:00
|
|
|
switch (info[i].ePatchDataType)
|
2009-09-02 11:44:17 +02:00
|
|
|
{
|
|
|
|
case MSIPATCH_DATATYPE_PATCHFILE:
|
|
|
|
{
|
2011-07-07 09:22:34 +02:00
|
|
|
if (MSI_ApplicablePatchW( package, info[i].szPatchData ) != ERROR_SUCCESS)
|
2009-09-02 11:44:17 +02:00
|
|
|
{
|
2011-07-07 09:22:34 +02:00
|
|
|
info[i].dwOrder = ~0u;
|
|
|
|
info[i].uStatus = ERROR_PATCH_TARGET_NOT_FOUND;
|
2009-09-02 11:44:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-07-07 09:22:34 +02:00
|
|
|
info[i].dwOrder = i;
|
|
|
|
info[i].uStatus = ERROR_SUCCESS;
|
2009-09-02 11:44:17 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-01-17 21:46:16 +01:00
|
|
|
case MSIPATCH_DATATYPE_XMLPATH:
|
2012-01-17 20:07:11 +01:00
|
|
|
case MSIPATCH_DATATYPE_XMLBLOB:
|
|
|
|
{
|
|
|
|
VARIANT_BOOL b;
|
|
|
|
HRESULT hr;
|
|
|
|
BSTR s;
|
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
{
|
|
|
|
hr = CoCreateInstance( &CLSID_DOMDocument30, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IXMLDOMDocument, (void**)&desc );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
ERR("failed to create DOMDocument30 instance, 0x%08x\n", hr);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s = SysAllocString( info[i].szPatchData );
|
2012-01-17 21:46:16 +01:00
|
|
|
if (info[i].ePatchDataType == MSIPATCH_DATATYPE_XMLPATH)
|
|
|
|
{
|
|
|
|
VARIANT src;
|
|
|
|
|
|
|
|
V_VT(&src) = VT_BSTR;
|
|
|
|
V_BSTR(&src) = s;
|
|
|
|
hr = IXMLDOMDocument_load( desc, src, &b );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = IXMLDOMDocument_loadXML( desc, s, &b );
|
2012-01-17 20:07:11 +01:00
|
|
|
SysFreeString( s );
|
|
|
|
if ( hr != S_OK )
|
|
|
|
{
|
|
|
|
ERR("failed to parse patch description\n");
|
|
|
|
IXMLDOMDocument_Release( desc );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MSI_ApplicablePatchXML( package, desc ) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
info[i].dwOrder = ~0u;
|
|
|
|
info[i].uStatus = ERROR_PATCH_TARGET_NOT_FOUND;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
info[i].dwOrder = i;
|
|
|
|
info[i].uStatus = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-09-02 11:44:17 +02:00
|
|
|
default:
|
|
|
|
{
|
2012-01-17 21:46:16 +01:00
|
|
|
FIXME("unknown patch data type %u\n", info[i].ePatchDataType);
|
2011-07-07 09:22:34 +02:00
|
|
|
info[i].dwOrder = i;
|
|
|
|
info[i].uStatus = ERROR_SUCCESS;
|
2009-09-02 11:44:17 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-17 20:07:11 +01:00
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
TRACE("szPatchData: %s\n", debugstr_w(info[i].szPatchData));
|
|
|
|
TRACE("ePatchDataType: %u\n", info[i].ePatchDataType);
|
|
|
|
TRACE("dwOrder: %u\n", info[i].dwOrder);
|
|
|
|
TRACE("uStatus: %u\n", info[i].uStatus);
|
2009-09-02 11:44:17 +02:00
|
|
|
}
|
2012-01-17 20:07:11 +01:00
|
|
|
|
|
|
|
if (desc) IXMLDOMDocument_Release( desc );
|
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
return ERROR_SUCCESS;
|
2008-10-09 06:07:19 +02:00
|
|
|
}
|
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
UINT WINAPI MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath,
|
|
|
|
DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOW pPatchInfo)
|
2009-03-24 10:24:46 +01:00
|
|
|
{
|
2011-07-07 09:22:34 +02:00
|
|
|
UINT r;
|
|
|
|
MSIPACKAGE *package;
|
2009-03-24 10:24:46 +01:00
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
TRACE("%s, %u, %p\n", debugstr_w(szProductPackagePath), cPatchInfo, pPatchInfo);
|
|
|
|
|
2018-06-21 21:48:56 +02:00
|
|
|
r = MSI_OpenPackageW( szProductPackagePath, 0, &package );
|
2011-07-07 09:22:34 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("failed to open package %u\n", r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
r = determine_patch_sequence( package, cPatchInfo, pPatchInfo );
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return r;
|
2009-03-24 10:24:46 +01:00
|
|
|
}
|
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
UINT WINAPI MsiDeterminePatchSequenceA( LPCSTR product, LPCSTR usersid,
|
|
|
|
MSIINSTALLCONTEXT context, DWORD count, PMSIPATCHSEQUENCEINFOA patchinfo )
|
2009-03-24 10:24:46 +01:00
|
|
|
{
|
2011-07-07 09:22:34 +02:00
|
|
|
UINT i, r;
|
|
|
|
WCHAR *productW, *usersidW = NULL;
|
|
|
|
MSIPATCHSEQUENCEINFOW *patchinfoW;
|
2009-03-24 10:24:46 +01:00
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
TRACE("%s, %s, %d, %d, %p\n", debugstr_a(product), debugstr_a(usersid),
|
|
|
|
context, count, patchinfo);
|
|
|
|
|
|
|
|
if (!product) return ERROR_INVALID_PARAMETER;
|
|
|
|
if (!(productW = strdupAtoW( product ))) return ERROR_OUTOFMEMORY;
|
|
|
|
if (usersid && !(usersidW = strdupAtoW( usersid )))
|
|
|
|
{
|
|
|
|
msi_free( productW );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
if (!(patchinfoW = patchinfoAtoW( count, patchinfo )))
|
|
|
|
{
|
|
|
|
msi_free( productW );
|
|
|
|
msi_free( usersidW );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
r = MsiDeterminePatchSequenceW( productW, usersidW, context, count, patchinfoW );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
patchinfo[i].dwOrder = patchinfoW[i].dwOrder;
|
|
|
|
patchinfo[i].uStatus = patchinfoW[i].uStatus;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
msi_free( productW );
|
|
|
|
msi_free( usersidW );
|
|
|
|
free_patchinfo( count, patchinfoW );
|
|
|
|
return r;
|
2009-03-24 10:24:46 +01:00
|
|
|
}
|
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
static UINT open_package( const WCHAR *product, const WCHAR *usersid,
|
|
|
|
MSIINSTALLCONTEXT context, MSIPACKAGE **package )
|
2008-08-05 17:28:27 +02:00
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
HKEY props;
|
2011-07-07 09:22:34 +02:00
|
|
|
WCHAR *localpath, sourcepath[MAX_PATH], filename[MAX_PATH];
|
2008-08-05 17:28:27 +02:00
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
r = MSIREG_OpenInstallProps( product, context, usersid, &props, FALSE );
|
|
|
|
if (r != ERROR_SUCCESS) return ERROR_BAD_CONFIGURATION;
|
2008-08-05 17:28:27 +02:00
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
if ((localpath = msi_reg_get_val_str( props, szLocalPackage )))
|
2008-08-05 17:28:27 +02:00
|
|
|
{
|
2011-07-07 09:22:34 +02:00
|
|
|
strcpyW( sourcepath, localpath );
|
|
|
|
msi_free( localpath );
|
2008-08-05 17:28:27 +02:00
|
|
|
}
|
2011-07-07 09:22:34 +02:00
|
|
|
RegCloseKey( props );
|
|
|
|
if (!localpath || GetFileAttributesW( sourcepath ) == INVALID_FILE_ATTRIBUTES)
|
2008-08-05 17:28:27 +02:00
|
|
|
{
|
2011-07-07 09:22:34 +02:00
|
|
|
DWORD sz = sizeof(sourcepath);
|
|
|
|
MsiSourceListGetInfoW( product, usersid, context, MSICODE_PRODUCT,
|
|
|
|
INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz );
|
2008-08-05 17:28:27 +02:00
|
|
|
sz = sizeof(filename);
|
2011-07-07 09:22:34 +02:00
|
|
|
MsiSourceListGetInfoW( product, usersid, context, MSICODE_PRODUCT,
|
|
|
|
INSTALLPROPERTY_PACKAGENAMEW, filename, &sz );
|
|
|
|
strcatW( sourcepath, filename );
|
2008-08-05 17:28:27 +02:00
|
|
|
}
|
2011-07-07 09:22:34 +02:00
|
|
|
if (GetFileAttributesW( sourcepath ) == INVALID_FILE_ATTRIBUTES)
|
2008-08-05 17:28:27 +02:00
|
|
|
return ERROR_INSTALL_SOURCE_ABSENT;
|
|
|
|
|
2018-06-21 21:48:56 +02:00
|
|
|
return MSI_OpenPackageW( sourcepath, 0, package );
|
2011-07-07 09:22:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiDeterminePatchSequenceW( LPCWSTR product, LPCWSTR usersid,
|
|
|
|
MSIINSTALLCONTEXT context, DWORD count, PMSIPATCHSEQUENCEINFOW patchinfo )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
MSIPACKAGE *package;
|
|
|
|
|
|
|
|
TRACE("%s, %s, %d, %d, %p\n", debugstr_w(product), debugstr_w(usersid),
|
|
|
|
context, count, patchinfo);
|
|
|
|
|
|
|
|
if (!product) return ERROR_INVALID_PARAMETER;
|
|
|
|
r = open_package( product, usersid, context, &package );
|
|
|
|
if (r != ERROR_SUCCESS) return r;
|
|
|
|
|
|
|
|
r = determine_patch_sequence( package, count, patchinfo );
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return r;
|
2008-08-05 17:28:27 +02:00
|
|
|
}
|
|
|
|
|
2005-01-19 17:58:03 +01:00
|
|
|
UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
|
|
|
|
INSTALLSTATE eInstallState, LPCWSTR szCommandLine)
|
|
|
|
{
|
2005-09-28 12:13:18 +02:00
|
|
|
MSIPACKAGE* package = NULL;
|
2008-07-29 01:48:13 +02:00
|
|
|
MSIINSTALLCONTEXT context;
|
2005-09-28 12:13:18 +02:00
|
|
|
UINT r;
|
2005-01-19 17:58:03 +01:00
|
|
|
DWORD sz;
|
2009-03-31 11:31:28 +02:00
|
|
|
WCHAR sourcepath[MAX_PATH], filename[MAX_PATH];
|
2008-07-29 01:48:56 +02:00
|
|
|
LPWSTR commandline;
|
|
|
|
|
2005-01-19 17:58:03 +01:00
|
|
|
static const WCHAR szInstalled[] = {
|
|
|
|
' ','I','n','s','t','a','l','l','e','d','=','1',0};
|
2011-05-02 16:04:25 +02:00
|
|
|
static const WCHAR szMaxInstallLevel[] = {
|
2010-12-24 15:31:26 +01:00
|
|
|
' ','I','N','S','T','A','L','L','L','E','V','E','L','=','3','2','7','6','7',0};
|
2008-07-29 01:48:56 +02:00
|
|
|
static const WCHAR szRemoveAll[] = {
|
|
|
|
' ','R','E','M','O','V','E','=','A','L','L',0};
|
2008-07-29 01:49:47 +02:00
|
|
|
static const WCHAR szMachine[] = {
|
|
|
|
' ','A','L','L','U','S','E','R','S','=','1',0};
|
2005-01-19 17:58:03 +01:00
|
|
|
|
2006-07-21 07:04:09 +02:00
|
|
|
TRACE("%s %d %d %s\n",debugstr_w(szProduct), iInstallLevel, eInstallState,
|
2005-01-24 12:22:00 +01:00
|
|
|
debugstr_w(szCommandLine));
|
2005-01-19 17:58:03 +01:00
|
|
|
|
2008-07-29 01:47:30 +02:00
|
|
|
if (!szProduct || lstrlenW(szProduct) != GUID_SIZE - 1)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2008-07-29 01:48:56 +02:00
|
|
|
if (eInstallState == INSTALLSTATE_ADVERTISED ||
|
|
|
|
eInstallState == INSTALLSTATE_SOURCE)
|
2005-01-19 17:58:03 +01:00
|
|
|
{
|
2008-07-29 01:48:56 +02:00
|
|
|
FIXME("State %d not implemented\n", eInstallState);
|
2005-01-19 17:58:03 +01:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2008-07-29 01:48:13 +02:00
|
|
|
r = msi_locate_product(szProduct, &context);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
2005-01-19 17:58:03 +01:00
|
|
|
|
2011-07-07 09:22:34 +02:00
|
|
|
r = open_package(szProduct, NULL, context, &package);
|
2005-09-28 12:13:18 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2005-09-28 12:13:18 +02:00
|
|
|
sz = lstrlenW(szInstalled) + 1;
|
2005-01-19 17:58:03 +01:00
|
|
|
|
|
|
|
if (szCommandLine)
|
2005-03-24 20:04:06 +01:00
|
|
|
sz += lstrlenW(szCommandLine);
|
2005-01-19 17:58:03 +01:00
|
|
|
|
2010-12-24 15:31:26 +01:00
|
|
|
if (eInstallState != INSTALLSTATE_DEFAULT)
|
2011-05-02 16:04:25 +02:00
|
|
|
sz += lstrlenW(szMaxInstallLevel);
|
2010-12-24 15:31:26 +01:00
|
|
|
|
2008-07-29 01:48:56 +02:00
|
|
|
if (eInstallState == INSTALLSTATE_ABSENT)
|
|
|
|
sz += lstrlenW(szRemoveAll);
|
|
|
|
|
2008-07-29 01:49:47 +02:00
|
|
|
if (context == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
sz += lstrlenW(szMachine);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
commandline = msi_alloc(sz * sizeof(WCHAR));
|
2008-07-29 01:48:13 +02:00
|
|
|
if (!commandline)
|
2005-09-28 12:13:18 +02:00
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto end;
|
|
|
|
}
|
2005-01-19 17:58:03 +01:00
|
|
|
|
2005-09-28 12:13:18 +02:00
|
|
|
commandline[0] = 0;
|
2005-03-29 13:28:57 +02:00
|
|
|
if (szCommandLine)
|
|
|
|
lstrcpyW(commandline,szCommandLine);
|
2005-01-19 17:58:03 +01:00
|
|
|
|
2010-12-24 15:31:26 +01:00
|
|
|
if (eInstallState != INSTALLSTATE_DEFAULT)
|
2011-05-02 16:04:25 +02:00
|
|
|
lstrcatW(commandline, szMaxInstallLevel);
|
2010-12-24 15:31:26 +01:00
|
|
|
|
2008-07-29 01:48:56 +02:00
|
|
|
if (eInstallState == INSTALLSTATE_ABSENT)
|
|
|
|
lstrcatW(commandline, szRemoveAll);
|
|
|
|
|
2008-07-29 01:49:47 +02:00
|
|
|
if (context == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
lstrcatW(commandline, szMachine);
|
|
|
|
|
2009-03-31 11:31:28 +02:00
|
|
|
sz = sizeof(sourcepath);
|
|
|
|
MsiSourceListGetInfoW(szProduct, NULL, context, MSICODE_PRODUCT,
|
|
|
|
INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
|
|
|
|
|
|
|
|
sz = sizeof(filename);
|
|
|
|
MsiSourceListGetInfoW(szProduct, NULL, context, MSICODE_PRODUCT,
|
|
|
|
INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
|
|
|
|
|
|
|
|
strcatW(sourcepath, filename);
|
|
|
|
|
2005-09-30 12:32:41 +02:00
|
|
|
r = MSI_InstallPackage( package, sourcepath, commandline );
|
2005-02-09 14:22:49 +01:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(commandline);
|
2005-09-28 12:13:18 +02:00
|
|
|
|
2005-01-19 17:58:03 +01:00
|
|
|
end:
|
2005-09-28 12:13:18 +02:00
|
|
|
msiobj_release( &package->hdr );
|
2005-01-19 17:58:03 +01:00
|
|
|
|
2005-09-28 12:13:18 +02:00
|
|
|
return r;
|
2005-01-19 17:58:03 +01:00
|
|
|
}
|
|
|
|
|
2005-01-25 11:58:36 +01:00
|
|
|
UINT WINAPI MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel,
|
|
|
|
INSTALLSTATE eInstallState, LPCSTR szCommandLine)
|
|
|
|
{
|
|
|
|
LPWSTR szwProduct = NULL;
|
|
|
|
LPWSTR szwCommandLine = NULL;
|
2005-03-29 13:28:57 +02:00
|
|
|
UINT r = ERROR_OUTOFMEMORY;
|
2005-01-25 11:58:36 +01:00
|
|
|
|
|
|
|
if( szProduct )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwProduct = strdupAtoW( szProduct );
|
2005-01-25 11:58:36 +01:00
|
|
|
if( !szwProduct )
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( szCommandLine)
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwCommandLine = strdupAtoW( szCommandLine );
|
2005-01-25 11:58:36 +01:00
|
|
|
if( !szwCommandLine)
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
r = MsiConfigureProductExW( szwProduct, iInstallLevel, eInstallState,
|
2005-01-25 11:58:36 +01:00
|
|
|
szwCommandLine );
|
|
|
|
end:
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwProduct );
|
|
|
|
msi_free( szwCommandLine);
|
2005-01-25 11:58:36 +01:00
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
return r;
|
2005-01-25 11:58:36 +01:00
|
|
|
}
|
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel,
|
2005-01-19 17:58:03 +01:00
|
|
|
INSTALLSTATE eInstallState)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2004-04-28 02:29:25 +02:00
|
|
|
LPWSTR szwProduct = NULL;
|
2005-03-29 13:28:57 +02:00
|
|
|
UINT r;
|
2004-04-28 02:29:25 +02:00
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
TRACE("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
|
2004-04-28 02:29:25 +02:00
|
|
|
|
|
|
|
if( szProduct )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwProduct = strdupAtoW( szProduct );
|
2004-04-28 02:29:25 +02:00
|
|
|
if( !szwProduct )
|
2005-03-29 13:28:57 +02:00
|
|
|
return ERROR_OUTOFMEMORY;
|
2004-04-28 02:29:25 +02:00
|
|
|
}
|
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
r = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwProduct );
|
2004-04-28 02:29:25 +02:00
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel,
|
2005-01-19 17:58:03 +01:00
|
|
|
INSTALLSTATE eInstallState)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-03-29 13:28:57 +02:00
|
|
|
return MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, NULL);
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer)
|
|
|
|
{
|
2005-01-24 12:22:00 +01:00
|
|
|
LPWSTR szwComponent = NULL;
|
2005-03-29 13:28:57 +02:00
|
|
|
UINT r;
|
2005-01-24 12:22:00 +01:00
|
|
|
WCHAR szwBuffer[GUID_SIZE];
|
2004-04-28 02:29:25 +02:00
|
|
|
|
2010-06-14 14:21:12 +02:00
|
|
|
TRACE("%s %p\n", debugstr_a(szComponent), szBuffer);
|
2004-04-28 02:29:25 +02:00
|
|
|
|
|
|
|
if( szComponent )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwComponent = strdupAtoW( szComponent );
|
2004-04-28 02:29:25 +02:00
|
|
|
if( !szwComponent )
|
2005-03-29 13:28:57 +02:00
|
|
|
return ERROR_OUTOFMEMORY;
|
2004-04-28 02:29:25 +02:00
|
|
|
}
|
|
|
|
|
2007-12-07 21:49:54 +01:00
|
|
|
*szwBuffer = '\0';
|
2005-03-29 13:28:57 +02:00
|
|
|
r = MsiGetProductCodeW( szwComponent, szwBuffer );
|
2004-04-28 02:29:25 +02:00
|
|
|
|
2007-12-07 21:49:54 +01:00
|
|
|
if(*szwBuffer)
|
2004-04-28 02:29:25 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, GUID_SIZE, NULL, NULL);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwComponent );
|
2004-04-28 02:29:25 +02:00
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
|
|
|
|
{
|
2007-12-07 21:49:54 +01:00
|
|
|
UINT rc, index;
|
|
|
|
HKEY compkey, prodkey;
|
2016-11-04 13:28:07 +01:00
|
|
|
WCHAR squashed_comp[SQUASHED_GUID_SIZE], squashed_prod[SQUASHED_GUID_SIZE];
|
2018-08-20 21:15:43 +02:00
|
|
|
DWORD sz = ARRAY_SIZE(squashed_prod);
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2007-12-07 21:49:54 +01:00
|
|
|
TRACE("%s %p\n", debugstr_w(szComponent), szBuffer);
|
|
|
|
|
|
|
|
if (!szComponent || !*szComponent)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
if (!squash_guid( szComponent, squashed_comp ))
|
2005-01-24 12:22:00 +01:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2008-12-09 07:21:00 +01:00
|
|
|
if (MSIREG_OpenUserDataComponentKey(szComponent, NULL, &compkey, FALSE) != ERROR_SUCCESS &&
|
2008-12-09 07:21:15 +01:00
|
|
|
MSIREG_OpenUserDataComponentKey(szComponent, szLocalSid, &compkey, FALSE) != ERROR_SUCCESS)
|
2007-12-07 21:49:54 +01:00
|
|
|
{
|
|
|
|
return ERROR_UNKNOWN_COMPONENT;
|
|
|
|
}
|
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
rc = RegEnumValueW( compkey, 0, squashed_prod, &sz, NULL, NULL, NULL, NULL );
|
2005-05-20 20:59:11 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
2007-12-07 21:49:54 +01:00
|
|
|
{
|
|
|
|
RegCloseKey(compkey);
|
2005-05-20 20:59:11 +02:00
|
|
|
return ERROR_UNKNOWN_COMPONENT;
|
2007-12-07 21:49:54 +01:00
|
|
|
}
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2007-12-07 21:49:54 +01:00
|
|
|
/* check simple case, only one product */
|
2016-11-04 13:28:07 +01:00
|
|
|
rc = RegEnumValueW( compkey, 1, squashed_prod, &sz, NULL, NULL, NULL, NULL );
|
2007-12-07 21:49:54 +01:00
|
|
|
if (rc == ERROR_NO_MORE_ITEMS)
|
2005-05-20 20:59:11 +02:00
|
|
|
{
|
2007-12-07 21:49:54 +01:00
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
goto done;
|
2005-05-20 20:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-12-07 21:49:54 +01:00
|
|
|
index = 0;
|
2016-11-04 13:28:07 +01:00
|
|
|
while ((rc = RegEnumValueW( compkey, index, squashed_prod, &sz, NULL, NULL, NULL, NULL )) !=
|
|
|
|
ERROR_NO_MORE_ITEMS)
|
2007-12-07 21:49:54 +01:00
|
|
|
{
|
|
|
|
index++;
|
|
|
|
sz = GUID_SIZE;
|
2016-11-04 13:28:07 +01:00
|
|
|
unsquash_guid( squashed_prod, szBuffer );
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2009-03-22 22:30:16 +01:00
|
|
|
if (MSIREG_OpenProductKey(szBuffer, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&prodkey, FALSE) == ERROR_SUCCESS ||
|
2009-03-22 22:30:16 +01:00
|
|
|
MSIREG_OpenProductKey(szBuffer, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERUNMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&prodkey, FALSE) == ERROR_SUCCESS ||
|
2009-03-22 22:30:16 +01:00
|
|
|
MSIREG_OpenProductKey(szBuffer, NULL,
|
|
|
|
MSIINSTALLCONTEXT_MACHINE,
|
2008-11-04 05:16:43 +01:00
|
|
|
&prodkey, FALSE) == ERROR_SUCCESS)
|
2007-12-07 21:49:54 +01:00
|
|
|
{
|
|
|
|
RegCloseKey(prodkey);
|
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2007-12-07 21:49:54 +01:00
|
|
|
rc = ERROR_INSTALL_FAILURE;
|
|
|
|
|
|
|
|
done:
|
|
|
|
RegCloseKey(compkey);
|
2016-11-04 13:28:07 +01:00
|
|
|
unsquash_guid( squashed_prod, szBuffer );
|
2007-12-07 21:49:54 +01:00
|
|
|
return rc;
|
2004-04-28 02:29:25 +02:00
|
|
|
}
|
|
|
|
|
2017-04-19 11:26:48 +02:00
|
|
|
static WCHAR *reg_get_value( HKEY hkey, const WCHAR *name, DWORD *type )
|
2008-02-17 06:39:16 +01:00
|
|
|
{
|
|
|
|
LONG res;
|
|
|
|
|
2017-04-19 11:26:48 +02:00
|
|
|
if ((res = RegQueryValueExW( hkey, name, NULL, type, NULL, NULL )) != ERROR_SUCCESS) return NULL;
|
2008-02-17 06:39:16 +01:00
|
|
|
|
2017-04-19 11:26:48 +02:00
|
|
|
if (*type == REG_SZ) return msi_reg_get_val_str( hkey, name );
|
|
|
|
if (*type == REG_DWORD)
|
|
|
|
{
|
|
|
|
static const WCHAR fmt[] = {'%','u',0};
|
|
|
|
WCHAR temp[11];
|
|
|
|
DWORD val;
|
2008-02-17 06:39:16 +01:00
|
|
|
|
2017-04-19 11:26:48 +02:00
|
|
|
if (!msi_reg_get_val_dword( hkey, name, &val )) return NULL;
|
|
|
|
sprintfW( temp, fmt, val );
|
|
|
|
return strdupW( temp );
|
|
|
|
}
|
2008-02-17 06:39:16 +01:00
|
|
|
|
2017-04-19 11:26:48 +02:00
|
|
|
ERR( "unhandled value type %u\n", *type );
|
|
|
|
return NULL;
|
2008-02-17 06:39:16 +01:00
|
|
|
}
|
|
|
|
|
2008-11-26 17:15:59 +01:00
|
|
|
static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
|
|
|
|
awstring *szValue, LPDWORD pcchValueBuf)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2012-10-29 12:16:42 +01:00
|
|
|
static WCHAR empty[] = {0};
|
|
|
|
static const WCHAR sourcelist[] = {'S','o','u','r','c','e','L','i','s','t',0};
|
|
|
|
static const WCHAR display_name[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
|
|
|
|
static const WCHAR display_version[] = {'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
|
|
|
|
static const WCHAR assignment[] = {'A','s','s','i','g','n','m','e','n','t',0};
|
2008-12-15 04:07:14 +01:00
|
|
|
MSIINSTALLCONTEXT context = MSIINSTALLCONTEXT_USERUNMANAGED;
|
2008-02-12 08:35:46 +01:00
|
|
|
UINT r = ERROR_UNKNOWN_PROPERTY;
|
|
|
|
HKEY prodkey, userdata, source;
|
2016-11-28 17:29:58 +01:00
|
|
|
WCHAR *val = NULL, squashed_pc[SQUASHED_GUID_SIZE], packagecode[GUID_SIZE];
|
2008-02-12 08:35:46 +01:00
|
|
|
BOOL badconfig = FALSE;
|
|
|
|
LONG res;
|
2009-12-14 04:35:27 +01:00
|
|
|
DWORD type = REG_NONE;
|
2008-02-12 08:35:46 +01:00
|
|
|
|
2006-07-14 08:21:10 +02:00
|
|
|
TRACE("%s %s %p %p\n", debugstr_w(szProduct),
|
|
|
|
debugstr_w(szAttribute), szValue, pcchValueBuf);
|
2004-04-28 02:29:25 +02:00
|
|
|
|
2008-02-11 08:16:49 +01:00
|
|
|
if ((szValue->str.w && !pcchValueBuf) || !szProduct || !szAttribute)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
if (!squash_guid( szProduct, squashed_pc ))
|
2005-01-24 12:22:00 +01:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
2006-07-14 08:21:10 +02:00
|
|
|
|
2009-03-22 22:30:16 +01:00
|
|
|
if ((r = MSIREG_OpenProductKey(szProduct, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&prodkey, FALSE)) != ERROR_SUCCESS &&
|
2009-03-22 22:30:16 +01:00
|
|
|
(r = MSIREG_OpenProductKey(szProduct, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERUNMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&prodkey, FALSE)) != ERROR_SUCCESS &&
|
2009-03-22 22:30:16 +01:00
|
|
|
(r = MSIREG_OpenProductKey(szProduct, NULL,
|
|
|
|
MSIINSTALLCONTEXT_MACHINE,
|
|
|
|
&prodkey, FALSE)) == ERROR_SUCCESS)
|
2005-04-26 16:30:31 +02:00
|
|
|
{
|
2008-12-15 04:07:14 +01:00
|
|
|
context = MSIINSTALLCONTEXT_MACHINE;
|
2005-04-26 16:30:31 +02:00
|
|
|
}
|
2006-07-14 08:20:44 +02:00
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( szAttribute, INSTALLPROPERTY_HELPLINKW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_HELPTELEPHONEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_INSTALLDATEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_INSTALLLOCATIONW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_INSTALLSOURCEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_LOCALPACKAGEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_PUBLISHERW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_URLINFOABOUTW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_URLUPDATEINFOW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_VERSIONMINORW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_VERSIONMAJORW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_VERSIONSTRINGW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_PRODUCTIDW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_REGCOMPANYW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_REGOWNERW ))
|
2008-02-12 08:35:46 +01:00
|
|
|
{
|
|
|
|
if (!prodkey)
|
2005-06-13 21:04:39 +02:00
|
|
|
{
|
2008-02-12 08:35:46 +01:00
|
|
|
r = ERROR_UNKNOWN_PRODUCT;
|
|
|
|
goto done;
|
2005-06-13 21:04:39 +02:00
|
|
|
}
|
2014-01-04 19:17:01 +01:00
|
|
|
if (MSIREG_OpenInstallProps(szProduct, context, NULL, &userdata, FALSE))
|
|
|
|
{
|
|
|
|
r = ERROR_UNKNOWN_PROPERTY;
|
|
|
|
goto done;
|
|
|
|
}
|
2006-07-14 08:20:44 +02:00
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( szAttribute, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW ))
|
2008-02-12 08:35:46 +01:00
|
|
|
szAttribute = display_name;
|
2010-10-19 11:27:44 +02:00
|
|
|
else if (!strcmpW( szAttribute, INSTALLPROPERTY_VERSIONSTRINGW ))
|
2008-02-12 08:35:46 +01:00
|
|
|
szAttribute = display_version;
|
2005-06-08 20:35:43 +02:00
|
|
|
|
2017-04-19 11:26:48 +02:00
|
|
|
val = reg_get_value(userdata, szAttribute, &type);
|
2008-02-12 08:35:46 +01:00
|
|
|
if (!val)
|
|
|
|
val = empty;
|
2014-01-04 19:17:01 +01:00
|
|
|
RegCloseKey(userdata);
|
2005-06-08 20:35:43 +02:00
|
|
|
}
|
2010-10-19 11:27:44 +02:00
|
|
|
else if (!strcmpW( szAttribute, INSTALLPROPERTY_INSTANCETYPEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_TRANSFORMSW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_LANGUAGEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_PRODUCTNAMEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_PACKAGECODEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_VERSIONW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_PRODUCTICONW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_PACKAGENAMEW ) ||
|
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_AUTHORIZED_LUA_APPW ))
|
2007-05-17 07:42:20 +02:00
|
|
|
{
|
2008-02-12 08:35:46 +01:00
|
|
|
if (!prodkey)
|
|
|
|
{
|
|
|
|
r = ERROR_UNKNOWN_PRODUCT;
|
|
|
|
goto done;
|
|
|
|
}
|
2006-07-14 08:20:44 +02:00
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW ))
|
2008-02-12 08:35:46 +01:00
|
|
|
szAttribute = assignment;
|
2006-07-14 08:21:10 +02:00
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( szAttribute, INSTALLPROPERTY_PACKAGENAMEW ))
|
2008-02-12 08:35:46 +01:00
|
|
|
{
|
|
|
|
res = RegOpenKeyW(prodkey, sourcelist, &source);
|
2009-03-22 22:30:56 +01:00
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
r = ERROR_UNKNOWN_PRODUCT;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2017-04-19 11:26:48 +02:00
|
|
|
val = reg_get_value(source, szAttribute, &type);
|
2009-03-22 22:30:56 +01:00
|
|
|
if (!val)
|
|
|
|
val = empty;
|
2006-07-14 08:20:44 +02:00
|
|
|
|
2008-02-12 08:35:46 +01:00
|
|
|
RegCloseKey(source);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-19 11:26:48 +02:00
|
|
|
val = reg_get_value(prodkey, szAttribute, &type);
|
2008-02-12 08:35:46 +01:00
|
|
|
if (!val)
|
|
|
|
val = empty;
|
|
|
|
}
|
2006-07-14 08:20:44 +02:00
|
|
|
|
2008-02-17 06:39:16 +01:00
|
|
|
if (val != empty && type != REG_DWORD &&
|
2010-10-19 11:27:44 +02:00
|
|
|
!strcmpW( szAttribute, INSTALLPROPERTY_PACKAGECODEW ))
|
2008-02-12 08:35:46 +01:00
|
|
|
{
|
2016-11-04 13:28:07 +01:00
|
|
|
if (lstrlenW( val ) != SQUASHED_GUID_SIZE - 1)
|
2008-02-12 08:35:46 +01:00
|
|
|
badconfig = TRUE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsquash_guid(val, packagecode);
|
|
|
|
msi_free(val);
|
|
|
|
val = strdupW(packagecode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-04-26 16:30:31 +02:00
|
|
|
|
2008-02-12 08:35:46 +01:00
|
|
|
if (!val)
|
|
|
|
{
|
|
|
|
r = ERROR_UNKNOWN_PROPERTY;
|
|
|
|
goto done;
|
2005-04-26 16:30:31 +02:00
|
|
|
}
|
2004-04-28 02:29:25 +02:00
|
|
|
|
2008-03-12 18:40:51 +01:00
|
|
|
if (pcchValueBuf)
|
|
|
|
{
|
2012-10-29 12:16:42 +01:00
|
|
|
int len = strlenW( val );
|
|
|
|
|
2009-12-14 04:35:27 +01:00
|
|
|
/* If szBuffer (szValue->str) is NULL, there's no need to copy the value
|
|
|
|
* out. Also, *pcchValueBuf may be uninitialized in this case, so we
|
|
|
|
* can't rely on its value.
|
|
|
|
*/
|
|
|
|
if (szValue->str.a || szValue->str.w)
|
|
|
|
{
|
|
|
|
DWORD size = *pcchValueBuf;
|
2012-10-29 12:16:42 +01:00
|
|
|
if (len < size)
|
|
|
|
r = msi_strcpy_to_awstring( val, len, szValue, &size );
|
2009-12-14 04:35:27 +01:00
|
|
|
else
|
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
}
|
2006-07-14 08:20:44 +02:00
|
|
|
|
2008-03-12 18:40:51 +01:00
|
|
|
if (!badconfig)
|
2012-10-29 12:16:42 +01:00
|
|
|
*pcchValueBuf = len;
|
2008-02-12 08:35:46 +01:00
|
|
|
}
|
2009-12-14 04:35:27 +01:00
|
|
|
|
|
|
|
if (badconfig)
|
2008-03-12 18:40:51 +01:00
|
|
|
r = ERROR_BAD_CONFIGURATION;
|
2006-07-14 08:20:44 +02:00
|
|
|
|
2008-02-12 08:35:46 +01:00
|
|
|
if (val != empty)
|
|
|
|
msi_free(val);
|
2006-07-14 08:20:44 +02:00
|
|
|
|
2008-02-12 08:35:46 +01:00
|
|
|
done:
|
|
|
|
RegCloseKey(prodkey);
|
2006-07-14 08:21:10 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPSTR szBuffer, LPDWORD pcchValueBuf)
|
2006-07-14 08:21:10 +02:00
|
|
|
{
|
|
|
|
LPWSTR szwProduct, szwAttribute = NULL;
|
|
|
|
UINT r = ERROR_OUTOFMEMORY;
|
|
|
|
awstring buffer;
|
|
|
|
|
|
|
|
TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
|
|
|
|
szBuffer, pcchValueBuf);
|
|
|
|
|
|
|
|
szwProduct = strdupAtoW( szProduct );
|
|
|
|
if( szProduct && !szwProduct )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
szwAttribute = strdupAtoW( szAttribute );
|
|
|
|
if( szAttribute && !szwAttribute )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
buffer.unicode = FALSE;
|
|
|
|
buffer.str.a = szBuffer;
|
|
|
|
|
|
|
|
r = MSI_GetProductInfo( szwProduct, szwAttribute,
|
|
|
|
&buffer, pcchValueBuf );
|
|
|
|
|
|
|
|
end:
|
|
|
|
msi_free( szwProduct );
|
|
|
|
msi_free( szwAttribute );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPWSTR szBuffer, LPDWORD pcchValueBuf)
|
2006-07-14 08:21:10 +02:00
|
|
|
{
|
|
|
|
awstring buffer;
|
|
|
|
|
|
|
|
TRACE("%s %s %p %p\n", debugstr_w(szProduct), debugstr_w(szAttribute),
|
|
|
|
szBuffer, pcchValueBuf);
|
|
|
|
|
|
|
|
buffer.unicode = TRUE;
|
|
|
|
buffer.str.w = szBuffer;
|
|
|
|
|
|
|
|
return MSI_GetProductInfo( szProduct, szAttribute,
|
|
|
|
&buffer, pcchValueBuf );
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2008-03-04 10:08:19 +01:00
|
|
|
UINT WINAPI MsiGetProductInfoExA(LPCSTR szProductCode, LPCSTR szUserSid,
|
|
|
|
MSIINSTALLCONTEXT dwContext, LPCSTR szProperty,
|
|
|
|
LPSTR szValue, LPDWORD pcchValue)
|
|
|
|
{
|
|
|
|
LPWSTR product = NULL;
|
|
|
|
LPWSTR usersid = NULL;
|
|
|
|
LPWSTR property = NULL;
|
|
|
|
LPWSTR value = NULL;
|
|
|
|
DWORD len = 0;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_a(szProductCode),
|
|
|
|
debugstr_a(szUserSid), dwContext, debugstr_a(szProperty),
|
|
|
|
szValue, pcchValue);
|
|
|
|
|
|
|
|
if (szValue && !pcchValue)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (szProductCode) product = strdupAtoW(szProductCode);
|
|
|
|
if (szUserSid) usersid = strdupAtoW(szUserSid);
|
|
|
|
if (szProperty) property = strdupAtoW(szProperty);
|
|
|
|
|
|
|
|
r = MsiGetProductInfoExW(product, usersid, dwContext, property,
|
|
|
|
NULL, &len);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
value = msi_alloc(++len * sizeof(WCHAR));
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MsiGetProductInfoExW(product, usersid, dwContext, property,
|
|
|
|
value, &len);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (!pcchValue)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, value, -1, NULL, 0, NULL, NULL);
|
|
|
|
if (*pcchValue >= len)
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, value, -1, szValue, len, NULL, NULL);
|
|
|
|
else if (szValue)
|
|
|
|
{
|
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
if (*pcchValue > 0)
|
|
|
|
*szValue = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*pcchValue <= len || !szValue)
|
|
|
|
len = len * sizeof(WCHAR) - 1;
|
|
|
|
|
|
|
|
*pcchValue = len - 1;
|
|
|
|
|
|
|
|
done:
|
|
|
|
msi_free(product);
|
|
|
|
msi_free(usersid);
|
|
|
|
msi_free(property);
|
|
|
|
msi_free(value);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT msi_copy_outval(LPWSTR val, LPWSTR out, LPDWORD size)
|
|
|
|
{
|
2010-05-07 21:22:34 +02:00
|
|
|
UINT r = ERROR_SUCCESS;
|
2008-03-04 10:08:19 +01:00
|
|
|
|
|
|
|
if (!val)
|
|
|
|
return ERROR_UNKNOWN_PROPERTY;
|
|
|
|
|
|
|
|
if (out)
|
|
|
|
{
|
2008-10-20 23:06:20 +02:00
|
|
|
if (strlenW(val) >= *size)
|
2008-03-04 10:08:19 +01:00
|
|
|
{
|
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
if (*size > 0)
|
|
|
|
*out = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
lstrcpyW(out, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size)
|
|
|
|
*size = lstrlenW(val);
|
|
|
|
|
2010-05-07 21:22:34 +02:00
|
|
|
return r;
|
2008-03-04 10:08:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
|
|
|
|
MSIINSTALLCONTEXT dwContext, LPCWSTR szProperty,
|
|
|
|
LPWSTR szValue, LPDWORD pcchValue)
|
|
|
|
{
|
|
|
|
static const WCHAR five[] = {'5',0};
|
|
|
|
static const WCHAR displayname[] = {
|
|
|
|
'D','i','s','p','l','a','y','N','a','m','e',0};
|
|
|
|
static const WCHAR displayversion[] = {
|
|
|
|
'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
|
|
|
|
static const WCHAR managed_local_package[] = {
|
|
|
|
'M','a','n','a','g','e','d','L','o','c','a','l',
|
|
|
|
'P','a','c','k','a','g','e',0};
|
2016-11-04 13:28:07 +01:00
|
|
|
WCHAR *val = NULL, squashed_pc[SQUASHED_GUID_SIZE];
|
|
|
|
LPCWSTR package = NULL;
|
|
|
|
HKEY props = NULL, prod, classes = NULL, managed, hkey = NULL;
|
|
|
|
DWORD type;
|
|
|
|
UINT r = ERROR_UNKNOWN_PRODUCT;
|
2008-03-04 10:08:19 +01:00
|
|
|
|
|
|
|
TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_w(szProductCode),
|
|
|
|
debugstr_w(szUserSid), dwContext, debugstr_w(szProperty),
|
|
|
|
szValue, pcchValue);
|
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
if (!szProductCode || !squash_guid( szProductCode, squashed_pc ))
|
2008-03-04 10:08:19 +01:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (szValue && !pcchValue)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (dwContext != MSIINSTALLCONTEXT_USERUNMANAGED &&
|
|
|
|
dwContext != MSIINSTALLCONTEXT_USERMANAGED &&
|
|
|
|
dwContext != MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (!szProperty || !*szProperty)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2008-12-15 04:07:14 +01:00
|
|
|
/* FIXME: dwContext is provided, no need to search for it */
|
2009-03-22 22:30:16 +01:00
|
|
|
MSIREG_OpenProductKey(szProductCode, NULL,MSIINSTALLCONTEXT_USERMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&managed, FALSE);
|
2009-03-22 22:30:16 +01:00
|
|
|
MSIREG_OpenProductKey(szProductCode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&prod, FALSE);
|
2008-03-04 10:08:19 +01:00
|
|
|
|
2008-12-15 04:07:14 +01:00
|
|
|
MSIREG_OpenInstallProps(szProductCode, dwContext, NULL, &props, FALSE);
|
|
|
|
|
2008-03-04 10:08:19 +01:00
|
|
|
if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
|
|
|
|
{
|
|
|
|
package = INSTALLPROPERTY_LOCALPACKAGEW;
|
|
|
|
|
|
|
|
if (!props && !prod)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
else if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
|
|
|
|
{
|
|
|
|
package = managed_local_package;
|
|
|
|
|
|
|
|
if (!props && !managed)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
else if (dwContext == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
{
|
|
|
|
package = INSTALLPROPERTY_LOCALPACKAGEW;
|
2009-03-22 22:30:16 +01:00
|
|
|
MSIREG_OpenProductKey(szProductCode, NULL, dwContext, &classes, FALSE);
|
2008-03-04 10:08:19 +01:00
|
|
|
|
|
|
|
if (!props && !classes)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( szProperty, INSTALLPROPERTY_HELPLINKW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_HELPTELEPHONEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_INSTALLDATEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_INSTALLLOCATIONW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_INSTALLSOURCEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_LOCALPACKAGEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_PUBLISHERW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_URLINFOABOUTW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_URLUPDATEINFOW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_VERSIONMINORW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_VERSIONMAJORW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_VERSIONSTRINGW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_PRODUCTIDW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_REGCOMPANYW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_REGOWNERW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_INSTANCETYPEW ))
|
2008-03-04 10:08:19 +01:00
|
|
|
{
|
2017-04-19 11:26:48 +02:00
|
|
|
val = reg_get_value(props, package, &type);
|
2008-03-04 10:08:19 +01:00
|
|
|
if (!val)
|
|
|
|
{
|
|
|
|
if (prod || classes)
|
|
|
|
r = ERROR_UNKNOWN_PROPERTY;
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
msi_free(val);
|
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( szProperty, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW ))
|
2008-03-04 10:08:19 +01:00
|
|
|
szProperty = displayname;
|
2010-10-19 11:27:44 +02:00
|
|
|
else if (!strcmpW( szProperty, INSTALLPROPERTY_VERSIONSTRINGW ))
|
2008-03-04 10:08:19 +01:00
|
|
|
szProperty = displayversion;
|
|
|
|
|
2017-04-19 11:26:48 +02:00
|
|
|
val = reg_get_value(props, szProperty, &type);
|
2008-03-04 10:08:19 +01:00
|
|
|
if (!val)
|
2009-10-15 12:46:27 +02:00
|
|
|
val = strdupW(szEmpty);
|
2008-03-04 10:08:19 +01:00
|
|
|
|
|
|
|
r = msi_copy_outval(val, szValue, pcchValue);
|
|
|
|
}
|
2010-10-19 11:27:44 +02:00
|
|
|
else if (!strcmpW( szProperty, INSTALLPROPERTY_TRANSFORMSW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_LANGUAGEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_PRODUCTNAMEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_PACKAGECODEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_VERSIONW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_PRODUCTICONW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_PACKAGENAMEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_AUTHORIZED_LUA_APPW ))
|
2008-03-04 10:08:19 +01:00
|
|
|
{
|
|
|
|
if (!prod && !classes)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
|
|
|
|
hkey = prod;
|
|
|
|
else if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
|
|
|
|
hkey = managed;
|
|
|
|
else if (dwContext == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
hkey = classes;
|
|
|
|
|
2017-04-19 11:26:48 +02:00
|
|
|
val = reg_get_value(hkey, szProperty, &type);
|
2008-03-04 10:08:19 +01:00
|
|
|
if (!val)
|
2009-10-15 12:46:27 +02:00
|
|
|
val = strdupW(szEmpty);
|
2008-03-04 10:08:19 +01:00
|
|
|
|
|
|
|
r = msi_copy_outval(val, szValue, pcchValue);
|
|
|
|
}
|
2010-10-19 11:27:44 +02:00
|
|
|
else if (!strcmpW( szProperty, INSTALLPROPERTY_PRODUCTSTATEW ))
|
2008-03-04 10:08:19 +01:00
|
|
|
{
|
|
|
|
if (dwContext == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
{
|
|
|
|
if (props)
|
|
|
|
{
|
2017-04-19 11:26:48 +02:00
|
|
|
val = reg_get_value(props, package, &type);
|
2008-03-04 10:08:19 +01:00
|
|
|
if (!val)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
msi_free(val);
|
|
|
|
val = strdupW(five);
|
|
|
|
}
|
|
|
|
else
|
2009-10-15 12:46:27 +02:00
|
|
|
val = strdupW(szOne);
|
2008-03-04 10:08:19 +01:00
|
|
|
|
|
|
|
r = msi_copy_outval(val, szValue, pcchValue);
|
|
|
|
goto done;
|
|
|
|
}
|
2017-04-19 11:26:48 +02:00
|
|
|
else if (props && (val = reg_get_value(props, package, &type)))
|
2008-03-04 10:08:19 +01:00
|
|
|
{
|
|
|
|
msi_free(val);
|
|
|
|
val = strdupW(five);
|
|
|
|
r = msi_copy_outval(val, szValue, pcchValue);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prod || managed)
|
2009-10-15 12:46:27 +02:00
|
|
|
val = strdupW(szOne);
|
2008-03-04 10:08:19 +01:00
|
|
|
else
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = msi_copy_outval(val, szValue, pcchValue);
|
|
|
|
}
|
2010-10-19 11:27:44 +02:00
|
|
|
else if (!strcmpW( szProperty, INSTALLPROPERTY_ASSIGNMENTTYPEW ))
|
2008-03-04 10:08:19 +01:00
|
|
|
{
|
|
|
|
if (!prod && !classes)
|
|
|
|
goto done;
|
|
|
|
|
2008-04-07 21:44:23 +02:00
|
|
|
/* FIXME */
|
2009-10-15 12:46:27 +02:00
|
|
|
val = strdupW(szEmpty);
|
2008-03-04 10:08:19 +01:00
|
|
|
r = msi_copy_outval(val, szValue, pcchValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
r = ERROR_UNKNOWN_PROPERTY;
|
|
|
|
|
|
|
|
done:
|
|
|
|
RegCloseKey(props);
|
|
|
|
RegCloseKey(prod);
|
|
|
|
RegCloseKey(managed);
|
|
|
|
RegCloseKey(classes);
|
|
|
|
msi_free(val);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2017-05-08 11:46:32 +02:00
|
|
|
UINT WINAPI MsiGetPatchFileListA(LPCSTR szProductCode, LPCSTR szPatchList,
|
|
|
|
LPDWORD pcFiles, MSIHANDLE **pphFileRecords)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %s, %p, %p) stub!\n", debugstr_a(szProductCode),
|
|
|
|
debugstr_a(szPatchList), pcFiles, pphFileRecords);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetPatchFileListW(LPCWSTR szProductCode, LPCWSTR szPatchList,
|
|
|
|
LPDWORD pcFiles, MSIHANDLE **pphFileRecords)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %s, %p, %p) stub!\n", debugstr_w(szProductCode),
|
|
|
|
debugstr_w(szPatchList), pcFiles, pphFileRecords);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2008-12-15 04:06:55 +01:00
|
|
|
UINT WINAPI MsiGetPatchInfoExA(LPCSTR szPatchCode, LPCSTR szProductCode,
|
|
|
|
LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext,
|
|
|
|
LPCSTR szProperty, LPSTR lpValue, DWORD *pcchValue)
|
|
|
|
{
|
2008-12-15 04:07:02 +01:00
|
|
|
LPWSTR patch = NULL, product = NULL, usersid = NULL;
|
|
|
|
LPWSTR property = NULL, val = NULL;
|
|
|
|
DWORD len;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_a(szPatchCode),
|
2008-12-15 04:06:55 +01:00
|
|
|
debugstr_a(szProductCode), debugstr_a(szUserSid), dwContext,
|
|
|
|
debugstr_a(szProperty), lpValue, pcchValue);
|
|
|
|
|
2008-12-15 04:07:02 +01:00
|
|
|
if (lpValue && !pcchValue)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (szPatchCode) patch = strdupAtoW(szPatchCode);
|
|
|
|
if (szProductCode) product = strdupAtoW(szProductCode);
|
|
|
|
if (szUserSid) usersid = strdupAtoW(szUserSid);
|
|
|
|
if (szProperty) property = strdupAtoW(szProperty);
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
r = MsiGetPatchInfoExW(patch, product, usersid, dwContext, property,
|
|
|
|
NULL, &len);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
val = msi_alloc(++len * sizeof(WCHAR));
|
|
|
|
if (!val)
|
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MsiGetPatchInfoExW(patch, product, usersid, dwContext, property,
|
|
|
|
val, &len);
|
|
|
|
if (r != ERROR_SUCCESS || !pcchValue)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (lpValue)
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, val, -1, lpValue,
|
|
|
|
*pcchValue - 1, NULL, NULL);
|
|
|
|
|
|
|
|
len = lstrlenW(val);
|
|
|
|
if ((*val && *pcchValue < len + 1) || !lpValue)
|
|
|
|
{
|
|
|
|
if (lpValue)
|
|
|
|
{
|
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
lpValue[*pcchValue - 1] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcchValue = len * sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*pcchValue = len;
|
|
|
|
|
|
|
|
done:
|
|
|
|
msi_free(val);
|
|
|
|
msi_free(patch);
|
|
|
|
msi_free(product);
|
|
|
|
msi_free(usersid);
|
|
|
|
msi_free(property);
|
|
|
|
|
|
|
|
return r;
|
2008-12-15 04:06:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetPatchInfoExW(LPCWSTR szPatchCode, LPCWSTR szProductCode,
|
|
|
|
LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext,
|
|
|
|
LPCWSTR szProperty, LPWSTR lpValue, DWORD *pcchValue)
|
|
|
|
{
|
2016-11-04 13:28:07 +01:00
|
|
|
static const WCHAR szManagedPackage[] =
|
|
|
|
{'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0};
|
|
|
|
WCHAR *val = NULL, squashed_pc[SQUASHED_GUID_SIZE], squashed_patch[SQUASHED_GUID_SIZE];
|
2008-12-15 04:07:17 +01:00
|
|
|
HKEY udprod = 0, prod = 0, props = 0;
|
|
|
|
HKEY patch = 0, patches = 0;
|
|
|
|
HKEY udpatch = 0, datakey = 0;
|
|
|
|
HKEY prodpatches = 0;
|
|
|
|
UINT r = ERROR_UNKNOWN_PRODUCT;
|
2017-04-19 11:26:48 +02:00
|
|
|
DWORD len, type;
|
2008-12-15 04:07:17 +01:00
|
|
|
LONG res;
|
|
|
|
|
|
|
|
TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_w(szPatchCode),
|
2008-12-15 04:06:55 +01:00
|
|
|
debugstr_w(szProductCode), debugstr_w(szUserSid), dwContext,
|
|
|
|
debugstr_w(szProperty), lpValue, pcchValue);
|
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
if (!szProductCode || !squash_guid( szProductCode, squashed_pc ))
|
2008-12-15 04:07:17 +01:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
if (!szPatchCode || !squash_guid( szPatchCode, squashed_patch ))
|
2008-12-15 04:07:17 +01:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (!szProperty)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (lpValue && !pcchValue)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (dwContext != MSIINSTALLCONTEXT_USERMANAGED &&
|
|
|
|
dwContext != MSIINSTALLCONTEXT_USERUNMANAGED &&
|
|
|
|
dwContext != MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (szUserSid && !strcmpW( szUserSid, szLocalSid ))
|
2008-12-15 04:07:17 +01:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (MSIREG_OpenUserDataProductKey(szProductCode, dwContext, NULL,
|
|
|
|
&udprod, FALSE) != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (MSIREG_OpenInstallProps(szProductCode, dwContext, NULL,
|
|
|
|
&props, FALSE) != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = ERROR_UNKNOWN_PATCH;
|
|
|
|
|
2011-04-06 09:52:16 +02:00
|
|
|
res = RegOpenKeyExW(udprod, szPatches, 0, KEY_WOW64_64KEY|KEY_READ, &patches);
|
2008-12-15 04:07:17 +01:00
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
res = RegOpenKeyExW( patches, squashed_patch, 0, KEY_WOW64_64KEY|KEY_READ, &patch );
|
2008-12-15 04:07:17 +01:00
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( szProperty, INSTALLPROPERTY_TRANSFORMSW ))
|
2008-12-15 04:07:17 +01:00
|
|
|
{
|
2009-03-22 22:30:16 +01:00
|
|
|
if (MSIREG_OpenProductKey(szProductCode, NULL, dwContext,
|
2008-12-15 04:07:17 +01:00
|
|
|
&prod, FALSE) != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
2011-04-06 09:52:16 +02:00
|
|
|
res = RegOpenKeyExW(prod, szPatches, 0, KEY_WOW64_64KEY|KEY_ALL_ACCESS, &prodpatches);
|
2008-12-15 04:07:17 +01:00
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
datakey = prodpatches;
|
2016-11-04 13:28:07 +01:00
|
|
|
szProperty = squashed_patch;
|
2008-12-15 04:07:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (MSIREG_OpenUserDataPatchKey(szPatchCode, dwContext,
|
|
|
|
&udpatch, FALSE) != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( szProperty, INSTALLPROPERTY_LOCALPACKAGEW ))
|
2008-12-15 04:07:17 +01:00
|
|
|
{
|
|
|
|
if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
|
|
|
|
szProperty = szManagedPackage;
|
|
|
|
datakey = udpatch;
|
|
|
|
}
|
2010-10-19 11:27:44 +02:00
|
|
|
else if (!strcmpW( szProperty, INSTALLPROPERTY_INSTALLDATEW ))
|
2008-12-15 04:07:17 +01:00
|
|
|
{
|
|
|
|
datakey = patch;
|
|
|
|
szProperty = szInstalled;
|
|
|
|
}
|
2010-10-19 11:27:44 +02:00
|
|
|
else if (!strcmpW( szProperty, INSTALLPROPERTY_UNINSTALLABLEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_PATCHSTATEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_DISPLAYNAMEW ) ||
|
|
|
|
!strcmpW( szProperty, INSTALLPROPERTY_MOREINFOURLW ))
|
2008-12-15 04:07:17 +01:00
|
|
|
{
|
|
|
|
datakey = patch;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = ERROR_UNKNOWN_PROPERTY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-19 11:26:48 +02:00
|
|
|
val = reg_get_value(datakey, szProperty, &type);
|
2008-12-15 04:07:17 +01:00
|
|
|
if (!val)
|
|
|
|
val = strdupW(szEmpty);
|
|
|
|
|
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
if (!pcchValue)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (lpValue)
|
|
|
|
lstrcpynW(lpValue, val, *pcchValue);
|
|
|
|
|
|
|
|
len = lstrlenW(val);
|
|
|
|
if ((*val && *pcchValue < len + 1) || !lpValue)
|
|
|
|
{
|
|
|
|
if (lpValue)
|
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
|
|
|
|
*pcchValue = len * sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcchValue = len;
|
|
|
|
|
|
|
|
done:
|
|
|
|
msi_free(val);
|
|
|
|
RegCloseKey(prodpatches);
|
|
|
|
RegCloseKey(prod);
|
|
|
|
RegCloseKey(patch);
|
|
|
|
RegCloseKey(patches);
|
|
|
|
RegCloseKey(udpatch);
|
|
|
|
RegCloseKey(props);
|
|
|
|
RegCloseKey(udprod);
|
|
|
|
|
|
|
|
return r;
|
2008-12-15 04:06:55 +01:00
|
|
|
}
|
|
|
|
|
2010-02-15 16:18:30 +01:00
|
|
|
UINT WINAPI MsiGetPatchInfoA( LPCSTR patch, LPCSTR attr, LPSTR buffer, LPDWORD buflen )
|
|
|
|
{
|
|
|
|
UINT r = ERROR_OUTOFMEMORY;
|
|
|
|
DWORD size;
|
|
|
|
LPWSTR patchW = NULL, attrW = NULL, bufferW = NULL;
|
|
|
|
|
|
|
|
TRACE("%s %s %p %p\n", debugstr_a(patch), debugstr_a(attr), buffer, buflen);
|
|
|
|
|
|
|
|
if (!patch || !attr)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (!(patchW = strdupAtoW( patch )))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (!(attrW = strdupAtoW( attr )))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
r = MsiGetPatchInfoW( patchW, attrW, NULL, &size );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
size++;
|
|
|
|
if (!(bufferW = msi_alloc( size * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MsiGetPatchInfoW( patchW, attrW, bufferW, &size );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
int len = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
|
|
|
|
if (len > *buflen)
|
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
else if (buffer)
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, *buflen, NULL, NULL );
|
|
|
|
|
|
|
|
*buflen = len - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
msi_free( patchW );
|
|
|
|
msi_free( attrW );
|
|
|
|
msi_free( bufferW );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetPatchInfoW( LPCWSTR patch, LPCWSTR attr, LPWSTR buffer, LPDWORD buflen )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
WCHAR product[GUID_SIZE];
|
|
|
|
DWORD index;
|
|
|
|
|
|
|
|
TRACE("%s %s %p %p\n", debugstr_w(patch), debugstr_w(attr), buffer, buflen);
|
|
|
|
|
|
|
|
if (!patch || !attr)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (strcmpW( INSTALLPROPERTY_LOCALPACKAGEW, attr ))
|
|
|
|
return ERROR_UNKNOWN_PROPERTY;
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
r = MsiEnumProductsW( index, product );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_USERMANAGED, attr, buffer, buflen );
|
|
|
|
if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, attr, buffer, buflen );
|
|
|
|
if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_MACHINE, attr, buffer, buflen );
|
|
|
|
if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_UNKNOWN_PRODUCT;
|
|
|
|
}
|
|
|
|
|
2004-07-24 01:28:45 +02:00
|
|
|
UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2004-04-28 02:29:25 +02:00
|
|
|
LPWSTR szwLogFile = NULL;
|
2005-03-25 17:38:26 +01:00
|
|
|
UINT r;
|
2004-04-28 02:29:25 +02:00
|
|
|
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("%08x %s %08x\n", dwLogMode, debugstr_a(szLogFile), attributes);
|
2004-04-28 02:29:25 +02:00
|
|
|
|
|
|
|
if( szLogFile )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwLogFile = strdupAtoW( szLogFile );
|
2004-04-28 02:29:25 +02:00
|
|
|
if( !szwLogFile )
|
2005-03-25 17:38:26 +01:00
|
|
|
return ERROR_OUTOFMEMORY;
|
2004-04-28 02:29:25 +02:00
|
|
|
}
|
2005-03-25 17:38:26 +01:00
|
|
|
r = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwLogFile );
|
2005-03-25 17:38:26 +01:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2004-07-24 01:28:45 +02:00
|
|
|
UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("%08x %s %08x\n", dwLogMode, debugstr_w(szLogFile), attributes);
|
2005-01-24 12:22:00 +01:00
|
|
|
|
2010-10-26 12:42:34 +02:00
|
|
|
msi_free(gszLogFile);
|
|
|
|
gszLogFile = NULL;
|
2006-07-24 12:45:50 +02:00
|
|
|
if (szLogFile)
|
|
|
|
{
|
2010-10-26 12:42:34 +02:00
|
|
|
HANDLE file;
|
|
|
|
|
2006-07-24 12:45:50 +02:00
|
|
|
if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
|
|
|
|
DeleteFileW(szLogFile);
|
2010-10-26 12:42:16 +02:00
|
|
|
file = CreateFileW(szLogFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
2006-07-24 12:45:50 +02:00
|
|
|
if (file != INVALID_HANDLE_VALUE)
|
2010-10-26 12:42:34 +02:00
|
|
|
{
|
|
|
|
gszLogFile = strdupW(szLogFile);
|
2006-07-24 12:45:50 +02:00
|
|
|
CloseHandle(file);
|
2010-10-26 12:42:34 +02:00
|
|
|
}
|
2006-07-24 12:45:50 +02:00
|
|
|
else
|
2010-10-26 12:42:16 +02:00
|
|
|
ERR("Unable to enable log %s (%u)\n", debugstr_w(szLogFile), GetLastError());
|
2006-07-24 12:45:50 +02:00
|
|
|
}
|
2004-07-09 21:26:30 +02:00
|
|
|
|
2004-04-28 02:29:25 +02:00
|
|
|
return ERROR_SUCCESS;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2011-04-01 14:54:12 +02:00
|
|
|
UINT WINAPI MsiEnumComponentCostsA( MSIHANDLE handle, LPCSTR component, DWORD index,
|
|
|
|
INSTALLSTATE state, LPSTR drive, DWORD *buflen,
|
|
|
|
int *cost, int *temp )
|
2007-12-02 09:05:29 +01:00
|
|
|
{
|
2011-04-01 14:54:12 +02:00
|
|
|
UINT r;
|
|
|
|
DWORD len;
|
|
|
|
WCHAR *driveW, *componentW = NULL;
|
|
|
|
|
|
|
|
TRACE("%d, %s, %u, %d, %p, %p, %p %p\n", handle, debugstr_a(component), index,
|
|
|
|
state, drive, buflen, cost, temp);
|
|
|
|
|
|
|
|
if (!drive || !buflen) return ERROR_INVALID_PARAMETER;
|
|
|
|
if (component && !(componentW = strdupAtoW( component ))) return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
len = *buflen;
|
|
|
|
if (!(driveW = msi_alloc( len * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
msi_free( componentW );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
r = MsiEnumComponentCostsW( handle, componentW, index, state, driveW, buflen, cost, temp );
|
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, driveW, -1, drive, len, NULL, NULL );
|
|
|
|
}
|
|
|
|
msi_free( componentW );
|
|
|
|
msi_free( driveW );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2011-05-20 12:32:23 +02:00
|
|
|
static UINT set_drive( WCHAR *buffer, WCHAR letter )
|
|
|
|
{
|
|
|
|
buffer[0] = letter;
|
|
|
|
buffer[1] = ':';
|
|
|
|
buffer[2] = 0;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2011-04-01 14:54:12 +02:00
|
|
|
UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD index,
|
|
|
|
INSTALLSTATE state, LPWSTR drive, DWORD *buflen,
|
|
|
|
int *cost, int *temp )
|
|
|
|
{
|
|
|
|
UINT r = ERROR_NO_MORE_ITEMS;
|
|
|
|
MSICOMPONENT *comp = NULL;
|
|
|
|
MSIPACKAGE *package;
|
|
|
|
MSIFILE *file;
|
|
|
|
STATSTG stat = {0};
|
|
|
|
WCHAR path[MAX_PATH];
|
2007-12-02 09:05:29 +01:00
|
|
|
|
2011-04-01 14:54:12 +02:00
|
|
|
TRACE("%d, %s, %u, %d, %p, %p, %p %p\n", handle, debugstr_w(component), index,
|
|
|
|
state, drive, buflen, cost, temp);
|
|
|
|
|
|
|
|
if (!drive || !buflen || !cost || !temp) return ERROR_INVALID_PARAMETER;
|
2011-05-02 16:02:40 +02:00
|
|
|
if (!(package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE )))
|
|
|
|
{
|
2018-04-26 03:54:38 +02:00
|
|
|
WCHAR buffer[3];
|
2018-04-16 03:52:10 +02:00
|
|
|
MSIHANDLE remote;
|
2011-05-02 16:02:40 +02:00
|
|
|
|
2018-04-16 03:52:10 +02:00
|
|
|
if (!(remote = msi_get_remote(handle)))
|
2011-05-02 16:02:40 +02:00
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_EnumComponentCosts(remote, component, index, state, buffer, cost, temp);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-04-26 03:54:38 +02:00
|
|
|
if (r == ERROR_SUCCESS)
|
2011-05-02 16:02:40 +02:00
|
|
|
{
|
2018-04-26 03:54:38 +02:00
|
|
|
lstrcpynW(drive, buffer, *buflen);
|
|
|
|
if (*buflen < 3)
|
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
*buflen = 2;
|
2011-05-02 16:02:40 +02:00
|
|
|
}
|
2018-04-26 03:54:38 +02:00
|
|
|
return r;
|
2011-05-02 16:02:40 +02:00
|
|
|
}
|
|
|
|
|
2011-04-01 14:54:12 +02:00
|
|
|
if (!msi_get_property_int( package->db, szCostingComplete, 0 ))
|
|
|
|
{
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_FUNCTION_NOT_CALLED;
|
|
|
|
}
|
2011-05-06 14:39:17 +02:00
|
|
|
if (component && component[0] && !(comp = msi_get_loaded_component( package, component )))
|
2011-04-01 14:54:12 +02:00
|
|
|
{
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_UNKNOWN_COMPONENT;
|
|
|
|
}
|
|
|
|
if (*buflen < 3)
|
|
|
|
{
|
|
|
|
*buflen = 2;
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_MORE_DATA;
|
|
|
|
}
|
|
|
|
if (index)
|
|
|
|
{
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_NO_MORE_ITEMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
drive[0] = 0;
|
|
|
|
*cost = *temp = 0;
|
2011-05-02 16:02:25 +02:00
|
|
|
GetWindowsDirectoryW( path, MAX_PATH );
|
2011-04-01 14:54:12 +02:00
|
|
|
if (component && component[0])
|
|
|
|
{
|
2015-04-01 12:32:44 +02:00
|
|
|
if (msi_is_global_assembly( comp )) *temp = comp->Cost;
|
2011-05-02 16:02:25 +02:00
|
|
|
if (!comp->Enabled || !comp->KeyPath)
|
2011-04-01 14:54:12 +02:00
|
|
|
{
|
2011-05-02 16:02:25 +02:00
|
|
|
*cost = 0;
|
2011-05-20 12:32:23 +02:00
|
|
|
*buflen = set_drive( drive, path[0] );
|
2011-05-02 16:02:25 +02:00
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
}
|
2011-05-06 14:39:17 +02:00
|
|
|
else if ((file = msi_get_loaded_file( package, comp->KeyPath )))
|
2011-05-02 16:02:25 +02:00
|
|
|
{
|
|
|
|
*cost = max( 8, comp->Cost / 512 );
|
2011-05-20 12:32:23 +02:00
|
|
|
*buflen = set_drive( drive, file->TargetPath[0] );
|
2011-04-01 14:54:12 +02:00
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (IStorage_Stat( package->db->storage, &stat, STATFLAG_NONAME ) == S_OK)
|
|
|
|
{
|
|
|
|
*temp = max( 8, stat.cbSize.QuadPart / 512 );
|
2011-05-20 12:32:23 +02:00
|
|
|
*buflen = set_drive( drive, path[0] );
|
2011-04-01 14:54:12 +02:00
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return r;
|
2007-12-02 09:05:29 +01:00
|
|
|
}
|
|
|
|
|
2007-08-07 04:36:28 +02:00
|
|
|
UINT WINAPI MsiQueryComponentStateA(LPCSTR szProductCode,
|
|
|
|
LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext,
|
|
|
|
LPCSTR szComponent, INSTALLSTATE *pdwState)
|
2007-06-26 01:44:47 +02:00
|
|
|
{
|
2007-08-07 04:36:28 +02:00
|
|
|
LPWSTR prodcode = NULL, usersid = NULL, comp = NULL;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode),
|
|
|
|
debugstr_a(szUserSid), dwContext, debugstr_a(szComponent), pdwState);
|
|
|
|
|
|
|
|
if (szProductCode && !(prodcode = strdupAtoW(szProductCode)))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (szUserSid && !(usersid = strdupAtoW(szUserSid)))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (szComponent && !(comp = strdupAtoW(szComponent)))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
r = MsiQueryComponentStateW(prodcode, usersid, dwContext, comp, pdwState);
|
|
|
|
|
|
|
|
msi_free(prodcode);
|
|
|
|
msi_free(usersid);
|
|
|
|
msi_free(comp);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-08-09 03:42:30 +02:00
|
|
|
static BOOL msi_comp_find_prod_key(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
|
2007-08-07 04:36:28 +02:00
|
|
|
{
|
2007-08-09 03:42:30 +02:00
|
|
|
UINT r;
|
2012-04-23 15:46:30 +02:00
|
|
|
HKEY hkey = NULL;
|
2007-08-09 03:42:30 +02:00
|
|
|
|
2009-03-22 22:30:16 +01:00
|
|
|
r = MSIREG_OpenProductKey(prodcode, NULL, context, &hkey, FALSE);
|
2007-08-09 03:42:30 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
return (r == ERROR_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL msi_comp_find_package(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
|
|
|
|
{
|
|
|
|
LPCWSTR package;
|
2007-08-07 05:48:34 +02:00
|
|
|
HKEY hkey;
|
|
|
|
DWORD sz;
|
2007-08-09 03:42:30 +02:00
|
|
|
LONG res;
|
2007-08-07 05:48:34 +02:00
|
|
|
UINT r;
|
|
|
|
|
2007-08-07 23:25:14 +02:00
|
|
|
static const WCHAR local_package[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
|
|
|
|
static const WCHAR managed_local_package[] = {
|
2007-08-09 03:42:30 +02:00
|
|
|
'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
|
2007-08-07 23:25:14 +02:00
|
|
|
};
|
|
|
|
|
2008-12-15 04:07:14 +01:00
|
|
|
r = MSIREG_OpenInstallProps(prodcode, context, NULL, &hkey, FALSE);
|
2007-08-09 03:42:30 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (context == MSIINSTALLCONTEXT_USERMANAGED)
|
|
|
|
package = managed_local_package;
|
|
|
|
else
|
|
|
|
package = local_package;
|
|
|
|
|
|
|
|
sz = 0;
|
|
|
|
res = RegQueryValueExW(hkey, package, NULL, NULL, NULL, &sz);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
return (res == ERROR_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
static UINT msi_comp_find_prodcode(WCHAR *squashed_pc,
|
2007-08-09 03:42:30 +02:00
|
|
|
MSIINSTALLCONTEXT context,
|
2008-08-21 09:16:03 +02:00
|
|
|
LPCWSTR comp, LPWSTR val, DWORD *sz)
|
2007-08-09 03:42:30 +02:00
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
LONG res;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if (context == MSIINSTALLCONTEXT_MACHINE)
|
2008-12-09 07:21:15 +01:00
|
|
|
r = MSIREG_OpenUserDataComponentKey(comp, szLocalSid, &hkey, FALSE);
|
2007-08-09 03:42:30 +02:00
|
|
|
else
|
2008-12-09 07:21:00 +01:00
|
|
|
r = MSIREG_OpenUserDataComponentKey(comp, NULL, &hkey, FALSE);
|
2007-08-09 03:42:30 +02:00
|
|
|
|
|
|
|
if (r != ERROR_SUCCESS)
|
2012-04-23 15:46:41 +02:00
|
|
|
return r;
|
2007-08-09 03:42:30 +02:00
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
res = RegQueryValueExW( hkey, squashed_pc, NULL, NULL, (BYTE *)val, sz );
|
2007-08-09 03:42:30 +02:00
|
|
|
if (res != ERROR_SUCCESS)
|
2012-04-23 15:46:41 +02:00
|
|
|
return res;
|
2007-08-09 03:42:30 +02:00
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
2012-04-23 15:46:41 +02:00
|
|
|
return res;
|
2007-08-09 03:42:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode,
|
|
|
|
LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext,
|
|
|
|
LPCWSTR szComponent, INSTALLSTATE *pdwState)
|
|
|
|
{
|
2016-11-04 13:28:07 +01:00
|
|
|
WCHAR squashed_pc[SQUASHED_GUID_SIZE];
|
2007-08-09 03:42:30 +02:00
|
|
|
BOOL found;
|
|
|
|
DWORD sz;
|
|
|
|
|
2007-08-07 05:48:34 +02:00
|
|
|
TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode),
|
2007-08-07 04:36:28 +02:00
|
|
|
debugstr_w(szUserSid), dwContext, debugstr_w(szComponent), pdwState);
|
2007-06-26 01:44:47 +02:00
|
|
|
|
2009-01-24 14:56:49 +01:00
|
|
|
if (!pdwState || !szComponent)
|
2007-06-26 01:44:47 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2007-08-07 05:48:34 +02:00
|
|
|
if (!szProductCode || !*szProductCode || lstrlenW(szProductCode) != GUID_SIZE - 1)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
if (!squash_guid( szProductCode, squashed_pc ))
|
2007-08-07 05:48:34 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2007-08-09 03:42:30 +02:00
|
|
|
found = msi_comp_find_prod_key(szProductCode, dwContext);
|
2007-08-07 23:25:14 +02:00
|
|
|
|
2007-08-09 03:42:30 +02:00
|
|
|
if (!msi_comp_find_package(szProductCode, dwContext))
|
|
|
|
{
|
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
*pdwState = INSTALLSTATE_UNKNOWN;
|
|
|
|
return ERROR_UNKNOWN_COMPONENT;
|
|
|
|
}
|
2007-08-07 23:25:14 +02:00
|
|
|
|
|
|
|
return ERROR_UNKNOWN_PRODUCT;
|
2007-08-09 03:42:30 +02:00
|
|
|
}
|
2007-08-07 23:25:14 +02:00
|
|
|
|
|
|
|
*pdwState = INSTALLSTATE_UNKNOWN;
|
2007-08-07 05:48:34 +02:00
|
|
|
|
2012-04-23 15:46:41 +02:00
|
|
|
sz = 0;
|
2016-11-04 13:28:07 +01:00
|
|
|
if (msi_comp_find_prodcode( squashed_pc, dwContext, szComponent, NULL, &sz ))
|
2007-08-07 23:25:14 +02:00
|
|
|
return ERROR_UNKNOWN_COMPONENT;
|
2007-08-07 05:48:34 +02:00
|
|
|
|
2007-08-07 23:25:14 +02:00
|
|
|
if (sz == 0)
|
|
|
|
*pdwState = INSTALLSTATE_NOTUSED;
|
|
|
|
else
|
2008-08-21 09:16:03 +02:00
|
|
|
{
|
2012-04-23 15:46:41 +02:00
|
|
|
WCHAR *val;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if (!(val = msi_alloc( sz ))) return ERROR_OUTOFMEMORY;
|
2016-11-04 13:28:07 +01:00
|
|
|
if ((r = msi_comp_find_prodcode( squashed_pc, dwContext, szComponent, val, &sz )))
|
2012-11-07 01:05:50 +01:00
|
|
|
{
|
|
|
|
msi_free(val);
|
2012-04-23 15:46:41 +02:00
|
|
|
return r;
|
2012-11-07 01:05:50 +01:00
|
|
|
}
|
2012-04-23 15:46:41 +02:00
|
|
|
|
2008-08-21 09:16:03 +02:00
|
|
|
if (lstrlenW(val) > 2 &&
|
2012-04-20 10:55:52 +02:00
|
|
|
val[0] >= '0' && val[0] <= '9' && val[1] >= '0' && val[1] <= '9' && val[2] != ':')
|
2008-08-21 09:16:03 +02:00
|
|
|
{
|
|
|
|
*pdwState = INSTALLSTATE_SOURCE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*pdwState = INSTALLSTATE_LOCAL;
|
2012-04-23 15:46:41 +02:00
|
|
|
msi_free( val );
|
2008-08-21 09:16:03 +02:00
|
|
|
}
|
2007-08-07 05:48:34 +02:00
|
|
|
|
2010-12-23 17:08:10 +01:00
|
|
|
TRACE("-> %d\n", *pdwState);
|
2007-08-07 23:25:14 +02:00
|
|
|
return ERROR_SUCCESS;
|
2007-06-26 01:44:47 +02:00
|
|
|
}
|
|
|
|
|
2003-08-13 03:27:48 +02:00
|
|
|
INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
LPWSTR szwProduct = NULL;
|
|
|
|
INSTALLSTATE r;
|
2005-01-17 14:39:57 +01:00
|
|
|
|
2005-03-24 20:04:06 +01:00
|
|
|
if( szProduct )
|
|
|
|
{
|
|
|
|
szwProduct = strdupAtoW( szProduct );
|
|
|
|
if( !szwProduct )
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
r = MsiQueryProductStateW( szwProduct );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwProduct );
|
2005-03-24 20:04:06 +01:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
|
|
|
|
{
|
2008-12-15 04:07:14 +01:00
|
|
|
MSIINSTALLCONTEXT context = MSIINSTALLCONTEXT_USERUNMANAGED;
|
2008-04-05 12:41:54 +02:00
|
|
|
INSTALLSTATE state = INSTALLSTATE_ADVERTISED;
|
|
|
|
HKEY prodkey = 0, userdata = 0;
|
|
|
|
DWORD val;
|
|
|
|
UINT r;
|
2005-01-17 14:39:57 +01:00
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(szProduct));
|
|
|
|
|
2008-04-05 12:41:54 +02:00
|
|
|
if (!szProduct || !*szProduct)
|
|
|
|
return INSTALLSTATE_INVALIDARG;
|
|
|
|
|
|
|
|
if (lstrlenW(szProduct) != GUID_SIZE - 1)
|
2006-04-17 11:17:52 +02:00
|
|
|
return INSTALLSTATE_INVALIDARG;
|
|
|
|
|
2010-12-02 12:24:16 +01:00
|
|
|
if (szProduct[0] != '{' || szProduct[37] != '}')
|
|
|
|
return INSTALLSTATE_UNKNOWN;
|
|
|
|
|
|
|
|
SetLastError( ERROR_SUCCESS );
|
|
|
|
|
2009-03-22 22:30:16 +01:00
|
|
|
if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&prodkey, FALSE) != ERROR_SUCCESS &&
|
2009-03-22 22:30:16 +01:00
|
|
|
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&prodkey, FALSE) != ERROR_SUCCESS &&
|
2009-03-22 22:30:16 +01:00
|
|
|
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
|
2008-11-04 05:16:43 +01:00
|
|
|
&prodkey, FALSE) == ERROR_SUCCESS)
|
2007-06-27 04:04:08 +02:00
|
|
|
{
|
2008-12-15 04:07:14 +01:00
|
|
|
context = MSIINSTALLCONTEXT_MACHINE;
|
2007-06-27 04:04:08 +02:00
|
|
|
}
|
2005-01-17 14:39:57 +01:00
|
|
|
|
2008-12-15 04:07:14 +01:00
|
|
|
r = MSIREG_OpenInstallProps(szProduct, context, NULL, &userdata, FALSE);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
2005-01-17 14:39:57 +01:00
|
|
|
|
2008-04-05 12:41:54 +02:00
|
|
|
if (!msi_reg_get_val_dword(userdata, szWindowsInstaller, &val))
|
|
|
|
goto done;
|
2005-01-17 14:39:57 +01:00
|
|
|
|
2008-04-05 12:41:54 +02:00
|
|
|
if (val)
|
2007-06-27 01:36:02 +02:00
|
|
|
state = INSTALLSTATE_DEFAULT;
|
2007-06-27 04:01:37 +02:00
|
|
|
else
|
2007-06-27 01:36:02 +02:00
|
|
|
state = INSTALLSTATE_UNKNOWN;
|
2007-06-27 04:01:37 +02:00
|
|
|
|
2008-04-05 12:41:54 +02:00
|
|
|
done:
|
|
|
|
if (!prodkey)
|
|
|
|
{
|
|
|
|
state = INSTALLSTATE_UNKNOWN;
|
2007-06-27 04:04:08 +02:00
|
|
|
|
2008-04-05 12:41:54 +02:00
|
|
|
if (userdata)
|
|
|
|
state = INSTALLSTATE_ABSENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(prodkey);
|
|
|
|
RegCloseKey(userdata);
|
2010-12-23 17:08:10 +01:00
|
|
|
TRACE("-> %d\n", state);
|
2007-06-27 01:36:02 +02:00
|
|
|
return state;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
|
|
|
|
{
|
2004-07-04 02:26:54 +02:00
|
|
|
INSTALLUILEVEL old = gUILevel;
|
|
|
|
HWND oldwnd = gUIhwnd;
|
2005-01-24 12:22:00 +01:00
|
|
|
|
2004-07-04 02:26:54 +02:00
|
|
|
TRACE("%08x %p\n", dwUILevel, phWnd);
|
|
|
|
|
2017-07-06 06:31:52 +02:00
|
|
|
if (dwUILevel & ~(INSTALLUILEVEL_MASK|INSTALLUILEVEL_HIDECANCEL|INSTALLUILEVEL_PROGRESSONLY|
|
|
|
|
INSTALLUILEVEL_ENDDIALOG|INSTALLUILEVEL_SOURCERESONLY))
|
|
|
|
{
|
|
|
|
FIXME("Unrecognized flags %08x\n", dwUILevel);
|
|
|
|
return INSTALLUILEVEL_NOCHANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwUILevel != INSTALLUILEVEL_NOCHANGE)
|
|
|
|
gUILevel = dwUILevel;
|
|
|
|
|
2004-07-04 02:26:54 +02:00
|
|
|
if (phWnd)
|
|
|
|
{
|
|
|
|
gUIhwnd = *phWnd;
|
|
|
|
*phWnd = oldwnd;
|
|
|
|
}
|
|
|
|
return old;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
|
2004-06-28 22:34:35 +02:00
|
|
|
DWORD dwMessageFilter, LPVOID pvContext)
|
|
|
|
{
|
2005-01-24 13:55:31 +01:00
|
|
|
INSTALLUI_HANDLERA prev = gUIHandlerA;
|
2004-07-04 02:31:17 +02:00
|
|
|
|
2009-11-02 10:03:14 +01:00
|
|
|
TRACE("%p %08x %p\n", puiHandler, dwMessageFilter, pvContext);
|
|
|
|
|
2005-01-24 13:55:31 +01:00
|
|
|
gUIHandlerA = puiHandler;
|
2009-11-02 10:03:39 +01:00
|
|
|
gUIHandlerW = NULL;
|
|
|
|
gUIFilter = dwMessageFilter;
|
|
|
|
gUIContext = pvContext;
|
2004-07-04 02:31:17 +02:00
|
|
|
|
|
|
|
return prev;
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
|
|
|
|
2004-12-23 12:22:00 +01:00
|
|
|
INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler,
|
|
|
|
DWORD dwMessageFilter, LPVOID pvContext)
|
|
|
|
{
|
2005-01-03 17:54:43 +01:00
|
|
|
INSTALLUI_HANDLERW prev = gUIHandlerW;
|
|
|
|
|
2009-11-02 10:03:14 +01:00
|
|
|
TRACE("%p %08x %p\n", puiHandler, dwMessageFilter, pvContext);
|
|
|
|
|
2009-11-02 10:03:39 +01:00
|
|
|
gUIHandlerA = NULL;
|
2005-01-03 17:54:43 +01:00
|
|
|
gUIHandlerW = puiHandler;
|
2009-11-02 10:03:39 +01:00
|
|
|
gUIFilter = dwMessageFilter;
|
|
|
|
gUIContext = pvContext;
|
2005-01-03 17:54:43 +01:00
|
|
|
|
|
|
|
return prev;
|
2004-12-23 12:22:00 +01:00
|
|
|
}
|
|
|
|
|
2005-02-08 13:12:29 +01:00
|
|
|
/******************************************************************
|
|
|
|
* MsiLoadStringW [MSI.@]
|
|
|
|
*
|
|
|
|
* Loads a string from MSI's string resources.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
*
|
|
|
|
* handle [I] only -1 is handled currently
|
|
|
|
* id [I] id of the string to be loaded
|
|
|
|
* lpBuffer [O] buffer for the string to be written to
|
|
|
|
* nBufferMax [I] maximum size of the buffer in characters
|
2005-02-25 15:07:56 +01:00
|
|
|
* lang [I] the preferred language for the string
|
2005-02-08 13:12:29 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* If successful, this function returns the language id of the string loaded
|
|
|
|
* If the function fails, the function returns zero.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
*
|
|
|
|
* The type of the first parameter is unknown. LoadString's prototype
|
|
|
|
* suggests that it might be a module handle. I have made it an MSI handle
|
|
|
|
* for starters, as -1 is an invalid MSI handle, but not an invalid module
|
|
|
|
* handle. Maybe strings can be stored in an MSI database somehow.
|
|
|
|
*/
|
|
|
|
LANGID WINAPI MsiLoadStringW( MSIHANDLE handle, UINT id, LPWSTR lpBuffer,
|
|
|
|
int nBufferMax, LANGID lang )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-02-08 13:12:29 +01:00
|
|
|
HRSRC hres;
|
|
|
|
HGLOBAL hResData;
|
|
|
|
LPWSTR p;
|
|
|
|
DWORD i, len;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %u %p %d %d\n", handle, id, lpBuffer, nBufferMax, lang);
|
2005-02-08 13:12:29 +01:00
|
|
|
|
|
|
|
if( handle != -1 )
|
2009-01-04 14:14:15 +01:00
|
|
|
FIXME("don't know how to deal with handle = %08x\n", handle);
|
2005-02-08 13:12:29 +01:00
|
|
|
|
|
|
|
if( !lang )
|
|
|
|
lang = GetUserDefaultLangID();
|
|
|
|
|
|
|
|
hres = FindResourceExW( msi_hInstance, (LPCWSTR) RT_STRING,
|
|
|
|
(LPWSTR)1, lang );
|
|
|
|
if( !hres )
|
|
|
|
return 0;
|
|
|
|
hResData = LoadResource( msi_hInstance, hres );
|
|
|
|
if( !hResData )
|
|
|
|
return 0;
|
|
|
|
p = LockResource( hResData );
|
|
|
|
if( !p )
|
|
|
|
return 0;
|
|
|
|
|
2011-06-30 12:16:02 +02:00
|
|
|
for (i = 0; i < (id & 0xf); i++) p += *p + 1;
|
2005-02-08 13:12:29 +01:00
|
|
|
len = *p;
|
|
|
|
|
|
|
|
if( nBufferMax <= len )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
memcpy( lpBuffer, p+1, len * sizeof(WCHAR));
|
|
|
|
lpBuffer[ len ] = 0;
|
|
|
|
|
|
|
|
TRACE("found -> %s\n", debugstr_w(lpBuffer));
|
|
|
|
return lang;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2005-02-08 13:12:29 +01:00
|
|
|
LANGID WINAPI MsiLoadStringA( MSIHANDLE handle, UINT id, LPSTR lpBuffer,
|
|
|
|
int nBufferMax, LANGID lang )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-02-08 13:12:29 +01:00
|
|
|
LPWSTR bufW;
|
|
|
|
LANGID r;
|
2008-10-20 23:06:20 +02:00
|
|
|
INT len;
|
2005-02-08 13:12:29 +01:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
bufW = msi_alloc(nBufferMax*sizeof(WCHAR));
|
2005-02-08 13:12:29 +01:00
|
|
|
r = MsiLoadStringW(handle, id, bufW, nBufferMax, lang);
|
|
|
|
if( r )
|
|
|
|
{
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL, NULL );
|
|
|
|
if( len <= nBufferMax )
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, bufW, -1,
|
|
|
|
lpBuffer, nBufferMax, NULL, NULL );
|
|
|
|
else
|
|
|
|
r = 0;
|
|
|
|
}
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(bufW);
|
2005-02-08 13:12:29 +01:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
INSTALLSTATE WINAPI MsiLocateComponentA(LPCSTR szComponent, LPSTR lpPathBuf,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pcchBuf)
|
2004-04-13 00:06:12 +02:00
|
|
|
{
|
2006-05-29 12:51:00 +02:00
|
|
|
char szProduct[GUID_SIZE];
|
|
|
|
|
|
|
|
TRACE("%s %p %p\n", debugstr_a(szComponent), lpPathBuf, pcchBuf);
|
|
|
|
|
2010-06-14 14:21:31 +02:00
|
|
|
if (!szComponent || !pcchBuf)
|
|
|
|
return INSTALLSTATE_INVALIDARG;
|
|
|
|
|
2006-05-29 12:51:00 +02:00
|
|
|
if (MsiGetProductCodeA( szComponent, szProduct ) != ERROR_SUCCESS)
|
|
|
|
return INSTALLSTATE_UNKNOWN;
|
|
|
|
|
|
|
|
return MsiGetComponentPathA( szProduct, szComponent, lpPathBuf, pcchBuf );
|
2004-04-13 00:06:12 +02:00
|
|
|
}
|
|
|
|
|
2005-05-30 13:12:24 +02:00
|
|
|
INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPWSTR lpPathBuf,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pcchBuf)
|
2004-04-13 00:06:12 +02:00
|
|
|
{
|
2006-05-29 12:51:00 +02:00
|
|
|
WCHAR szProduct[GUID_SIZE];
|
|
|
|
|
|
|
|
TRACE("%s %p %p\n", debugstr_w(szComponent), lpPathBuf, pcchBuf);
|
|
|
|
|
2010-06-14 14:21:31 +02:00
|
|
|
if (!szComponent || !pcchBuf)
|
|
|
|
return INSTALLSTATE_INVALIDARG;
|
|
|
|
|
2006-05-29 12:51:00 +02:00
|
|
|
if (MsiGetProductCodeW( szComponent, szProduct ) != ERROR_SUCCESS)
|
|
|
|
return INSTALLSTATE_UNKNOWN;
|
|
|
|
|
|
|
|
return MsiGetComponentPathW( szProduct, szComponent, lpPathBuf, pcchBuf );
|
2004-04-13 00:06:12 +02:00
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
|
|
|
|
WORD wLanguageId, DWORD f)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_a(lpText), debugstr_a(lpCaption),
|
|
|
|
uType, wLanguageId, f);
|
2005-11-11 11:52:53 +01:00
|
|
|
return MessageBoxExA(hWnd,lpText,lpCaption,uType,wLanguageId);
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
|
|
|
|
WORD wLanguageId, DWORD f)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_w(lpText), debugstr_w(lpCaption),
|
|
|
|
uType, wLanguageId, f);
|
2005-11-11 11:52:53 +01:00
|
|
|
return MessageBoxExW(hWnd,lpText,lpCaption,uType,wLanguageId);
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2010-04-11 19:47:20 +02:00
|
|
|
UINT WINAPI MsiMessageBoxExA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
|
|
|
|
DWORD unknown, WORD wLanguageId, DWORD f)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd, debugstr_a(lpText),
|
|
|
|
debugstr_a(lpCaption), uType, unknown, wLanguageId, f);
|
|
|
|
return MessageBoxExA(hWnd, lpText, lpCaption, uType, wLanguageId);
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiMessageBoxExW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
|
|
|
|
DWORD unknown, WORD wLanguageId, DWORD f)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd, debugstr_w(lpText),
|
|
|
|
debugstr_w(lpCaption), uType, unknown, wLanguageId, f);
|
|
|
|
return MessageBoxExW(hWnd, lpText, lpCaption, uType, wLanguageId);
|
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
|
|
|
|
DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pcchPathBuf )
|
2003-09-02 01:57:06 +02:00
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName),
|
2005-01-24 12:22:00 +01:00
|
|
|
debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
|
|
|
|
pcchPathBuf);
|
2003-09-02 01:57:06 +02:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
|
|
|
|
DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pcchPathBuf )
|
2003-09-02 01:57:06 +02:00
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName),
|
2005-01-24 12:22:00 +01:00
|
|
|
debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
|
|
|
|
pcchPathBuf);
|
2003-09-02 01:57:06 +02:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor,
|
2007-08-04 03:14:53 +02:00
|
|
|
LPSTR szPath, LPDWORD pcchPath, LPDWORD pcchArgs )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
|
|
|
FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor,
|
2007-08-04 03:14:53 +02:00
|
|
|
LPWSTR szPath, LPDWORD pcchPath, LPDWORD pcchArgs )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
|
|
|
FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-03-30 12:31:35 +02:00
|
|
|
HRESULT WINAPI MsiGetFileSignatureInformationA( LPCSTR path, DWORD flags, PCCERT_CONTEXT *cert,
|
|
|
|
LPBYTE hash, LPDWORD hashlen )
|
2003-09-02 01:57:06 +02:00
|
|
|
{
|
2011-03-30 12:31:35 +02:00
|
|
|
UINT r;
|
|
|
|
WCHAR *pathW = NULL;
|
|
|
|
|
|
|
|
TRACE("%s %08x %p %p %p\n", debugstr_a(path), flags, cert, hash, hashlen);
|
|
|
|
|
2016-09-13 17:53:20 +02:00
|
|
|
if (path && !(pathW = strdupAtoW( path ))) return E_OUTOFMEMORY;
|
2011-03-30 12:31:35 +02:00
|
|
|
r = MsiGetFileSignatureInformationW( pathW, flags, cert, hash, hashlen );
|
|
|
|
msi_free( pathW );
|
|
|
|
return r;
|
2003-09-02 01:57:06 +02:00
|
|
|
}
|
|
|
|
|
2011-03-30 12:31:35 +02:00
|
|
|
HRESULT WINAPI MsiGetFileSignatureInformationW( LPCWSTR path, DWORD flags, PCCERT_CONTEXT *cert,
|
|
|
|
LPBYTE hash, LPDWORD hashlen )
|
|
|
|
{
|
|
|
|
static GUID generic_verify_v2 = WINTRUST_ACTION_GENERIC_VERIFY_V2;
|
|
|
|
HRESULT hr;
|
|
|
|
WINTRUST_DATA data;
|
|
|
|
WINTRUST_FILE_INFO info;
|
|
|
|
CRYPT_PROVIDER_SGNR *signer;
|
|
|
|
CRYPT_PROVIDER_CERT *provider;
|
|
|
|
|
|
|
|
TRACE("%s %08x %p %p %p\n", debugstr_w(path), flags, cert, hash, hashlen);
|
|
|
|
|
|
|
|
if (!path || !cert) return E_INVALIDARG;
|
|
|
|
|
|
|
|
info.cbStruct = sizeof(info);
|
|
|
|
info.pcwszFilePath = path;
|
|
|
|
info.hFile = NULL;
|
|
|
|
info.pgKnownSubject = NULL;
|
|
|
|
|
|
|
|
data.cbStruct = sizeof(data);
|
|
|
|
data.pPolicyCallbackData = NULL;
|
|
|
|
data.pSIPClientData = NULL;
|
|
|
|
data.dwUIChoice = WTD_UI_NONE;
|
|
|
|
data.fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN;
|
|
|
|
data.dwUnionChoice = WTD_CHOICE_FILE;
|
|
|
|
data.u.pFile = &info;
|
|
|
|
data.dwStateAction = WTD_STATEACTION_VERIFY;
|
|
|
|
data.hWVTStateData = NULL;
|
|
|
|
data.pwszURLReference = NULL;
|
|
|
|
data.dwProvFlags = 0;
|
|
|
|
data.dwUIContext = WTD_UICONTEXT_INSTALL;
|
|
|
|
hr = WinVerifyTrustEx( INVALID_HANDLE_VALUE, &generic_verify_v2, &data );
|
2012-03-28 15:34:26 +02:00
|
|
|
*cert = NULL;
|
2011-04-14 14:40:15 +02:00
|
|
|
if (FAILED(hr)) goto done;
|
2011-03-30 12:31:35 +02:00
|
|
|
|
2011-04-14 14:40:15 +02:00
|
|
|
if (!(signer = WTHelperGetProvSignerFromChain( data.hWVTStateData, 0, FALSE, 0 )))
|
|
|
|
{
|
|
|
|
hr = TRUST_E_NOSIGNATURE;
|
|
|
|
goto done;
|
|
|
|
}
|
2011-03-30 12:31:35 +02:00
|
|
|
if (hash)
|
|
|
|
{
|
|
|
|
DWORD len = signer->psSigner->EncryptedHash.cbData;
|
|
|
|
if (*hashlen < len)
|
|
|
|
{
|
|
|
|
*hashlen = len;
|
2011-04-14 14:40:15 +02:00
|
|
|
hr = HRESULT_FROM_WIN32(ERROR_MORE_DATA);
|
|
|
|
goto done;
|
2011-03-30 12:31:35 +02:00
|
|
|
}
|
|
|
|
memcpy( hash, signer->psSigner->EncryptedHash.pbData, len );
|
|
|
|
*hashlen = len;
|
|
|
|
}
|
2011-04-14 14:40:15 +02:00
|
|
|
if (!(provider = WTHelperGetProvCertFromChain( signer, 0 )))
|
|
|
|
{
|
|
|
|
hr = TRUST_E_PROVIDER_UNKNOWN;
|
|
|
|
goto done;
|
|
|
|
}
|
2011-03-30 12:31:35 +02:00
|
|
|
*cert = CertDuplicateCertificateContext( provider->pCert );
|
2011-04-14 14:40:15 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
data.dwStateAction = WTD_STATEACTION_CLOSE;
|
|
|
|
WinVerifyTrustEx( INVALID_HANDLE_VALUE, &generic_verify_v2, &data );
|
|
|
|
return hr;
|
2003-09-02 01:57:06 +02:00
|
|
|
}
|
|
|
|
|
2008-12-09 07:21:35 +01:00
|
|
|
/******************************************************************
|
|
|
|
* MsiGetProductPropertyA [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetProductPropertyA(MSIHANDLE hProduct, LPCSTR szProperty,
|
|
|
|
LPSTR szValue, LPDWORD pccbValue)
|
2003-10-30 23:47:42 +01:00
|
|
|
{
|
2008-12-09 07:21:35 +01:00
|
|
|
LPWSTR prop = NULL, val = NULL;
|
|
|
|
DWORD len;
|
|
|
|
UINT r;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("(%d, %s, %p, %p)\n", hProduct, debugstr_a(szProperty),
|
2008-12-09 07:21:35 +01:00
|
|
|
szValue, pccbValue);
|
|
|
|
|
|
|
|
if (szValue && !pccbValue)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (szProperty) prop = strdupAtoW(szProperty);
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
r = MsiGetProductPropertyW(hProduct, prop, NULL, &len);
|
|
|
|
if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (szValue) *szValue = '\0';
|
|
|
|
if (pccbValue) *pccbValue = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
val = msi_alloc(++len * sizeof(WCHAR));
|
|
|
|
if (!val)
|
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MsiGetProductPropertyW(hProduct, prop, val, &len);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, val, -1, NULL, 0, NULL, NULL);
|
|
|
|
|
|
|
|
if (szValue)
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, val, -1, szValue,
|
|
|
|
*pccbValue, NULL, NULL);
|
|
|
|
|
|
|
|
if (pccbValue)
|
|
|
|
{
|
|
|
|
if (len > *pccbValue)
|
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
|
|
|
|
*pccbValue = len - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
msi_free(prop);
|
|
|
|
msi_free(val);
|
|
|
|
|
|
|
|
return r;
|
2003-10-30 23:47:42 +01:00
|
|
|
}
|
|
|
|
|
2008-12-09 07:21:38 +01:00
|
|
|
/******************************************************************
|
|
|
|
* MsiGetProductPropertyW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetProductPropertyW(MSIHANDLE hProduct, LPCWSTR szProperty,
|
|
|
|
LPWSTR szValue, LPDWORD pccbValue)
|
2003-10-30 23:47:42 +01:00
|
|
|
{
|
2008-12-09 07:21:38 +01:00
|
|
|
MSIPACKAGE *package;
|
|
|
|
MSIQUERY *view = NULL;
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
LPCWSTR val;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
|
|
|
|
'`','P','r','o','p','e','r','t','y','`','=','\'','%','s','\'',0};
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("(%d, %s, %p, %p)\n", hProduct, debugstr_w(szProperty),
|
2008-12-09 07:21:38 +01:00
|
|
|
szValue, pccbValue);
|
|
|
|
|
|
|
|
if (!szProperty)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (szValue && !pccbValue)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
package = msihandle2msiinfo(hProduct, MSIHANDLETYPE_PACKAGE);
|
|
|
|
if (!package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
r = MSI_OpenQuery(package->db, &view, query, szProperty);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = MSI_ViewExecute(view, 0);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = MSI_ViewFetch(view, &rec);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
val = MSI_RecordGetString(rec, 2);
|
|
|
|
if (!val)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (lstrlenW(val) >= *pccbValue)
|
|
|
|
{
|
2016-12-11 12:46:16 +01:00
|
|
|
if (szValue) lstrcpynW(szValue, val, *pccbValue);
|
2008-12-09 07:21:38 +01:00
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-11 12:46:16 +01:00
|
|
|
if (szValue) lstrcpyW(szValue, val);
|
2008-12-09 07:21:38 +01:00
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2016-12-11 12:46:16 +01:00
|
|
|
*pccbValue = lstrlenW(val);
|
|
|
|
|
2008-12-09 07:21:38 +01:00
|
|
|
done:
|
|
|
|
if (view)
|
|
|
|
{
|
|
|
|
MSI_ViewClose(view);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
if (rec) msiobj_release(&rec->hdr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rec)
|
|
|
|
{
|
|
|
|
if (szValue) *szValue = '\0';
|
|
|
|
if (pccbValue) *pccbValue = 0;
|
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-05-20 12:01:15 +02:00
|
|
|
msiobj_release(&package->hdr);
|
2008-12-09 07:21:38 +01:00
|
|
|
return r;
|
2003-10-30 23:47:42 +01:00
|
|
|
}
|
|
|
|
|
2003-11-05 02:42:02 +01:00
|
|
|
UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
UINT r;
|
2004-07-10 00:58:27 +02:00
|
|
|
LPWSTR szPack = NULL;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_a(szPackage) );
|
|
|
|
|
|
|
|
if( szPackage )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szPack = strdupAtoW( szPackage );
|
2004-07-10 00:58:27 +02:00
|
|
|
if( !szPack )
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MsiVerifyPackageW( szPack );
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szPack );
|
2004-07-10 00:58:27 +02:00
|
|
|
|
|
|
|
return r;
|
2003-11-05 02:42:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
|
|
|
|
{
|
2004-07-10 00:58:27 +02:00
|
|
|
MSIHANDLE handle;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(szPackage) );
|
|
|
|
|
|
|
|
r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
|
|
|
|
MsiCloseHandle( handle );
|
|
|
|
|
|
|
|
return r;
|
2003-11-05 02:42:02 +01:00
|
|
|
}
|
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
static BOOL open_userdata_comp_key( const WCHAR *comp, const WCHAR *usersid, MSIINSTALLCONTEXT ctx,
|
|
|
|
HKEY *hkey )
|
|
|
|
{
|
|
|
|
if (ctx & MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
{
|
|
|
|
if (!MSIREG_OpenUserDataComponentKey( comp, szLocalSid, hkey, FALSE )) return TRUE;
|
|
|
|
}
|
|
|
|
if (ctx & (MSIINSTALLCONTEXT_USERMANAGED|MSIINSTALLCONTEXT_USERUNMANAGED))
|
|
|
|
{
|
|
|
|
if (usersid && !strcmpiW( usersid, szAllSid ))
|
|
|
|
{
|
|
|
|
FIXME( "only looking at the current user\n" );
|
|
|
|
usersid = NULL;
|
|
|
|
}
|
|
|
|
if (!MSIREG_OpenUserDataComponentKey( comp, usersid, hkey, FALSE )) return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INSTALLSTATE MSI_GetComponentPath( const WCHAR *szProduct, const WCHAR *szComponent,
|
|
|
|
const WCHAR *szUserSid, MSIINSTALLCONTEXT ctx,
|
|
|
|
awstring *lpPathBuf, DWORD *pcchBuf )
|
2004-07-09 21:38:40 +02:00
|
|
|
{
|
2011-12-13 13:18:42 +01:00
|
|
|
static const WCHAR wininstaller[] =
|
|
|
|
{'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
|
2016-11-04 13:28:07 +01:00
|
|
|
WCHAR *path = NULL, squashed_pc[SQUASHED_GUID_SIZE], squashed_comp[SQUASHED_GUID_SIZE];
|
2007-12-05 07:29:01 +01:00
|
|
|
HKEY hkey;
|
|
|
|
INSTALLSTATE state;
|
|
|
|
DWORD version;
|
|
|
|
|
|
|
|
if (!szProduct || !szComponent)
|
2005-10-28 12:41:20 +02:00
|
|
|
return INSTALLSTATE_INVALIDARG;
|
2007-12-05 07:29:01 +01:00
|
|
|
|
|
|
|
if (lpPathBuf->str.w && !pcchBuf)
|
2005-02-16 17:04:36 +01:00
|
|
|
return INSTALLSTATE_INVALIDARG;
|
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
if (!squash_guid( szProduct, squashed_pc ) || !squash_guid( szComponent, squashed_comp ))
|
2006-07-06 12:01:11 +02:00
|
|
|
return INSTALLSTATE_INVALIDARG;
|
2005-01-17 14:39:57 +01:00
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
if (szUserSid && ctx == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
return INSTALLSTATE_INVALIDARG;
|
|
|
|
|
2007-12-05 07:29:01 +01:00
|
|
|
state = INSTALLSTATE_UNKNOWN;
|
2005-01-14 18:05:53 +01:00
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
if (open_userdata_comp_key( szComponent, szUserSid, ctx, &hkey ))
|
2007-12-05 07:29:01 +01:00
|
|
|
{
|
2016-11-04 13:28:07 +01:00
|
|
|
path = msi_reg_get_val_str( hkey, squashed_pc );
|
2007-12-05 07:29:01 +01:00
|
|
|
RegCloseKey(hkey);
|
2005-01-14 18:05:53 +01:00
|
|
|
|
2007-12-05 07:29:01 +01:00
|
|
|
state = INSTALLSTATE_ABSENT;
|
2005-01-14 18:05:53 +01:00
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
if ((!MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_MACHINE, NULL, &hkey, FALSE) ||
|
|
|
|
!MSIREG_OpenUserDataProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED, NULL, &hkey, FALSE)) &&
|
2007-12-05 07:29:01 +01:00
|
|
|
msi_reg_get_val_dword(hkey, wininstaller, &version) &&
|
|
|
|
GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
state = INSTALLSTATE_LOCAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state != INSTALLSTATE_LOCAL &&
|
2017-03-03 11:52:36 +01:00
|
|
|
(!MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, &hkey, FALSE) ||
|
|
|
|
!MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE, &hkey, FALSE)))
|
2007-12-05 07:29:01 +01:00
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
if (open_userdata_comp_key( szComponent, szUserSid, ctx, &hkey ))
|
2007-12-05 07:29:01 +01:00
|
|
|
{
|
|
|
|
msi_free(path);
|
2016-11-04 13:28:07 +01:00
|
|
|
path = msi_reg_get_val_str( hkey, squashed_pc );
|
2007-12-05 07:29:01 +01:00
|
|
|
RegCloseKey(hkey);
|
2005-01-14 18:05:53 +01:00
|
|
|
|
2007-12-05 07:29:01 +01:00
|
|
|
state = INSTALLSTATE_ABSENT;
|
|
|
|
|
|
|
|
if (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
|
|
|
|
state = INSTALLSTATE_LOCAL;
|
|
|
|
}
|
|
|
|
}
|
2005-01-14 18:05:53 +01:00
|
|
|
|
2006-07-06 12:00:45 +02:00
|
|
|
if (!path)
|
|
|
|
return INSTALLSTATE_UNKNOWN;
|
|
|
|
|
2007-12-05 07:29:01 +01:00
|
|
|
if (state == INSTALLSTATE_LOCAL && !*path)
|
|
|
|
state = INSTALLSTATE_NOTUSED;
|
2005-02-16 17:04:36 +01:00
|
|
|
|
2014-09-01 16:04:19 +02:00
|
|
|
if (msi_strcpy_to_awstring(path, -1, lpPathBuf, pcchBuf) == ERROR_MORE_DATA)
|
|
|
|
state = INSTALLSTATE_MOREDATA;
|
|
|
|
|
2007-12-05 07:29:01 +01:00
|
|
|
msi_free(path);
|
|
|
|
return state;
|
2004-07-09 21:38:40 +02:00
|
|
|
}
|
|
|
|
|
2006-07-06 12:00:45 +02:00
|
|
|
/******************************************************************
|
2017-03-03 11:52:36 +01:00
|
|
|
* MsiGetComponentPathExW [MSI.@]
|
2006-07-06 12:00:45 +02:00
|
|
|
*/
|
2017-03-03 11:52:36 +01:00
|
|
|
INSTALLSTATE WINAPI MsiGetComponentPathExW( LPCWSTR product, LPCWSTR comp, LPCWSTR usersid,
|
|
|
|
MSIINSTALLCONTEXT ctx, LPWSTR buf, LPDWORD buflen )
|
2006-07-06 12:00:45 +02:00
|
|
|
{
|
|
|
|
awstring path;
|
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
TRACE( "%s %s %s 0x%x %p %p\n", debugstr_w(product), debugstr_w(comp), debugstr_w(usersid),
|
|
|
|
ctx, buf, buflen );
|
2011-12-13 13:18:42 +01:00
|
|
|
|
2006-07-06 12:00:45 +02:00
|
|
|
path.unicode = TRUE;
|
2017-03-03 11:52:36 +01:00
|
|
|
path.str.w = buf;
|
2006-07-06 12:00:45 +02:00
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
return MSI_GetComponentPath( product, comp, usersid, ctx, &path, buflen );
|
2006-07-06 12:00:45 +02:00
|
|
|
}
|
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
INSTALLSTATE WINAPI MsiGetComponentPathExA( LPCSTR product, LPCSTR comp, LPCSTR usersid,
|
|
|
|
MSIINSTALLCONTEXT ctx, LPSTR buf, LPDWORD buflen )
|
2006-07-06 12:00:45 +02:00
|
|
|
{
|
2017-03-03 11:52:36 +01:00
|
|
|
WCHAR *productW = NULL, *compW = NULL, *usersidW = NULL;
|
2006-07-06 12:00:45 +02:00
|
|
|
INSTALLSTATE r = INSTALLSTATE_UNKNOWN;
|
|
|
|
awstring path;
|
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
TRACE( "%s %s %s 0x%x %p %p\n", debugstr_a(product), debugstr_a(comp), debugstr_a(usersid),
|
|
|
|
ctx, buf, buflen );
|
2011-12-13 13:18:42 +01:00
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
if (product && !(productW = strdupAtoW( product ))) return INSTALLSTATE_UNKNOWN;
|
|
|
|
if (comp && !(compW = strdupAtoW( comp ))) goto end;
|
|
|
|
if (usersid && !(usersidW = strdupAtoW( usersid ))) goto end;
|
2006-07-06 12:00:45 +02:00
|
|
|
|
|
|
|
path.unicode = FALSE;
|
2017-03-03 11:52:36 +01:00
|
|
|
path.str.a = buf;
|
2006-07-06 12:00:45 +02:00
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
r = MSI_GetComponentPath( productW, compW, usersidW, ctx, &path, buflen );
|
2006-07-06 12:00:45 +02:00
|
|
|
|
|
|
|
end:
|
2017-03-03 11:52:36 +01:00
|
|
|
msi_free( productW );
|
|
|
|
msi_free( compW );
|
|
|
|
msi_free( usersidW );
|
2006-07-06 12:00:45 +02:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
/******************************************************************
|
|
|
|
* MsiGetComponentPathW [MSI.@]
|
|
|
|
*/
|
|
|
|
INSTALLSTATE WINAPI MsiGetComponentPathW( LPCWSTR product, LPCWSTR comp, LPWSTR buf, LPDWORD buflen )
|
|
|
|
{
|
|
|
|
return MsiGetComponentPathExW( product, comp, szAllSid, MSIINSTALLCONTEXT_ALL, buf, buflen );
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* MsiGetComponentPathA [MSI.@]
|
|
|
|
*/
|
|
|
|
INSTALLSTATE WINAPI MsiGetComponentPathA( LPCSTR product, LPCSTR comp, LPSTR buf, LPDWORD buflen )
|
|
|
|
{
|
|
|
|
return MsiGetComponentPathExA( product, comp, "s-1-1-0", MSIINSTALLCONTEXT_ALL, buf, buflen );
|
|
|
|
}
|
|
|
|
|
2013-01-09 11:44:19 +01:00
|
|
|
static UINT query_feature_state( const WCHAR *product, const WCHAR *squashed, const WCHAR *usersid,
|
|
|
|
MSIINSTALLCONTEXT ctx, const WCHAR *feature, INSTALLSTATE *state )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
HKEY hkey;
|
|
|
|
WCHAR *parent, *components, *path;
|
|
|
|
const WCHAR *p;
|
|
|
|
BOOL missing = FALSE, source = FALSE;
|
|
|
|
WCHAR comp[GUID_SIZE];
|
|
|
|
GUID guid;
|
|
|
|
|
|
|
|
if (ctx != MSIINSTALLCONTEXT_MACHINE) SetLastError( ERROR_SUCCESS );
|
|
|
|
|
|
|
|
if (MSIREG_OpenFeaturesKey( product, usersid, ctx, &hkey, FALSE )) return ERROR_UNKNOWN_PRODUCT;
|
|
|
|
|
|
|
|
parent = msi_reg_get_val_str( hkey, feature );
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
if (!parent) return ERROR_UNKNOWN_FEATURE;
|
|
|
|
|
|
|
|
*state = (parent[0] == 6) ? INSTALLSTATE_ABSENT : INSTALLSTATE_LOCAL;
|
|
|
|
msi_free( parent );
|
|
|
|
if (*state == INSTALLSTATE_ABSENT)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
r = MSIREG_OpenUserDataFeaturesKey( product, usersid, ctx, &hkey, FALSE );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
*state = INSTALLSTATE_ADVERTISED;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
components = msi_reg_get_val_str( hkey, feature );
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
|
|
|
|
TRACE("buffer = %s\n", debugstr_w(components));
|
|
|
|
|
|
|
|
if (!components)
|
|
|
|
{
|
|
|
|
*state = INSTALLSTATE_ADVERTISED;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
for (p = components; *p && *p != 2 ; p += 20)
|
|
|
|
{
|
|
|
|
if (!decode_base85_guid( p, &guid ))
|
|
|
|
{
|
|
|
|
if (p != components) break;
|
|
|
|
msi_free( components );
|
|
|
|
*state = INSTALLSTATE_BADCONFIG;
|
|
|
|
return ERROR_BAD_CONFIGURATION;
|
|
|
|
}
|
|
|
|
StringFromGUID2( &guid, comp, GUID_SIZE );
|
|
|
|
if (ctx == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
r = MSIREG_OpenUserDataComponentKey( comp, szLocalSid, &hkey, FALSE );
|
|
|
|
else
|
|
|
|
r = MSIREG_OpenUserDataComponentKey( comp, usersid, &hkey, FALSE );
|
|
|
|
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msi_free( components );
|
|
|
|
*state = INSTALLSTATE_ADVERTISED;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
path = msi_reg_get_val_str( hkey, squashed );
|
|
|
|
if (!path) missing = TRUE;
|
|
|
|
else if (strlenW( path ) > 2 &&
|
|
|
|
path[0] >= '0' && path[0] <= '9' &&
|
|
|
|
path[1] >= '0' && path[1] <= '9')
|
|
|
|
{
|
|
|
|
source = TRUE;
|
|
|
|
}
|
|
|
|
msi_free( path );
|
|
|
|
}
|
|
|
|
msi_free( components );
|
|
|
|
|
|
|
|
if (missing)
|
|
|
|
*state = INSTALLSTATE_ADVERTISED;
|
|
|
|
else if (source)
|
|
|
|
*state = INSTALLSTATE_SOURCE;
|
|
|
|
else
|
|
|
|
*state = INSTALLSTATE_LOCAL;
|
|
|
|
|
|
|
|
TRACE("returning state %d\n", *state);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiQueryFeatureStateExA( LPCSTR product, LPCSTR usersid, MSIINSTALLCONTEXT ctx,
|
|
|
|
LPCSTR feature, INSTALLSTATE *state )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
WCHAR *productW = NULL, *usersidW = NULL, *featureW = NULL;
|
|
|
|
|
|
|
|
if (product && !(productW = strdupAtoW( product ))) return ERROR_OUTOFMEMORY;
|
|
|
|
if (usersid && !(usersidW = strdupAtoW( usersid )))
|
|
|
|
{
|
|
|
|
msi_free( productW );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
if (feature && !(featureW = strdupAtoW( feature )))
|
|
|
|
{
|
|
|
|
msi_free( productW );
|
|
|
|
msi_free( usersidW );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
r = MsiQueryFeatureStateExW( productW, usersidW, ctx, featureW, state );
|
|
|
|
msi_free( productW );
|
|
|
|
msi_free( usersidW );
|
|
|
|
msi_free( featureW );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiQueryFeatureStateExW( LPCWSTR product, LPCWSTR usersid, MSIINSTALLCONTEXT ctx,
|
|
|
|
LPCWSTR feature, INSTALLSTATE *state )
|
|
|
|
{
|
|
|
|
WCHAR squashed[33];
|
|
|
|
if (!squash_guid( product, squashed )) return ERROR_INVALID_PARAMETER;
|
|
|
|
return query_feature_state( product, squashed, usersid, ctx, feature, state );
|
|
|
|
}
|
|
|
|
|
2005-04-20 17:18:42 +02:00
|
|
|
/******************************************************************
|
|
|
|
* MsiQueryFeatureStateA [MSI.@]
|
|
|
|
*/
|
2004-07-09 21:38:40 +02:00
|
|
|
INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
|
|
|
|
{
|
2005-10-31 15:07:20 +01:00
|
|
|
LPWSTR szwProduct = NULL, szwFeature= NULL;
|
|
|
|
INSTALLSTATE rc = INSTALLSTATE_UNKNOWN;
|
2004-07-09 21:38:40 +02:00
|
|
|
|
2005-10-31 15:07:20 +01:00
|
|
|
szwProduct = strdupAtoW( szProduct );
|
|
|
|
if ( szProduct && !szwProduct )
|
|
|
|
goto end;
|
2004-07-09 21:38:40 +02:00
|
|
|
|
2005-10-31 15:07:20 +01:00
|
|
|
szwFeature = strdupAtoW( szFeature );
|
|
|
|
if ( szFeature && !szwFeature )
|
|
|
|
goto end;
|
2004-07-09 21:38:40 +02:00
|
|
|
|
|
|
|
rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
|
|
|
|
|
2005-10-31 15:07:20 +01:00
|
|
|
end:
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwProduct);
|
|
|
|
msi_free( szwFeature);
|
2004-07-09 21:38:40 +02:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-04-20 17:18:42 +02:00
|
|
|
/******************************************************************
|
|
|
|
* MsiQueryFeatureStateW [MSI.@]
|
2005-04-28 14:01:06 +02:00
|
|
|
*
|
2006-07-06 12:01:50 +02:00
|
|
|
* Checks the state of a feature
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* szProduct [I] Product's GUID string
|
|
|
|
* szFeature [I] Feature's GUID string
|
|
|
|
*
|
|
|
|
* RETURNS
|
2008-05-06 15:54:52 +02:00
|
|
|
* INSTALLSTATE_LOCAL Feature is installed and usable
|
2006-07-06 12:01:50 +02:00
|
|
|
* INSTALLSTATE_ABSENT Feature is absent
|
|
|
|
* INSTALLSTATE_ADVERTISED Feature should be installed on demand
|
2006-08-06 12:28:32 +02:00
|
|
|
* INSTALLSTATE_UNKNOWN An error occurred
|
2006-07-06 12:01:50 +02:00
|
|
|
* INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
|
|
|
|
*
|
2005-04-20 17:18:42 +02:00
|
|
|
*/
|
2004-07-09 21:38:40 +02:00
|
|
|
INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
|
|
|
|
{
|
2013-01-09 11:44:19 +01:00
|
|
|
UINT r;
|
|
|
|
INSTALLSTATE state;
|
|
|
|
WCHAR squashed[33];
|
2005-04-28 14:01:06 +02:00
|
|
|
|
|
|
|
TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
|
|
|
|
|
2013-01-09 11:44:19 +01:00
|
|
|
if (!szProduct || !szFeature || !squash_guid( szProduct, squashed ))
|
2005-10-31 15:07:20 +01:00
|
|
|
return INSTALLSTATE_INVALIDARG;
|
|
|
|
|
2013-01-09 11:44:19 +01:00
|
|
|
r = query_feature_state( szProduct, squashed, NULL, MSIINSTALLCONTEXT_USERMANAGED, szFeature, &state );
|
|
|
|
if (r == ERROR_SUCCESS || r == ERROR_BAD_CONFIGURATION) return state;
|
2005-10-31 15:07:20 +01:00
|
|
|
|
2013-01-09 11:44:19 +01:00
|
|
|
r = query_feature_state( szProduct, squashed, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, szFeature, &state );
|
|
|
|
if (r == ERROR_SUCCESS || r == ERROR_BAD_CONFIGURATION) return state;
|
2006-07-15 04:05:20 +02:00
|
|
|
|
2013-01-09 11:44:19 +01:00
|
|
|
r = query_feature_state( szProduct, squashed, NULL, MSIINSTALLCONTEXT_MACHINE, szFeature, &state );
|
|
|
|
if (r == ERROR_SUCCESS || r == ERROR_BAD_CONFIGURATION) return state;
|
2007-07-03 05:23:58 +02:00
|
|
|
|
2013-01-09 11:44:19 +01:00
|
|
|
return INSTALLSTATE_UNKNOWN;
|
2004-07-09 21:38:40 +02:00
|
|
|
}
|
|
|
|
|
2005-04-20 17:18:42 +02:00
|
|
|
/******************************************************************
|
|
|
|
* MsiGetFileVersionA [MSI.@]
|
|
|
|
*/
|
2005-01-24 12:22:00 +01:00
|
|
|
UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pcchVersionBuf, LPSTR lpLangBuf, LPDWORD pcchLangBuf)
|
2004-09-06 23:25:48 +02:00
|
|
|
{
|
2005-01-24 12:22:00 +01:00
|
|
|
LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
|
2005-03-24 20:04:06 +01:00
|
|
|
UINT ret = ERROR_OUTOFMEMORY;
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2008-02-04 18:34:59 +01:00
|
|
|
if ((lpVersionBuf && !pcchVersionBuf) ||
|
|
|
|
(lpLangBuf && !pcchLangBuf))
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
if( szFilePath )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwFilePath = strdupAtoW( szFilePath );
|
2005-01-24 12:22:00 +01:00
|
|
|
if( !szwFilePath )
|
|
|
|
goto end;
|
2004-09-06 23:25:48 +02:00
|
|
|
}
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
|
|
|
|
{
|
2005-09-20 13:59:14 +02:00
|
|
|
lpwVersionBuff = msi_alloc(*pcchVersionBuf*sizeof(WCHAR));
|
2005-01-24 12:22:00 +01:00
|
|
|
if( !lpwVersionBuff )
|
2004-12-10 16:24:52 +01:00
|
|
|
goto end;
|
2004-09-06 23:25:48 +02:00
|
|
|
}
|
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
|
|
|
|
{
|
2007-06-10 09:43:30 +02:00
|
|
|
lpwLangBuff = msi_alloc(*pcchLangBuf*sizeof(WCHAR));
|
2005-01-24 12:22:00 +01:00
|
|
|
if( !lpwLangBuff )
|
2004-12-10 16:24:52 +01:00
|
|
|
goto end;
|
2004-09-06 23:25:48 +02:00
|
|
|
}
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2005-01-24 12:22:00 +01:00
|
|
|
ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
|
|
|
|
lpwLangBuff, pcchLangBuf);
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2008-02-04 18:33:20 +01:00
|
|
|
if( (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) && lpwVersionBuff )
|
2005-01-24 12:22:00 +01:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
|
2008-02-04 18:36:37 +01:00
|
|
|
lpVersionBuf, *pcchVersionBuf + 1, NULL, NULL);
|
2008-02-04 18:33:20 +01:00
|
|
|
if( (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) && lpwLangBuff )
|
2005-01-24 12:22:00 +01:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
|
2008-02-04 18:36:37 +01:00
|
|
|
lpLangBuf, *pcchLangBuf + 1, NULL, NULL);
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2004-12-10 16:24:52 +01:00
|
|
|
end:
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(szwFilePath);
|
|
|
|
msi_free(lpwVersionBuff);
|
|
|
|
msi_free(lpwLangBuff);
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2004-09-06 23:25:48 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-09-20 11:31:41 +02:00
|
|
|
static UINT get_file_version( const WCHAR *path, WCHAR *verbuf, DWORD *verlen,
|
|
|
|
WCHAR *langbuf, DWORD *langlen )
|
2004-09-06 23:25:48 +02:00
|
|
|
{
|
2007-02-17 20:24:20 +01:00
|
|
|
static const WCHAR szVersionResource[] = {'\\',0};
|
2012-04-23 15:47:15 +02:00
|
|
|
static const WCHAR szVersionFormat[] = {'%','d','.','%','d','.','%','d','.','%','d',0};
|
2004-09-06 23:25:48 +02:00
|
|
|
static const WCHAR szLangFormat[] = {'%','d',0};
|
2013-01-31 15:10:45 +01:00
|
|
|
UINT ret = ERROR_MORE_DATA;
|
2011-09-20 11:31:41 +02:00
|
|
|
DWORD len, error;
|
|
|
|
LPVOID version;
|
2004-09-06 23:25:48 +02:00
|
|
|
VS_FIXEDFILEINFO *ffi;
|
2008-02-12 08:36:34 +01:00
|
|
|
USHORT *lang;
|
2004-09-06 23:25:48 +02:00
|
|
|
WCHAR tmp[32];
|
|
|
|
|
2011-09-20 11:31:41 +02:00
|
|
|
if (!(len = GetFileVersionInfoSizeW( path, NULL )))
|
2008-02-04 18:34:10 +01:00
|
|
|
{
|
2011-09-20 11:31:41 +02:00
|
|
|
error = GetLastError();
|
|
|
|
if (error == ERROR_BAD_PATHNAME) return ERROR_FILE_NOT_FOUND;
|
2013-01-31 15:10:45 +01:00
|
|
|
if (error == ERROR_RESOURCE_DATA_NOT_FOUND) return ERROR_FILE_INVALID;
|
2011-09-20 11:31:41 +02:00
|
|
|
return error;
|
2008-02-04 18:34:10 +01:00
|
|
|
}
|
2011-09-20 11:31:41 +02:00
|
|
|
if (!(version = msi_alloc( len ))) return ERROR_OUTOFMEMORY;
|
|
|
|
if (!GetFileVersionInfoW( path, 0, len, version ))
|
2005-01-24 12:22:00 +01:00
|
|
|
{
|
2011-09-20 11:31:41 +02:00
|
|
|
msi_free( version );
|
|
|
|
return GetLastError();
|
2004-09-06 23:25:48 +02:00
|
|
|
}
|
2013-02-02 09:56:53 +01:00
|
|
|
if (!verbuf && !verlen && !langbuf && !langlen)
|
|
|
|
{
|
|
|
|
msi_free( version );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2011-09-20 11:31:41 +02:00
|
|
|
if (verlen)
|
2005-01-24 12:22:00 +01:00
|
|
|
{
|
2011-09-20 11:31:41 +02:00
|
|
|
if (VerQueryValueW( version, szVersionResource, (LPVOID *)&ffi, &len ) && len > 0)
|
2005-01-24 12:22:00 +01:00
|
|
|
{
|
2011-09-20 11:31:41 +02:00
|
|
|
sprintfW( tmp, szVersionFormat,
|
|
|
|
HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
|
|
|
|
HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS) );
|
|
|
|
if (verbuf) lstrcpynW( verbuf, tmp, *verlen );
|
|
|
|
len = strlenW( tmp );
|
2013-01-31 15:10:45 +01:00
|
|
|
if (*verlen > len) ret = ERROR_SUCCESS;
|
2011-09-20 11:31:41 +02:00
|
|
|
*verlen = len;
|
2004-09-06 23:25:48 +02:00
|
|
|
}
|
2005-01-24 12:22:00 +01:00
|
|
|
else
|
|
|
|
{
|
2011-09-20 11:31:41 +02:00
|
|
|
if (verbuf) *verbuf = 0;
|
|
|
|
*verlen = 0;
|
2004-09-06 23:25:48 +02:00
|
|
|
}
|
|
|
|
}
|
2011-09-20 11:31:41 +02:00
|
|
|
if (langlen)
|
2005-01-24 12:22:00 +01:00
|
|
|
{
|
2011-09-20 11:31:41 +02:00
|
|
|
if (VerQueryValueW( version, szLangResource, (LPVOID *)&lang, &len ) && len > 0)
|
2008-02-12 08:36:34 +01:00
|
|
|
{
|
2011-09-20 11:31:41 +02:00
|
|
|
sprintfW( tmp, szLangFormat, *lang );
|
|
|
|
if (langbuf) lstrcpynW( langbuf, tmp, *langlen );
|
|
|
|
len = strlenW( tmp );
|
2013-01-31 15:10:45 +01:00
|
|
|
if (*langlen > len) ret = ERROR_SUCCESS;
|
2011-09-20 11:31:41 +02:00
|
|
|
*langlen = len;
|
2008-02-12 08:36:34 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-20 11:31:41 +02:00
|
|
|
if (langbuf) *langbuf = 0;
|
|
|
|
*langlen = 0;
|
2008-02-12 08:36:34 +01:00
|
|
|
}
|
2004-09-06 23:25:48 +02:00
|
|
|
}
|
2011-09-20 11:31:41 +02:00
|
|
|
msi_free( version );
|
|
|
|
return ret;
|
|
|
|
}
|
2004-09-06 23:25:48 +02:00
|
|
|
|
2011-09-20 11:31:41 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* MsiGetFileVersionW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFileVersionW( LPCWSTR path, LPWSTR verbuf, LPDWORD verlen,
|
|
|
|
LPWSTR langbuf, LPDWORD langlen )
|
|
|
|
{
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%s %p %u %p %u\n", debugstr_w(path), verbuf, verlen ? *verlen : 0,
|
|
|
|
langbuf, langlen ? *langlen : 0);
|
|
|
|
|
|
|
|
if ((verbuf && !verlen) || (langbuf && !langlen))
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
ret = get_file_version( path, verbuf, verlen, langbuf, langlen );
|
2012-02-03 10:49:00 +01:00
|
|
|
if (ret == ERROR_RESOURCE_DATA_NOT_FOUND && verlen)
|
2011-09-20 11:31:41 +02:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
WCHAR *version = msi_font_version_from_file( path );
|
|
|
|
if (!version) return ERROR_FILE_INVALID;
|
|
|
|
len = strlenW( version );
|
2012-02-03 10:49:00 +01:00
|
|
|
if (len >= *verlen) ret = ERROR_MORE_DATA;
|
|
|
|
else if (verbuf)
|
2011-09-20 11:31:41 +02:00
|
|
|
{
|
|
|
|
strcpyW( verbuf, version );
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
*verlen = len;
|
|
|
|
msi_free( version );
|
|
|
|
}
|
2004-09-06 23:25:48 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-10-29 13:36:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFeatureUsageW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFeatureUsageW( LPCWSTR szProduct, LPCWSTR szFeature,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pdwUseCount, LPWORD pwDateUsed )
|
2005-01-03 17:54:43 +01:00
|
|
|
{
|
|
|
|
FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szFeature),
|
|
|
|
pdwUseCount, pwDateUsed);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-10-29 13:36:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFeatureUsageA [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFeatureUsageA( LPCSTR szProduct, LPCSTR szFeature,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pdwUseCount, LPWORD pwDateUsed )
|
2005-01-03 17:54:43 +01:00
|
|
|
{
|
2005-10-29 13:36:57 +02:00
|
|
|
LPWSTR prod = NULL, feat = NULL;
|
|
|
|
UINT ret = ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szFeature),
|
2005-01-03 17:54:43 +01:00
|
|
|
pdwUseCount, pwDateUsed);
|
2005-10-29 13:36:57 +02:00
|
|
|
|
|
|
|
prod = strdupAtoW( szProduct );
|
|
|
|
if (szProduct && !prod)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
feat = strdupAtoW( szFeature );
|
|
|
|
if (szFeature && !feat)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
ret = MsiGetFeatureUsageW( prod, feat, pdwUseCount, pwDateUsed );
|
|
|
|
|
|
|
|
end:
|
|
|
|
msi_free( prod );
|
|
|
|
msi_free( feat );
|
|
|
|
|
|
|
|
return ret;
|
2004-06-29 06:04:13 +02:00
|
|
|
}
|
2005-01-19 17:58:03 +01:00
|
|
|
|
2005-10-29 13:36:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiUseFeatureExW [MSI.@]
|
|
|
|
*/
|
|
|
|
INSTALLSTATE WINAPI MsiUseFeatureExW( LPCWSTR szProduct, LPCWSTR szFeature,
|
|
|
|
DWORD dwInstallMode, DWORD dwReserved )
|
2005-01-19 17:58:03 +01:00
|
|
|
{
|
2005-10-31 15:07:20 +01:00
|
|
|
INSTALLSTATE state;
|
|
|
|
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("%s %s %i %i\n", debugstr_w(szProduct), debugstr_w(szFeature),
|
2005-01-19 17:58:03 +01:00
|
|
|
dwInstallMode, dwReserved);
|
2005-02-16 17:24:38 +01:00
|
|
|
|
2005-10-31 15:07:20 +01:00
|
|
|
state = MsiQueryFeatureStateW( szProduct, szFeature );
|
|
|
|
|
|
|
|
if (dwReserved)
|
|
|
|
return INSTALLSTATE_INVALIDARG;
|
|
|
|
|
|
|
|
if (state == INSTALLSTATE_LOCAL && dwInstallMode != INSTALLMODE_NODETECTION)
|
|
|
|
{
|
|
|
|
FIXME("mark product %s feature %s as used\n",
|
|
|
|
debugstr_w(szProduct), debugstr_w(szFeature) );
|
|
|
|
}
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2005-10-31 15:07:20 +01:00
|
|
|
return state;
|
2005-02-16 17:24:38 +01:00
|
|
|
}
|
|
|
|
|
2005-04-20 17:18:42 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiUseFeatureExA [MSI.@]
|
|
|
|
*/
|
2005-10-29 13:36:57 +02:00
|
|
|
INSTALLSTATE WINAPI MsiUseFeatureExA( LPCSTR szProduct, LPCSTR szFeature,
|
|
|
|
DWORD dwInstallMode, DWORD dwReserved )
|
2005-02-16 17:24:38 +01:00
|
|
|
{
|
2005-10-29 13:36:57 +02:00
|
|
|
INSTALLSTATE ret = INSTALLSTATE_UNKNOWN;
|
|
|
|
LPWSTR prod = NULL, feat = NULL;
|
|
|
|
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("%s %s %i %i\n", debugstr_a(szProduct), debugstr_a(szFeature),
|
2005-02-16 17:24:38 +01:00
|
|
|
dwInstallMode, dwReserved);
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2005-10-29 13:36:57 +02:00
|
|
|
prod = strdupAtoW( szProduct );
|
|
|
|
if (szProduct && !prod)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
feat = strdupAtoW( szFeature );
|
|
|
|
if (szFeature && !feat)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
ret = MsiUseFeatureExW( prod, feat, dwInstallMode, dwReserved );
|
|
|
|
|
|
|
|
end:
|
|
|
|
msi_free( prod );
|
|
|
|
msi_free( feat );
|
|
|
|
|
|
|
|
return ret;
|
2005-02-16 17:24:38 +01:00
|
|
|
}
|
|
|
|
|
2006-07-05 11:34:13 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiUseFeatureW [MSI.@]
|
|
|
|
*/
|
2005-10-29 13:36:57 +02:00
|
|
|
INSTALLSTATE WINAPI MsiUseFeatureW( LPCWSTR szProduct, LPCWSTR szFeature )
|
2005-02-16 17:24:38 +01:00
|
|
|
{
|
2006-07-05 11:34:13 +02:00
|
|
|
return MsiUseFeatureExW(szProduct, szFeature, 0, 0);
|
2005-02-16 17:24:38 +01:00
|
|
|
}
|
|
|
|
|
2006-07-05 11:34:13 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiUseFeatureA [MSI.@]
|
|
|
|
*/
|
2005-10-29 13:36:57 +02:00
|
|
|
INSTALLSTATE WINAPI MsiUseFeatureA( LPCSTR szProduct, LPCSTR szFeature )
|
2005-02-16 17:24:38 +01:00
|
|
|
{
|
2006-07-05 11:34:13 +02:00
|
|
|
return MsiUseFeatureExA(szProduct, szFeature, 0, 0);
|
2005-01-19 17:58:03 +01:00
|
|
|
}
|
|
|
|
|
2017-01-07 14:40:10 +01:00
|
|
|
static WCHAR *reg_get_multisz( HKEY hkey, const WCHAR *name )
|
2016-11-04 13:28:04 +01:00
|
|
|
{
|
|
|
|
WCHAR *ret;
|
|
|
|
DWORD len, type;
|
|
|
|
if (RegQueryValueExW( hkey, name, NULL, &type, NULL, &len ) || type != REG_MULTI_SZ) return NULL;
|
|
|
|
if ((ret = msi_alloc( len ))) RegQueryValueExW( hkey, name, NULL, NULL, (BYTE *)ret, &len );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-01-07 14:40:10 +01:00
|
|
|
static WCHAR *reg_get_sz( HKEY hkey, const WCHAR *name )
|
2016-11-04 13:28:04 +01:00
|
|
|
{
|
|
|
|
WCHAR *ret;
|
|
|
|
DWORD len, type;
|
|
|
|
if (RegQueryValueExW( hkey, name, NULL, &type, NULL, &len ) || type != REG_SZ) return NULL;
|
|
|
|
if ((ret = msi_alloc( len ))) RegQueryValueExW( hkey, name, NULL, NULL, (BYTE *)ret, &len );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BASE85_SIZE 20
|
|
|
|
|
2005-11-10 12:06:04 +01:00
|
|
|
/***********************************************************************
|
2006-07-21 07:05:29 +02:00
|
|
|
* MSI_ProvideQualifiedComponentEx [internal]
|
2005-11-10 12:06:04 +01:00
|
|
|
*/
|
2008-11-26 17:15:59 +01:00
|
|
|
static UINT MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent,
|
2007-06-05 19:53:43 +02:00
|
|
|
LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct,
|
2006-07-21 07:05:29 +02:00
|
|
|
DWORD Unused1, DWORD Unused2, awstring *lpPathBuf,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pcchPathBuf)
|
2005-01-19 17:58:03 +01:00
|
|
|
{
|
2016-11-04 13:28:04 +01:00
|
|
|
WCHAR product[MAX_FEATURE_CHARS+1], comp[MAX_FEATURE_CHARS+1], feature[MAX_FEATURE_CHARS+1];
|
|
|
|
WCHAR *desc;
|
2006-07-21 07:05:29 +02:00
|
|
|
HKEY hkey;
|
2016-11-04 13:28:04 +01:00
|
|
|
DWORD size;
|
|
|
|
UINT ret;
|
2014-09-01 16:04:19 +02:00
|
|
|
INSTALLSTATE state;
|
2005-04-20 14:50:05 +02:00
|
|
|
|
2016-11-04 13:28:04 +01:00
|
|
|
if (MSIREG_OpenUserComponentsKey( szComponent, &hkey, FALSE )) return ERROR_UNKNOWN_COMPONENT;
|
2005-04-20 14:50:05 +02:00
|
|
|
|
2016-11-04 13:28:04 +01:00
|
|
|
desc = reg_get_multisz( hkey, szQualifier );
|
2006-07-21 07:05:15 +02:00
|
|
|
RegCloseKey(hkey);
|
2016-11-04 13:28:04 +01:00
|
|
|
if (!desc) return ERROR_INDEX_ABSENT;
|
2005-04-20 14:50:05 +02:00
|
|
|
|
2016-11-04 13:28:04 +01:00
|
|
|
/* FIXME: handle multiple descriptors */
|
|
|
|
ret = MsiDecomposeDescriptorW( desc, product, feature, comp, &size );
|
|
|
|
msi_free( desc );
|
|
|
|
if (ret != ERROR_SUCCESS) return ret;
|
2006-07-14 08:21:10 +02:00
|
|
|
|
2016-11-04 13:28:04 +01:00
|
|
|
if (!szProduct) szProduct = product;
|
|
|
|
if (!comp[0])
|
|
|
|
{
|
|
|
|
MSIINSTALLCONTEXT ctx;
|
|
|
|
WCHAR *components;
|
|
|
|
GUID guid;
|
2006-07-14 08:21:10 +02:00
|
|
|
|
2016-11-04 13:28:04 +01:00
|
|
|
/* use the first component of the feature if the descriptor component is empty */
|
|
|
|
if ((ret = msi_locate_product( szProduct, &ctx ))) return ret;
|
|
|
|
if ((ret = MSIREG_OpenUserDataFeaturesKey( szProduct, NULL, ctx, &hkey, FALSE )))
|
|
|
|
{
|
|
|
|
return ERROR_FILE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
components = reg_get_sz( hkey, feature );
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
if (!components) return ERROR_FILE_NOT_FOUND;
|
2005-04-21 19:24:27 +02:00
|
|
|
|
2016-11-04 13:28:04 +01:00
|
|
|
if (strlenW( components ) < BASE85_SIZE || !decode_base85_guid( components, &guid ))
|
|
|
|
{
|
|
|
|
msi_free( components );
|
|
|
|
return ERROR_FILE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
msi_free( components );
|
2018-08-20 21:15:43 +02:00
|
|
|
StringFromGUID2( &guid, comp, ARRAY_SIZE( comp ));
|
2016-11-04 13:28:04 +01:00
|
|
|
}
|
2014-09-01 16:04:19 +02:00
|
|
|
|
2017-03-03 11:52:36 +01:00
|
|
|
state = MSI_GetComponentPath( szProduct, comp, szAllSid, MSIINSTALLCONTEXT_ALL, lpPathBuf, pcchPathBuf );
|
2006-07-21 07:05:29 +02:00
|
|
|
|
2016-11-04 13:28:04 +01:00
|
|
|
if (state == INSTALLSTATE_MOREDATA) return ERROR_MORE_DATA;
|
|
|
|
if (state != INSTALLSTATE_LOCAL) return ERROR_FILE_NOT_FOUND;
|
2006-07-21 07:05:29 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiProvideQualifiedComponentExW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
|
2007-08-04 03:14:53 +02:00
|
|
|
LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct,
|
2006-07-21 07:05:29 +02:00
|
|
|
DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
|
2007-08-04 03:14:53 +02:00
|
|
|
LPDWORD pcchPathBuf)
|
2006-07-21 07:05:29 +02:00
|
|
|
{
|
|
|
|
awstring path;
|
|
|
|
|
2011-12-13 13:18:42 +01:00
|
|
|
TRACE("%s %s %u %s %u %u %p %p\n", debugstr_w(szComponent),
|
|
|
|
debugstr_w(szQualifier), dwInstallMode, debugstr_w(szProduct),
|
|
|
|
Unused1, Unused2, lpPathBuf, pcchPathBuf);
|
|
|
|
|
2006-07-21 07:05:29 +02:00
|
|
|
path.unicode = TRUE;
|
|
|
|
path.str.w = lpPathBuf;
|
|
|
|
|
|
|
|
return MSI_ProvideQualifiedComponentEx(szComponent, szQualifier,
|
|
|
|
dwInstallMode, szProduct, Unused1, Unused2, &path, pcchPathBuf);
|
2005-04-20 14:50:05 +02:00
|
|
|
}
|
|
|
|
|
2006-07-21 07:05:00 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiProvideQualifiedComponentExA [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiProvideQualifiedComponentExA(LPCSTR szComponent,
|
2007-08-04 03:14:53 +02:00
|
|
|
LPCSTR szQualifier, DWORD dwInstallMode, LPCSTR szProduct,
|
2006-07-21 07:05:00 +02:00
|
|
|
DWORD Unused1, DWORD Unused2, LPSTR lpPathBuf,
|
2007-08-04 03:14:53 +02:00
|
|
|
LPDWORD pcchPathBuf)
|
2006-07-21 07:05:00 +02:00
|
|
|
{
|
2006-07-21 07:05:29 +02:00
|
|
|
LPWSTR szwComponent, szwQualifier = NULL, szwProduct = NULL;
|
|
|
|
UINT r = ERROR_OUTOFMEMORY;
|
|
|
|
awstring path;
|
|
|
|
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent),
|
2006-07-21 07:05:00 +02:00
|
|
|
debugstr_a(szQualifier), dwInstallMode, debugstr_a(szProduct),
|
|
|
|
Unused1, Unused2, lpPathBuf, pcchPathBuf);
|
|
|
|
|
2006-07-21 07:05:29 +02:00
|
|
|
szwComponent = strdupAtoW( szComponent );
|
|
|
|
if (szComponent && !szwComponent)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
szwQualifier = strdupAtoW( szQualifier );
|
|
|
|
if (szQualifier && !szwQualifier)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
szwProduct = strdupAtoW( szProduct );
|
|
|
|
if (szProduct && !szwProduct)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
path.unicode = FALSE;
|
|
|
|
path.str.a = lpPathBuf;
|
|
|
|
|
|
|
|
r = MSI_ProvideQualifiedComponentEx(szwComponent, szwQualifier,
|
|
|
|
dwInstallMode, szwProduct, Unused1,
|
|
|
|
Unused2, &path, pcchPathBuf);
|
|
|
|
end:
|
|
|
|
msi_free(szwProduct);
|
|
|
|
msi_free(szwComponent);
|
|
|
|
msi_free(szwQualifier);
|
|
|
|
|
|
|
|
return r;
|
2006-07-21 07:05:00 +02:00
|
|
|
}
|
|
|
|
|
2005-04-22 21:04:41 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiProvideQualifiedComponentW [MSI.@]
|
|
|
|
*/
|
2005-04-20 14:50:05 +02:00
|
|
|
UINT WINAPI MsiProvideQualifiedComponentW( LPCWSTR szComponent,
|
|
|
|
LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pcchPathBuf)
|
2005-04-20 14:50:05 +02:00
|
|
|
{
|
|
|
|
return MsiProvideQualifiedComponentExW(szComponent, szQualifier,
|
|
|
|
dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
|
|
|
|
}
|
|
|
|
|
2005-04-22 21:04:41 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiProvideQualifiedComponentA [MSI.@]
|
|
|
|
*/
|
2005-04-20 14:50:05 +02:00
|
|
|
UINT WINAPI MsiProvideQualifiedComponentA( LPCSTR szComponent,
|
|
|
|
LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPDWORD pcchPathBuf)
|
2005-04-20 14:50:05 +02:00
|
|
|
{
|
2006-07-21 07:05:29 +02:00
|
|
|
return MsiProvideQualifiedComponentExA(szComponent, szQualifier,
|
|
|
|
dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
|
2005-01-19 17:58:03 +01:00
|
|
|
}
|
|
|
|
|
2006-07-24 08:25:29 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MSI_GetUserInfo [internal]
|
|
|
|
*/
|
2008-11-26 17:15:59 +01:00
|
|
|
static USERINFOSTATE MSI_GetUserInfo(LPCWSTR szProduct,
|
2007-08-09 10:41:41 +02:00
|
|
|
awstring *lpUserNameBuf, LPDWORD pcchUserNameBuf,
|
|
|
|
awstring *lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
|
|
|
|
awstring *lpSerialBuf, LPDWORD pcchSerialBuf)
|
2005-01-19 17:58:03 +01:00
|
|
|
{
|
2016-11-04 13:28:07 +01:00
|
|
|
WCHAR *user, *org, *serial, squashed_pc[SQUASHED_GUID_SIZE];
|
2006-07-24 08:25:29 +02:00
|
|
|
USERINFOSTATE state;
|
2008-06-24 06:08:06 +02:00
|
|
|
HKEY hkey, props;
|
|
|
|
LPCWSTR orgptr;
|
|
|
|
UINT r;
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2008-06-24 06:08:06 +02:00
|
|
|
TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct), lpUserNameBuf,
|
2005-02-10 19:57:42 +01:00
|
|
|
pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
|
|
|
|
pcchSerialBuf);
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2016-11-04 13:28:07 +01:00
|
|
|
if (!szProduct || !squash_guid( szProduct, squashed_pc ))
|
2006-07-24 08:25:29 +02:00
|
|
|
return USERINFOSTATE_INVALIDARG;
|
|
|
|
|
2009-03-22 22:30:16 +01:00
|
|
|
if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&hkey, FALSE) != ERROR_SUCCESS &&
|
2009-03-22 22:30:16 +01:00
|
|
|
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
|
2008-11-04 05:16:43 +01:00
|
|
|
&hkey, FALSE) != ERROR_SUCCESS &&
|
2009-03-22 22:30:16 +01:00
|
|
|
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
|
2008-11-04 05:16:43 +01:00
|
|
|
&hkey, FALSE) != ERROR_SUCCESS)
|
2008-06-24 06:08:06 +02:00
|
|
|
{
|
2005-05-20 20:59:11 +02:00
|
|
|
return USERINFOSTATE_UNKNOWN;
|
2008-06-24 06:08:06 +02:00
|
|
|
}
|
|
|
|
|
2008-12-15 04:07:14 +01:00
|
|
|
if (MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
|
|
|
|
NULL, &props, FALSE) != ERROR_SUCCESS &&
|
|
|
|
MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_MACHINE,
|
|
|
|
NULL, &props, FALSE) != ERROR_SUCCESS)
|
2008-06-24 06:08:06 +02:00
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return USERINFOSTATE_ABSENT;
|
|
|
|
}
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2008-06-24 06:08:06 +02:00
|
|
|
user = msi_reg_get_val_str(props, INSTALLPROPERTY_REGOWNERW);
|
|
|
|
org = msi_reg_get_val_str(props, INSTALLPROPERTY_REGCOMPANYW);
|
|
|
|
serial = msi_reg_get_val_str(props, INSTALLPROPERTY_PRODUCTIDW);
|
|
|
|
state = USERINFOSTATE_ABSENT;
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2006-07-24 08:25:29 +02:00
|
|
|
RegCloseKey(hkey);
|
2008-06-24 06:08:06 +02:00
|
|
|
RegCloseKey(props);
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2008-06-24 06:08:06 +02:00
|
|
|
if (user && serial)
|
|
|
|
state = USERINFOSTATE_PRESENT;
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2008-06-24 06:08:06 +02:00
|
|
|
if (pcchUserNameBuf)
|
2007-04-12 07:46:43 +02:00
|
|
|
{
|
2008-06-24 06:08:06 +02:00
|
|
|
if (lpUserNameBuf && !user)
|
|
|
|
{
|
|
|
|
(*pcchUserNameBuf)--;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2012-10-29 12:16:42 +01:00
|
|
|
r = msi_strcpy_to_awstring(user, -1, lpUserNameBuf, pcchUserNameBuf);
|
2007-04-12 07:46:43 +02:00
|
|
|
if (r == ERROR_MORE_DATA)
|
2008-06-24 06:08:06 +02:00
|
|
|
{
|
2007-04-12 07:46:43 +02:00
|
|
|
state = USERINFOSTATE_MOREDATA;
|
2008-06-24 06:08:06 +02:00
|
|
|
goto done;
|
|
|
|
}
|
2007-04-12 07:46:43 +02:00
|
|
|
}
|
2008-06-24 06:08:06 +02:00
|
|
|
|
|
|
|
if (pcchOrgNameBuf)
|
2007-04-12 07:46:43 +02:00
|
|
|
{
|
2008-06-24 06:08:06 +02:00
|
|
|
orgptr = org;
|
|
|
|
if (!orgptr) orgptr = szEmpty;
|
|
|
|
|
2012-10-29 12:16:42 +01:00
|
|
|
r = msi_strcpy_to_awstring(orgptr, -1, lpOrgNameBuf, pcchOrgNameBuf);
|
2008-06-24 06:08:06 +02:00
|
|
|
if (r == ERROR_MORE_DATA)
|
|
|
|
{
|
2007-04-12 07:46:43 +02:00
|
|
|
state = USERINFOSTATE_MOREDATA;
|
2008-06-24 06:08:06 +02:00
|
|
|
goto done;
|
|
|
|
}
|
2007-04-12 07:46:43 +02:00
|
|
|
}
|
2008-06-24 06:08:06 +02:00
|
|
|
|
|
|
|
if (pcchSerialBuf)
|
2007-04-12 07:46:43 +02:00
|
|
|
{
|
2008-06-24 06:08:06 +02:00
|
|
|
if (!serial)
|
|
|
|
{
|
|
|
|
(*pcchSerialBuf)--;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2012-10-29 12:16:42 +01:00
|
|
|
r = msi_strcpy_to_awstring(serial, -1, lpSerialBuf, pcchSerialBuf);
|
2008-06-24 06:08:06 +02:00
|
|
|
if (r == ERROR_MORE_DATA)
|
2007-04-12 07:46:43 +02:00
|
|
|
state = USERINFOSTATE_MOREDATA;
|
|
|
|
}
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2008-06-24 06:08:06 +02:00
|
|
|
done:
|
|
|
|
msi_free(user);
|
|
|
|
msi_free(org);
|
|
|
|
msi_free(serial);
|
2005-05-20 20:59:11 +02:00
|
|
|
|
2006-07-24 08:25:29 +02:00
|
|
|
return state;
|
|
|
|
}
|
2006-07-14 08:21:10 +02:00
|
|
|
|
2006-07-24 08:25:29 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetUserInfoW [MSI.@]
|
|
|
|
*/
|
|
|
|
USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPWSTR lpUserNameBuf, LPDWORD pcchUserNameBuf,
|
|
|
|
LPWSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
|
|
|
|
LPWSTR lpSerialBuf, LPDWORD pcchSerialBuf)
|
2006-07-24 08:25:29 +02:00
|
|
|
{
|
|
|
|
awstring user, org, serial;
|
|
|
|
|
2008-06-24 06:08:06 +02:00
|
|
|
if ((lpUserNameBuf && !pcchUserNameBuf) ||
|
|
|
|
(lpOrgNameBuf && !pcchOrgNameBuf) ||
|
|
|
|
(lpSerialBuf && !pcchSerialBuf))
|
|
|
|
return USERINFOSTATE_INVALIDARG;
|
|
|
|
|
2006-07-24 08:25:29 +02:00
|
|
|
user.unicode = TRUE;
|
|
|
|
user.str.w = lpUserNameBuf;
|
|
|
|
org.unicode = TRUE;
|
|
|
|
org.str.w = lpOrgNameBuf;
|
|
|
|
serial.unicode = TRUE;
|
|
|
|
serial.str.w = lpSerialBuf;
|
|
|
|
|
|
|
|
return MSI_GetUserInfo( szProduct, &user, pcchUserNameBuf,
|
|
|
|
&org, pcchOrgNameBuf,
|
|
|
|
&serial, pcchSerialBuf );
|
2005-02-10 19:57:42 +01:00
|
|
|
}
|
|
|
|
|
2006-07-24 08:25:29 +02:00
|
|
|
USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPSTR lpUserNameBuf, LPDWORD pcchUserNameBuf,
|
|
|
|
LPSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
|
|
|
|
LPSTR lpSerialBuf, LPDWORD pcchSerialBuf)
|
2005-02-10 19:57:42 +01:00
|
|
|
{
|
2006-07-24 08:25:29 +02:00
|
|
|
awstring user, org, serial;
|
|
|
|
LPWSTR prod;
|
|
|
|
UINT r;
|
|
|
|
|
2008-06-24 06:08:06 +02:00
|
|
|
if ((lpUserNameBuf && !pcchUserNameBuf) ||
|
|
|
|
(lpOrgNameBuf && !pcchOrgNameBuf) ||
|
|
|
|
(lpSerialBuf && !pcchSerialBuf))
|
|
|
|
return USERINFOSTATE_INVALIDARG;
|
|
|
|
|
2006-07-24 08:25:29 +02:00
|
|
|
prod = strdupAtoW( szProduct );
|
|
|
|
if (szProduct && !prod)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
2005-03-29 13:28:57 +02:00
|
|
|
|
2006-07-24 08:25:29 +02:00
|
|
|
user.unicode = FALSE;
|
|
|
|
user.str.a = lpUserNameBuf;
|
|
|
|
org.unicode = FALSE;
|
|
|
|
org.str.a = lpOrgNameBuf;
|
|
|
|
serial.unicode = FALSE;
|
|
|
|
serial.str.a = lpSerialBuf;
|
|
|
|
|
|
|
|
r = MSI_GetUserInfo( prod, &user, pcchUserNameBuf,
|
|
|
|
&org, pcchOrgNameBuf,
|
|
|
|
&serial, pcchSerialBuf );
|
|
|
|
|
|
|
|
msi_free( prod );
|
|
|
|
|
|
|
|
return r;
|
2005-01-19 17:58:03 +01:00
|
|
|
}
|
|
|
|
|
2005-01-26 20:41:13 +01:00
|
|
|
UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
|
2005-01-19 17:58:03 +01:00
|
|
|
{
|
2005-05-20 20:59:11 +02:00
|
|
|
MSIHANDLE handle;
|
|
|
|
UINT rc;
|
2005-05-23 18:23:54 +02:00
|
|
|
MSIPACKAGE *package;
|
2005-05-20 20:59:11 +02:00
|
|
|
static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
|
|
|
|
|
|
|
|
TRACE("(%s)\n",debugstr_w(szProduct));
|
|
|
|
|
|
|
|
rc = MsiOpenProductW(szProduct,&handle);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2009-03-22 22:31:13 +01:00
|
|
|
/* MsiCollectUserInfo cannot be called from a custom action. */
|
2005-05-23 18:23:54 +02:00
|
|
|
package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
|
2009-03-22 22:31:13 +01:00
|
|
|
if (!package)
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
2018-06-06 07:59:22 +02:00
|
|
|
rc = ACTION_PerformAction(package, szFirstRun);
|
2005-05-23 18:23:54 +02:00
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
|
2005-05-20 20:59:11 +02:00
|
|
|
MsiCloseHandle(handle);
|
|
|
|
|
|
|
|
return rc;
|
2005-01-26 20:41:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct)
|
|
|
|
{
|
2005-05-20 20:59:11 +02:00
|
|
|
MSIHANDLE handle;
|
|
|
|
UINT rc;
|
2005-05-23 18:23:54 +02:00
|
|
|
MSIPACKAGE *package;
|
2005-05-20 20:59:11 +02:00
|
|
|
static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
|
|
|
|
|
|
|
|
TRACE("(%s)\n",debugstr_a(szProduct));
|
|
|
|
|
|
|
|
rc = MsiOpenProductA(szProduct,&handle);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2009-03-22 22:31:13 +01:00
|
|
|
/* MsiCollectUserInfo cannot be called from a custom action. */
|
2005-05-23 18:23:54 +02:00
|
|
|
package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
|
2009-03-22 22:31:13 +01:00
|
|
|
if (!package)
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
2018-06-06 07:59:22 +02:00
|
|
|
rc = ACTION_PerformAction(package, szFirstRun);
|
2005-05-23 18:23:54 +02:00
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
|
2005-05-20 20:59:11 +02:00
|
|
|
MsiCloseHandle(handle);
|
|
|
|
|
|
|
|
return rc;
|
2005-01-26 20:41:13 +01:00
|
|
|
}
|
|
|
|
|
2005-09-16 20:45:04 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiConfigureFeatureA [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiConfigureFeatureA(LPCSTR szProduct, LPCSTR szFeature, INSTALLSTATE eInstallState)
|
2005-08-03 12:56:43 +02:00
|
|
|
{
|
2006-07-17 10:44:29 +02:00
|
|
|
LPWSTR prod, feat = NULL;
|
|
|
|
UINT r = ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
TRACE("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature), eInstallState);
|
|
|
|
|
|
|
|
prod = strdupAtoW( szProduct );
|
|
|
|
if (szProduct && !prod)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
feat = strdupAtoW( szFeature );
|
|
|
|
if (szFeature && !feat)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
r = MsiConfigureFeatureW(prod, feat, eInstallState);
|
|
|
|
|
|
|
|
end:
|
|
|
|
msi_free(feat);
|
|
|
|
msi_free(prod);
|
|
|
|
|
|
|
|
return r;
|
2005-08-03 12:56:43 +02:00
|
|
|
}
|
|
|
|
|
2005-09-16 20:45:04 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiConfigureFeatureW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiConfigureFeatureW(LPCWSTR szProduct, LPCWSTR szFeature, INSTALLSTATE eInstallState)
|
|
|
|
{
|
2006-07-19 10:39:04 +02:00
|
|
|
MSIPACKAGE *package = NULL;
|
|
|
|
UINT r;
|
|
|
|
WCHAR sourcepath[MAX_PATH], filename[MAX_PATH];
|
|
|
|
DWORD sz;
|
|
|
|
|
|
|
|
TRACE("%s %s %i\n", debugstr_w(szProduct), debugstr_w(szFeature), eInstallState);
|
|
|
|
|
|
|
|
if (!szProduct || !szFeature)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2006-07-24 13:34:14 +02:00
|
|
|
switch (eInstallState)
|
|
|
|
{
|
|
|
|
case INSTALLSTATE_DEFAULT:
|
|
|
|
/* FIXME: how do we figure out the default location? */
|
|
|
|
eInstallState = INSTALLSTATE_LOCAL;
|
|
|
|
break;
|
|
|
|
case INSTALLSTATE_LOCAL:
|
|
|
|
case INSTALLSTATE_SOURCE:
|
|
|
|
case INSTALLSTATE_ABSENT:
|
|
|
|
case INSTALLSTATE_ADVERTISED:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2006-07-19 10:39:04 +02:00
|
|
|
r = MSI_OpenProductW( szProduct, &package );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
sz = sizeof(sourcepath);
|
2008-02-26 08:53:27 +01:00
|
|
|
MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
|
2006-07-19 10:39:04 +02:00
|
|
|
MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
|
|
|
|
|
|
|
|
sz = sizeof(filename);
|
2008-02-26 08:53:27 +01:00
|
|
|
MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
|
2006-07-19 10:39:04 +02:00
|
|
|
MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
|
|
|
|
|
|
|
|
lstrcatW( sourcepath, filename );
|
|
|
|
|
|
|
|
MsiSetInternalUI( INSTALLUILEVEL_BASIC, NULL );
|
|
|
|
|
2018-06-06 07:59:22 +02:00
|
|
|
r = ACTION_PerformAction(package, szCostInitialize);
|
2006-07-19 10:39:04 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
r = MSI_SetFeatureStateW( package, szFeature, eInstallState);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
r = MSI_InstallPackage( package, sourcepath, NULL );
|
|
|
|
|
|
|
|
end:
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
|
|
|
|
return r;
|
2005-09-16 20:45:04 +02:00
|
|
|
}
|
2005-08-03 12:56:43 +02:00
|
|
|
|
2006-07-17 10:45:04 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiCreateAndVerifyInstallerDirectory [MSI.@]
|
|
|
|
*
|
|
|
|
* Notes: undocumented
|
|
|
|
*/
|
2005-03-23 11:24:53 +01:00
|
|
|
UINT WINAPI MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved)
|
2005-01-26 20:41:13 +01:00
|
|
|
{
|
2005-05-11 14:01:12 +02:00
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("%d\n", dwReserved);
|
2006-07-17 10:45:04 +02:00
|
|
|
|
|
|
|
if (dwReserved)
|
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("dwReserved=%d\n", dwReserved);
|
2006-07-17 10:45:04 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
2005-05-11 14:01:12 +02:00
|
|
|
}
|
|
|
|
|
2006-07-17 10:45:04 +02:00
|
|
|
if (!GetWindowsDirectoryW(path, MAX_PATH))
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-05-11 14:01:12 +02:00
|
|
|
|
2006-07-17 10:45:04 +02:00
|
|
|
lstrcatW(path, installerW);
|
2005-05-11 14:01:12 +02:00
|
|
|
|
2013-01-31 15:10:04 +01:00
|
|
|
if (!CreateDirectoryW(path, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
|
2006-07-17 10:45:04 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-05-11 14:01:12 +02:00
|
|
|
|
2006-07-17 10:45:04 +02:00
|
|
|
return ERROR_SUCCESS;
|
2005-01-19 17:58:03 +01:00
|
|
|
}
|
2005-02-10 18:10:14 +01:00
|
|
|
|
2005-10-29 12:28:30 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetShortcutTargetA [MSI.@]
|
|
|
|
*/
|
2005-02-10 18:10:14 +01:00
|
|
|
UINT WINAPI MsiGetShortcutTargetA( LPCSTR szShortcutTarget,
|
2005-02-16 17:24:38 +01:00
|
|
|
LPSTR szProductCode, LPSTR szFeatureId,
|
|
|
|
LPSTR szComponentCode )
|
2005-02-10 18:10:14 +01:00
|
|
|
{
|
2005-09-23 12:48:42 +02:00
|
|
|
LPWSTR target;
|
|
|
|
const int len = MAX_FEATURE_CHARS+1;
|
|
|
|
WCHAR product[MAX_FEATURE_CHARS+1], feature[MAX_FEATURE_CHARS+1], component[MAX_FEATURE_CHARS+1];
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
target = strdupAtoW( szShortcutTarget );
|
|
|
|
if (szShortcutTarget && !target )
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
product[0] = 0;
|
|
|
|
feature[0] = 0;
|
|
|
|
component[0] = 0;
|
|
|
|
r = MsiGetShortcutTargetW( target, product, feature, component );
|
|
|
|
msi_free( target );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, product, -1, szProductCode, len, NULL, NULL );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, feature, -1, szFeatureId, len, NULL, NULL );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, component, -1, szComponentCode, len, NULL, NULL );
|
|
|
|
}
|
|
|
|
return r;
|
2005-02-10 18:10:14 +01:00
|
|
|
}
|
|
|
|
|
2005-10-29 12:28:30 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetShortcutTargetW [MSI.@]
|
|
|
|
*/
|
2005-02-10 18:10:14 +01:00
|
|
|
UINT WINAPI MsiGetShortcutTargetW( LPCWSTR szShortcutTarget,
|
2005-02-16 17:24:38 +01:00
|
|
|
LPWSTR szProductCode, LPWSTR szFeatureId,
|
|
|
|
LPWSTR szComponentCode )
|
2005-02-10 18:10:14 +01:00
|
|
|
{
|
2005-10-29 12:28:30 +02:00
|
|
|
IShellLinkDataList *dl = NULL;
|
|
|
|
IPersistFile *pf = NULL;
|
|
|
|
LPEXP_DARWIN_LINK darwin = NULL;
|
2005-11-09 11:58:24 +01:00
|
|
|
HRESULT r, init;
|
2005-10-29 12:28:30 +02:00
|
|
|
|
|
|
|
TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget),
|
|
|
|
szProductCode, szFeatureId, szComponentCode );
|
|
|
|
|
2005-11-09 11:58:24 +01:00
|
|
|
init = CoInitialize(NULL);
|
2005-10-29 12:28:30 +02:00
|
|
|
|
|
|
|
r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IPersistFile, (LPVOID*) &pf );
|
|
|
|
if( SUCCEEDED( r ) )
|
|
|
|
{
|
|
|
|
r = IPersistFile_Load( pf, szShortcutTarget,
|
|
|
|
STGM_READ | STGM_SHARE_DENY_WRITE );
|
|
|
|
if( SUCCEEDED( r ) )
|
|
|
|
{
|
|
|
|
r = IPersistFile_QueryInterface( pf, &IID_IShellLinkDataList,
|
2005-11-09 11:58:24 +01:00
|
|
|
(LPVOID*) &dl );
|
2005-10-29 12:28:30 +02:00
|
|
|
if( SUCCEEDED( r ) )
|
|
|
|
{
|
|
|
|
IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG,
|
|
|
|
(LPVOID) &darwin );
|
|
|
|
IShellLinkDataList_Release( dl );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IPersistFile_Release( pf );
|
|
|
|
}
|
|
|
|
|
2005-11-09 11:58:24 +01:00
|
|
|
if (SUCCEEDED(init))
|
|
|
|
CoUninitialize();
|
2005-10-29 12:28:30 +02:00
|
|
|
|
|
|
|
TRACE("darwin = %p\n", darwin);
|
|
|
|
|
|
|
|
if (darwin)
|
|
|
|
{
|
|
|
|
DWORD sz;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
ret = MsiDecomposeDescriptorW( darwin->szwDarwinID,
|
|
|
|
szProductCode, szFeatureId, szComponentCode, &sz );
|
|
|
|
LocalFree( darwin );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-02-10 18:10:14 +01:00
|
|
|
}
|
2005-02-16 17:24:38 +01:00
|
|
|
|
2011-12-13 13:19:49 +01:00
|
|
|
UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature, DWORD dwReinstallMode )
|
2005-02-16 17:24:38 +01:00
|
|
|
{
|
2011-12-13 13:19:49 +01:00
|
|
|
static const WCHAR fmtW[] = {'%','s','=','%','s',' ','%','s','=','%','s',0};
|
2011-12-13 13:19:01 +01:00
|
|
|
MSIPACKAGE *package;
|
|
|
|
MSIINSTALLCONTEXT context;
|
2005-09-28 12:13:18 +02:00
|
|
|
UINT r;
|
2011-12-13 13:19:01 +01:00
|
|
|
WCHAR sourcepath[MAX_PATH], filename[MAX_PATH], reinstallmode[11];
|
2011-12-13 13:19:49 +01:00
|
|
|
WCHAR *ptr, *cmdline;
|
2006-07-18 11:45:41 +02:00
|
|
|
DWORD sz;
|
2005-09-07 15:26:06 +02:00
|
|
|
|
2011-12-13 13:19:01 +01:00
|
|
|
TRACE("%s, %s, 0x%08x\n", debugstr_w(szProduct), debugstr_w(szFeature), dwReinstallMode);
|
|
|
|
|
|
|
|
r = msi_locate_product( szProduct, &context );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
2005-09-07 15:26:06 +02:00
|
|
|
|
|
|
|
ptr = reinstallmode;
|
|
|
|
|
|
|
|
if (dwReinstallMode & REINSTALLMODE_FILEMISSING)
|
2006-04-18 19:29:03 +02:00
|
|
|
*ptr++ = 'p';
|
2005-09-07 15:26:06 +02:00
|
|
|
if (dwReinstallMode & REINSTALLMODE_FILEOLDERVERSION)
|
2006-04-18 19:29:03 +02:00
|
|
|
*ptr++ = 'o';
|
2005-09-07 15:26:06 +02:00
|
|
|
if (dwReinstallMode & REINSTALLMODE_FILEEQUALVERSION)
|
2006-04-18 19:29:03 +02:00
|
|
|
*ptr++ = 'w';
|
2005-09-07 15:26:06 +02:00
|
|
|
if (dwReinstallMode & REINSTALLMODE_FILEEXACT)
|
2006-04-18 19:29:03 +02:00
|
|
|
*ptr++ = 'd';
|
2005-09-07 15:26:06 +02:00
|
|
|
if (dwReinstallMode & REINSTALLMODE_FILEVERIFY)
|
2006-04-18 19:29:03 +02:00
|
|
|
*ptr++ = 'c';
|
2005-09-07 15:26:06 +02:00
|
|
|
if (dwReinstallMode & REINSTALLMODE_FILEREPLACE)
|
2006-04-18 19:29:03 +02:00
|
|
|
*ptr++ = 'a';
|
2005-09-07 15:26:06 +02:00
|
|
|
if (dwReinstallMode & REINSTALLMODE_USERDATA)
|
2006-04-18 19:29:03 +02:00
|
|
|
*ptr++ = 'u';
|
2005-09-07 15:26:06 +02:00
|
|
|
if (dwReinstallMode & REINSTALLMODE_MACHINEDATA)
|
2006-04-18 19:29:03 +02:00
|
|
|
*ptr++ = 'm';
|
2005-09-07 15:26:06 +02:00
|
|
|
if (dwReinstallMode & REINSTALLMODE_SHORTCUT)
|
2006-04-18 19:29:03 +02:00
|
|
|
*ptr++ = 's';
|
2005-09-07 15:26:06 +02:00
|
|
|
if (dwReinstallMode & REINSTALLMODE_PACKAGE)
|
2006-04-18 19:29:03 +02:00
|
|
|
*ptr++ = 'v';
|
|
|
|
*ptr = 0;
|
2005-09-07 15:26:06 +02:00
|
|
|
|
|
|
|
sz = sizeof(sourcepath);
|
2011-12-13 13:19:01 +01:00
|
|
|
MsiSourceListGetInfoW( szProduct, NULL, context, MSICODE_PRODUCT,
|
|
|
|
INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz );
|
2005-09-07 15:26:06 +02:00
|
|
|
sz = sizeof(filename);
|
2011-12-13 13:19:01 +01:00
|
|
|
MsiSourceListGetInfoW( szProduct, NULL, context, MSICODE_PRODUCT,
|
|
|
|
INSTALLPROPERTY_PACKAGENAMEW, filename, &sz );
|
2011-12-13 13:19:49 +01:00
|
|
|
strcatW( sourcepath, filename );
|
2005-09-07 15:26:06 +02:00
|
|
|
|
2005-09-28 12:13:18 +02:00
|
|
|
if (dwReinstallMode & REINSTALLMODE_PACKAGE)
|
2018-06-21 21:48:56 +02:00
|
|
|
r = MSI_OpenPackageW( sourcepath, 0, &package );
|
2005-09-07 15:26:06 +02:00
|
|
|
else
|
2005-09-28 12:13:18 +02:00
|
|
|
r = MSI_OpenProductW( szProduct, &package );
|
2005-09-07 15:26:06 +02:00
|
|
|
|
2005-09-28 12:13:18 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
2005-09-07 15:26:06 +02:00
|
|
|
|
2011-12-13 13:19:49 +01:00
|
|
|
sz = (strlenW( fmtW ) + strlenW( szReinstallMode ) + strlenW( reinstallmode )) * sizeof(WCHAR);
|
|
|
|
sz += (strlenW( szReinstall ) + strlenW( szFeature )) * sizeof(WCHAR);
|
|
|
|
if (!(cmdline = msi_alloc( sz )))
|
|
|
|
{
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
sprintfW( cmdline, fmtW, szReinstallMode, reinstallmode, szReinstall, szFeature );
|
2005-09-07 15:26:06 +02:00
|
|
|
|
2011-12-13 13:19:49 +01:00
|
|
|
r = MSI_InstallPackage( package, sourcepath, cmdline );
|
2005-09-07 15:26:06 +02:00
|
|
|
msiobj_release( &package->hdr );
|
2011-12-13 13:19:49 +01:00
|
|
|
msi_free( cmdline );
|
2005-09-07 15:26:06 +02:00
|
|
|
|
2005-09-28 12:13:18 +02:00
|
|
|
return r;
|
2005-02-16 17:24:38 +01:00
|
|
|
}
|
|
|
|
|
2005-03-29 13:28:57 +02:00
|
|
|
UINT WINAPI MsiReinstallFeatureA( LPCSTR szProduct, LPCSTR szFeature,
|
2005-02-16 17:24:38 +01:00
|
|
|
DWORD dwReinstallMode )
|
|
|
|
{
|
2005-09-07 15:26:06 +02:00
|
|
|
LPWSTR wszProduct;
|
|
|
|
LPWSTR wszFeature;
|
|
|
|
UINT rc;
|
|
|
|
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature),
|
2005-02-16 17:24:38 +01:00
|
|
|
dwReinstallMode);
|
2005-09-07 15:26:06 +02:00
|
|
|
|
|
|
|
wszProduct = strdupAtoW(szProduct);
|
|
|
|
wszFeature = strdupAtoW(szFeature);
|
|
|
|
|
|
|
|
rc = MsiReinstallFeatureW(wszProduct, wszFeature, dwReinstallMode);
|
2006-07-14 08:21:10 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(wszProduct);
|
|
|
|
msi_free(wszFeature);
|
2005-09-07 15:26:06 +02:00
|
|
|
return rc;
|
2005-02-16 17:24:38 +01:00
|
|
|
}
|
2005-09-06 13:05:24 +02:00
|
|
|
|
2006-07-24 11:13:25 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned int i[2];
|
|
|
|
unsigned int buf[4];
|
|
|
|
unsigned char in[64];
|
|
|
|
unsigned char digest[16];
|
|
|
|
} MD5_CTX;
|
|
|
|
|
|
|
|
extern VOID WINAPI MD5Init( MD5_CTX *);
|
|
|
|
extern VOID WINAPI MD5Update( MD5_CTX *, const unsigned char *, unsigned int );
|
|
|
|
extern VOID WINAPI MD5Final( MD5_CTX *);
|
|
|
|
|
2015-03-16 10:55:21 +01:00
|
|
|
UINT msi_get_filehash( const WCHAR *path, MSIFILEHASHINFO *hash )
|
2005-11-02 11:56:54 +01:00
|
|
|
{
|
2006-07-24 11:13:25 +02:00
|
|
|
HANDLE handle, mapping;
|
|
|
|
void *p;
|
|
|
|
DWORD length;
|
|
|
|
UINT r = ERROR_FUNCTION_FAILED;
|
|
|
|
|
2015-03-16 10:55:21 +01:00
|
|
|
handle = CreateFileW( path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL );
|
2006-07-24 11:13:25 +02:00
|
|
|
if (handle == INVALID_HANDLE_VALUE)
|
2010-12-23 17:08:10 +01:00
|
|
|
{
|
|
|
|
WARN("can't open file %u\n", GetLastError());
|
2006-07-24 11:13:25 +02:00
|
|
|
return ERROR_FILE_NOT_FOUND;
|
2010-12-23 17:08:10 +01:00
|
|
|
}
|
2015-03-16 10:55:21 +01:00
|
|
|
if ((length = GetFileSize( handle, NULL )))
|
2006-07-24 11:13:25 +02:00
|
|
|
{
|
2015-03-16 10:55:21 +01:00
|
|
|
if ((mapping = CreateFileMappingW( handle, NULL, PAGE_READONLY, 0, 0, NULL )))
|
2006-07-24 11:13:25 +02:00
|
|
|
{
|
2015-03-16 10:55:21 +01:00
|
|
|
if ((p = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, length )))
|
2012-04-05 13:08:08 +02:00
|
|
|
{
|
|
|
|
MD5_CTX ctx;
|
2006-07-24 11:13:25 +02:00
|
|
|
|
2012-04-05 13:08:08 +02:00
|
|
|
MD5Init( &ctx );
|
|
|
|
MD5Update( &ctx, p, length );
|
|
|
|
MD5Final( &ctx );
|
|
|
|
UnmapViewOfFile( p );
|
2006-07-24 11:13:25 +02:00
|
|
|
|
2015-03-16 10:55:21 +01:00
|
|
|
memcpy( hash->dwData, ctx.digest, sizeof(hash->dwData) );
|
2012-04-05 13:08:08 +02:00
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
CloseHandle( mapping );
|
2006-07-24 11:13:25 +02:00
|
|
|
}
|
|
|
|
}
|
2012-04-05 13:08:08 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Empty file -> set hash to 0 */
|
2015-03-16 10:55:21 +01:00
|
|
|
memset( hash->dwData, 0, sizeof(hash->dwData) );
|
2012-04-05 13:08:08 +02:00
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-07-24 11:13:25 +02:00
|
|
|
CloseHandle( handle );
|
|
|
|
return r;
|
2005-11-02 11:56:54 +01:00
|
|
|
}
|
|
|
|
|
2015-03-16 10:55:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFileHashW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
|
|
|
|
PMSIFILEHASHINFO pHash )
|
|
|
|
{
|
|
|
|
TRACE("%s %08x %p\n", debugstr_w(szFilePath), dwOptions, pHash );
|
|
|
|
|
|
|
|
if (!szFilePath)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (!*szFilePath)
|
|
|
|
return ERROR_PATH_NOT_FOUND;
|
|
|
|
|
|
|
|
if (dwOptions)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
if (!pHash)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
if (pHash->dwFileHashInfoSize < sizeof *pHash)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
return msi_get_filehash( szFilePath, pHash );
|
|
|
|
}
|
|
|
|
|
2005-11-02 11:56:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiGetFileHashA [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiGetFileHashA( LPCSTR szFilePath, DWORD dwOptions,
|
|
|
|
PMSIFILEHASHINFO pHash )
|
|
|
|
{
|
2006-07-24 11:13:25 +02:00
|
|
|
LPWSTR file;
|
|
|
|
UINT r;
|
|
|
|
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("%s %08x %p\n", debugstr_a(szFilePath), dwOptions, pHash );
|
2006-07-24 11:13:25 +02:00
|
|
|
|
|
|
|
file = strdupAtoW( szFilePath );
|
|
|
|
if (szFilePath && !file)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
r = MsiGetFileHashW( file, dwOptions, pHash );
|
|
|
|
msi_free( file );
|
|
|
|
return r;
|
2005-11-02 11:56:54 +01:00
|
|
|
}
|
2005-11-02 20:54:31 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiAdvertiseScriptW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiAdvertiseScriptW( LPCWSTR szScriptFile, DWORD dwFlags,
|
|
|
|
PHKEY phRegData, BOOL fRemoveItems )
|
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("%s %08x %p %d\n",
|
2005-11-02 20:54:31 +01:00
|
|
|
debugstr_w( szScriptFile ), dwFlags, phRegData, fRemoveItems );
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiAdvertiseScriptA [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiAdvertiseScriptA( LPCSTR szScriptFile, DWORD dwFlags,
|
|
|
|
PHKEY phRegData, BOOL fRemoveItems )
|
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("%s %08x %p %d\n",
|
2005-11-02 20:54:31 +01:00
|
|
|
debugstr_a( szScriptFile ), dwFlags, phRegData, fRemoveItems );
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
2008-02-13 19:08:07 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiIsProductElevatedW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiIsProductElevatedW( LPCWSTR szProduct, BOOL *pfElevated )
|
|
|
|
{
|
|
|
|
FIXME("%s %p - stub\n",
|
|
|
|
debugstr_w( szProduct ), pfElevated );
|
|
|
|
*pfElevated = TRUE;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiIsProductElevatedA [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiIsProductElevatedA( LPCSTR szProduct, BOOL *pfElevated )
|
|
|
|
{
|
|
|
|
FIXME("%s %p - stub\n",
|
|
|
|
debugstr_a( szProduct ), pfElevated );
|
|
|
|
*pfElevated = TRUE;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2008-09-24 20:19:16 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiSetExternalUIRecord [MSI.@]
|
|
|
|
*/
|
2009-11-02 10:04:05 +01:00
|
|
|
UINT WINAPI MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD handler,
|
|
|
|
DWORD filter, LPVOID context,
|
|
|
|
PINSTALLUI_HANDLER_RECORD prev )
|
2008-09-24 20:19:16 +02:00
|
|
|
{
|
2009-11-02 10:04:05 +01:00
|
|
|
TRACE("%p %08x %p %p\n", handler, filter, context, prev);
|
|
|
|
|
|
|
|
if (prev)
|
|
|
|
*prev = gUIHandlerRecord;
|
|
|
|
|
|
|
|
gUIHandlerRecord = handler;
|
2017-06-19 04:53:28 +02:00
|
|
|
gUIFilterRecord = filter;
|
|
|
|
gUIContextRecord = context;
|
2009-11-02 10:04:05 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2008-09-24 20:19:16 +02:00
|
|
|
}
|
2008-10-06 23:05:25 +02:00
|
|
|
|
2010-11-16 09:07:36 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiInstallMissingComponentA [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiInstallMissingComponentA( LPCSTR product, LPCSTR component, INSTALLSTATE state )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
WCHAR *productW = NULL, *componentW = NULL;
|
|
|
|
|
|
|
|
TRACE("%s, %s, %d\n", debugstr_a(product), debugstr_a(component), state);
|
|
|
|
|
|
|
|
if (product && !(productW = strdupAtoW( product )))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (component && !(componentW = strdupAtoW( component )))
|
|
|
|
{
|
|
|
|
msi_free( productW );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MsiInstallMissingComponentW( productW, componentW, state );
|
|
|
|
msi_free( productW );
|
|
|
|
msi_free( componentW );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2008-10-06 23:05:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiInstallMissingComponentW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiInstallMissingComponentW(LPCWSTR szProduct, LPCWSTR szComponent, INSTALLSTATE eInstallState)
|
|
|
|
{
|
|
|
|
FIXME("(%s %s %d\n", debugstr_w(szProduct), debugstr_w(szComponent), eInstallState);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2010-09-02 13:20:23 +02:00
|
|
|
|
2015-01-21 13:26:31 +01:00
|
|
|
UINT WINAPI MsiProvideComponentA( LPCSTR product, LPCSTR feature, LPCSTR component, DWORD mode, LPSTR buf, LPDWORD buflen )
|
|
|
|
{
|
|
|
|
WCHAR *productW = NULL, *componentW = NULL, *featureW = NULL, *bufW = NULL;
|
|
|
|
UINT r = ERROR_OUTOFMEMORY;
|
2015-04-21 11:20:04 +02:00
|
|
|
DWORD lenW = 0;
|
2015-01-21 13:26:31 +01:00
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("%s, %s, %s, %x, %p, %p\n", debugstr_a(product), debugstr_a(component), debugstr_a(feature), mode, buf, buflen);
|
|
|
|
|
|
|
|
if (product && !(productW = strdupAtoW( product ))) goto done;
|
|
|
|
if (feature && !(featureW = strdupAtoW( feature ))) goto done;
|
|
|
|
if (component && !(componentW = strdupAtoW( component ))) goto done;
|
|
|
|
|
|
|
|
r = MsiProvideComponentW( productW, featureW, componentW, mode, NULL, &lenW );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (!(bufW = msi_alloc( ++lenW * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MsiProvideComponentW( productW, featureW, componentW, mode, bufW, &lenW );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, bufW, -1, NULL, 0, NULL, NULL );
|
|
|
|
if (buf)
|
|
|
|
{
|
|
|
|
if (len > *buflen)
|
|
|
|
r = ERROR_MORE_DATA;
|
|
|
|
else
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, bufW, -1, buf, *buflen, NULL, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
*buflen = len - 1;
|
|
|
|
|
|
|
|
done:
|
|
|
|
msi_free( productW );
|
|
|
|
msi_free( featureW );
|
|
|
|
msi_free( componentW );
|
|
|
|
msi_free( bufW );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiProvideComponentW( LPCWSTR product, LPCWSTR feature, LPCWSTR component, DWORD mode, LPWSTR buf, LPDWORD buflen )
|
|
|
|
{
|
|
|
|
INSTALLSTATE state;
|
|
|
|
|
|
|
|
TRACE("%s, %s, %s, %x, %p, %p\n", debugstr_w(product), debugstr_w(component), debugstr_w(feature), mode, buf, buflen);
|
|
|
|
|
|
|
|
state = MsiQueryFeatureStateW( product, feature );
|
|
|
|
TRACE("feature state: %d\n", state);
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case INSTALLMODE_NODETECTION:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("mode %x not implemented\n", mode);
|
|
|
|
return ERROR_INSTALL_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
state = MsiGetComponentPathW( product, component, buf, buflen );
|
|
|
|
TRACE("component state: %d\n", state);
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case INSTALLSTATE_INVALIDARG:
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
case INSTALLSTATE_MOREDATA:
|
|
|
|
return ERROR_MORE_DATA;
|
|
|
|
|
|
|
|
case INSTALLSTATE_ADVERTISED:
|
|
|
|
case INSTALLSTATE_LOCAL:
|
|
|
|
case INSTALLSTATE_SOURCE:
|
|
|
|
MsiUseFeatureW( product, feature );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
default:
|
|
|
|
TRACE("MsiGetComponentPathW returned %d\n", state);
|
|
|
|
return ERROR_INSTALL_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-02 13:20:23 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiBeginTransactionA [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiBeginTransactionA( LPCSTR name, DWORD attrs, MSIHANDLE *id, HANDLE *event )
|
|
|
|
{
|
|
|
|
WCHAR *nameW;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
FIXME("%s %u %p %p\n", debugstr_a(name), attrs, id, event);
|
|
|
|
|
|
|
|
nameW = strdupAtoW( name );
|
|
|
|
if (name && !nameW)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
r = MsiBeginTransactionW( nameW, attrs, id, event );
|
|
|
|
msi_free( nameW );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiBeginTransactionW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiBeginTransactionW( LPCWSTR name, DWORD attrs, MSIHANDLE *id, HANDLE *event )
|
|
|
|
{
|
|
|
|
FIXME("%s %u %p %p\n", debugstr_w(name), attrs, id, event);
|
|
|
|
|
|
|
|
*id = (MSIHANDLE)0xdeadbeef;
|
|
|
|
*event = (HANDLE)0xdeadbeef;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-07-15 15:15:05 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiJoinTransaction [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiJoinTransaction( MSIHANDLE handle, DWORD attrs, HANDLE *event )
|
|
|
|
{
|
|
|
|
FIXME("%u %08x %p\n", handle, attrs, event);
|
|
|
|
|
|
|
|
*event = (HANDLE)0xdeadbeef;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-09-02 13:20:23 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MsiEndTransaction [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiEndTransaction( DWORD state )
|
|
|
|
{
|
|
|
|
FIXME("%u\n", state);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2012-07-30 21:34:20 +02:00
|
|
|
|
|
|
|
UINT WINAPI Migrate10CachedPackagesW(void* a, void* b, void* c, DWORD d)
|
|
|
|
{
|
|
|
|
FIXME("%p,%p,%p,%08x\n", a, b, c, d);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2014-11-03 03:28:02 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiRemovePatchesA [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiRemovePatchesA(LPCSTR patchlist, LPCSTR product, INSTALLTYPE type, LPCSTR propertylist)
|
|
|
|
{
|
|
|
|
FIXME("(%s %s %d %s\n", debugstr_a(patchlist), debugstr_a(product), type, debugstr_a(propertylist));
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MsiRemovePatchesW [MSI.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI MsiRemovePatchesW(LPCWSTR patchlist, LPCWSTR product, INSTALLTYPE type, LPCWSTR propertylist)
|
|
|
|
{
|
|
|
|
FIXME("(%s %s %d %s\n", debugstr_w(patchlist), debugstr_w(product), type, debugstr_w(propertylist));
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|