CVS: winex/programs/msiexec .cvsignore, NONE, 1.1 Makefile.in, NONE, 1.1 msiexec.c, NONE, 1.1 msiexec.spec, NONE, 1.1 msiexec.spec.c, NONE, 1.1 rsrc.rc, NONE, 1.1 version.rc, NONE, 1.1

[email protected] 14 Dec 2007 20:41:18 -0000
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/programs/msiexec .cvsignore,NONE,1.1 Makefile.in,NONE,1.1 msiexec.c,NONE,1.1 msiexec.spec,NONE,1.1 msiexec.spec.c,NONE,1.1 rsrc.rc,NONE,1.1 version.rc,NONE,1.1Update of /var/lib/cvsd/cvsroot/winex/programs/msiexec
In directory agravaine:/tmp/cvs-serv18045/programs/msiexec

Added Files:
	.cvsignore Makefile.in msiexec.c msiexec.spec msiexec.spec.c 
	rsrc.rc version.rc 
Log Message:
Imported MSIexec from Wine.


--- NEW FILE: .cvsignore ---
Makefile
msiexec
rsrc.res
msiexec.spec.c
*.d

--- NEW FILE: Makefile.in ---
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR    = @srcdir@
VPATH     = @srcdir@
MODULE    = msiexec

C_SRCS = \
	msiexec.c

RC_SRCS = rsrc.rc

@MAKE_PROG_RULES@

### Dependencies:

--- NEW FILE: msiexec.c ---
/*
 * msiexec.exe implementation
 *
 * Copyright 2004 Vincent Béron
 * Copyright 2005 Mike McCormack
 *
 * 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
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <wine-lgpl/msi.h>
#include <objbase.h>
#include <stdio.h>

#include "wine/debug.h"
#include "wine/unicode.h"

WINE_DEFAULT_DEBUG_CHANNEL(msiexec);

typedef HRESULT (WINAPI *DLLREGISTERSERVER)(void);
typedef HRESULT (WINAPI *DLLUNREGISTERSERVER)(void);

struct string_list
{
	struct string_list *next;
	WCHAR str[1];
};

static const char UsageStr[] =
"Usage:\n"
"  Install a product:\n"
"    msiexec {package|productcode} [property]\n"
"    msiexec /i {package|productcode} [property]\n"
"    msiexec /a package [property]\n"
"  Repair an installation:\n"
"    msiexec /f[p|o|e|d|c|a|u|m|s|v] {package|productcode}\n"
"  Uninstall a product:\n"
"    msiexec /x {package|productcode} [property]\n"
"  Advertise a product:\n"
"    msiexec /j[u|m] package [/t transform] [/g languageid]\n"
"    msiexec {u|m} package [/t transform] [/g languageid]\n"
"  Apply a patch:\n"
"    msiexec /p patchpackage [property]\n"
"    msiexec /p patchpackage /a package [property]\n"
"  Modifiers for above operations:\n"
"    msiexec /l[*][i|w|e|a|r|u|c|m|o|p|v|][+|!] logfile\n"
"    msiexec /q{|n|b|r|f|n+|b+|b-}\n"
"  Register a module:\n"
"    msiexec /y module\n"
"  Unregister a module:\n"
"    msiexec /z module\n"
"  Display usage and copyright:\n"
"    msiexec {/h|/?}\n"
"NOTE: Product code on commandline unimplemented as of yet\n"
"\n"
"Copyright 2004 Vincent Béron\n";

static const WCHAR ActionAdmin[] = {
   'A','C','T','I','O','N','=','A','D','M','I','N',0 };
static const WCHAR RemoveAll[] = {
   'R','E','M','O','V','E','=','A','L','L',0 };

static const WCHAR InstallRunOnce[] = {
   'S','o','f','t','w','a','r','e','\\',
   'M','i','c','r','o','s','o','f','t','\\',
   'W','i','n','d','o','w','s','\\',
   'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
   'I','n','s','t','a','l','l','e','r','\\',
   'R','u','n','O','n','c','e','E','n','t','r','i','e','s',0};

static void ShowUsage(int ExitCode)
{
	printf(UsageStr);
	ExitProcess(ExitCode);
}

static BOOL IsProductCode(LPWSTR str)
{
	GUID ProductCode;

	if(lstrlenW(str) != 38)
		return FALSE;
	return ( (CLSIDFromString(str, &ProductCode) == NOERROR) );

}

static VOID StringListAppend(struct string_list **list, LPCWSTR str)
{
	struct string_list *entry;
	DWORD size;

	size = sizeof *entry + lstrlenW(str) * sizeof (WCHAR);
	entry = HeapAlloc(GetProcessHeap(), 0, size);
	if(!entry)
	{
		WINE_ERR("Out of memory!\n");
		ExitProcess(1);
	}
	lstrcpyW(entry->str, str);
	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;
}

static LPWSTR build_properties(struct string_list *property_list)
{
	struct string_list *list;
	LPWSTR ret, p, value;
	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)
		len += lstrlenW(list->str) + 3;

	ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );

	/* add a space before each string, and quote the value */
	p = ret;
	for(list = property_list; list; list = list->next)
	{
		value = strchrW(list->str,'=');
		if(!value)
			continue;
		len = value - list->str;
		*p++ = ' ';
		memcpy(p, list->str, len * sizeof(WCHAR));
		p += len;
		*p++ = '=';

		/* check if the value contains spaces and maybe quote it */
		value++;
		needs_quote = strchrW(value,' ') ? 1 : 0;
		if(needs_quote)
			*p++ = '"';
		len = lstrlenW(value);
		memcpy(p, value, len * sizeof(WCHAR));
		p += len;
		if(needs_quote)
			*p++ = '"';
	}
	*p = 0;

	WINE_TRACE("properties -> %s\n", wine_dbgstr_w(ret) );

	return ret;
}

static LPWSTR build_transforms(struct string_list *transform_list)
{
	struct string_list *list;
	LPWSTR ret, p;
	DWORD len;

	/* count the space we need */
	len = 1;
	for(list = transform_list; list; list = list->next)
		len += lstrlenW(list->str) + 1;

	ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );

	/* add all the transforms with a semicolon between each one */
	p = ret;
	for(list = transform_list; list; list = list->next)
	{
		len = lstrlenW(list->str);
		lstrcpynW(p, list->str, len );
		p += len;
		if(list->next)
			*p++ = ';';
	}
	*p = 0;

	return ret;
}

