On Thu, 10 Jan 2002, Francois Gouget wrote:
On Thu, 10 Jan 2002, Uwe Bonnes wrote:
Hallo,
some application builds a commandline with arguments enclosed by quotes '"', starts a daughter process with this commandline and relies on the quotes being intact in the daughter process. Wine happily removed the quotes and so the daughter process failed. Appended patch keeps quotes intact, tested via CreateProcess and calling a programm from the shell. When invoking wine from the shell, quotes need to be escaped, like any other special characters.
No. Your patch mishandles quotes.
Hmm. If so, here's some stuff from the WineX tree (because SafeDisc needs the quotes to be preserved in the child process's command line), at least what's left of it after the last WineHQ merge. If it still works, is it better than Uwe's patch?
Gavriel State gav@transgaming.com Preserve exact command line - including quotes - used when creating a process. Certain copy-protection software expects this...
diff -u wine/scheduler/process.c:1.1.1.23 wine/scheduler/process.c:1.11 --- wine/scheduler/process.c:1.1.1.23 Mon Dec 31 02:52:36 2001 +++ wine/scheduler/process.c Mon Dec 31 08:07:18 2001 @@ -476,14 +476,34 @@
if (!main_exe_name[0]) { + char *argv_noquotes; + DWORD argv_len; + if (!app_argv[0]) OPTIONS_Usage();
- /* open the exe file */ - if (!SearchPathA( NULL, app_argv[0], ".exe", sizeof(main_exe_name), main_exe_name, NULL) && - !SearchPathA( NULL, app_argv[0], NULL, sizeof(main_exe_name), main_exe_name, NULL)) + /* Remove any quotes around the file name, without modifying argv[0] */ + argv_len = strlen(app_argv[0]); + if ((argv_noquotes = HeapAlloc( GetProcessHeap(), 0, argv_len+1 ))) { - MESSAGE( "%s: cannot find '%s'\n", argv0, app_argv[0] ); - goto error; + char *p = app_argv[0]; + char *q; + /* If there are quotes around the *full* argument only, remove them */ + if ((*p == '"') && (q = strchr( p + 1, '"' )) && (q == (p+argv_len-1))) + { + strncpy(argv_noquotes, p+1, argv_len-2); + argv_noquotes[argv_len-2] = 0; + } + else + strcpy(argv_noquotes, p); + + /* open the exe file */ + if (!SearchPathA( NULL, argv_noquotes, ".exe", sizeof(main_exe_name), main_exe_name, NULL ) && + !SearchPathA( NULL, argv_noquotes, NULL, sizeof(main_exe_name), main_exe_name, NULL )) + { + MESSAGE( "%s: cannot find '%s'\n", argv0, argv[0] ); + goto error; + } + HeapFree( GetProcessHeap(), 0, argv_noquotes); } }