PRB: GPF When Spawn Windows-Based App w/ WinExec() in Win32s

Last reviewed: November 28, 1994
Article ID: Q121095
The information in this article applies to:
  • Microsoft Win32s, versions 1.1, 1.15, and 1.2

SYMPTOMS

Win32-based applications running under Win32s can spawn both Windows-based and Win32-based applications by using either WinExec() or CreateProcess(). However, there is a case where spawning a Windows-based application with WinExec() does not work as expected and may cause a general protection (GP) fault.

CAUSE

There is a bug in the C start-up code that comes with Microsoft C version 6.0. If you spawn an application built with Microsoft C version 6.0 by calling LoadModule() with an explicit environment, the application does not run correctly. This is true whether the application was spawned from a Win32-based application or a Windows-based application. Win32s calls LoadModule() with an explicit environment when you spawn a Windows-based application with WinExec(). As a result, under Win32s version 1.1 and 1.15, WinExec() will report success, but the Windows-based application built with Microsoft C version 6.0 may cause a GP fault.

RESOLUTION

The best solution is to rebuild the application with another compiler package. However, because a number of Windows accessories (such as Notepad and Write) were built with Microsoft C version 6.0 and you cannot modify these applications, changes were introduced into Win32s version 1.2 to help you work around this problem. These changes are detailed in the More Information section below.

NOTE: Win32s uses a different mechanism to spawn Win32-based applications, so the problems discussed in this article do not occur when spawning Win32- based applications with WinExec().

MORE INFORMATION

In Win32s version 1.2, WinExec() does not pass the environment to the spawned application (child). The child receives the standard global environment strings. This allows the application to run, but the child does not receive the modified environment from the parent. This seemed to be a reasonable compromise, because most applications do not change the environment for the child. If an application must modify the child's environment, it can spawn the application using CreateProcess() and specify an explicit environment. However, if the child was built using Microsoft C version 6.0, it may cause a GP fault. In addition, if the parent exits, the child's environment becomes invalid. These three problems are not specific to Win32s and will happen with Windows-based applications as well.


Additional reference words: 1.00 1.15 1.20 GPF
KBCategory: kbprg kbprb
KBSubCategory: W32s


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 28, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.