static DWORD msi_atou(LPCWSTR str)
{
	DWORD ret = 0;
	while(*str >= '0' && *str <= '9')
	{
		ret *= 10;
		ret += (*str - '0');
		str++;
	}
	return 0;
}

static LPWSTR msi_strdup(LPCWSTR str)
{
	DWORD len = lstrlenW(str)+1;
	LPWSTR ret = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
	lstrcpyW(ret, str);
	return ret;
}

/* 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 )
		return FALSE;
	if( lstrlenW(str1) != (len-1) )
		return FALSE;
	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);
	return (ret == CSTR_EQUAL);
}

/* 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] != '-')
        return FALSE;

    /* skip over the hyphen or slash */
    return msi_strequal(str1 + 1, str2);
}

/* 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 )
		return FALSE;
	if( lstrlenW(str1) < (len-1) )
		return FALSE;
	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);
	return (ret == CSTR_EQUAL);
}

/* 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] != '-')
        return FALSE;

    /* skip over the hyphen or slash */
    return msi_strprefix(str1 + 1, str2);
}

static VOID *LoadProc(LPCWSTR DllName, LPCSTR ProcName, HMODULE* DllHandle)
{
	VOID* (*proc)(void);

	*DllHandle = LoadLibraryExW(DllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
	if(!*DllHandle)
	{
		fprintf(stderr, "Unable to load dll %s\n", wine_dbgstr_w(DllName));
		ExitProcess(1);
	}
	proc = (VOID *) GetProcAddress(*DllHandle, ProcName);
	if(!proc)
	{
		fprintf(stderr, "Dll %s does not implement function %s\n",
			wine_dbgstr_w(DllName), ProcName);
		FreeLibrary(*DllHandle);
		ExitProcess(1);
	}

	return proc;
}

static DWORD DoDllRegisterServer(LPCWSTR DllName)
{
	HRESULT hr;
	DLLREGISTERSERVER pfDllRegisterServer = NULL;
	HMODULE DllHandle = NULL;

	pfDllRegisterServer = LoadProc(DllName, "DllRegisterServer", &DllHandle);

	hr = pfDllRegisterServer();
	if(FAILED(hr))
	{
		fprintf(stderr, "Failed to register dll %s\n", wine_dbgstr_w(DllName));
		return 1;
	}
	printf("Successfully registered dll %s\n", wine_dbgstr_w(DllName));
	if(DllHandle)
		FreeLibrary(DllHandle);
	return 0;
}

static DWORD DoDllUnregisterServer(LPCWSTR DllName)
{
	HRESULT hr;
	DLLUNREGISTERSERVER pfDllUnregisterServer = NULL;
	HMODULE DllHandle = NULL;

	pfDllUnregisterServer = LoadProc(DllName, "DllUnregisterServer", &DllHandle);

	hr = pfDllUnregisterServer();
	if(FAILED(hr))
	{
		fprintf(stderr, "Failed to unregister dll %s\n", wine_dbgstr_w(DllName));
		return 1;
	}
	printf("Successfully unregistered dll %s\n", wine_dbgstr_w(DllName));
	if(DllHandle)
		FreeLibrary(DllHandle);
	return 0;
}

static DWORD DoRegServer(void)
{
    SC_HANDLE scm, service;
    CHAR path[MAX_PATH+12];
    DWORD ret = 0;

    scm = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_CREATE_SERVICE);
    if (!scm)
    {
        fprintf(stderr, "Failed to open the service control manager.\n");
        return 1;
    }

    GetSystemDirectory(path, MAX_PATH);
    lstrcatA(path, "\\msiexec.exe");

    service = CreateServiceA(scm, "MSIServer", "MSIServer", GENERIC_ALL,
                             SERVICE_WIN32_SHARE_PROCESS, SERVICE_DEMAND_START,
                             SERVICE_ERROR_NORMAL, path, NULL, NULL,
                             NULL, NULL, NULL);

    if (service) CloseServiceHandle(service);
    else if (GetLastError() != ERROR_SERVICE_EXISTS)
    {
        fprintf(stderr, "Failed to create MSI service\n");
        ret = 1;
    }
    CloseServiceHandle(scm);
    return ret;
}

static INT DoEmbedding( LPWSTR key )
{
	printf("Remote custom actions are not supported yet\n");
	return 1;
}

/*
 * state machine to break up the command line properly
 */

enum chomp_state
{
	cs_whitespace,
	cs_token,
	cs_quote
};

static int chomp( WCHAR *str )
{
	enum chomp_state state = cs_whitespace;
	WCHAR *p, *out;
	int count = 0, ignore;

	for( p = str, out = str; *p; p++ )
	{
		ignore = 1;
		switch( state )
		{
		case cs_whitespace:
			switch( *p )
			{
			case ' ':
				break;
			case '"':
				state = cs_quote;
				count++;
				break;
			default:
				count++;
				ignore = 0;
				state = cs_token;
			}
			break;

		case cs_token:
			switch( *p )
			{
			case '"':
				state = cs_quote;
				break;
			case ' ':
				state = cs_whitespace;
				*out++ = 0;
				break;
			default:
				ignore = 0;
			}
			break;

		case cs_quote:
			switch( *p )
			{
			case '"':
				state = cs_token;
				break;
			default:
				ignore = 0;
			}
			break;
		}
		if( !ignore )
			*out++ = *p;
	}

	*out = 0;

	return count;
}

static void process_args( WCHAR *cmdline, int *pargc, WCHAR ***pargv )
{
	WCHAR **argv, *p = msi_strdup(cmdline);
	int i, n;

	n = chomp( p );
	argv = HeapAlloc(GetProcessHeap(), 0, sizeof (WCHAR*)*(n+1));
	for( i=0; i<n; i++ )
	{
		argv[i] = p;
		p += lstrlenW(p) + 1;
	}
	argv[i] = NULL;

	*pargc = n;
	*pargv = argv;
}

