Microsoft KB Archive/199290

= PRB: Visual C++ 6.0 Compiled Unicode CreateProcess Access Violation =

PSS ID Number: 199290

Article Last Modified on 6/18/2001

-

The information in this article applies to:


 * Microsoft Visual Studio 6.0
 * Microsoft Visual C++, 32-bit Professional Edition 6.0
 * Microsoft Visual Basic Enterprise Edition for Windows 6.0

-



This article was previously published under Q199290



SYMPTOMS
The Unicode version of CreateProcess attempts to modify the lpCommandLine parameter, causing an access violation when compiled with Visual C++ 6.0 or other compilers that put string literals in read-only memory. For example, the following CreateProcess command line fails when compiled as Unicode with Visual C++ 6.0: CreateProcess(NULL,L"Cmd.exe",...) The ANSI version of CreateProcess API does not exhibit the problem because internally it makes a read/write Unicode copy of the lpCommandLine parameter, and passes that to CreateProcessW.



CAUSE
The cause of the problem is the default project setting include /ZI flag, which enables Edit and Continue debug information; this flag implies the /GF flag, which enables read-only string pooling.



RESOLUTION
It is possible to add the /Zi flag to your project options to eliminate the problem. This cancels the read-only access to the string pool, but still allows debug symbols to be generated.

However, a better alternative is to either use the ANSI version of the API, CreateProcessA, or pass your own read/write buffer with the Unicode command line into CreateProcess. Because this API does modify the buffer, it is better to remove any confusion by using your own buffer.



STATUS
This behavior is by design. See the documentation for CreateProcess.

