PRB: GPF When Spawn Windows-Based App w/ WinExec() in Win32s (121095)
The information in this article applies to:
- Microsoft Win32s 1.2
- Microsoft Win32s 1.1
- Microsoft Win32s 1.15
This article was previously published under Q121095 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.
Modification Type: | Major | Last Reviewed: | 3/16/2004 |
---|
Keywords: | KB121095 |
---|
|