static BOOL process_args_from_reg( LPWSTR ident, int *pargc, WCHAR ***pargv )
{
	LONG r;
	HKEY hkey = 0, hkeyArgs = 0;
	DWORD sz = 0, type = 0;
	LPWSTR buf = NULL;
	BOOL ret = FALSE;

	r = RegOpenKeyW(HKEY_LOCAL_MACHINE, InstallRunOnce, &hkey);
	if(r != ERROR_SUCCESS)
		return FALSE;
	r = RegQueryValueExW(hkey, ident, 0, &type, 0, &sz);
	if(r == ERROR_SUCCESS && type == REG_SZ)
	{
		buf = HeapAlloc(GetProcessHeap(), 0, sz);
		r = RegQueryValueExW(hkey, ident, 0, &type, (LPBYTE)buf, &sz);
		if( r == ERROR_SUCCESS )
		{
			process_args(buf, pargc, pargv);
			ret = TRUE;
		}
	}
	RegCloseKey(hkeyArgs);
	return ret;
}

int main(int argc, char **argv)
{
	int i;
	BOOL FunctionInstall = FALSE;
	BOOL FunctionInstallAdmin = FALSE;
	BOOL FunctionRepair = FALSE;
	BOOL FunctionAdvertise = FALSE;
	BOOL FunctionPatch = FALSE;
	BOOL FunctionDllRegisterServer = FALSE;
	BOOL FunctionDllUnregisterServer = FALSE;
	BOOL FunctionRegServer = FALSE;
	BOOL FunctionUnregServer = FALSE;
	BOOL FunctionUnknown = FALSE;

	LPWSTR PackageName = NULL;
	LPWSTR Properties = NULL;
	struct string_list *property_list = NULL;

	DWORD RepairMode = 0;

	DWORD_PTR AdvertiseMode = 0;
	struct string_list *transform_list = NULL;
	LANGID Language = 0;

	DWORD LogMode = 0;
	LPWSTR LogFileName = NULL;
	DWORD LogAttributes = 0;

	LPWSTR PatchFileName = NULL;
	INSTALLTYPE InstallType = INSTALLTYPE_DEFAULT;

	INSTALLUILEVEL InstallUILevel = INSTALLUILEVEL_FULL;

	LPWSTR DllName = NULL;
	DWORD ReturnCode;
	LPWSTR *argvW = NULL;

	/* overwrite the command line */
	process_args( GetCommandLineW(), &argc, &argvW );

	/*
	 * 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.
	 */
	if(argc>1 && msi_option_equal(argvW[1], "@"))
	{
		if(!process_args_from_reg( argvW[2], &argc, &argvW ))
			return 1;
	}

	if (argc == 3 && msi_option_equal(argvW[1], "Embedding"))
		return DoEmbedding( argvW[2] );

	for(i = 1; i < argc; i++)
	{
		WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));

		if (msi_option_equal(argvW[i], "regserver"))
		{
			FunctionRegServer = TRUE;
		}
		else if (msi_option_equal(argvW[i], "unregserver") || msi_option_equal(argvW[i], "unregister"))
		{
			FunctionUnregServer = TRUE;
		}
		else if(msi_option_prefix(argvW[i], "i"))
		{
			LPWSTR argvWi = argvW[i];
			FunctionInstall = TRUE;
			if(lstrlenW(argvWi) > 2)
				argvWi += 2;
			else
			{
				i++;
				if(i >= argc)
					ShowUsage(1);
				WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
				argvWi = argvW[i];
			}
			PackageName = argvWi;
		}
		else if(msi_option_equal(argvW[i], "a"))
		{
			FunctionInstall = TRUE;
			FunctionInstallAdmin = TRUE;
			InstallType = INSTALLTYPE_NETWORK_IMAGE;
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			PackageName = argvW[i];
			StringListAppend(&property_list, ActionAdmin);
		}
		else if(msi_option_prefix(argvW[i], "f"))
		{
			int j;
			int len = lstrlenW(argvW[i]);
			FunctionRepair = TRUE;
			for(j = 2; j < len; j++)
			{
				switch(argvW[i][j])
				{
					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:
						fprintf(stderr, "Unknown option \"%c\" in Repair mode\n", argvW[i][j]);
						break;
				}
			}
			if(len == 2)
			{
				RepairMode = REINSTALLMODE_FILEMISSING |
					REINSTALLMODE_FILEEQUALVERSION |
					REINSTALLMODE_FILEVERIFY |
					REINSTALLMODE_MACHINEDATA |
					REINSTALLMODE_SHORTCUT;
			}
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			PackageName = argvW[i];
		}
		else if(msi_option_prefix(argvW[i], "x"))
		{
			FunctionInstall = TRUE;
			PackageName = argvW[i]+2;
			if (!PackageName[0])
			{
				i++;
				if (i >= argc)
					ShowUsage(1);
				PackageName = argvW[i];
			}
			WINE_TRACE("PackageName = %s\n", wine_dbgstr_w(PackageName));
			StringListAppend(&property_list, RemoveAll);
		}
		else if(msi_option_prefix(argvW[i], "j"))
		{
			int j;
			int len = lstrlenW(argvW[i]);
			FunctionAdvertise = TRUE;
			for(j = 2; j < len; j++)
			{
				switch(argvW[i][j])
				{
					case 'U':
					case 'u':
						AdvertiseMode = ADVERTISEFLAGS_USERASSIGN;
						break;
					case 'M':
					case 'm':
						AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
						break;
					default:
						fprintf(stderr, "Unknown option \"%c\" in Advertise mode\n", argvW[i][j]);
						break;
				}
			}
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			PackageName = argvW[i];
		}
		else if(msi_strequal(argvW[i], "u"))
		{
			FunctionAdvertise = TRUE;
			AdvertiseMode = ADVERTISEFLAGS_USERASSIGN;
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			PackageName = argvW[i];
		}
		else if(msi_strequal(argvW[i], "m"))
		{
			FunctionAdvertise = TRUE;
			AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			PackageName = argvW[i];
		}
		else if(msi_option_equal(argvW[i], "t"))
		{
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			StringListAppend(&transform_list, argvW[i]);
		}
		else if(msi_option_equal(argvW[i], "g"))
		{
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			Language = msi_atou(argvW[i]);
		}
		else if(msi_option_prefix(argvW[i], "l"))
		{
			int j;
			int len = lstrlenW(argvW[i]);
			for(j = 2; j < len; j++)
			{
				switch(argvW[i][j])
				{
					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;
				}
			}
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			LogFileName = argvW[i];
			if(MsiEnableLogW(LogMode, LogFileName, LogAttributes) != ERROR_SUCCESS)
			{
				fprintf(stderr, "Logging in %s (0x%08x, %u) failed\n",
					 wine_dbgstr_w(LogFileName), LogMode, LogAttributes);
				ExitProcess(1);
			}
		}
		else if(msi_option_equal(argvW[i], "p"))
		{
			FunctionPatch = TRUE;
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			PatchFileName = argvW[i];
		}
		else if(msi_option_prefix(argvW[i], "q"))
		{
			if(lstrlenW(argvW[i]) == 2 || msi_strequal(argvW[i]+2, "n") ||
			   msi_strequal(argvW[i] + 2, "uiet"))
			{
				InstallUILevel = INSTALLUILEVEL_NONE;
			}
			else if(msi_strequal(argvW[i]+2, "b"))
			{
				InstallUILevel = INSTALLUILEVEL_BASIC;
			}
			else if(msi_strequal(argvW[i]+2, "r"))
			{
				InstallUILevel = INSTALLUILEVEL_REDUCED;
			}
			else if(msi_strequal(argvW[i]+2, "f"))
			{
				InstallUILevel = INSTALLUILEVEL_FULL|INSTALLUILEVEL_ENDDIALOG;
			}
			else if(msi_strequal(argvW[i]+2, "n+"))
			{
				InstallUILevel = INSTALLUILEVEL_NONE|INSTALLUILEVEL_ENDDIALOG;
			}
			else if(msi_strequal(argvW[i]+2, "b+"))
			{
				InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_ENDDIALOG;
			}
			else if(msi_strequal(argvW[i]+2, "b-"))
			{
				InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_PROGRESSONLY;
			}
			else if(msi_strequal(argvW[i]+2, "b+!"))
			{
				InstallUILevel = INSTALLUILEVEL_BASIC|INSTALLUILEVEL_ENDDIALOG;
				WINE_FIXME("Unknown modifier: !\n");
			}
			else
			{
				fprintf(stderr, "Unknown option \"%s\" for UI level\n",
					 wine_dbgstr_w(argvW[i]+2));
			}
		}
		else if(msi_option_equal(argvW[i], "y"))
		{
			FunctionDllRegisterServer = TRUE;
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			DllName = argvW[i];
		}
		else if(msi_option_equal(argvW[i], "z"))
		{
			FunctionDllUnregisterServer = TRUE;
			i++;
			if(i >= argc)
				ShowUsage(1);
			WINE_TRACE("argvW[%d] = %s\n", i, wine_dbgstr_w(argvW[i]));
			DllName = argvW[i];
		}
		else if(msi_option_equal(argvW[i], "h") || msi_option_equal(argvW[i], "?"))
		{
			ShowUsage(0);
		}
		else if(msi_option_equal(argvW[i], "m"))
		{
			FunctionUnknown = TRUE;
			WINE_FIXME("Unknown parameter /m\n");
		}
		else if(msi_option_equal(argvW[i], "D"))
		{
			FunctionUnknown = TRUE;
			WINE_FIXME("Unknown parameter /D\n");
		}
		else
			StringListAppend(&property_list, argvW[i]);
	}

	/* start the GUI */
	MsiSetInternalUI(InstallUILevel, NULL);

	Properties = build_properties( property_list );

	if(FunctionInstallAdmin && FunctionPatch)
		FunctionInstall = FALSE;

	ReturnCode = 1;
	if(FunctionInstall)
	{
		if(IsProductCode(PackageName))
			ReturnCode = MsiConfigureProductExW(PackageName, 0, INSTALLSTATE_DEFAULT, Properties);
		else
			ReturnCode = MsiInstallProductW(PackageName, Properties);
	}
	else if(FunctionRepair)
	{
		if(IsProductCode(PackageName))
			WINE_FIXME("Product code treatment not implemented yet\n");
		else
			ReturnCode = MsiReinstallProductW(PackageName, RepairMode);
	}
	else if(FunctionAdvertise)
	{
		LPWSTR Transforms = build_transforms( property_list );
		ReturnCode = MsiAdvertiseProductW(PackageName, (LPWSTR) AdvertiseMode, Transforms, Language);
	}
	else if(FunctionPatch)
	{
		ReturnCode = MsiApplyPatchW(PatchFileName, PackageName, InstallType, Properties);
	}
	else if(FunctionDllRegisterServer)
	{
		ReturnCode = DoDllRegisterServer(DllName);
	}
	else if(FunctionDllUnregisterServer)
	{
		ReturnCode = DoDllUnregisterServer(DllName);
	}
	else if (FunctionRegServer)
	{
		ReturnCode = DoRegServer();
	}
	else if (FunctionUnregServer)
	{
		WINE_FIXME( "/unregserver not implemented yet, ignoring\n" );
	}
	else if (FunctionUnknown)
	{
		WINE_FIXME( "Unknown function, ignoring\n" );
	}
	else
		ShowUsage(1);

	return ReturnCode;
}

