First draft for a msiexec.exe replacement.

oldstable
Vincent Béron 2004-07-19 19:44:07 +00:00 committed by Alexandre Julliard
parent 53150367b0
commit 3496689a89
7 changed files with 394 additions and 1 deletions

3
configure vendored

File diff suppressed because one or more lines are too long

View File

@ -1699,6 +1699,7 @@ programs/clock/Makefile
programs/cmdlgtst/Makefile
programs/control/Makefile
programs/expand/Makefile
programs/msiexec/Makefile
programs/notepad/Makefile
programs/progman/Makefile
programs/regedit/Makefile

View File

@ -11,6 +11,7 @@ SUBDIRS = \
cmdlgtst \
control \
expand \
msiexec \
notepad \
progman \
regedit \
@ -42,6 +43,7 @@ INSTALLSUBDIRS = \
clock \
control \
expand \
msiexec \
notepad \
progman \
regedit \
@ -93,6 +95,7 @@ SYMLINKS = \
control.exe \
expand.exe \
icinfo.exe \
msiexec.exe \
notepad.exe \
progman.exe \
regedit.exe \
@ -182,6 +185,9 @@ expand.exe$(DLLEXT): expand/expand.exe$(DLLEXT)
icinfo.exe$(DLLEXT): avitools/icinfo.exe$(DLLEXT)
$(RM) $@ && $(LN_S) avitools/icinfo.exe$(DLLEXT) $@
msiexec.exe$(DLLEXT): msiexec/msiexec.exe$(DLLEXT)
$(RM) $@ && $(LN_S) msiexec/msiexec.exe$(DLLEXT) $@
notepad.exe$(DLLEXT): notepad/notepad.exe$(DLLEXT)
$(RM) $@ && $(LN_S) notepad/notepad.exe$(DLLEXT) $@
@ -261,6 +267,7 @@ cmdlgtst/cmdlgtst.exe$(DLLEXT): cmdlgtst
control/control.exe$(DLLEXT): control
expand/expand.exe$(DLLEXT): expand
avitools/icinfo.exe$(DLLEXT): avitools
msiexec/msiexec.exe$(DLLEXT): msiexec
notepad/notepad.exe$(DLLEXT): notepad
progman/progman.exe$(DLLEXT): progman
regedit/regedit.exe$(DLLEXT): regedit

View File

@ -0,0 +1,2 @@
Makefile
msiexec.exe.dbg.c

View File

@ -0,0 +1,14 @@
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = msiexec.exe
APPMODE = -mconsole
IMPORTS = msi ole32 user32 kernel32
C_SRCS = \
msiexec.c
@MAKE_PROG_RULES@
### Dependencies:

View File

