exec quote patch

Marius Grigoriu <[email protected]>
Newsgroups gmane.comp.emulators.winex.devel
Message-ID <[email protected]>
When ShellExecute is used to run a program the command line should have 
quotes around the executable name to match what happens in Windows. Some 
programs like the Anarchy patcher depend on this when checking the 
command line. The patch performs some string manipulation to insert 
quotes in the proper places. I don't use the new string everywhere in 
ShellExecuteExA32 because I am not sure that it wont break other things. 
If not, then references to szApplicationName should be changed to 
szFinalCmdLine after the strcats and the redundant strcats removed. This 
patch is provided under the X11 license.

_______________________________________________
winex-devel mailing list
[email protected]
http://lists.transgaming.org/cgi-bin/mailman/listinfo/winex-devel
exec-quote.patch (text/plain, 1.3 KB)
Index: dlls/shell32/shlexec.c
===================================================================
RCS file: /cvsroot/winex/dlls/shell32/shlexec.c,v
retrieving revision 1.7
diff -u -r1.7 shlexec.c
--- dlls/shell32/shlexec.c	19 Dec 2003 04:01:19 -0000	1.7
+++ dlls/shell32/shlexec.c	23 Jan 2004 06:49:29 -0000
@@ -488,7 +488,7 @@
  */
 BOOL WINAPI ShellExecuteExA32 (LPSHELLEXECUTEINFOA sei, BOOL is32)
 {
-    CHAR szApplicationName[MAX_PATH],szCommandline[MAX_PATH],szPidl[20],fileName[MAX_PATH];
+    CHAR szFinalCmdLine[2*MAX_PATH], szApplicationName[MAX_PATH],szCommandline[MAX_PATH],szPidl[20],fileName[MAX_PATH];
     LPSTR pos;
     int gap, len;
     char lpstrProtocol[256];
@@ -583,12 +583,18 @@
 
     strcpy(fileName, szApplicationName);
     lpFile = fileName;
+	ZeroMemory(szFinalCmdLine, 2*MAX_PATH);
+	szFinalCmdLine[0] = '"';
+	strcat(szFinalCmdLine, szApplicationName);
+	strcat(szFinalCmdLine, "\"");
     if (szCommandline[0]) {
         strcat(szApplicationName, " ");
+        strcat(szFinalCmdLine, " ");
         strcat(szApplicationName, szCommandline);
+        strcat(szFinalCmdLine, szCommandline);
     }
 
-    retval = SHELL_ExecuteA(szApplicationName, sei, is32);
+    retval = SHELL_ExecuteA(szFinalCmdLine, sei, is32);
     if (retval > 32)
         return TRUE;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.