--- NEW FILE: msiexec.spec ---
name	msiexec
mode	cuiexe
type	win32
rsrc	rsrc.res

import msi.dll
import ole32.dll
import advapi32.dll
import user32.dll
import kernel32.dll


--- NEW FILE: msiexec.spec.c ---
/* File generated automatically from ./msiexec.spec; do not edit! */

#include "wine/compiler_defines.h"

extern char pe_header[];
#ifndef __GNUC__
static void __asm__dummy_header(void) {
#endif
asm(".section \".text\"\n\t"
    ".align 4096\n"
    "pe_header:\t.skip 4096\n\t");
#ifndef __GNUC__
}
#endif
#if defined( __GNUC__ )
static const char dllname[] WINE_USED = "msiexec";
#else
const char dllname[] = "msiexec";
#endif

extern int __wine_spec_exports[];

#define __stdcall __attribute__((__stdcall__))


static struct {
  struct {
    void        *OriginalFirstThunk;
    unsigned int TimeDateStamp;
    unsigned int ForwarderChain;
    const char  *Name;
    void        *FirstThunk;
  } imp[6];
  const char *data[32];
} imports = {
  {
    { 0, 0, 0, "msi.dll", &imports.data[0] },
    { 0, 0, 0, "ole32.dll", &imports.data[8] },
    { 0, 0, 0, "advapi32.dll", &imports.data[10] },
    { 0, 0, 0, "user32.dll", &imports.data[17] },
    { 0, 0, 0, "kernel32.dll", &imports.data[18] },
    { 0, 0, 0, 0, 0 },
  },
  {
    /* msi.dll */
    "\0\0MsiAdvertiseProductW",
    "\0\0MsiApplyPatchW",
    "\0\0MsiConfigureProductExW",
    "\0\0MsiEnableLogW",
    "\0\0MsiInstallProductW",
    "\0\0MsiReinstallProductW",
    "\0\0MsiSetInternalUI",
    0,
    /* ole32.dll */
    "\0\0CLSIDFromString",
    0,
    /* advapi32.dll */
    "\0\0CloseServiceHandle",
    "\0\0CreateServiceA",
    "\0\0OpenSCManagerA",
    "\0\0RegCloseKey",
    "\0\0RegOpenKeyW",
    "\0\0RegQueryValueExW",
    0,
    /* user32.dll */
    0,
    /* kernel32.dll */
    "\0\0CompareStringW",
    "\0\0ExitProcess",
    "\0\0FreeLibrary",
    "\0\0GetCommandLineW",
    "\0\0GetProcAddress",
    "\0\0GetSystemDirectoryA",
    "\0\0GetThreadLocale",
    "\0\0LoadLibraryExW",
    "\0\0MultiByteToWideChar",
    "\0\0lstrcatA",
    "\0\0lstrcpyW",
    "\0\0lstrcpynW",
    "\0\0lstrlenW",
    0,
  }
};

