rundll32 utility

Alberto Massari alby at exln.com
Tue Nov 12 12:43:28 CST 2002


License: LGPL

Changelog:
    - added rundll32 utility

The patch creates a new directory (programs/rundll32); I hope I have 
generated it right...

Alberto
-------------- next part --------------
Index: configure
===================================================================
RCS file: /home/wine/wine/configure,v
retrieving revision 1.359
diff -u -r1.359 configure
--- configure	12 Nov 2002 02:22:24 -0000	1.359
+++ configure	12 Nov 2002 14:23:47 -0000
@@ -13547,7 +13547,7 @@
 MAKE_PROG_RULES=programs/Makeprog.rules
 
 
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/d3d8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/msvideo/msrle32/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/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/rpcrt4/tests/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/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/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile include/Makefile library/Makefile miscemu/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/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/winedbg/Makefile programs/winefile/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wpp/Makefile tools/wrc/Makefile unicode/Makefile"
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/d3d8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/msvideo/msrle32/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/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/rpcrt4/tests/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/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/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile include/Makefile library/Makefile miscemu/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/regtest/Makefile programs/rundll32/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wpp/Makefile tools/wrc/Makefile unicode/Makefile"
 
 
 cat >confcache <<\_ACEOF
@@ -14192,6 +14192,7 @@
   "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/rundll32/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/rundll32/Makefile" ;;
   "programs/uninstaller/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/uninstaller/Makefile" ;;
   "programs/view/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/view/Makefile" ;;
   "programs/wcmd/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/wcmd/Makefile" ;;

Index: Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/Makefile.in,v
retrieving revision 1.28
diff -u -r1.28 Makefile.in
--- Makefile.in	11 Nov 2002 22:20:47 -0000	1.28
+++ Makefile.in	12 Nov 2002 14:24:28 -0000
@@ -17,6 +17,7 @@
 	regedit \
 	regsvr32 \
 	regtest \
+	rundll32 \
 	uninstaller \
 	view \
 	wcmd \
@@ -38,6 +39,7 @@
 	progman \
 	regedit \
 	regsvr32 \
+	rundll32 \
 	uninstaller \
 	wcmd \
 	wineconsole \
@@ -55,6 +57,7 @@
 	progman \
 	regedit \
 	regsvr32 \
+	rundll32 \
 	uninstaller \
 	wcmd \
 	wineconsole \
--- /dev/null	Thu Aug 30 22:30:55 2001
+++ programs/rundll32/Makefile.in	Mon Nov 11 17:33:24 2002
@@ -0,0 +1,14 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = rundll32.exe
+APPMODE   = cui
+IMPORTS   = kernel32
+
+C_SRCS = \
+	rundll32.c
+
+ at MAKE_PROG_RULES@
+
+### Dependencies:
--- /dev/null	Thu Aug 30 22:30:55 2001
+++ programs/rundll32/rundll32.c	Tue Nov 12 11:34:36 2002
@@ -0,0 +1,128 @@
+/*
+ * PURPOSE: Load a DLL and run an entry point with the specified parameters
+ *
+ * Copyright 2002 Alberto Massari
+ *
+ * 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
+ *
+ * This version deliberately differs in error handling compared to the
+ * windows version.
+ */
+
+/*
+ *
+ *  rundll32 dllname,entrypoint [arguments]
+ * 
+ *  Documentation for this utility found on KB Q164787
+ *
+ */
+
+/**
+ * FIXME - currently receives command-line parameters in ASCII only and later
+ * converts to Unicode. Ideally the function should have wWinMain entry point
+ * and then work in Unicode only, but it seems Wine does not have necessary
+ * support.
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <windows.h>
+
+typedef void (*EntryPointW) (HWND hWnd, HINSTANCE hInst, LPWSTR lpszCmdLine, int nCmdShow);
+typedef void (*EntryPointA) (HWND hWnd, HINSTANCE hInst, LPSTR lpszCmdLine, int nCmdShow);
+
+/**
+ * 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)
+    {
+        exit(-1);
+    }
+    proc = (VOID *) GetProcAddress(*DllHandle, procName);
+    if(!proc)
+    {
+        FreeLibrary(*DllHandle);
+        return NULL;
+    }
+    return proc;
+}
+
+int main(int argc, char* argv[])
+{
+    char szDllName[MAX_PATH],szEntryPoint[64],szCmdLine[2048];
+    char* comma;
+    EntryPointW pfEntryPointW;
+    EntryPointA pfEntryPointA;
+    HMODULE DllHandle=NULL;
+
+    comma=strchr(argv[1],',');
+    if(comma==NULL)
+        return 0;
+    /* Extract the name of the DLL */
+    memset(szDllName,0,MAX_PATH);
+    strncpy(szDllName,argv[1],(comma-argv[1]));
+    /* Merge the other paramters into one big command line */
+    memset(szCmdLine,0,2048);
+    if(argc>2)
+    {
+        int i;
+        for(i=2;i<argc;i++)
+        {
+            strcat(szCmdLine,argv[i]);
+            if(i+1<argc) strcat(szCmdLine," ");
+        }
+    }
+
+    /* try loading the UNICODE version first */
+    strcpy(szEntryPoint,comma+1);
+    strcat(szEntryPoint,"W");
+    pfEntryPointW=LoadProc(szDllName, szEntryPoint, &DllHandle);
+    if(pfEntryPointW!=NULL)
+    {
+        WCHAR wszCmdLine[2048];
+        MultiByteToWideChar(CP_ACP,0,szCmdLine,-1,wszCmdLine,2048);
+        pfEntryPointW(NULL,DllHandle,wszCmdLine,SW_HIDE);
+    }
+    else
+    {
+        strcpy(szEntryPoint,comma+1);
+        strcat(szEntryPoint,"A");
+        pfEntryPointA=LoadProc(szDllName, szEntryPoint, &DllHandle);
+        if(pfEntryPointA==NULL)
+        {
+            strcpy(szEntryPoint,comma+1);
+            pfEntryPointA=LoadProc(szDllName, szEntryPoint, &DllHandle);
+            if(pfEntryPointA==NULL)
+                return 0;
+        }
+        pfEntryPointA(NULL,DllHandle,szCmdLine,SW_HIDE);
+    }
+    if(DllHandle)
+        FreeLibrary(DllHandle);
+    return 0;
+}


More information about the wine-patches mailing list