2004-07-19 21:44:07 +02:00
|
|
|
/*
|
|
|
|
* msiexec.exe implementation
|
|
|
|
*
|
2008-10-18 19:22:19 +02:00
|
|
|
* Copyright 2004 Vincent Béron
|
2005-02-09 15:05:40 +01:00
|
|
|
* Copyright 2005 Mike McCormack
|
2004-07-19 21:44:07 +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
|
2004-07-19 21:44:07 +02:00
|
|
|
*/
|
|
|
|
|
2006-01-16 20:41:34 +01:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
|
2004-07-19 21:44:07 +02:00
|
|
|
#include <windows.h>
|
2021-06-09 15:57:51 +02:00
|
|
|
#include <commctrl.h>
|
2004-07-19 21:44:07 +02:00
|
|
|
#include <msi.h>
|
2012-01-23 12:16:36 +01:00
|
|
|
#include <winsvc.h>
|
2004-07-19 21:44:07 +02:00
|
|
|
#include <objbase.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2018-08-16 17:34:40 +02:00
|
|
|
#include "wine/heap.h"
|
2004-07-19 21:44:07 +02:00
|
|
|
|
2018-07-10 12:08:47 +02:00
|
|
|
#include "initguid.h"
|
|
|
|
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
|
|
|
|
2004-07-19 21:44:07 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msiexec);
|
|
|
|
|
2005-08-11 12:59:51 +02:00
|
|
|
typedef HRESULT (WINAPI *DLLREGISTERSERVER)(void);
|
|
|
|
typedef HRESULT (WINAPI *DLLUNREGISTERSERVER)(void);
|
|
|
|
|
2007-07-30 20:53:16 +02:00
|
|
|
DWORD DoService(void);
|
|
|
|
|
2005-02-09 15:05:40 +01:00
|
|
|
struct string_list
|
|
|
|
{
|
|
|
|
struct string_list *next;
|
2005-02-10 18:12:59 +01:00
|
|
|
WCHAR str[1];
|
2005-02-09 15:05:40 +01:00
|
|
|
};
|
|
|
|
|
2004-07-19 21:44:07 +02:00
|
|
|
static void ShowUsage(int ExitCode)
|
|
|
|
{
|
2010-05-06 17:24:53 +02:00
|
|
|
WCHAR msiexec_version[40];
|
|
|
|
WCHAR filename[MAX_PATH];
|
|
|
|
LPWSTR msi_res;
|
|
|
|
LPWSTR msiexec_help;
|
|
|
|
HMODULE hmsi = GetModuleHandleA("msi.dll");
|
|
|
|
DWORD len;
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
/* MsiGetFileVersion need the full path */
|
|
|
|
*filename = 0;
|
2018-07-24 00:01:30 +02:00
|
|
|
res = GetModuleFileNameW(hmsi, filename, ARRAY_SIZE(filename));
|
2010-05-06 17:24:53 +02:00
|
|
|
if (!res)
|
|
|
|
WINE_ERR("GetModuleFileName failed: %d\n", GetLastError());
|
|
|
|
|
2018-07-24 00:01:30 +02:00
|
|
|
len = ARRAY_SIZE(msiexec_version);
|
2010-05-06 17:24:53 +02:00
|
|
|
*msiexec_version = 0;
|
|
|
|
res = MsiGetFileVersionW(filename, msiexec_version, &len, NULL, NULL);
|
|
|
|
if (res)
|
|
|
|
WINE_ERR("MsiGetFileVersion failed with %d\n", res);
|
|
|
|
|
|
|
|
/* Return the length of the resource.
|
|
|
|
No typo: The LPWSTR parameter must be a LPWSTR * for this mode */
|
|
|
|
len = LoadStringW(hmsi, 10, (LPWSTR) &msi_res, 0);
|
|
|
|
|
|
|
|
msi_res = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
|
|
|
|
msiexec_help = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) + sizeof(msiexec_version));
|
|
|
|
if (msi_res && msiexec_help) {
|
|
|
|
*msi_res = 0;
|
|
|
|
LoadStringW(hmsi, 10, msi_res, len + 1);
|
|
|
|
|
2019-04-29 12:10:09 +02:00
|
|
|
swprintf(msiexec_help, len + 1 + ARRAY_SIZE(msiexec_version), msi_res, msiexec_version);
|
2010-05-06 17:24:53 +02:00
|
|
|
MsiMessageBoxW(0, msiexec_help, NULL, 0, GetUserDefaultLangID(), 0);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, msi_res);
|
|
|
|
HeapFree(GetProcessHeap(), 0, msiexec_help);
|
|
|
|
ExitProcess(ExitCode);
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
|
|
|
|
2005-02-10 19:57:56 +01:00
|
|
|
static BOOL IsProductCode(LPWSTR str)
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
2005-02-10 19:57:56 +01:00
|
|
|
GUID ProductCode;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
2005-02-10 19:57:56 +01:00
|
|
|
if(lstrlenW(str) != 38)
|
|
|
|
return FALSE;
|
|
|
|
return ( (CLSIDFromString(str, &ProductCode) == NOERROR) );
|
2004-07-30 06:23:37 +02:00
|
|
|
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
static VOID StringListAppend(struct string_list **list, LPCWSTR str)
|
2004-07-30 06:21:27 +02:00
|
|
|
{
|
2005-02-09 15:05:40 +01:00
|
|
|
struct string_list *entry;
|
|
|
|
|
2012-11-12 10:43:44 +01:00
|
|
|
entry = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(struct string_list, str[lstrlenW(str) + 1]));
|
2005-02-09 15:05:40 +01:00
|
|
|
if(!entry)
|
2004-07-30 06:21:27 +02:00
|
|
|
{
|
|
|
|
WINE_ERR("Out of memory!\n");
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
2005-02-10 18:12:59 +01:00
|
|
|
lstrcpyW(entry->str, str);
|
2005-02-09 15:05:40 +01:00
|
|
|
entry->next = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ignoring o(n^2) time complexity to add n strings for simplicity,
|
|
|
|
* add the string to the end of the list to preserve the order.
|
|
|
|
*/
|
|
|
|
while( *list )
|
|
|
|
list = &(*list)->next;
|
|
|
|
*list = entry;
|
|
|
|
}
|
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
static LPWSTR build_properties(struct string_list *property_list)
|
2005-02-09 15:05:40 +01:00
|
|
|
{
|
|
|
|
struct string_list *list;
|
2005-02-10 18:12:59 +01:00
|
|
|
LPWSTR ret, p, value;
|
2005-02-09 15:05:40 +01:00
|
|
|
DWORD len;
|
|
|
|
BOOL needs_quote;
|
|
|
|
|
|
|
|
if(!property_list)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* count the space we need */
|
|
|
|
len = 1;
|
|
|
|
for(list = property_list; list; list = list->next)
|
2005-02-10 18:12:59 +01:00
|
|
|
len += lstrlenW(list->str) + 3;
|
2005-02-09 15:05:40 +01:00
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
|
2005-02-09 15:05:40 +01:00
|
|
|
|
|
|
|
/* add a space before each string, and quote the value */
|
|
|
|
p = ret;
|
|
|
|
for(list = property_list; list; list = list->next)
|
|
|
|
{
|
2019-04-29 12:10:09 +02:00
|
|
|
value = wcschr(list->str,'=');
|
2005-02-09 15:05:40 +01:00
|
|
|
if(!value)
|
|
|
|
continue;
|
|
|
|
len = value - list->str;
|
|
|
|
*p++ = ' ';
|
2005-03-28 16:17:51 +02:00
|
|
|
memcpy(p, list->str, len * sizeof(WCHAR));
|
2005-02-09 15:05:40 +01:00
|
|
|
p += len;
|
|
|
|
*p++ = '=';
|
|
|
|
|
|
|
|
/* check if the value contains spaces and maybe quote it */
|
|
|
|
value++;
|
2019-04-29 12:10:09 +02:00
|
|
|
needs_quote = wcschr(value,' ') ? 1 : 0;
|
2005-02-09 15:05:40 +01:00
|
|
|
if(needs_quote)
|
|
|
|
*p++ = '"';
|
2005-02-10 18:12:59 +01:00
|
|
|
len = lstrlenW(value);
|
2005-03-28 16:17:51 +02:00
|
|
|
memcpy(p, value, len * sizeof(WCHAR));
|
2005-02-09 15:05:40 +01:00
|
|
|
p += len;
|
|
|
|
if(needs_quote)
|
|
|
|
*p++ = '"';
|
|
|
|
}
|
|
|
|
*p = 0;
|
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("properties -> %s\n", wine_dbgstr_w(ret) );
|
|
|
|
|
2005-02-09 15:05:40 +01:00
|
|
|
return ret;
|
2004-07-30 06:21:27 +02:00
|
|
|
}
|
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
static LPWSTR build_transforms(struct string_list *transform_list)
|
2004-07-30 06:21:27 +02:00
|
|
|
{
|
2005-02-09 15:05:40 +01:00
|
|
|
struct string_list *list;
|
2005-02-10 18:12:59 +01:00
|
|
|
LPWSTR ret, p;
|
2005-02-09 15:05:40 +01:00
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
/* count the space we need */
|
|
|
|
len = 1;
|
|
|
|
for(list = transform_list; list; list = list->next)
|
2005-02-10 18:12:59 +01:00
|
|
|
len += lstrlenW(list->str) + 1;
|
2005-02-09 15:05:40 +01:00
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
|
2005-02-09 15:05:40 +01:00
|
|
|
|
|
|
|
/* add all the transforms with a semicolon between each one */
|
|
|
|
p = ret;
|
|
|
|
for(list = transform_list; list; list = list->next)
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
len = lstrlenW(list->str);
|
|
|
|
lstrcpynW(p, list->str, len );
|
2005-02-09 15:05:40 +01:00
|
|
|
p += len;
|
|
|
|
if(list->next)
|
|
|
|
*p++ = ';';
|
|
|
|
}
|
|
|
|
*p = 0;
|
|
|
|
|
|
|
|
return ret;
|
2004-07-30 06:21:27 +02:00
|
|
|
}
|
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
static DWORD msi_atou(LPCWSTR str)
|
2004-11-23 13:12:31 +01:00
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
DWORD ret = 0;
|
|
|
|
while(*str >= '0' && *str <= '9')
|
|
|
|
{
|
|
|
|
ret *= 10;
|
|
|
|
ret += (*str - '0');
|
|
|
|
str++;
|
|
|
|
}
|
2007-11-25 08:35:27 +01:00
|
|
|
return ret;
|
2005-02-10 18:12:59 +01:00
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
/* str1 is the same as str2, ignoring case */
|
|
|
|
static BOOL msi_strequal(LPCWSTR str1, LPCSTR str2)
|
|
|
|
{
|
|
|
|
DWORD len, ret;
|
|
|
|
LPWSTR strW;
|
|
|
|
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, str2, -1, NULL, 0);
|
|
|
|
if( !len )
|
2006-07-14 12:38:20 +02:00
|
|
|
return FALSE;
|
2005-02-10 18:12:59 +01:00
|
|
|
if( lstrlenW(str1) != (len-1) )
|
2006-07-14 12:38:20 +02:00
|
|
|
return FALSE;
|
2005-02-10 18:12:59 +01:00
|
|
|
strW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, str2, -1, strW, len);
|
|
|
|
ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, str1, len, strW, len);
|
|
|
|
HeapFree(GetProcessHeap(), 0, strW);
|
2006-07-14 12:38:20 +02:00
|
|
|
return (ret == CSTR_EQUAL);
|
2005-02-10 18:12:59 +01:00
|
|
|
}
|
2004-11-23 13:12:31 +01:00
|
|
|
|
2006-07-13 23:46:51 +02:00
|
|
|
/* prefix is hyphen or dash, and str1 is the same as str2, ignoring case */
|
|
|
|
static BOOL msi_option_equal(LPCWSTR str1, LPCSTR str2)
|
|
|
|
{
|
|
|
|
if (str1[0] != '/' && str1[0] != '-')
|
2006-07-14 12:38:20 +02:00
|
|
|
return FALSE;
|
2006-07-13 23:46:51 +02:00
|
|
|
|
|
|
|
/* skip over the hyphen or slash */
|
|
|
|
return msi_strequal(str1 + 1, str2);
|
|
|
|
}
|
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
/* str2 is at the beginning of str1, ignoring case */
|
|
|
|
static BOOL msi_strprefix(LPCWSTR str1, LPCSTR str2)
|
|
|
|
{
|
|
|
|
DWORD len, ret;
|
|
|
|
LPWSTR strW;
|
|
|
|
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, str2, -1, NULL, 0);
|
|
|
|
if( !len )
|
2006-07-14 12:38:20 +02:00
|
|
|
return FALSE;
|
2005-02-10 18:12:59 +01:00
|
|
|
if( lstrlenW(str1) < (len-1) )
|
2006-07-14 12:38:20 +02:00
|
|
|
return FALSE;
|
2005-02-10 18:12:59 +01:00
|
|
|
strW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, str2, -1, strW, len);
|
|
|
|
ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, str1, len-1, strW, len-1);
|
|
|
|
HeapFree(GetProcessHeap(), 0, strW);
|
2006-07-14 12:38:20 +02:00
|
|
|
return (ret == CSTR_EQUAL);
|
2004-11-23 13:12:31 +01:00
|
|
|
}
|
|
|
|
|
2006-07-13 23:46:51 +02:00
|
|
|
/* prefix is hyphen or dash, and str2 is at the beginning of str1, ignoring case */
|
|
|
|
static BOOL msi_option_prefix(LPCWSTR str1, LPCSTR str2)
|
|
|
|
{
|
|
|
|
if (str1[0] != '/' && str1[0] != '-')
|
2006-07-14 12:38:20 +02:00
|
|
|
return FALSE;
|
2006-07-13 23:46:51 +02:00
|
|
|
|
|
|
|
/* skip over the hyphen or slash */
|
|
|
|
return msi_strprefix(str1 + 1, str2);
|
|
|
|
}
|
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
static VOID *LoadProc(LPCWSTR DllName, LPCSTR ProcName, HMODULE* DllHandle)
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
VOID* (*proc)(void);
|
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
*DllHandle = LoadLibraryExW(DllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
2004-07-19 21:44:07 +02:00
|
|
|
if(!*DllHandle)
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
fprintf(stderr, "Unable to load dll %s\n", wine_dbgstr_w(DllName));
|
2004-07-19 21:44:07 +02:00
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
proc = (VOID *) GetProcAddress(*DllHandle, ProcName);
|
|
|
|
if(!proc)
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
fprintf(stderr, "Dll %s does not implement function %s\n",
|
|
|
|
wine_dbgstr_w(DllName), ProcName);
|
2004-07-19 21:44:07 +02:00
|
|
|
FreeLibrary(*DllHandle);
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return proc;
|
|
|
|
}
|
|
|
|
|
2005-05-17 16:33:36 +02:00
|
|
|
static DWORD DoDllRegisterServer(LPCWSTR DllName)
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DLLREGISTERSERVER pfDllRegisterServer = NULL;
|
|
|
|
HMODULE DllHandle = NULL;
|
|
|
|
|
|
|
|
pfDllRegisterServer = LoadProc(DllName, "DllRegisterServer", &DllHandle);
|
|
|
|
|
|
|
|
hr = pfDllRegisterServer();
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
fprintf(stderr, "Failed to register dll %s\n", wine_dbgstr_w(DllName));
|
2005-02-09 15:05:40 +01:00
|
|
|
return 1;
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2005-02-10 18:12:59 +01:00
|
|
|
printf("Successfully registered dll %s\n", wine_dbgstr_w(DllName));
|
2004-07-19 21:44:07 +02:00
|
|
|
if(DllHandle)
|
|
|
|
FreeLibrary(DllHandle);
|
2005-02-09 15:05:40 +01:00
|
|
|
return 0;
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
|
|
|
|
2005-05-17 16:33:36 +02:00
|
|
|
static DWORD DoDllUnregisterServer(LPCWSTR DllName)
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DLLUNREGISTERSERVER pfDllUnregisterServer = NULL;
|
|
|
|
HMODULE DllHandle = NULL;
|
|
|
|
|
|
|
|
pfDllUnregisterServer = LoadProc(DllName, "DllUnregisterServer", &DllHandle);
|
|
|
|
|
|
|
|
hr = pfDllUnregisterServer();
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
fprintf(stderr, "Failed to unregister dll %s\n", wine_dbgstr_w(DllName));
|
2005-02-09 15:05:40 +01:00
|
|
|
return 1;
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2005-02-10 18:12:59 +01:00
|
|
|
printf("Successfully unregistered dll %s\n", wine_dbgstr_w(DllName));
|
2004-07-19 21:44:07 +02:00
|
|
|
if(DllHandle)
|
|
|
|
FreeLibrary(DllHandle);
|
2005-02-09 15:05:40 +01:00
|
|
|
return 0;
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
|
|
|
|
2006-08-23 03:56:00 +02:00
|
|
|
static DWORD DoRegServer(void)
|
|
|
|
{
|
|
|
|
SC_HANDLE scm, service;
|
2013-02-12 14:33:23 +01:00
|
|
|
WCHAR path[MAX_PATH+12];
|
|
|
|
DWORD len, ret = 0;
|
2006-08-23 03:56:00 +02:00
|
|
|
|
2013-02-12 14:33:23 +01:00
|
|
|
if (!(scm = OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASEW, SC_MANAGER_CREATE_SERVICE)))
|
2006-08-23 03:56:00 +02:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to open the service control manager.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2013-02-12 14:33:23 +01:00
|
|
|
len = GetSystemDirectoryW(path, MAX_PATH);
|
2020-10-07 23:34:30 +02:00
|
|
|
lstrcpyW(path + len, L"\\msiexec /V");
|
|
|
|
if ((service = CreateServiceW(scm, L"MSIServer", L"MSIServer", GENERIC_ALL,
|
2013-02-12 14:33:23 +01:00
|
|
|
SERVICE_WIN32_SHARE_PROCESS, SERVICE_DEMAND_START,
|
|
|
|
SERVICE_ERROR_NORMAL, path, NULL, NULL, NULL, NULL, NULL)))
|
|
|
|
{
|
|
|
|
CloseServiceHandle(service);
|
|
|
|
}
|
2006-09-13 12:56:37 +02:00
|
|
|
else if (GetLastError() != ERROR_SERVICE_EXISTS)
|
2006-08-23 03:56:00 +02:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to create MSI service\n");
|
2006-09-13 12:56:37 +02:00
|
|
|
ret = 1;
|
2006-08-23 03:56:00 +02:00
|
|
|
}
|
2006-09-13 12:56:37 +02:00
|
|
|
CloseServiceHandle(scm);
|
|
|
|
return ret;
|
2006-08-23 03:56:00 +02:00
|
|
|
}
|
|
|
|
|
2013-02-12 14:32:45 +01:00
|
|
|
static DWORD DoUnregServer(void)
|
|
|
|
{
|
|
|
|
SC_HANDLE scm, service;
|
|
|
|
DWORD ret = 0;
|
|
|
|
|
|
|
|
if (!(scm = OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASEW, SC_MANAGER_CONNECT)))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to open service control manager\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2020-10-07 23:34:30 +02:00
|
|
|
if ((service = OpenServiceW(scm, L"MSIServer", DELETE)))
|
2013-02-12 14:32:45 +01:00
|
|
|
{
|
|
|
|
if (!DeleteService(service))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to delete MSI service\n");
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
CloseServiceHandle(service);
|
|
|
|
}
|
|
|
|
else if (GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to open MSI service\n");
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
CloseServiceHandle(scm);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-03-23 03:17:17 +01:00
|
|
|
extern UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid);
|
|
|
|
|
|
|
|
static DWORD client_pid;
|
2018-04-26 03:54:40 +02:00
|
|
|
|
2018-07-10 12:08:45 +02:00
|
|
|
static DWORD CALLBACK custom_action_thread(void *arg)
|
|
|
|
{
|
2018-08-16 17:34:40 +02:00
|
|
|
GUID guid = *(GUID *)arg;
|
|
|
|
heap_free(arg);
|
2019-03-23 03:17:17 +01:00
|
|
|
return __wine_msi_call_dll_function(client_pid, &guid);
|
2018-07-10 12:08:45 +02:00
|
|
|
}
|
|
|
|
|
2018-07-10 12:08:47 +02:00
|
|
|
static int custom_action_server(const WCHAR *arg)
|
2007-02-08 02:56:27 +01:00
|
|
|
{
|
2018-08-16 17:34:40 +02:00
|
|
|
GUID guid, *thread_guid;
|
2018-07-10 12:08:47 +02:00
|
|
|
DWORD64 thread64;
|
|
|
|
WCHAR buffer[24];
|
2018-07-10 12:08:45 +02:00
|
|
|
HANDLE thread;
|
2018-07-10 12:08:47 +02:00
|
|
|
HANDLE pipe;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(arg));
|
|
|
|
|
2019-04-29 12:10:09 +02:00
|
|
|
if (!(client_pid = wcstol(arg, NULL, 10)))
|
2018-07-10 12:08:47 +02:00
|
|
|
{
|
|
|
|
ERR("Invalid parameter %s\n", debugstr_w(arg));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-10-07 23:34:30 +02:00
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"\\\\.\\pipe\\msica_%x_%d", client_pid, sizeof(void *) * 8);
|
2018-07-10 12:08:47 +02:00
|
|
|
pipe = CreateFileW(buffer, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
|
|
|
|
if (pipe == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
ERR("Failed to create custom action server pipe: %u\n", GetLastError());
|
|
|
|
return GetLastError();
|
|
|
|
}
|
2018-07-10 12:08:45 +02:00
|
|
|
|
|
|
|
/* We need this to unmarshal streams, and some apps expect it to be present. */
|
|
|
|
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
|
|
|
|
2018-07-10 12:08:47 +02:00
|
|
|
while (ReadFile(pipe, &guid, sizeof(guid), &size, NULL) && size == sizeof(guid))
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(&guid, &GUID_NULL))
|
|
|
|
{
|
|
|
|
/* package closed; time to shut down */
|
|
|
|
CoUninitialize();
|
|
|
|
return 0;
|
|
|
|
}
|
2018-07-10 12:08:45 +02:00
|
|
|
|
2018-08-16 17:34:40 +02:00
|
|
|
thread_guid = heap_alloc(sizeof(GUID));
|
|
|
|
memcpy(thread_guid, &guid, sizeof(GUID));
|
|
|
|
thread = CreateThread(NULL, 0, custom_action_thread, thread_guid, 0, NULL);
|
2018-07-10 12:08:45 +02:00
|
|
|
|
2018-07-10 12:08:47 +02:00
|
|
|
/* give the thread handle to the client to wait on, since we might have
|
|
|
|
* to run a nested action and can't block during this one */
|
|
|
|
thread64 = (DWORD_PTR)thread;
|
|
|
|
if (!WriteFile(pipe, &thread64, sizeof(thread64), &size, NULL) || size != sizeof(thread64))
|
|
|
|
{
|
|
|
|
ERR("Failed to write to custom action server pipe: %u\n", GetLastError());
|
|
|
|
CoUninitialize();
|
|
|
|
return GetLastError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ERR("Failed to read from custom action server pipe: %u\n", GetLastError());
|
|
|
|
CoUninitialize();
|
|
|
|
return GetLastError();
|
2007-02-08 02:56:27 +01:00
|
|
|
}
|
|
|
|
|
2007-03-22 14:20:16 +01:00
|
|
|
/*
|
|
|
|
* state machine to break up the command line properly
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum chomp_state
|
|
|
|
{
|
2017-06-06 09:20:16 +02:00
|
|
|
CS_WHITESPACE,
|
|
|
|
CS_TOKEN,
|
|
|
|
CS_QUOTE
|
2007-03-22 14:20:16 +01:00
|
|
|
};
|
|
|
|
|
2017-06-06 09:20:16 +02:00
|
|
|
static int chomp( const WCHAR *in, WCHAR *out )
|
2007-03-22 14:20:16 +01:00
|
|
|
{
|
2017-06-06 09:20:16 +02:00
|
|
|
enum chomp_state state = CS_TOKEN;
|
|
|
|
const WCHAR *p;
|
|
|
|
int count = 1;
|
|
|
|
BOOL ignore;
|
2007-03-22 14:20:16 +01:00
|
|
|
|
2017-06-06 09:20:16 +02:00
|
|
|
for (p = in; *p; p++)
|
|
|
|
{
|
|
|
|
ignore = TRUE;
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case CS_WHITESPACE:
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case ' ':
|
|
|
|
break;
|
|
|
|
case '"':
|
|
|
|
state = CS_QUOTE;
|
|
|
|
count++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
count++;
|
|
|
|
ignore = FALSE;
|
|
|
|
state = CS_TOKEN;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CS_TOKEN:
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '"':
|
|
|
|
state = CS_QUOTE;
|
|
|
|
break;
|
|
|
|
case ' ':
|
|
|
|
state = CS_WHITESPACE;
|
|
|
|
if (out) *out++ = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (p > in && p[-1] == '"')
|
|
|
|
{
|
|
|
|
if (out) *out++ = 0;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
ignore = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CS_QUOTE:
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '"':
|
|
|
|
state = CS_TOKEN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ignore = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!ignore && out) *out++ = *p;
|
|
|
|
}
|
|
|
|
if (out) *out = 0;
|
|
|
|
return count;
|
2007-03-22 14:20:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void process_args( WCHAR *cmdline, int *pargc, WCHAR ***pargv )
|
|
|
|
{
|
2017-06-06 09:20:16 +02:00
|
|
|
WCHAR **argv, *p;
|
|
|
|
int i, count;
|
2007-03-22 14:20:16 +01:00
|
|
|
|
2017-06-06 09:20:16 +02:00
|
|
|
*pargc = 0;
|
|
|
|
*pargv = NULL;
|
|
|
|
|
|
|
|
count = chomp( cmdline, NULL );
|
|
|
|
if (!(p = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(cmdline) + count + 1) * sizeof(WCHAR) )))
|
|
|
|
return;
|
|
|
|
|
|
|
|
count = chomp( cmdline, p );
|
|
|
|
if (!(argv = HeapAlloc( GetProcessHeap(), 0, (count + 1) * sizeof(WCHAR *) )))
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, p );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
argv[i] = p;
|
|
|
|
p += lstrlenW( p ) + 1;
|
|
|
|
}
|
|
|
|
argv[i] = NULL;
|
2007-03-22 14:20:16 +01:00
|
|
|
|
2017-06-06 09:20:16 +02:00
|
|
|
*pargc = count;
|
|
|
|
*pargv = argv;
|
2007-03-22 14:20:16 +01:00
|
|
|
}
|
|
|
|
|
2011-11-03 11:39:44 +01:00
|
|
|
static BOOL process_args_from_reg( const WCHAR *ident, int *pargc, WCHAR ***pargv )
|
2005-02-10 19:57:56 +01:00
|
|
|
{
|
|
|
|
LONG r;
|
2011-11-03 11:39:44 +01:00
|
|
|
HKEY hkey;
|
2005-02-10 19:57:56 +01:00
|
|
|
DWORD sz = 0, type = 0;
|
2011-11-03 11:39:44 +01:00
|
|
|
WCHAR *buf;
|
2005-02-10 19:57:56 +01:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
2020-10-07 23:34:30 +02:00
|
|
|
r = RegOpenKeyW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\RunOnceEntries", &hkey);
|
2005-02-10 19:57:56 +01:00
|
|
|
if(r != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
r = RegQueryValueExW(hkey, ident, 0, &type, 0, &sz);
|
|
|
|
if(r == ERROR_SUCCESS && type == REG_SZ)
|
|
|
|
{
|
2011-11-03 11:39:44 +01:00
|
|
|
int len = lstrlenW( *pargv[0] );
|
|
|
|
if (!(buf = HeapAlloc( GetProcessHeap(), 0, sz + (len + 1) * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
memcpy( buf, *pargv[0], len * sizeof(WCHAR) );
|
|
|
|
buf[len++] = ' ';
|
|
|
|
r = RegQueryValueExW(hkey, ident, 0, &type, (LPBYTE)(buf + len), &sz);
|
2005-02-10 19:57:56 +01:00
|
|
|
if( r == ERROR_SUCCESS )
|
|
|
|
{
|
2007-03-22 14:20:16 +01:00
|
|
|
process_args(buf, pargc, pargv);
|
2005-02-10 19:57:56 +01:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
2007-10-15 21:29:19 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2005-02-10 19:57:56 +01:00
|
|
|
}
|
2011-11-03 11:39:44 +01:00
|
|
|
RegCloseKey(hkey);
|
2005-02-10 19:57:56 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-11-05 17:53:40 +01:00
|
|
|
static WCHAR *get_path_with_extension(const WCHAR *package_name)
|
|
|
|
{
|
|
|
|
static const WCHAR ext[] = L".msi";
|
|
|
|
unsigned int p;
|
|
|
|
WCHAR *path;
|
|
|
|
|
|
|
|
if (!(path = heap_alloc(lstrlenW(package_name) * sizeof(WCHAR) + sizeof(ext))))
|
|
|
|
{
|
|
|
|
WINE_ERR("No memory.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
lstrcpyW(path, package_name);
|
|
|
|
p = lstrlenW(path);
|
|
|
|
while (p && path[p] != '.' && path[p] != L'\\' && path[p] != '/')
|
|
|
|
--p;
|
|
|
|
if (path[p] == '.')
|
|
|
|
{
|
|
|
|
heap_free(path);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
lstrcatW(path, ext);
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2008-11-12 17:16:24 +01:00
|
|
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
BOOL FunctionInstall = FALSE;
|
2004-07-29 04:39:20 +02:00
|
|
|
BOOL FunctionInstallAdmin = FALSE;
|
2004-07-19 23:19:45 +02:00
|
|
|
BOOL FunctionRepair = FALSE;
|
2004-07-24 01:00:30 +02:00
|
|
|
BOOL FunctionAdvertise = FALSE;
|
2004-07-29 04:39:20 +02:00
|
|
|
BOOL FunctionPatch = FALSE;
|
2004-07-19 21:44:07 +02:00
|
|
|
BOOL FunctionDllRegisterServer = FALSE;
|
|
|
|
BOOL FunctionDllUnregisterServer = FALSE;
|
2004-09-20 23:49:42 +02:00
|
|
|
BOOL FunctionRegServer = FALSE;
|
|
|
|
BOOL FunctionUnregServer = FALSE;
|
2007-07-30 20:53:16 +02:00
|
|
|
BOOL FunctionServer = FALSE;
|
2004-11-22 19:27:39 +01:00
|
|
|
BOOL FunctionUnknown = FALSE;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
2005-02-10 19:57:56 +01:00
|
|
|
LPWSTR PackageName = NULL;
|
2005-02-10 18:12:59 +01:00
|
|
|
LPWSTR Properties = NULL;
|
2005-02-09 15:05:40 +01:00
|
|
|
struct string_list *property_list = NULL;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
2004-07-19 23:19:45 +02:00
|
|
|
DWORD RepairMode = 0;
|
|
|
|
|
2006-05-30 03:47:27 +02:00
|
|
|
DWORD_PTR AdvertiseMode = 0;
|
2005-02-09 15:05:40 +01:00
|
|
|
struct string_list *transform_list = NULL;
|
2004-07-24 01:00:30 +02:00
|
|
|
LANGID Language = 0;
|
|
|
|
|
2004-07-24 01:28:45 +02:00
|
|
|
DWORD LogMode = 0;
|
2005-02-10 18:12:59 +01:00
|
|
|
LPWSTR LogFileName = NULL;
|
2004-07-24 01:28:45 +02:00
|
|
|
DWORD LogAttributes = 0;
|
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
LPWSTR PatchFileName = NULL;
|
2004-07-29 04:39:20 +02:00
|
|
|
INSTALLTYPE InstallType = INSTALLTYPE_DEFAULT;
|
|
|
|
|
2005-02-10 21:26:30 +01:00
|
|
|
INSTALLUILEVEL InstallUILevel = INSTALLUILEVEL_FULL;
|
2004-07-24 01:24:29 +02:00
|
|
|
|
2005-02-10 18:12:59 +01:00
|
|
|
LPWSTR DllName = NULL;
|
2005-02-09 15:05:40 +01:00
|
|
|
DWORD ReturnCode;
|
2008-11-12 17:16:24 +01:00
|
|
|
int argc;
|
2005-02-10 18:12:59 +01:00
|
|
|
LPWSTR *argvW = NULL;
|
2021-11-05 17:53:40 +01:00
|
|
|
WCHAR *path;
|
2004-07-19 21:44:07 +02:00
|
|
|
|
2021-06-09 15:57:51 +02:00
|
|
|
InitCommonControls();
|
|
|
|
|
2008-11-12 17:16:24 +01:00
|
|
|
/* parse the command line */
|
2007-03-22 14:20:16 +01:00
|
|
|
process_args( GetCommandLineW(), &argc, &argvW );
|
2005-02-09 14:58:31 +01:00
|
|
|
|
2005-02-10 19:57:56 +01:00
|
|
|
/*
|
|
|
|
* If the args begin with /@ IDENT then we need to load the real
|
|
|
|
* command line out of the RunOnceEntries key in the registry.
|
|
|
|
* We do that before starting to process the real commandline,
|
|
|
|
* then overwrite the commandline again.
|
|
|
|
*/
|
2006-07-27 16:39:49 +02:00
|
|
|
if(argc>1 && msi_option_equal(argvW[1], "@"))
|
2005-02-10 19:57:56 +01:00
|
|
|
{
|
|
|
|
if(!process_args_from_reg( argvW[2], &argc, &argvW ))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-02-08 02:56:27 +01:00
|
|
|
if (argc == 3 && msi_option_equal(argvW[1], "Embedding"))
|
2018-07-10 12:08:47 +02:00
|
|
|
return custom_action_server(argvW[2]);
|
2007-02-08 02:56:27 +01:00
|
|
|
|
2004-07-19 21:44:07 +02:00
|
|
|
for(i = 1; i < argc; i++)
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
2004-07-19 21:44:07 +02:00
|
|
|
|
2006-07-14 12:38:20 +02:00
|
|
|
if (msi_option_equal(argvW[i], "regserver"))
|
2005-02-09 14:58:31 +01:00
|
|
|
{
|
|
|
|
FunctionRegServer = TRUE;
|
|
|
|
}
|
2011-02-13 06:05:20 +01:00
|
|
|
else if (msi_option_equal(argvW[i], "unregserver") || msi_option_equal(argvW[i], "unregister")
|
|
|
|
|| msi_option_equal(argvW[i], "unreg"))
|
2005-02-09 14:58:31 +01:00
|
|
|
{
|
|
|
|
FunctionUnregServer = TRUE;
|
|
|
|
}
|
2010-01-03 11:06:36 +01:00
|
|
|
else if(msi_option_prefix(argvW[i], "i") || msi_option_prefix(argvW[i], "package"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
LPWSTR argvWi = argvW[i];
|
2010-01-03 11:06:36 +01:00
|
|
|
int argLen = (msi_option_prefix(argvW[i], "i") ? 2 : 8);
|
2004-07-19 21:44:07 +02:00
|
|
|
FunctionInstall = TRUE;
|
2010-01-03 11:06:36 +01:00
|
|
|
if(lstrlenW(argvW[i]) > argLen)
|
|
|
|
argvWi += argLen;
|
2005-02-09 14:58:31 +01:00
|
|
|
else
|
|
|
|
{
|
2004-08-30 20:39:44 +02:00
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
argvWi = argvW[i];
|
2004-08-30 20:39:44 +02:00
|
|
|
}
|
2005-02-10 19:57:56 +01:00
|
|
|
PackageName = argvWi;
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_equal(argvW[i], "a"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
FunctionInstall = TRUE;
|
2004-07-29 04:39:20 +02:00
|
|
|
FunctionInstallAdmin = TRUE;
|
|
|
|
InstallType = INSTALLTYPE_NETWORK_IMAGE;
|
2004-07-19 21:44:07 +02:00
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
PackageName = argvW[i];
|
2020-10-07 23:34:30 +02:00
|
|
|
StringListAppend(&property_list, L"ACTION=ADMIN");
|
2013-09-10 22:46:57 +02:00
|
|
|
WINE_FIXME("Administrative installs are not currently supported\n");
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_prefix(argvW[i], "f"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
2004-07-19 23:19:45 +02:00
|
|
|
int j;
|
2005-02-10 18:12:59 +01:00
|
|
|
int len = lstrlenW(argvW[i]);
|
2004-07-19 23:19:45 +02:00
|
|
|
FunctionRepair = TRUE;
|
|
|
|
for(j = 2; j < len; j++)
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
switch(argvW[i][j])
|
2004-07-19 23:19:45 +02:00
|
|
|
{
|
|
|
|
case 'P':
|
|
|
|
case 'p':
|
|
|
|
RepairMode |= REINSTALLMODE_FILEMISSING;
|
|
|
|
break;
|
|
|
|
case 'O':
|
|
|
|
case 'o':
|
|
|
|
RepairMode |= REINSTALLMODE_FILEOLDERVERSION;
|
|
|
|
break;
|
|
|
|
case 'E':
|
|
|
|
case 'e':
|
|
|
|
RepairMode |= REINSTALLMODE_FILEEQUALVERSION;
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
case 'd':
|
|
|
|
RepairMode |= REINSTALLMODE_FILEEXACT;
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
case 'c':
|
|
|
|
RepairMode |= REINSTALLMODE_FILEVERIFY;
|
|
|
|
break;
|
|
|
|
case 'A':
|
|
|
|
case 'a':
|
|
|
|
RepairMode |= REINSTALLMODE_FILEREPLACE;
|
|
|
|
break;
|
|
|
|
case 'U':
|
|
|
|
case 'u':
|
|
|
|
RepairMode |= REINSTALLMODE_USERDATA;
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
case 'm':
|
|
|
|
RepairMode |= REINSTALLMODE_MACHINEDATA;
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
case 's':
|
|
|
|
RepairMode |= REINSTALLMODE_SHORTCUT;
|
|
|
|
break;
|
|
|
|
case 'V':
|
|
|
|
case 'v':
|
|
|
|
RepairMode |= REINSTALLMODE_PACKAGE;
|
|
|
|
break;
|
|
|
|
default:
|
2005-02-10 18:12:59 +01:00
|
|
|
fprintf(stderr, "Unknown option \"%c\" in Repair mode\n", argvW[i][j]);
|
2004-07-19 23:19:45 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-07-24 01:19:17 +02:00
|
|
|
if(len == 2)
|
|
|
|
{
|
|
|
|
RepairMode = REINSTALLMODE_FILEMISSING |
|
|
|
|
REINSTALLMODE_FILEEQUALVERSION |
|
|
|
|
REINSTALLMODE_FILEVERIFY |
|
|
|
|
REINSTALLMODE_MACHINEDATA |
|
|
|
|
REINSTALLMODE_SHORTCUT;
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
2005-02-10 19:57:56 +01:00
|
|
|
PackageName = argvW[i];
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2010-04-21 10:44:10 +02:00
|
|
|
else if(msi_option_prefix(argvW[i], "x") || msi_option_equal(argvW[i], "uninstall"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
FunctionInstall = TRUE;
|
2010-04-21 10:44:10 +02:00
|
|
|
if(msi_option_prefix(argvW[i], "x")) PackageName = argvW[i]+2;
|
|
|
|
if(!PackageName || !PackageName[0])
|
2006-09-22 04:16:52 +02:00
|
|
|
{
|
|
|
|
i++;
|
|
|
|
if (i >= argc)
|
|
|
|
ShowUsage(1);
|
|
|
|
PackageName = argvW[i];
|
|
|
|
}
|
|
|
|
WINE_TRACE("PackageName = %s\n", wine_dbgstr_w(PackageName));
|
2020-10-07 23:34:30 +02:00
|
|
|
StringListAppend(&property_list, L"REMOVE=ALL");
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_prefix(argvW[i], "j"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
2004-07-24 01:00:30 +02:00
|
|
|
int j;
|
2005-02-10 18:12:59 +01:00
|
|
|
int len = lstrlenW(argvW[i]);
|
2004-07-24 01:00:30 +02:00
|
|
|
FunctionAdvertise = TRUE;
|
|
|
|
for(j = 2; j < len; j++)
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
switch(argvW[i][j])
|
2004-07-24 01:00:30 +02:00
|
|
|
{
|
|
|
|
case 'U':
|
|
|
|
case 'u':
|
|
|
|
AdvertiseMode = ADVERTISEFLAGS_USERASSIGN;
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
case 'm':
|
|
|
|
AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
|
|
|
|
break;
|
|
|
|
default:
|
2005-02-10 18:12:59 +01:00
|
|
|
fprintf(stderr, "Unknown option \"%c\" in Advertise mode\n", argvW[i][j]);
|
2004-07-24 01:00:30 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
PackageName = argvW[i];
|
2004-07-24 01:00:30 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_strequal(argvW[i], "u"))
|
2004-07-24 01:00:30 +02:00
|
|
|
{
|
|
|
|
FunctionAdvertise = TRUE;
|
|
|
|
AdvertiseMode = ADVERTISEFLAGS_USERASSIGN;
|
2004-07-19 21:44:07 +02:00
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
PackageName = argvW[i];
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_strequal(argvW[i], "m"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
2004-07-24 01:00:30 +02:00
|
|
|
FunctionAdvertise = TRUE;
|
|
|
|
AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
|
2004-07-19 21:44:07 +02:00
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
PackageName = argvW[i];
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_equal(argvW[i], "t"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
StringListAppend(&transform_list, argvW[i]);
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_equal(argvW[i], "g"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
Language = msi_atou(argvW[i]);
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_prefix(argvW[i], "l"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
2004-07-24 01:28:45 +02:00
|
|
|
int j;
|
2005-02-10 18:12:59 +01:00
|
|
|
int len = lstrlenW(argvW[i]);
|
2004-07-24 01:28:45 +02:00
|
|
|
for(j = 2; j < len; j++)
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
switch(argvW[i][j])
|
2004-07-24 01:28:45 +02:00
|
|
|
{
|
|
|
|
case 'I':
|
|
|
|
case 'i':
|
|
|
|
LogMode |= INSTALLLOGMODE_INFO;
|
|
|
|
break;
|
|
|
|
case 'W':
|
|
|
|
case 'w':
|
|
|
|
LogMode |= INSTALLLOGMODE_WARNING;
|
|
|
|
break;
|
|
|
|
case 'E':
|
|
|
|
case 'e':
|
|
|
|
LogMode |= INSTALLLOGMODE_ERROR;
|
|
|
|
break;
|
|
|
|
case 'A':
|
|
|
|
case 'a':
|
|
|
|
LogMode |= INSTALLLOGMODE_ACTIONSTART;
|
|
|
|
break;
|
|
|
|
case 'R':
|
|
|
|
case 'r':
|
|
|
|
LogMode |= INSTALLLOGMODE_ACTIONDATA;
|
|
|
|
break;
|
|
|
|
case 'U':
|
|
|
|
case 'u':
|
|
|
|
LogMode |= INSTALLLOGMODE_USER;
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
case 'c':
|
|
|
|
LogMode |= INSTALLLOGMODE_COMMONDATA;
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
case 'm':
|
|
|
|
LogMode |= INSTALLLOGMODE_FATALEXIT;
|
|
|
|
break;
|
|
|
|
case 'O':
|
|
|
|
case 'o':
|
|
|
|
LogMode |= INSTALLLOGMODE_OUTOFDISKSPACE;
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
case 'p':
|
|
|
|
LogMode |= INSTALLLOGMODE_PROPERTYDUMP;
|
|
|
|
break;
|
|
|
|
case 'V':
|
|
|
|
case 'v':
|
|
|
|
LogMode |= INSTALLLOGMODE_VERBOSE;
|
|
|
|
break;
|
|
|
|
case '*':
|
|
|
|
LogMode = INSTALLLOGMODE_FATALEXIT |
|
|
|
|
INSTALLLOGMODE_ERROR |
|
|
|
|
INSTALLLOGMODE_WARNING |
|
|
|
|
INSTALLLOGMODE_USER |
|
|
|
|
INSTALLLOGMODE_INFO |
|
|
|
|
INSTALLLOGMODE_RESOLVESOURCE |
|
|
|
|
INSTALLLOGMODE_OUTOFDISKSPACE |
|
|
|
|
INSTALLLOGMODE_ACTIONSTART |
|
|
|
|
INSTALLLOGMODE_ACTIONDATA |
|
|
|
|
INSTALLLOGMODE_COMMONDATA |
|
|
|
|
INSTALLLOGMODE_PROPERTYDUMP |
|
|
|
|
INSTALLLOGMODE_PROGRESS |
|
|
|
|
INSTALLLOGMODE_INITIALIZE |
|
|
|
|
INSTALLLOGMODE_TERMINATE |
|
|
|
|
INSTALLLOGMODE_SHOWDIALOG;
|
|
|
|
break;
|
|
|
|
case '+':
|
|
|
|
LogAttributes |= INSTALLLOGATTRIBUTES_APPEND;
|
|
|
|
break;
|
|
|
|
case '!':
|
|
|
|
LogAttributes |= INSTALLLOGATTRIBUTES_FLUSHEACHLINE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
LogFileName = argvW[i];
|
|
|
|
if(MsiEnableLogW(LogMode, LogFileName, LogAttributes) != ERROR_SUCCESS)
|
2004-07-24 01:28:45 +02:00
|
|
|
{
|
2006-09-29 01:19:00 +02:00
|
|
|
fprintf(stderr, "Logging in %s (0x%08x, %u) failed\n",
|
2005-02-10 18:12:59 +01:00
|
|
|
wine_dbgstr_w(LogFileName), LogMode, LogAttributes);
|
2004-07-24 01:28:45 +02:00
|
|
|
ExitProcess(1);
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2014-11-27 12:15:46 +01:00
|
|
|
else if(msi_option_equal(argvW[i], "p") || msi_option_equal(argvW[i], "update"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
2004-07-29 04:39:20 +02:00
|
|
|
FunctionPatch = TRUE;
|
2004-07-19 21:44:07 +02:00
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
PatchFileName = argvW[i];
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_prefix(argvW[i], "q"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
2007-05-09 07:52:40 +02:00
|
|
|
if(lstrlenW(argvW[i]) == 2 || msi_strequal(argvW[i]+2, "n") ||
|
|
|
|
msi_strequal(argvW[i] + 2, "uiet"))
|
2004-07-24 01:24:29 +02:00
|
|
|
{
|
|
|
|
InstallUILevel = INSTALLUILEVEL_NONE;
|
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_strequal(argvW[i]+2, "r"))
|
2004-07-24 01:24:29 +02:00
|
|
|
{
|
|
|
|
InstallUILevel = INSTALLUILEVEL_REDUCED;
|
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_strequal(argvW[i]+2, "f"))
|
2004-07-24 01:24:29 +02:00
|
|
|
{
|
|
|
|
InstallUILevel = INSTALLUILEVEL_FULL|INSTALLUILEVEL_ENDDIALOG;
|
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_strequal(argvW[i]+2, "n+"))
|
2004-07-24 01:24:29 +02:00
|
|
|
{
|
|
|
|
InstallUILevel = INSTALLUILEVEL_NONE|INSTALLUILEVEL_ENDDIALOG;
|
|
|
|
}
|
2015-10-06 00:29:12 +02:00
|
|
|
else if(msi_strprefix(argvW[i]+2, "b"))
|
2012-03-12 12:24:55 +01:00
|
|
|
{
|
2015-10-06 00:29:12 +02:00
|
|
|
const WCHAR *ptr = argvW[i] + 3;
|
|
|
|
|
|
|
|
InstallUILevel = INSTALLUILEVEL_BASIC;
|
|
|
|
|
|
|
|
while (*ptr)
|
|
|
|
{
|
|
|
|
if (msi_strprefix(ptr, "+"))
|
|
|
|
InstallUILevel |= INSTALLUILEVEL_ENDDIALOG;
|
|
|
|
if (msi_strprefix(ptr, "-"))
|
|
|
|
InstallUILevel |= INSTALLUILEVEL_PROGRESSONLY;
|
|
|
|
if (msi_strprefix(ptr, "!"))
|
|
|
|
{
|
|
|
|
WINE_FIXME("Unhandled modifier: !\n");
|
|
|
|
InstallUILevel |= INSTALLUILEVEL_HIDECANCEL;
|
|
|
|
}
|
|
|
|
ptr++;
|
|
|
|
}
|
2012-03-12 12:24:55 +01:00
|
|
|
}
|
2004-07-24 01:24:29 +02:00
|
|
|
else
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
fprintf(stderr, "Unknown option \"%s\" for UI level\n",
|
|
|
|
wine_dbgstr_w(argvW[i]+2));
|
2004-07-24 01:24:29 +02:00
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2015-10-06 00:29:13 +02:00
|
|
|
else if(msi_option_equal(argvW[i], "passive"))
|
|
|
|
{
|
|
|
|
InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_PROGRESSONLY|INSTALLUILEVEL_HIDECANCEL;
|
2020-10-07 23:34:30 +02:00
|
|
|
StringListAppend(&property_list, L"REBOOTPROMPT=\"S\"");
|
2015-10-06 00:29:13 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_equal(argvW[i], "y"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
FunctionDllRegisterServer = TRUE;
|
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
DllName = argvW[i];
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_equal(argvW[i], "z"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
FunctionDllUnregisterServer = TRUE;
|
|
|
|
i++;
|
|
|
|
if(i >= argc)
|
|
|
|
ShowUsage(1);
|
2005-02-10 18:12:59 +01:00
|
|
|
WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
|
|
|
|
DllName = argvW[i];
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2010-05-06 17:24:53 +02:00
|
|
|
else if(msi_option_equal(argvW[i], "help") || msi_option_equal(argvW[i], "?"))
|
2004-07-19 21:44:07 +02:00
|
|
|
{
|
|
|
|
ShowUsage(0);
|
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_equal(argvW[i], "m"))
|
2004-11-22 19:27:39 +01:00
|
|
|
{
|
|
|
|
FunctionUnknown = TRUE;
|
|
|
|
WINE_FIXME("Unknown parameter /m\n");
|
|
|
|
}
|
2006-07-14 12:38:20 +02:00
|
|
|
else if(msi_option_equal(argvW[i], "D"))
|
2004-11-22 19:27:39 +01:00
|
|
|
{
|
|
|
|
FunctionUnknown = TRUE;
|
|
|
|
WINE_FIXME("Unknown parameter /D\n");
|
|
|
|
}
|
2007-07-30 20:53:16 +02:00
|
|
|
else if (msi_option_equal(argvW[i], "V"))
|
|
|
|
{
|
|
|
|
FunctionServer = TRUE;
|
|
|
|
}
|
2004-07-30 01:56:19 +02:00
|
|
|
else
|
2006-04-25 17:57:55 +02:00
|
|
|
StringListAppend(&property_list, argvW[i]);
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
|
|
|
|
2005-02-10 21:26:30 +01:00
|
|
|
/* start the GUI */
|
|
|
|
MsiSetInternalUI(InstallUILevel, NULL);
|
|
|
|
|
2005-02-09 15:05:40 +01:00
|
|
|
Properties = build_properties( property_list );
|
2004-07-19 22:05:54 +02:00
|
|
|
|
2004-07-29 04:39:20 +02:00
|
|
|
if(FunctionInstallAdmin && FunctionPatch)
|
|
|
|
FunctionInstall = FALSE;
|
|
|
|
|
2005-02-09 15:05:40 +01:00
|
|
|
ReturnCode = 1;
|
2004-07-19 22:05:54 +02:00
|
|
|
if(FunctionInstall)
|
|
|
|
{
|
2005-02-10 19:57:56 +01:00
|
|
|
if(IsProductCode(PackageName))
|
|
|
|
ReturnCode = MsiConfigureProductExW(PackageName, 0, INSTALLSTATE_DEFAULT, Properties);
|
2004-07-19 21:44:07 +02:00
|
|
|
else
|
2021-11-05 17:53:40 +01:00
|
|
|
{
|
|
|
|
if ((ReturnCode = MsiInstallProductW(PackageName, Properties)) == ERROR_FILE_NOT_FOUND
|
|
|
|
&& (path = get_path_with_extension(PackageName)))
|
|
|
|
{
|
|
|
|
ReturnCode = MsiInstallProductW(path, Properties);
|
|
|
|
heap_free(path);
|
|
|
|
}
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2004-07-19 23:19:45 +02:00
|
|
|
else if(FunctionRepair)
|
|
|
|
{
|
2005-02-10 19:57:56 +01:00
|
|
|
if(IsProductCode(PackageName))
|
2004-07-19 23:19:45 +02:00
|
|
|
WINE_FIXME("Product code treatment not implemented yet\n");
|
|
|
|
else
|
2021-11-05 17:53:40 +01:00
|
|
|
{
|
|
|
|
if ((ReturnCode = MsiReinstallProductW(PackageName, RepairMode)) == ERROR_FILE_NOT_FOUND
|
|
|
|
&& (path = get_path_with_extension(PackageName)))
|
|
|
|
{
|
|
|
|
ReturnCode = MsiReinstallProductW(path, RepairMode);
|
|
|
|
heap_free(path);
|
|
|
|
}
|
|
|
|
}
|
2004-07-19 23:19:45 +02:00
|
|
|
}
|
2004-07-24 01:00:30 +02:00
|
|
|
else if(FunctionAdvertise)
|
|
|
|
{
|
2006-01-04 14:51:42 +01:00
|
|
|
LPWSTR Transforms = build_transforms( property_list );
|
2005-02-10 18:12:59 +01:00
|
|
|
ReturnCode = MsiAdvertiseProductW(PackageName, (LPWSTR) AdvertiseMode, Transforms, Language);
|
2004-07-24 01:00:30 +02:00
|
|
|
}
|
2004-07-29 04:39:20 +02:00
|
|
|
else if(FunctionPatch)
|
|
|
|
{
|
2005-02-10 18:12:59 +01:00
|
|
|
ReturnCode = MsiApplyPatchW(PatchFileName, PackageName, InstallType, Properties);
|
2004-07-29 04:39:20 +02:00
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
else if(FunctionDllRegisterServer)
|
|
|
|
{
|
2005-05-17 16:33:36 +02:00
|
|
|
ReturnCode = DoDllRegisterServer(DllName);
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
|
|
|
else if(FunctionDllUnregisterServer)
|
|
|
|
{
|
2005-05-17 16:33:36 +02:00
|
|
|
ReturnCode = DoDllUnregisterServer(DllName);
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|
2004-09-20 23:49:42 +02:00
|
|
|
else if (FunctionRegServer)
|
|
|
|
{
|
2006-08-23 03:56:00 +02:00
|
|
|
ReturnCode = DoRegServer();
|
2004-09-20 23:49:42 +02:00
|
|
|
}
|
|
|
|
else if (FunctionUnregServer)
|
|
|
|
{
|
2013-02-12 14:32:45 +01:00
|
|
|
ReturnCode = DoUnregServer();
|
2004-09-20 23:49:42 +02:00
|
|
|
}
|
2007-07-30 20:53:16 +02:00
|
|
|
else if (FunctionServer)
|
|
|
|
{
|
|
|
|
ReturnCode = DoService();
|
|
|
|
}
|
2004-11-22 19:27:39 +01:00
|
|
|
else if (FunctionUnknown)
|
|
|
|
{
|
|
|
|
WINE_FIXME( "Unknown function, ignoring\n" );
|
|
|
|
}
|
2004-07-19 21:44:07 +02:00
|
|
|
else
|
|
|
|
ShowUsage(1);
|
|
|
|
|
2005-02-09 15:05:40 +01:00
|
|
|
return ReturnCode;
|
2004-07-19 21:44:07 +02:00
|
|
|
}
|