#ifndef __GNUC__
static void __asm__dummy_import(void) {
#endif

asm(".text\n\t.align 8\n"
    "\t.type MsiAdvertiseProductW,@function\n"
    "\t.globl MsiAdvertiseProductW\n"
    "MsiAdvertiseProductW:\n\tjmp *(imports+120)\n\tmovl %esi,%esi\n"
    "\t.type MsiApplyPatchW,@function\n"
    "\t.globl MsiApplyPatchW\n"
    "MsiApplyPatchW:\n\tjmp *(imports+124)\n\tmovl %esi,%esi\n"
    "\t.type MsiConfigureProductExW,@function\n"
    "\t.globl MsiConfigureProductExW\n"
    "MsiConfigureProductExW:\n\tjmp *(imports+128)\n\tmovl %esi,%esi\n"
    "\t.type MsiEnableLogW,@function\n"
    "\t.globl MsiEnableLogW\n"
    "MsiEnableLogW:\n\tjmp *(imports+132)\n\tmovl %esi,%esi\n"
    "\t.type MsiInstallProductW,@function\n"
    "\t.globl MsiInstallProductW\n"
    "MsiInstallProductW:\n\tjmp *(imports+136)\n\tmovl %esi,%esi\n"
    "\t.type MsiReinstallProductW,@function\n"
    "\t.globl MsiReinstallProductW\n"
    "MsiReinstallProductW:\n\tjmp *(imports+140)\n\tmovl %esi,%esi\n"
    "\t.type MsiSetInternalUI,@function\n"
    "\t.globl MsiSetInternalUI\n"
    "MsiSetInternalUI:\n\tjmp *(imports+144)\n\tmovl %esi,%esi\n"
    "\t.type CLSIDFromString,@function\n"
    "\t.globl CLSIDFromString\n"
    "CLSIDFromString:\n\tjmp *(imports+152)\n\tmovl %esi,%esi\n"
    "\t.type CloseServiceHandle,@function\n"
    "\t.globl CloseServiceHandle\n"
    "CloseServiceHandle:\n\tjmp *(imports+160)\n\tmovl %esi,%esi\n"
    "\t.type CreateServiceA,@function\n"
    "\t.globl CreateServiceA\n"
    "CreateServiceA:\n\tjmp *(imports+164)\n\tmovl %esi,%esi\n"
    "\t.type OpenSCManagerA,@function\n"
    "\t.globl OpenSCManagerA\n"
    "OpenSCManagerA:\n\tjmp *(imports+168)\n\tmovl %esi,%esi\n"
    "\t.type RegCloseKey,@function\n"
    "\t.globl RegCloseKey\n"
    "RegCloseKey:\n\tjmp *(imports+172)\n\tmovl %esi,%esi\n"
    "\t.type RegOpenKeyW,@function\n"
    "\t.globl RegOpenKeyW\n"
    "RegOpenKeyW:\n\tjmp *(imports+176)\n\tmovl %esi,%esi\n"
    "\t.type RegQueryValueExW,@function\n"
    "\t.globl RegQueryValueExW\n"
    "RegQueryValueExW:\n\tjmp *(imports+180)\n\tmovl %esi,%esi\n"
    "\t.type CompareStringW,@function\n"
    "\t.globl CompareStringW\n"
    "CompareStringW:\n\tjmp *(imports+192)\n\tmovl %esi,%esi\n"
    "\t.type ExitProcess,@function\n"
    "\t.globl ExitProcess\n"
    "ExitProcess:\n\tjmp *(imports+196)\n\tmovl %esi,%esi\n"
    "\t.type FreeLibrary,@function\n"
    "\t.globl FreeLibrary\n"
    "FreeLibrary:\n\tjmp *(imports+200)\n\tmovl %esi,%esi\n"
    "\t.type GetCommandLineW,@function\n"
    "\t.globl GetCommandLineW\n"
    "GetCommandLineW:\n\tjmp *(imports+204)\n\tmovl %esi,%esi\n"
    "\t.type GetProcAddress,@function\n"
    "\t.globl GetProcAddress\n"
    "GetProcAddress:\n\tjmp *(imports+208)\n\tmovl %esi,%esi\n"
    "\t.type GetSystemDirectoryA,@function\n"
    "\t.globl GetSystemDirectoryA\n"
    "GetSystemDirectoryA:\n\tjmp *(imports+212)\n\tmovl %esi,%esi\n"
    "\t.type GetThreadLocale,@function\n"
    "\t.globl GetThreadLocale\n"
    "GetThreadLocale:\n\tjmp *(imports+216)\n\tmovl %esi,%esi\n"
    "\t.type LoadLibraryExW,@function\n"
    "\t.globl LoadLibraryExW\n"
    "LoadLibraryExW:\n\tjmp *(imports+220)\n\tmovl %esi,%esi\n"
    "\t.type MultiByteToWideChar,@function\n"
    "\t.globl MultiByteToWideChar\n"
    "MultiByteToWideChar:\n\tjmp *(imports+224)\n\tmovl %esi,%esi\n"
    "\t.type lstrcatA,@function\n"
    "\t.globl lstrcatA\n"
    "lstrcatA:\n\tjmp *(imports+228)\n\tmovl %esi,%esi\n"
    "\t.type lstrcpyW,@function\n"
    "\t.globl lstrcpyW\n"
    "lstrcpyW:\n\tjmp *(imports+232)\n\tmovl %esi,%esi\n"
    "\t.type lstrcpynW,@function\n"
    "\t.globl lstrcpynW\n"
    "lstrcpynW:\n\tjmp *(imports+236)\n\tmovl %esi,%esi\n"
    "\t.type lstrlenW,@function\n"
    "\t.globl lstrlenW\n"
    "lstrlenW:\n\tjmp *(imports+240)\n\tmovl %esi,%esi\n"
".section\t\".text\"");
#ifndef __GNUC__
}
#endif

