Make cmdline writable (cmdline4)
Francois Gouget
fgouget at free.fr
Mon Sep 3 03:21:20 CDT 2001
CreateProcess may modify the command line that was passed as a
parameter. It does this not in the current process but in the child
process so that the caller may not realize it, but it may hit a snag if
the command line is not writable in the first place.
Changelog:
* loader/module.c
Copy the cmdline to make it writable in CreateProcess
Sample test program to add to the other cmdline tests:
--- cut here ---
#include <stdio.h>
#include <windows.h>
const char* cmdline="main a b";
int main(int argc,char** argv)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
int rc;
memset(&si,'\0',sizeof(si));
si.cb=sizeof(si);
rc=CreateProcess(NULL,cmdline,
NULL,NULL,FALSE,0,NULL,NULL,
&si,&pi);
printf("CreateProcess returned: %d error=%ld\n",rc,GetLastError());
WaitForSingleObject(pi.hProcess,INFINITE);
return 0;
}
--- cut here ---
--
Francois Gouget fgouget at free.fr http://fgouget.free.fr/
"Lotto: A tax on people who are bad at math." -- unknown
"Windows: Microsoft's tax on computer illiterates." -- WE7U
-------------- next part --------------
Index: loader/module.c
===================================================================
RCS file: /home/wine/wine/loader/module.c,v
retrieving revision 1.138
diff -u -r1.138 module.c
--- loader/module.c 2001/08/24 21:13:02 1.138
+++ loader/module.c 2001/09/03 07:09:05
@@ -1049,6 +1049,14 @@
if (!(tidy_cmdline = get_file_name( lpApplicationName, lpCommandLine, name, sizeof(name) )))
return FALSE;
+ if (tidy_cmdline==lpCommandLine)
+ {
+ /* Copy lpCommandLine to make it writable */
+ tidy_cmdline = HeapAlloc( GetProcessHeap(), 0, strlen(lpCommandLine)+1 );
+ if (!tidy_cmdline)
+ return FALSE;
+ strcpy(tidy_cmdline, lpCommandLine);
+ }
/* Warn if unsupported features are used */
More information about the wine-patches
mailing list