@ -0,0 +1,325 @@
/*
* msiexec.exe implementation
*
* Copyright 2004 Vincent Béron
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include <msi.h>
#include <objbase.h>
#include <stdio.h>
#include "msiexec.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msiexec);
static const char UsageStr[] =
"Usage: msiexec ...\n\n"
"Copyright 2004 Vincent Béron\n";
static const char ActionAdmin[] = "ACTION=ADMIN ";
static const char RemoveAll[] = "REMOVE=ALL ";
static void ShowUsage(int ExitCode)
{
printf(UsageStr);
ExitProcess(ExitCode);
}
static BOOL GetProductCode(LPCSTR str, LPGUID guid)
{
BOOL ret = FALSE;
int len = 0;
LPWSTR wstr = NULL;
if(strlen(str) == 38)
{
len = MultiByteToWideChar(CP_ACP, 0, str, -1, wstr, 0);
wstr = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
ret = (CLSIDFromString(wstr, guid) == NOERROR);
HeapFree(GetProcessHeap(), 0, wstr);
wstr = NULL;
}
return ret;
}
static VOID *LoadProc(LPCSTR DllName, LPCSTR ProcName, HMODULE* DllHandle)
{
VOID* (*proc)(void);
*DllHandle = LoadLibraryExA(DllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if(!*DllHandle)
{
fprintf(stderr, "Unable to load dll %s\n", DllName);
ExitProcess(1);
}
proc = (VOID *) GetProcAddress(*DllHandle, ProcName);
if(!proc)
{
fprintf(stderr, "Dll %s does not implement function %s\n", DllName, ProcName);
FreeLibrary(*DllHandle);
ExitProcess(1);
}
return proc;
}
static void DllRegisterServer(LPCSTR 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", DllName);
ExitProcess(1);
}
printf("Successfully registered dll %s\n", DllName);
if(DllHandle)
FreeLibrary(DllHandle);
}
static void DllUnregisterServer(LPCSTR 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", DllName);
ExitProcess(1);
}
printf("Successfully unregistered dll %s\n", DllName);
if(DllHandle)
FreeLibrary(DllHandle);
}
int main(int argc, char *argv[])
{
int i;
BOOL FunctionInstall = FALSE;
BOOL FunctionDllRegisterServer = FALSE;
BOOL FunctionDllUnregisterServer = FALSE;
BOOL GotProductCode = FALSE;
LPSTR PackageName = NULL;
LPGUID ProductCode = HeapAlloc(GetProcessHeap(), 0, sizeof(GUID));
LPSTR Properties = HeapAlloc(GetProcessHeap(), 0, 1);
LPSTR TempStr = NULL;
LPSTR DllName = NULL;
Properties[0] = 0;
for(i = 1; i < argc; i++)
{
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
if(!strcasecmp(argv[i], "/i"))
{
FunctionInstall = TRUE;
i++;
if(i >= argc)
ShowUsage(1);
GotProductCode = GetProductCode(argv[i], ProductCode);
if(!GotProductCode)
{
HeapFree(GetProcessHeap(), 0, ProductCode);
ProductCode = NULL;
PackageName = argv[i];
}
}
else if(!strcasecmp(argv[i], "/a"))
{
FunctionInstall = TRUE;
i++;
if(i >= argc)
ShowUsage(1);
PackageName = argv[i];
TempStr = HeapReAlloc(GetProcessHeap(), 0, Properties, HeapSize(GetProcessHeap(), 0, Properties)+strlen(ActionAdmin));
if(!TempStr)
{
WINE_ERR("Out of memory!\n");
ExitProcess(1);
}
Properties = TempStr;
strcat(Properties, ActionAdmin);
}
else if(!strncasecmp(argv[i], "/f", 2))
{
i++;
if(i >= argc)
ShowUsage(1);
WINE_FIXME("Repair not implemented yet\n");
ExitProcess(1);
}
else if(!strcasecmp(argv[i], "/x"))
{
FunctionInstall = TRUE;
i++;
if(i >= argc)
ShowUsage(1);
GotProductCode = GetProductCode(argv[i], ProductCode);
if(!GotProductCode)
{
HeapFree(GetProcessHeap(), 0, ProductCode);
ProductCode = NULL;
PackageName = argv[i];
}
TempStr = HeapReAlloc(GetProcessHeap(), 0, Properties, HeapSize(GetProcessHeap(), 0, Properties)+strlen(RemoveAll));
if(!TempStr)
{
WINE_ERR("Out of memory!\n");
ExitProcess(1);
}
Properties = TempStr;
strcat(Properties, RemoveAll);
}
else if(!strncasecmp(argv[i], "/j", 2))
{
i++;
if(i >= argc)
ShowUsage(1);
WINE_FIXME("Advertising not yet implemented\n");
ExitProcess(1);
}
else if(!strcasecmp(argv[i], "u") || !strcasecmp(argv[i], "m"))
{
i++;
if(i >= argc)
ShowUsage(1);
WINE_FIXME("Advertising not yet implemented\n");
ExitProcess(1);
}
else if(!strcasecmp(argv[i], "/t"))
{
i++;
if(i >= argc)
ShowUsage(1);
WINE_FIXME("Transforms not yet implemented\n");
ExitProcess(1);
}
else if(!strncasecmp(argv[i], "TRANSFORMS", 10))
{
WINE_FIXME("Transforms not yet implemented\n");
ExitProcess(1);
}
else if(!strcasecmp(argv[i], "/g"))
{
i++;
if(i >= argc)
ShowUsage(1);
WINE_FIXME("Language ID not yet implemented\n");
ExitProcess(1);
}
else if(!strncasecmp(argv[i], "/l", 2))
{
i++;
if(i >= argc)
ShowUsage(1);
WINE_FIXME("Logging not yet implemented\n");
ExitProcess(1);
}
else if(!strcasecmp(argv[i], "/p"))
{
i++;
if(i >= argc)
ShowUsage(1);
WINE_FIXME("Patching not yet implemented\n");
ExitProcess(1);
}
else if(!strncasecmp(argv[i], "/q", 2))
{
i++;
if(i >= argc)
ShowUsage(1);
WINE_FIXME("User interface not yet implemented\n");
ExitProcess(1);
}
else if(!strcasecmp(argv[i], "/y"))
{
FunctionDllRegisterServer = TRUE;
i++;
if(i >= argc)
ShowUsage(1);
DllName = argv[i];
}
else if(!strcasecmp(argv[i], "/z"))
{
FunctionDllUnregisterServer = TRUE;
i++;
if(i >= argc)
ShowUsage(1);
DllName = argv[i];
}
else if(!strcasecmp(argv[i], "/h") || !strcasecmp(argv[i], "/?"))
{
ShowUsage(0);
}
}
if(FunctionInstall)
{
if(Properties[strlen(Properties)-1] == ' ')
{
Properties[strlen(Properties)-1] = 0;
TempStr = HeapReAlloc(GetProcessHeap(), 0, Properties, HeapSize(GetProcessHeap(), 0, Properties)-1);
if(!TempStr)
{
fprintf(stderr, "Out of memory!\n");
ExitProcess(1);
}
Properties = TempStr;
}
if(GotProductCode)
{
WINE_FIXME("Product code treatment not implemented yet\n");
ExitProcess(1);
}
else
{
if(MsiInstallProductA(PackageName, Properties) != ERROR_SUCCESS)
{
fprintf(stderr, "Installation of %s (%s) failed.\n", PackageName, Properties);
ExitProcess(1);
}
}
}
else if(FunctionDllRegisterServer)
{
DllRegisterServer(DllName);
}
else if(FunctionDllUnregisterServer)
{
DllUnregisterServer(DllName);
}
else
ShowUsage(1);
return 0;
}

View File

@ -0,0 +1,43 @@
/*
* Msiexec (msiexec.h)
*
* Copyright 2004 Vincent Béron
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
typedef HRESULT (*DLLREGISTERSERVER)(void);
typedef HRESULT (*DLLUNREGISTERSERVER)(void);
/* Advertising flags */
#define ADVERTISE_CURRENT_USER 0x00000001
#define ADVERTISE_ALL_USERS 0x00000002
/* Logging flags */
#define LOG_STATUS_MESSAGES 0x00000001
#define LOG_NONFATAL_WARNINGS 0x00000002
#define LOG_ALL_ERROR_MESSAGES 0x00000004
#define LOG_STARTUP_OF_ACTIONS 0x00000008
#define LOG_ACTION_SPECIFIC_RECORDS 0x00000010
#define LOG_USER_REQUESTS 0x00000020
#define LOG_INITIAL_USER_INTERFACE_PARAMETERS 0x00000040
#define LOG_OUT_OF_MEMORY 0x00000080
#define LOG_TERMINAL_PROPERTIES 0x00000100
#define LOG_VERBOSE_OUTPUT 0x00000200
#define LOG_APPEND_TO_EXISTING_FILE 0x00000400
#define LOG_FLUSH_EACH_LINE 0x00000800
#define LOG_WILDCARD 0x000001ff