static const unsigned int res_0[186] = {
  0x00000028,0x00000020,0x00000040,0x00040001,0x00000000,0x00000280,0x00000000,0x00000000,
  0x00000000,0x00000000,0x00000000,0x00800000,0x00008000,0x00808000,0x00000080,0x00800080,
  0x00008080,0x00c0c0c0,0x00808080,0x00ff0000,0x0000ff00,0x00ffff00,0x000000ff,0x00ff00ff,
  0x0000ffff,0x00ffffff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
  0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
  0x00000000,0x00000000,0x00000000,0x00830300,0x00000000,0x00000000,0x00000000,0x00003333,
  0x00000000,0x00000000,0x03000000,0x0000303b,0x00008000,0x00000000,0x33000000,0x00000033,
  0x00003303,0x00000000,0x3b030000,0x00000030,0x0030b333,0x00000000,0x330b0000,0x00000000,
  0x00b03338,0x00000000,0x38030000,0x00030000,0x00303803,0x00000000,0x33330000,0x30000300,
  0x00000000,0x00000000,0xb3330000,0x00003033,0x00111101,0x00000000,0x33330000,0x0000b0b3,
  0x10111111,0x00000000,0x33330000,0x01003383,0x11111111,0x00000000,0xb3030000,0x01333333,
  0x11111111,0x00000010,0x33030000,0x013b333b,0x11111111,0x00000010,0x83030000,0x01833338,
  0x11111111,0x00000011,0x33000000,0x013333b3,0x11111111,0x00000011,0x03000000,0x3033b333,
  0x00101111,0x00001010,0x00000000,0x303b3833,0xff001011,0x00000f00,0x00000000,0x30330300,
  0xffff0001,0x0000ffff,0x00000000,0x00000000,0xffff0f01,0x0000ffff,0x00000000,0x00000000,
  0xffff0f00,0x0000f0ff,0x00000000,0x00000000,0xffff0f00,0x000000ff,0x00000000,0x00000000,
  0xffff0f00,0x000000f0,0x00000000,0x00000000,0xf0ff0000,0x00000000,0x00000000,0x00000000,
  0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
  0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
  0x00000000,0x00000000,0xffffffff,0xffffffff,0xffffffff,0xff1fe1ff,0xff1f00ff,0xff1f00fe,
  0xff0f00fc,0xff0700f8,0xff0300f0,0xff0300f0,0xff0300f0,0xff0100e0,0xff010ce0,0xff000ce0,
  0x7f0000e0,0x7f0000f0,0x3f0000f0,0x1f0000f0,0x0f0000f8,0x070000fc,0x070000fe,0x030000ff,
  0x0300e1ff,0x0780ffff,0x0f80ffff,0x1fc0ffff,0x3fc0ffff,0xffe0ffff,0xffffffff,0xffffffff,
  0xffffffff,0xffffffff
};

static const unsigned int res_1[5] = {
  0x00010000,0x20200001,0x00010010,0x02e80004,0x00010000
};

static const unsigned int res_2[218] = {
  0x00340368,0x00560000,0x005f0053,0x00450056,0x00530052,0x004f0049,0x005f004e,0x004e0049,
  0x004f0046,0x00000000,0xfeef04bd,0x00010000,0x00030001,0x0fa0071f,0x00030001,0x0fa0071f,
  0x00000000,0x00000000,0x00000000,0x00000002,0x00000000,0x00000000,0x00000000,0x000002c8,
  0x00530000,0x00720074,0x006e0069,0x00460067,0x006c0069,0x00490065,0x0066006e,0x0000006f,
  0x000002a4,0x00300000,0x00300034,0x00300039,0x00450034,0x00000034,0x000a0034,0x00430001,
  0x006d006f,0x00610070,0x0079006e,0x0061004e,0x0065006d,0x00000000,0x00690057,0x0065006e,
  0x00540020,0x00610065,0x0000006d,0x000f0046,0x00460001,0x006c0069,0x00440065,0x00730065,
  0x00720063,0x00700069,0x00690074,0x006e006f,0x00000000,0x00690057,0x0065006e,0x00490020,
  0x0073006e,0x00610074,0x006c006c,0x00720065,0x00000000,0x000e003c,0x00460001,0x006c0069,
  0x00560065,0x00720065,0x00690073,0x006e006f,0x00000000,0x002e0033,0x002e0031,0x00300034,
  0x00300030,0x0031002e,0x00320038,0x00000033,0x000c0038,0x00490001,0x0074006e,0x00720065,
  0x0061006e,0x004e006c,0x006d0061,0x00000065,0x0073006d,0x00650069,0x00650078,0x002e0063,
  0x00780065,0x00000065,0x005c00dc,0x004c0001,0x00670065,0x006c0061,0x006f0043,0x00790070,
  0x00690072,0x00680067,0x00000074,0x006f0043,0x00790070,0x00690072,0x00680067,0x00200074,
  0x00630028,0x00200029,0x00390031,0x00330039,0x0032002d,0x00300030,0x00200031,0x00680074,
  0x00200065,0x00690057,0x0065006e,0x00700020,0x006f0072,0x0065006a,0x00740063,0x00610020,
  0x00740075,0x006f0068,0x00730072,0x00280020,0x00650073,0x00200065,0x00680074,0x00200065,
  0x00690066,0x0065006c,0x00410020,0x00540055,0x004f0048,0x00530052,0x00660020,0x0072006f,
  0x00610020,0x00630020,0x006d006f,0x006c0070,0x00740065,0x00200065,0x0069006c,0x00740073,
  0x00000029,0x000c0040,0x004f0001,0x00690072,0x00690067,0x0061006e,0x0046006c,0x006c0069,
  0x006e0065,0x006d0061,0x00000065,0x0073006d,0x00650069,0x00650078,0x002e0063,0x00780065,
  0x00000065,0x000f003e,0x00500001,0x006f0072,0x00750064,0x00740063,0x0061004e,0x0065006d,
  0x00000000,0x00690057,0x0065006e,0x00490020,0x0073006e,0x00610074,0x006c006c,0x00720065,
  0x00000000,0x000e0040,0x00500001,0x006f0072,0x00750064,0x00740063,0x00650056,0x00730072,
  0x006f0069,0x0000006e,0x002e0033,0x002e0031,0x00300034,0x00300030,0x0031002e,0x00320038,
  0x00000033,0x00000044,0x00560000,0x00720061,0x00690046,0x0065006c,0x006e0049,0x006f0066,
  0x00000000,0x00040024,0x00540000,0x00610072,0x0073006e,0x0061006c,0x00690074,0x006e006f,
  0x00000000,0x04e40409
};

