Implemented regsvr32 tool. Based on ReactOS implementation.
diff --git a/configure b/configure
index f1c9499..c45ffef 100755
--- a/configure
+++ b/configure
@@ -12398,7 +12398,7 @@
MAKE_PROG_RULES=programs/Makeprog.rules
-ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules programs/Makeprog.rules Makefile controls/Makefile debugger/Makefile dlls/Makefile dlls/advapi32/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/gdi/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msg711/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/netapi32/Makefile dlls/ntdll/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/user/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile files/Makefile graphics/Makefile graphics/x11drv/Makefile if1632/Makefile include/Makefile library/Makefile libtest/Makefile loader/Makefile loader/ne/Makefile memory/Makefile misc/Makefile miscemu/Makefile msdos/Makefile objects/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regedit/Makefile programs/regtest/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winemine/Makefile programs/winetest/Makefile programs/winhelp/Makefile programs/winver/Makefile relay32/Makefile scheduler/Makefile server/Makefile tools/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wrc/Makefile tsx11/Makefile unicode/Makefile win32/Makefile windows/Makefile windows/x11drv/Makefile"
+ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules programs/Makeprog.rules Makefile controls/Makefile debugger/Makefile dlls/Makefile dlls/advapi32/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/gdi/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msg711/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/netapi32/Makefile dlls/ntdll/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/user/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile files/Makefile graphics/Makefile graphics/x11drv/Makefile if1632/Makefile include/Makefile library/Makefile libtest/Makefile loader/Makefile loader/ne/Makefile memory/Makefile misc/Makefile miscemu/Makefile msdos/Makefile objects/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/regtest/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winemine/Makefile programs/winetest/Makefile programs/winhelp/Makefile programs/winver/Makefile relay32/Makefile scheduler/Makefile server/Makefile tools/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wrc/Makefile tsx11/Makefile unicode/Makefile win32/Makefile windows/Makefile windows/x11drv/Makefile"
cat >confcache <<\_ACEOF
@@ -12996,6 +12996,7 @@
"programs/progman/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/progman/Makefile" ;;
"programs/regapi/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/regapi/Makefile" ;;
"programs/regedit/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/regedit/Makefile" ;;
+ "programs/regsvr32/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/regsvr32/Makefile" ;;
"programs/regtest/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/regtest/Makefile" ;;
"programs/uninstaller/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/uninstaller/Makefile" ;;
"programs/view/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/view/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index 9350ee8..c58f980 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1363,6 +1363,7 @@
programs/progman/Makefile
programs/regapi/Makefile
programs/regedit/Makefile
+programs/regsvr32/Makefile
programs/regtest/Makefile
programs/uninstaller/Makefile
programs/view/Makefile
diff --git a/programs/Makefile.in b/programs/Makefile.in
index fb12ead..1eae129 100644
--- a/programs/Makefile.in
+++ b/programs/Makefile.in
@@ -14,6 +14,7 @@
progman \
regapi \
regedit \
+ regsvr32 \
regtest \
uninstaller \
view \
diff --git a/programs/regsvr32/.cvsignore b/programs/regsvr32/.cvsignore
new file mode 100644
index 0000000..07ce01a
--- /dev/null
+++ b/programs/regsvr32/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+regsvr32.spec.c
diff --git a/programs/regsvr32/Makefile.in b/programs/regsvr32/Makefile.in
new file mode 100644
index 0000000..21364d6
--- /dev/null
+++ b/programs/regsvr32/Makefile.in
@@ -0,0 +1,13 @@
+EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+MODULE = regsvr32
+
+C_SRCS = \
+ regsvr32.c
+
+@MAKE_PROG_RULES@
+
+### Dependencies:
diff --git a/programs/regsvr32/regsvr32.c b/programs/regsvr32/regsvr32.c
new file mode 100644
index 0000000..587e6fb
--- /dev/null
+++ b/programs/regsvr32/regsvr32.c
@@ -0,0 +1,261 @@
+/*
+ * PURPOSE: Register an OLE component in the registry
+ *
+ * Copyright 2001 ReactOS project
+ * Copyright 2001 Jurgen Van Gael [jurgen.vangael@student.kuleuven.ac.be]
+ * Copyright 2002 Andriy Palamarchuk
+ *
+ * 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
+ */
+
+/*
+ *
+ * regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname
+ * [/u] unregister server
+ * [/s] silent (no message boxes)
+ * [/i] Call DllInstall passing it an optional [cmdline];
+ * when used with /u calls dll uninstall.
+ * [/n] Do not call DllRegisterServer; this option must be used with [/i]
+ */
+
+/**
+ * FIXME - currently receives command-line parameters in ASCII only and later
+ * converts to Unicode. Ideally the function should have wWinMain etry point
+ * and then work in Unicode only, but it seems Wine does not have necessary
+ * support.
+ */
+
+#include <stdio.h>
+#include <windows.h>
+
+typedef HRESULT (*DLLREGISTER) (void);
+typedef HRESULT (*DLLUNREGISTER) (void);
+typedef HRESULT (*DLLINSTALL) (BOOL,LPCWSTR);
+
+int Silent = 0;
+
+int Usage()
+{
+ printf("regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname\n");
+ printf("\t[/u] unregister server\n");
+ printf("\t[/s] silent (no message boxes)\n");
+ printf("\t[/i] Call DllInstall passing it an optional [cmdline];\n");
+ printf("\t when used with /u calls dll uninstall\n");
+ printf("\t[/n] Do not call DllRegisterServer; this option "
+ "must be used with [/i]\n");
+ return 0;
+}
+
+/**
+ * Loads procedure.
+ *
+ * Parameters:
+ * strDll - name of the dll.
+ * procName - name of the procedure to load from dll
+ * pDllHanlde - output variable receives handle of the loaded dll.
+ */
+VOID *LoadProc(char* strDll, char* procName, HMODULE* DllHandle)
+{
+ VOID* (*proc)(void);
+
+ *DllHandle = LoadLibrary(strDll);
+ if(!*DllHandle)
+ {
+ if(!Silent)
+ printf("Dll %s not found\n", strDll);
+
+ exit(-1);
+ }
+ proc = (VOID *) GetProcAddress(*DllHandle, procName);
+ if(!proc)
+ {
+ if(!Silent)
+ printf("%s not implemented in dll %s\n", procName, strDll);
+ FreeLibrary(*DllHandle);
+ exit(-1);
+ }
+ return proc;
+}
+
+int RegisterDll(char* strDll)
+{
+ HRESULT hr;
+ DLLREGISTER pfRegister;
+ HMODULE DllHandle = NULL;
+
+ pfRegister = LoadProc(strDll, "DllRegisterServer", &DllHandle);
+
+ hr = pfRegister();
+ if(FAILED(hr))
+ {
+ if(!Silent)
+ printf("Failed to register dll %s\n", strDll);
+
+ return -1;
+ }
+ if(!Silent)
+ printf("Succesfully registered dll %s\n", strDll);
+
+ if(DllHandle)
+ FreeLibrary(DllHandle);
+ return 0;
+}
+
+int UnregisterDll(char* strDll)
+{
+ HRESULT hr;
+ DLLUNREGISTER pfUnregister;
+ HMODULE DllHandle = NULL;
+
+ pfUnregister = LoadProc(strDll, "DllUnregisterServer", &DllHandle);
+ hr = pfUnregister();
+ if(FAILED(hr))
+ {
+ if(!Silent)
+ printf("Failed to unregister dll %s\n", strDll);
+
+ return -1;
+ }
+ if(!Silent)
+ printf("Succesfully unregistered dll %s\n", strDll);
+
+ if(DllHandle)
+ FreeLibrary(DllHandle);
+ return 0;
+}
+
+int InstallDll(BOOL install, char *strDll, WCHAR *command_line)
+{
+ HRESULT hr;
+ DLLINSTALL pfInstall;
+ HMODULE DllHandle = NULL;
+
+ pfInstall = LoadProc(strDll, "DllInstall", &DllHandle);
+ hr = pfInstall(install, command_line);
+ if(FAILED(hr))
+ {
+ if(!Silent)
+ printf("Failed to %s dll %s\n", install ? "install" : "uninstall",
+ strDll);
+ return -1;
+ }
+ if(!Silent)
+ printf("Succesfully %s dll %s\n", install ? "installed" : "uninstalled",
+ strDll);
+
+ if(DllHandle)
+ FreeLibrary(DllHandle);
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+ int i;
+ BOOL CallRegister = TRUE;
+ BOOL CallInstall = FALSE;
+ BOOL Unregister = FALSE;
+ BOOL DllFound = FALSE;
+ WCHAR* wsCommandLine = NULL;
+ WCHAR EmptyLine[1] = {0};
+
+
+ for(i = 1; i < argc; i++)
+ {
+ if (!stricmp(argv[i], "/u"))
+ Unregister = TRUE;
+ else if (!stricmp(argv[i], "/s"))
+ Silent = 1;
+ else if (!strnicmp(argv[i], "/i", strlen("/i")))
+ {
+ CHAR* command_line = argv[i] + strlen("/i");
+
+ CallInstall = TRUE;
+ if (command_line[0] == ':' && command_line[1])
+ {
+ int len = strlen(command_line);
+
+ 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])
+ {
+ len = MultiByteToWideChar(CP_ACP, 0, command_line, -1,
+ NULL, 0);
+ wsCommandLine = HeapAlloc(GetProcessHeap(), 0,
+ len * sizeof(WCHAR));
+ if (wsCommandLine)
+ MultiByteToWideChar(CP_ACP, 0, command_line, -1,
+ wsCommandLine, len);
+ }
+ else
+ {
+ wsCommandLine = EmptyLine;
+ }
+ }
+ else
+ {
+ wsCommandLine = EmptyLine;
+ }
+ }
+ else if(!stricmp(argv[i], "/n"))
+ CallRegister = FALSE;
+ else if (argv[i][0] == '/' && (!argv[i][2] || argv[i][2] == ':'))
+ printf("Unrecognized switch %s\n", argv[i]);
+ else
+ {
+ char *DllName = argv[i];
+ int res = 0;
+
+ DllFound = TRUE;
+ if (!CallInstall || (CallInstall && CallRegister))
+ {
+ if(Unregister)
+ res = UnregisterDll(DllName);
+ else
+ res = RegisterDll(DllName);
+ }
+
+ if (res)
+ return res;
+
+ if (CallInstall)
+ {
+ res = InstallDll(!Unregister, DllName, wsCommandLine);
+ }
+
+ return res;
+ }
+ }
+
+ if (!DllFound)
+ {
+ if(!Silent)
+ return Usage();
+ else
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/programs/regsvr32/regsvr32.spec b/programs/regsvr32/regsvr32.spec
new file mode 100644
index 0000000..4296e9f
--- /dev/null
+++ b/programs/regsvr32/regsvr32.spec
@@ -0,0 +1,8 @@
+name regsvr32
+type win32
+mode cuiexe
+init main
+
+import msvcrt.dll
+import kernel32.dll
+import ntdll.dll