2002-04-29 23:47:39 +00:00
|
|
|
/*
|
2002-07-20 18:54:03 +00:00
|
|
|
* PURPOSE: Register OLE components in the registry
|
2002-04-29 23:47:39 +00:00
|
|
|
*
|
|
|
|
* Copyright 2001 ReactOS project
|
|
|
|
* Copyright 2001 Jurgen Van Gael [jurgen.vangael@student.kuleuven.ac.be]
|
|
|
|
* Copyright 2002 Andriy Palamarchuk
|
2015-06-26 10:04:22 +00:00
|
|
|
* Copyright 2014, 2015 Hugh McMaster
|
2002-04-29 23:47:39 +00: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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-04-29 23:47:39 +00:00
|
|
|
*/
|
|
|
|
|
2006-01-18 13:23:11 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2002-04-29 23:47:39 +00:00
|
|
|
#include <windows.h>
|
2021-04-06 10:01:15 +00:00
|
|
|
#include <winternl.h>
|
2006-02-09 16:48:12 +00:00
|
|
|
#include <ole2.h>
|
2014-03-19 00:54:57 +00:00
|
|
|
#include "regsvr32.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(regsvr32);
|
2002-04-29 23:47:39 +00:00
|
|
|
|
2015-05-28 10:00:57 +00:00
|
|
|
typedef HRESULT (WINAPI *DLLREGISTER) (void);
|
|
|
|
typedef HRESULT (WINAPI *DLLUNREGISTER) (void);
|
|
|
|
typedef HRESULT (WINAPI *DLLINSTALL) (BOOL,LPCWSTR);
|
2002-04-29 23:47:39 +00:00
|
|
|
|
2013-11-05 00:06:04 +00:00
|
|
|
static BOOL Silent = FALSE;
|
2002-04-29 23:47:39 +00:00
|
|
|
|
2017-11-02 09:22:01 +00:00
|
|
|
static void WINAPIV output_write(UINT id, ...)
|
2002-04-29 23:47:39 +00:00
|
|
|
{
|
2015-06-23 11:27:22 +00:00
|
|
|
WCHAR fmt[1024];
|
2021-10-25 09:01:45 +00:00
|
|
|
va_list va_args;
|
2015-06-23 11:27:22 +00:00
|
|
|
WCHAR *str;
|
2022-04-28 09:22:40 +00:00
|
|
|
DWORD len, nOut;
|
2014-03-19 00:54:57 +00:00
|
|
|
|
2014-03-19 01:03:49 +00:00
|
|
|
if (Silent) return;
|
|
|
|
|
2018-08-10 10:27:52 +00:00
|
|
|
if (!LoadStringW(GetModuleHandleW(NULL), id, fmt, ARRAY_SIZE(fmt)))
|
2014-03-19 00:54:57 +00:00
|
|
|
{
|
2022-02-04 08:57:36 +00:00
|
|
|
WINE_FIXME("LoadString failed with %ld\n", GetLastError());
|
2014-03-19 00:54:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-25 09:01:45 +00:00
|
|
|
va_start(va_args, id);
|
2015-06-23 11:27:22 +00:00
|
|
|
len = FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
|
|
|
fmt, 0, 0, (LPWSTR)&str, 0, &va_args);
|
2021-10-25 09:01:45 +00:00
|
|
|
va_end(va_args);
|
2020-05-13 20:07:04 +00:00
|
|
|
if (len == 0 && GetLastError() != ERROR_NO_WORK_DONE)
|
2014-03-19 00:54:57 +00:00
|
|
|
{
|
2022-02-04 08:57:36 +00:00
|
|
|
WINE_FIXME("Could not format string: le=%lu, fmt=%s\n", GetLastError(), wine_dbgstr_w(fmt));
|
2014-03-19 00:54:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-23 11:27:23 +00:00
|
|
|
/* WriteConsole fails if its output is redirected to a file.
|
|
|
|
* If this occurs, we should use an OEM codepage and call WriteFile.
|
|
|
|
*/
|
2022-04-28 09:22:40 +00:00
|
|
|
if (!WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, len, &nOut, NULL))
|
2015-06-23 11:27:23 +00:00
|
|
|
{
|
|
|
|
DWORD lenA;
|
|
|
|
char *strA;
|
|
|
|
|
2022-04-28 09:22:40 +00:00
|
|
|
lenA = WideCharToMultiByte(GetOEMCP(), 0, str, len, NULL, 0, NULL, NULL);
|
2015-06-23 11:27:23 +00:00
|
|
|
strA = HeapAlloc(GetProcessHeap(), 0, lenA);
|
|
|
|
if (strA)
|
|
|
|
{
|
2022-04-28 09:22:40 +00:00
|
|
|
WideCharToMultiByte(GetOEMCP(), 0, str, len, strA, lenA, NULL, NULL);
|
2015-06-23 11:27:23 +00:00
|
|
|
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), strA, lenA, &nOut, FALSE);
|
|
|
|
HeapFree(GetProcessHeap(), 0, strA);
|
|
|
|
}
|
|
|
|
}
|
2014-03-19 00:54:57 +00:00
|
|
|
LocalFree(str);
|
2002-04-29 23:47:39 +00:00
|
|
|
}
|
|
|
|
|
2019-10-18 20:46:34 +00:00
|
|
|
static LPCWSTR find_arg_start(LPCWSTR cmdline)
|
|
|
|
{
|
|
|
|
LPCWSTR s;
|
|
|
|
BOOL in_quotes;
|
|
|
|
int bcount;
|
|
|
|
|
|
|
|
bcount=0;
|
|
|
|
in_quotes=FALSE;
|
|
|
|
s=cmdline;
|
|
|
|
while (1) {
|
|
|
|
if (*s==0 || ((*s=='\t' || *s==' ') && !in_quotes)) {
|
|
|
|
/* end of this command line argument */
|
|
|
|
break;
|
|
|
|
} else if (*s=='\\') {
|
|
|
|
/* '\', count them */
|
|
|
|
bcount++;
|
|
|
|
} else if ((*s=='"') && ((bcount & 1)==0)) {
|
|
|
|
/* unescaped '"' */
|
|
|
|
in_quotes=!in_quotes;
|
|
|
|
bcount=0;
|
|
|
|
} else {
|
|
|
|
/* a regular character */
|
|
|
|
bcount=0;
|
|
|
|
}
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2021-04-29 15:09:06 +00:00
|
|
|
static void reexec_self( WORD machine )
|
2019-10-18 20:46:34 +00:00
|
|
|
{
|
2021-04-29 15:09:06 +00:00
|
|
|
WCHAR app[MAX_PATH];
|
2019-10-18 20:46:34 +00:00
|
|
|
LPCWSTR args;
|
|
|
|
WCHAR *cmdline;
|
2021-04-29 15:09:06 +00:00
|
|
|
ULONG i, machines[8];
|
|
|
|
HANDLE process = 0;
|
2019-10-18 20:46:34 +00:00
|
|
|
STARTUPINFOW si = {0};
|
|
|
|
PROCESS_INFORMATION pi;
|
2021-04-29 15:09:06 +00:00
|
|
|
void *cookie;
|
2019-10-18 20:46:34 +00:00
|
|
|
|
2021-04-29 15:09:06 +00:00
|
|
|
NtQuerySystemInformationEx( SystemSupportedProcessorArchitectures, &process, sizeof(process),
|
|
|
|
machines, sizeof(machines), NULL );
|
|
|
|
for (i = 0; machines[i]; i++) if (LOWORD(machines[i]) == machine) break;
|
|
|
|
if (!machines[i]) return;
|
|
|
|
if (HIWORD(machines[i]) & 4 /* native machine */) machine = IMAGE_FILE_MACHINE_TARGET_HOST;
|
|
|
|
if (!GetSystemWow64Directory2W( app, MAX_PATH, machine )) return;
|
|
|
|
wcscat( app, L"\\regsvr32.exe" );
|
2019-10-18 20:46:34 +00:00
|
|
|
|
2021-04-29 15:09:06 +00:00
|
|
|
TRACE( "restarting as %s\n", debugstr_w(app) );
|
2019-10-18 20:46:34 +00:00
|
|
|
|
|
|
|
args = find_arg_start(GetCommandLineW());
|
|
|
|
|
|
|
|
cmdline = HeapAlloc(GetProcessHeap(), 0,
|
2021-04-29 15:09:06 +00:00
|
|
|
(wcslen(app)+wcslen(args)+1)*sizeof(WCHAR));
|
2019-10-18 20:46:34 +00:00
|
|
|
|
2021-04-29 15:09:06 +00:00
|
|
|
wcscpy(cmdline, app);
|
2019-10-18 20:46:34 +00:00
|
|
|
wcscat(cmdline, args);
|
|
|
|
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
|
2021-04-29 15:09:06 +00:00
|
|
|
Wow64DisableWow64FsRedirection(&cookie);
|
|
|
|
if (CreateProcessW(app, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
2019-10-18 20:46:34 +00:00
|
|
|
{
|
|
|
|
DWORD exit_code;
|
|
|
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
|
|
|
GetExitCodeProcess(pi.hProcess, &exit_code);
|
|
|
|
ExitProcess(exit_code);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-04 08:57:36 +00:00
|
|
|
WINE_TRACE("failed to restart, err=%ld\n", GetLastError());
|
2019-10-18 20:46:34 +00:00
|
|
|
}
|
2021-04-29 15:09:06 +00:00
|
|
|
Wow64RevertWow64FsRedirection(cookie);
|
2019-10-18 20:46:34 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, cmdline);
|
|
|
|
}
|
|
|
|
|
2002-04-29 23:47:39 +00:00
|
|
|
/**
|
|
|
|
* Loads procedure.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* strDll - name of the dll.
|
2015-06-26 10:04:22 +00:00
|
|
|
* procName - name of the procedure to load from the dll.
|
|
|
|
* DllHandle - a variable that receives the handle of the loaded dll.
|
2019-10-18 20:46:34 +00:00
|
|
|
* firstDll - true if this is the first dll in the command line.
|
2002-04-29 23:47:39 +00:00
|
|
|
*/
|
2019-10-18 20:46:34 +00:00
|
|
|
static VOID *LoadProc(const WCHAR* strDll, const char* procName, HMODULE* DllHandle, BOOL firstDll)
|
2002-04-29 23:47:39 +00:00
|
|
|
{
|
|
|
|
VOID* (*proc)(void);
|
|
|
|
|
2015-06-23 11:27:22 +00:00
|
|
|
*DllHandle = LoadLibraryExW(strDll, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
|
2002-04-29 23:47:39 +00:00
|
|
|
if(!*DllHandle)
|
|
|
|
{
|
2021-04-06 10:01:15 +00:00
|
|
|
HMODULE module;
|
2019-10-18 20:46:34 +00:00
|
|
|
if (firstDll && GetLastError() == ERROR_BAD_EXE_FORMAT &&
|
2021-04-06 10:01:15 +00:00
|
|
|
(module = LoadLibraryExW(strDll, 0, LOAD_LIBRARY_AS_IMAGE_RESOURCE)))
|
2019-10-18 20:46:34 +00:00
|
|
|
{
|
2021-04-06 10:01:15 +00:00
|
|
|
IMAGE_NT_HEADERS *nt = RtlImageNtHeader( (HMODULE)((ULONG_PTR)module & ~3) );
|
2021-04-29 15:09:06 +00:00
|
|
|
reexec_self( nt->FileHeader.Machine );
|
2019-10-18 20:46:34 +00:00
|
|
|
}
|
2014-03-19 01:03:49 +00:00
|
|
|
output_write(STRING_DLL_LOAD_FAILED, strDll);
|
2015-09-02 11:12:27 +00:00
|
|
|
ExitProcess(LOADLIBRARY_FAILED);
|
2002-04-29 23:47:39 +00:00
|
|
|
}
|
|
|
|
proc = (VOID *) GetProcAddress(*DllHandle, procName);
|
|
|
|
if(!proc)
|
|
|
|
{
|
2014-03-19 01:03:49 +00:00
|
|
|
output_write(STRING_PROC_NOT_IMPLEMENTED, procName, strDll);
|
2002-04-29 23:47:39 +00:00
|
|
|
FreeLibrary(*DllHandle);
|
2010-05-02 06:24:40 +00:00
|
|
|
return NULL;
|
2002-04-29 23:47:39 +00:00
|
|
|
}
|
|
|
|
return proc;
|
|
|
|
}
|
|
|
|
|
2019-10-18 20:46:34 +00:00
|
|
|
static int RegisterDll(const WCHAR* strDll, BOOL firstDll)
|
2002-04-29 23:47:39 +00:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DLLREGISTER pfRegister;
|
|
|
|
HMODULE DllHandle = NULL;
|
|
|
|
|
2019-10-18 20:46:34 +00:00
|
|
|
pfRegister = LoadProc(strDll, "DllRegisterServer", &DllHandle, firstDll);
|
2010-05-02 06:24:40 +00:00
|
|
|
if (!pfRegister)
|
2015-09-02 11:12:26 +00:00
|
|
|
return GETPROCADDRESS_FAILED;
|
2002-04-29 23:47:39 +00:00
|
|
|
|
|
|
|
hr = pfRegister();
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2014-03-19 01:03:49 +00:00
|
|
|
output_write(STRING_REGISTER_FAILED, strDll);
|
2015-09-03 09:29:42 +00:00
|
|
|
return DLLSERVER_FAILED;
|
2002-04-29 23:47:39 +00:00
|
|
|
}
|
2014-03-19 01:03:49 +00:00
|
|
|
output_write(STRING_REGISTER_SUCCESSFUL, strDll);
|
2002-04-29 23:47:39 +00:00
|
|
|
|
|
|
|
if(DllHandle)
|
|
|
|
FreeLibrary(DllHandle);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-18 20:46:34 +00:00
|
|
|
static int UnregisterDll(const WCHAR* strDll, BOOL firstDll)
|
2002-04-29 23:47:39 +00:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DLLUNREGISTER pfUnregister;
|
|
|
|
HMODULE DllHandle = NULL;
|
|
|
|
|
2019-10-18 20:46:34 +00:00
|
|
|
pfUnregister = LoadProc(strDll, "DllUnregisterServer", &DllHandle, firstDll);
|
2010-05-02 06:24:40 +00:00
|
|
|
if (!pfUnregister)
|
2015-09-02 11:12:26 +00:00
|
|
|
return GETPROCADDRESS_FAILED;
|
2010-05-02 06:24:40 +00:00
|
|
|
|
2002-04-29 23:47:39 +00:00
|
|
|
hr = pfUnregister();
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2014-03-19 01:03:49 +00:00
|
|
|
output_write(STRING_UNREGISTER_FAILED, strDll);
|
2015-09-03 09:29:42 +00:00
|
|
|
return DLLSERVER_FAILED;
|
2002-04-29 23:47:39 +00:00
|
|
|
}
|
2014-03-19 01:03:49 +00:00
|
|
|
output_write(STRING_UNREGISTER_SUCCESSFUL, strDll);
|
2002-04-29 23:47:39 +00:00
|
|
|
|
|
|
|
if(DllHandle)
|
|
|
|
FreeLibrary(DllHandle);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-18 20:46:34 +00:00
|
|
|
static int InstallDll(BOOL install, const WCHAR *strDll, const WCHAR *command_line, BOOL firstDll)
|
2002-04-29 23:47:39 +00:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DLLINSTALL pfInstall;
|
|
|
|
HMODULE DllHandle = NULL;
|
|
|
|
|
2019-10-18 20:46:34 +00:00
|
|
|
pfInstall = LoadProc(strDll, "DllInstall", &DllHandle, firstDll);
|
2010-05-02 06:24:40 +00:00
|
|
|
if (!pfInstall)
|
2015-09-02 11:12:26 +00:00
|
|
|
return GETPROCADDRESS_FAILED;
|
2010-05-02 06:24:40 +00:00
|
|
|
|
2002-04-29 23:47:39 +00:00
|
|
|
hr = pfInstall(install, command_line);
|
|
|
|
if(FAILED(hr))
|
2014-03-19 00:54:57 +00:00
|
|
|
{
|
|
|
|
if (install)
|
2014-03-19 01:03:49 +00:00
|
|
|
output_write(STRING_INSTALL_FAILED, strDll);
|
2014-03-19 00:54:57 +00:00
|
|
|
else
|
2014-03-19 01:03:49 +00:00
|
|
|
output_write(STRING_UNINSTALL_FAILED, strDll);
|
2015-09-03 09:29:42 +00:00
|
|
|
return DLLSERVER_FAILED;
|
2014-03-19 00:54:57 +00:00
|
|
|
}
|
2014-03-19 01:03:49 +00:00
|
|
|
if (install)
|
|
|
|
output_write(STRING_INSTALL_SUCCESSFUL, strDll);
|
|
|
|
else
|
|
|
|
output_write(STRING_UNINSTALL_SUCCESSFUL, strDll);
|
2002-04-29 23:47:39 +00:00
|
|
|
|
|
|
|
if(DllHandle)
|
|
|
|
FreeLibrary(DllHandle);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-23 11:27:22 +00:00
|
|
|
static WCHAR *parse_command_line(WCHAR *command_line)
|
2015-06-15 11:46:06 +00:00
|
|
|
{
|
|
|
|
if (command_line[0] == ':' && command_line[1])
|
|
|
|
{
|
2019-04-29 08:51:01 +00:00
|
|
|
int len = lstrlenW(command_line);
|
2015-06-15 11:46:06 +00:00
|
|
|
|
|
|
|
command_line++;
|
|
|
|
len--;
|
|
|
|
/* remove double quotes */
|
|
|
|
if (command_line[0] == '"')
|
|
|
|
{
|
|
|
|
command_line++;
|
|
|
|
len--;
|
|
|
|
if (command_line[0])
|
|
|
|
{
|
|
|
|
len--;
|
|
|
|
command_line[len] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (command_line[0])
|
2015-06-23 11:27:22 +00:00
|
|
|
return command_line;
|
2015-06-15 11:46:06 +00:00
|
|
|
}
|
2015-06-23 11:27:22 +00:00
|
|
|
return NULL;
|
2015-06-15 11:46:06 +00:00
|
|
|
}
|
|
|
|
|
2019-10-17 15:05:47 +00:00
|
|
|
int __cdecl wmain(int argc, WCHAR* argv[])
|
2002-04-29 23:47:39 +00:00
|
|
|
{
|
2015-09-09 10:43:52 +00:00
|
|
|
int i, res, ret = 0;
|
2002-04-29 23:47:39 +00:00
|
|
|
BOOL CallRegister = TRUE;
|
|
|
|
BOOL CallInstall = FALSE;
|
|
|
|
BOOL Unregister = FALSE;
|
|
|
|
BOOL DllFound = FALSE;
|
|
|
|
WCHAR* wsCommandLine = NULL;
|
2020-12-02 23:32:50 +00:00
|
|
|
WCHAR EmptyLine[] = L"";
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2006-02-09 16:48:12 +00:00
|
|
|
OleInitialize(NULL);
|
2002-04-29 23:47:39 +00:00
|
|
|
|
2015-08-31 09:51:44 +00:00
|
|
|
/* We mirror the Microsoft version by processing all of the flags before
|
2014-03-19 00:54:57 +00:00
|
|
|
* the files (e.g. regsvr32 file1 /s file2 is silent even for file1).
|
2015-06-26 10:04:22 +00:00
|
|
|
*
|
|
|
|
* Note the complication that this version may be passed Unix format filenames
|
|
|
|
* which could be mistaken for flags. The Windows version conveniently
|
|
|
|
* requires each flag to be separate (e.g. no /su), so we will simply
|
|
|
|
* assume that anything longer than /. is a filename.
|
2002-07-20 18:54:03 +00:00
|
|
|
*/
|
2002-04-29 23:47:39 +00:00
|
|
|
for(i = 1; i < argc; i++)
|
|
|
|
{
|
2015-09-03 11:29:23 +00:00
|
|
|
if (argv[i][0] == '/' || argv[i][0] == '-')
|
2015-06-15 12:12:45 +00:00
|
|
|
{
|
2015-09-03 11:29:23 +00:00
|
|
|
if (!argv[i][1])
|
|
|
|
return INVALID_ARG;
|
|
|
|
|
|
|
|
if (argv[i][2] && argv[i][2] != ':')
|
|
|
|
continue;
|
|
|
|
|
2019-04-29 08:51:01 +00:00
|
|
|
switch (towlower(argv[i][1]))
|
2015-06-15 12:12:45 +00:00
|
|
|
{
|
|
|
|
case 'u':
|
2002-04-29 23:47:39 +00:00
|
|
|
Unregister = TRUE;
|
2015-06-15 12:12:45 +00:00
|
|
|
break;
|
|
|
|
case 's':
|
2013-11-05 00:06:04 +00:00
|
|
|
Silent = TRUE;
|
2015-06-15 12:12:45 +00:00
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
CallInstall = TRUE;
|
2015-06-23 11:27:22 +00:00
|
|
|
wsCommandLine = parse_command_line(argv[i] + 2); /* argv[i] + strlen("/i") */
|
2015-06-15 12:12:45 +00:00
|
|
|
if (!wsCommandLine)
|
|
|
|
wsCommandLine = EmptyLine;
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
CallRegister = FALSE;
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
/* console output */;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
output_write(STRING_UNRECOGNIZED_SWITCH, argv[i]);
|
|
|
|
output_write(STRING_USAGE);
|
2015-09-02 11:12:28 +00:00
|
|
|
return INVALID_ARG;
|
2015-06-15 12:12:45 +00:00
|
|
|
}
|
2015-08-31 09:51:44 +00:00
|
|
|
argv[i] = NULL;
|
2014-03-19 00:54:57 +00:00
|
|
|
}
|
2015-08-31 09:51:44 +00:00
|
|
|
}
|
|
|
|
|
2015-09-02 05:32:07 +00:00
|
|
|
if (!CallInstall && !CallRegister) /* flags: /n or /u /n */
|
2015-09-02 11:12:28 +00:00
|
|
|
return INVALID_ARG;
|
2015-09-02 05:32:07 +00:00
|
|
|
|
2015-08-31 09:51:44 +00:00
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
if (argv[i])
|
2002-04-29 23:47:39 +00:00
|
|
|
{
|
2015-06-23 11:27:22 +00:00
|
|
|
WCHAR *DllName = argv[i];
|
2019-10-18 20:46:34 +00:00
|
|
|
BOOL firstDll = !DllFound;
|
2015-09-09 10:43:52 +00:00
|
|
|
res = 0;
|
2002-04-29 23:47:39 +00:00
|
|
|
|
|
|
|
DllFound = TRUE;
|
2015-09-07 10:08:10 +00:00
|
|
|
if (CallInstall && Unregister)
|
2019-10-18 20:46:34 +00:00
|
|
|
res = InstallDll(!Unregister, DllName, wsCommandLine, firstDll);
|
2015-09-07 10:08:10 +00:00
|
|
|
|
2015-09-07 10:38:04 +00:00
|
|
|
/* The Windows version stops processing the current file on the first error. */
|
2015-09-07 10:08:10 +00:00
|
|
|
if (res)
|
2015-09-09 10:43:52 +00:00
|
|
|
{
|
|
|
|
ret = res;
|
2015-09-07 10:38:04 +00:00
|
|
|
continue;
|
2015-09-09 10:43:52 +00:00
|
|
|
}
|
2015-09-07 10:08:10 +00:00
|
|
|
|
2015-10-13 10:35:39 +00:00
|
|
|
if (!CallInstall || CallRegister)
|
2002-04-29 23:47:39 +00:00
|
|
|
{
|
|
|
|
if(Unregister)
|
2019-10-18 20:46:34 +00:00
|
|
|
res = UnregisterDll(DllName, firstDll);
|
2002-04-29 23:47:39 +00:00
|
|
|
else
|
2019-10-18 20:46:34 +00:00
|
|
|
res = RegisterDll(DllName, firstDll);
|
2002-04-29 23:47:39 +00:00
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2002-04-29 23:47:39 +00:00
|
|
|
if (res)
|
2015-09-09 10:43:52 +00:00
|
|
|
{
|
|
|
|
ret = res;
|
2015-09-07 10:38:04 +00:00
|
|
|
continue;
|
2015-09-09 10:43:52 +00:00
|
|
|
}
|
2002-04-29 23:47:39 +00:00
|
|
|
|
2015-09-07 10:08:10 +00:00
|
|
|
if (CallInstall && !Unregister)
|
2019-10-18 20:46:34 +00:00
|
|
|
res = InstallDll(!Unregister, DllName, wsCommandLine, firstDll);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2002-07-20 18:54:03 +00:00
|
|
|
if (res)
|
2015-09-09 10:43:52 +00:00
|
|
|
{
|
|
|
|
ret = res;
|
2015-09-07 10:38:04 +00:00
|
|
|
continue;
|
2015-09-09 10:43:52 +00:00
|
|
|
}
|
2002-04-29 23:47:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!DllFound)
|
|
|
|
{
|
2014-03-19 01:03:49 +00:00
|
|
|
output_write(STRING_HEADER);
|
|
|
|
output_write(STRING_USAGE);
|
2015-09-02 11:12:28 +00:00
|
|
|
return INVALID_ARG;
|
2002-04-29 23:47:39 +00:00
|
|
|
}
|
|
|
|
|
2006-02-09 16:48:12 +00:00
|
|
|
OleUninitialize();
|
|
|
|
|
2015-09-09 10:43:52 +00:00
|
|
|
/* return the most recent error code, even if later DLLs succeed */
|
|
|
|
return ret;
|
2002-04-29 23:47:39 +00:00
|
|
|
}
|