struct res_dir {
  unsigned int Characteristics;
  unsigned int TimeDateStamp;
  unsigned short MajorVersion, MinorVersion;
  unsigned short NumerOfNamedEntries, NumberOfIdEntries;
};

struct res_dir_entry {
  unsigned int Name;
  unsigned int OffsetToData;
};

struct res_data_entry {
  const unsigned int *OffsetToData;
  unsigned int Size;
  unsigned int CodePage;
  unsigned int ResourceHandle;
};

#define OFFSETOF(field) ((char*)&((struct res_struct *)0)->field - (char*)((struct res_struct *) 0))
static struct res_struct{
  struct res_dir        type_dir;
  struct res_dir_entry  type_entries[3];
  struct res_dir        name_0_dir;
  struct res_dir_entry  name_0_entries[1];
  struct res_dir        lang_0_0_dir;
  struct res_dir_entry  lang_0_0_entries[1];
  struct res_dir        name_1_dir;
  struct res_dir_entry  name_1_entries[1];
  struct res_dir        lang_1_0_dir;
  struct res_dir_entry  lang_1_0_entries[1];
  struct res_dir        name_2_dir;
  struct res_dir_entry  name_2_entries[1];
  struct res_dir        lang_2_0_dir;
  struct res_dir_entry  lang_2_0_entries[1];
  struct res_data_entry data_entries[3];
} resources = {
  { 0, 0, 0, 0, 0, 3 },
  {
    { 0x0003, OFFSETOF(name_0_dir) | 0x80000000 },
    { 0x000e, OFFSETOF(name_1_dir) | 0x80000000 },
    { 0x0010, OFFSETOF(name_2_dir) | 0x80000000 },
  },
  { 0, 0, 0, 0, 0, 1 }, /* name_0_dir */
  {
    { 0x0001, OFFSETOF(lang_0_0_dir) | 0x80000000 },
  },
  { 0, 0, 0, 0, 0, 1 }, /* lang_0_0_dir */
  {
    { 0x0000, OFFSETOF(data_entries[0]) },
  },
  { 0, 0, 0, 0, 0, 1 }, /* name_1_dir */
  {
    { 0x0001, OFFSETOF(lang_1_0_dir) | 0x80000000 },
  },
  { 0, 0, 0, 0, 0, 1 }, /* lang_1_0_dir */
  {
    { 0x0000, OFFSETOF(data_entries[1]) },
  },
  { 0, 0, 0, 0, 0, 1 }, /* name_2_dir */
  {
    { 0x0001, OFFSETOF(lang_2_0_dir) | 0x80000000 },
  },
  { 0, 0, 0, 0, 0, 1 }, /* lang_2_0_dir */
  {
    { 0x0000, OFFSETOF(data_entries[2]) },
  },
  {
    { res_0, sizeof(res_0), 0, 0 },
    { res_1, sizeof(res_1), 0, 0 },
    { res_2, sizeof(res_2), 0, 0 },
  }
};
#undef OFFSETOF

char __wine_dbch_msiexec[] = "\003msiexec";

static char * const debug_channels[1] =
{
    __wine_dbch_msiexec
};

static void *debug_registration;


int _ARGC;
char **_ARGV;
extern void __stdcall ExitProcess(int);
static void __wine_exe_main(void)
{
    extern int main( int argc, char *argv[] );
    extern int __wine_get_main_args( char ***argv );
    _ARGC = __wine_get_main_args( &_ARGV );
    ExitProcess( main( _ARGC, _ARGV ) );
}

static const struct image_nt_headers
{
  int Signature;
  struct file_header {
    short Machine;
    short NumberOfSections;
    int   TimeDateStamp;
    void *PointerToSymbolTable;
    int   NumberOfSymbols;
    short SizeOfOptionalHeader;
    short Characteristics;
  } FileHeader;
  struct opt_header {
    short Magic;
    char  MajorLinkerVersion, MinorLinkerVersion;
    int   SizeOfCode;
    int   SizeOfInitializedData;
    int   SizeOfUninitializedData;
    void *AddressOfEntryPoint;
    void *BaseOfCode;
    void *BaseOfData;
    void *ImageBase;
    int   SectionAlignment;
    int   FileAlignment;
    short MajorOperatingSystemVersion;
    short MinorOperatingSystemVersion;
    short MajorImageVersion;
    short MinorImageVersion;
    short MajorSubsystemVersion;
    short MinorSubsystemVersion;
    int   Win32VersionValue;
    int   SizeOfImage;
    int   SizeOfHeaders;
    int   CheckSum;
    short Subsystem;
    short DllCharacteristics;
    int   SizeOfStackReserve;
    int   SizeOfStackCommit;
    int   SizeOfHeapReserve;
    int   SizeOfHeapCommit;
    int   LoaderFlags;
    int   NumberOfRvaAndSizes;
    struct { const void *VirtualAddress; int Size; } DataDirectory[16];
  } OptionalHeader;
  struct sec_header {
    char  Name[8];
    int   VirtualSize;
    void *VirtualAddress;
    int   SizeOfRawData;
    void *PointerToRawData;
    void *PointerToRelocations;
    void *PointerToLinenumbers;
    short NumberOfRelocations;
    short NumberOfLinenumbers;
    int   Characteristics;
  } SectionHeader[1];
} nt_header = {
  0x4550,
  { 0x014c,
    1,
    0, 0, 0,
    sizeof(nt_header.OptionalHeader),
    0x0000 },
  { 0x010b,
    0, 0,
    0, 0, 0,
    __wine_exe_main,
    0, 0,
    pe_header,
    4096,
    4096,
    1, 0,
    0, 0,
    4, 0,
    0,
    4096,
    4096,
    0,
    0x0003,
    0,
    0, 0,
    0, 0,
    0,
    16,
    {
      { 0, 0 },
      { &imports, sizeof(imports) },
      { &resources, sizeof(resources) },
    }
  },
  {
    { ".text   ",
      4096,
      pe_header,
      4096,
      0,
      0, 0, 0, 0,
      0x20000020,
    }
  }
};

#ifndef __GNUC__
static void __asm__dummy_dll_init(void) {
#endif /* defined(__GNUC__) */
asm("\t.section\t\".init\" ,\"ax\"\n"
    "\tcall __wine_spec_msiexec_init\n"
    "\t.section\t\".text\"\n");
asm("\t.section\t\".fini\" ,\"ax\"\n"
    "\tcall __wine_spec_msiexec_fini\n"
    "\t.section\t\".text\"\n");
#ifndef __GNUC__
}
#endif /* defined(__GNUC__) */

void __wine_spec_msiexec_init(void)
{
    extern void __wine_dll_register( const struct image_nt_headers *, const char * );
    extern void *__wine_dbg_register( char * const *, int );
    __wine_dll_register( &nt_header, "msiexec.exe" );
    debug_registration = __wine_dbg_register( debug_channels, 1 );
}

void __wine_spec_msiexec_fini(void)
{
    extern void __wine_dbg_unregister( void* );
    __wine_dbg_unregister( debug_registration );
}

--- NEW FILE: rsrc.rc ---
/*
 * Copyright (c) 2006 Mike McCormack
 *
 * 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
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <windows.h>

#include "version.rc"

LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL

/* BINRES msiexec.ico */
1 ICON DISCARDABLE
{
 '00 00 01 00 01 00 20 20 10 00 00 00 00 00 E8 02'
 '00 00 16 00 00 00 28 00 00 00 20 00 00 00 40 00'
 '00 00 01 00 04 00 00 00 00 00 80 02 00 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 00 00 80 00 00 80 00 00 00 80 80 00 80 00'
 '00 00 80 00 80 00 80 80 00 00 C0 C0 C0 00 80 80'
 '80 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 FF 00'
 '00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 00 03 83 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 33 33 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 03 3B 30 00 00 00 80 00 00 00 00 00 00 00 00'
 '00 33 33 00 00 00 03 33 00 00 00 00 00 00 00 00'
 '03 3B 30 00 00 00 33 B3 30 00 00 00 00 00 00 00'
 '0B 33 00 00 00 00 38 33 B0 00 00 00 00 00 00 00'
 '03 38 00 00 03 00 03 38 30 00 00 00 00 00 00 00'
 '33 33 00 03 00 30 00 00 00 00 00 00 00 00 00 00'
 '33 B3 33 30 00 00 01 11 11 00 00 00 00 00 00 00'
 '33 33 B3 B0 00 00 11 11 11 10 00 00 00 00 00 00'
 '33 33 83 33 00 01 11 11 11 11 00 00 00 00 00 00'
 '03 B3 33 33 33 01 11 11 11 11 10 00 00 00 00 00'
 '03 33 3B 33 3B 01 11 11 11 11 10 00 00 00 00 00'
 '03 83 38 33 83 01 11 11 11 11 11 00 00 00 00 00'
 '00 33 B3 33 33 01 11 11 11 11 11 00 00 00 00 00'
 '00 03 33 B3 33 30 11 11 10 00 10 10 00 00 00 00'
 '00 00 33 38 3B 30 11 10 00 FF 00 0F 00 00 00 00'
 '00 00 00 03 33 30 01 00 FF FF FF FF 00 00 00 00'
 '00 00 00 00 00 00 01 0F FF FF FF FF 00 00 00 00'
 '00 00 00 00 00 00 00 0F FF FF FF F0 00 00 00 00'
 '00 00 00 00 00 00 00 0F FF FF FF 00 00 00 00 00'
 '00 00 00 00 00 00 00 0F FF FF F0 00 00 00 00 00'
 '00 00 00 00 00 00 00 00 FF F0 00 00 00 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF'
 'FF FF FF FF FF FF FF FF FF FF FF E1 1F FF FF 00'
 '1F FF FE 00 1F FF FC 00 0F FF F8 00 07 FF F0 00'
 '03 FF F0 00 03 FF F0 00 03 FF E0 00 01 FF E0 0C'
 '01 FF E0 0C 00 FF E0 00 00 7F F0 00 00 7F F0 00'
 '00 3F F0 00 00 1F F8 00 00 0F FC 00 00 07 FE 00'
 '00 07 FF 00 00 03 FF E1 00 03 FF FF 80 07 FF FF'
 '80 0F FF FF C0 1F FF FF C0 3F FF FF E0 FF FF FF'
 'FF FF FF FF FF FF FF FF FF FF FF FF FF FF'
}

--- NEW FILE: version.rc ---
/*
 * Copyright (c) 2004 Mike McCormack
 *
 * 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
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#define WINE_FILEDESCRIPTION_STR "Wine Installer"
#define WINE_FILENAME_STR "msiexec.exe"
#define WINE_FILETYPE VFT_APP
#define WINE_FILEVERSION 3,1,4000,1823
#define WINE_FILEVERSION_STR "3.1.4000.1823"
#define WINE_PRODUCTVERSION 3,1,4000,1823
#define WINE_PRODUCTVERSION_STR "3.1.4000.1823"
#define WINE_PRODUCTNAME_STR "Wine Installer"

#include "wine/wine_common_ver.rc"