PRB: WOW System Hooks Limit Number of Concurrent MFC AppsLast reviewed: July 22, 1997Article ID: Q129429 |
1.00 1.50 1.51 1.52
WINDOWS
kbprg kbtshoot kbinterop kbprb
The information in this article applies to:
SYMPTOMSThere is a limit to the number of 16-bit MFC applications that can be run under the WOW subsystem of Windows at one time. You will see one of two symptoms depending on whether the application manifesting the problem is a release or debug build:
CAUSEMFC uses a WH_CALLWNDPROC hook during the creation of a window to connect a CWnd object to the window. If the hook cannot be set, the window is not properly added to MFC's permanent handle map. When the window receives a message, MFC attempts to retrieve a pointer to the corresponding CWnd object from the permanent handle map. Because the window is not in the map, a NULL pointer is retrieved. In release builds, the pointer is used, causing an access violation, which results in a GP fault. In debug builds, the pointer is trapped by the assertion. The WOW subsystem of Windows NT provides a limited number of system hooks. Windows NT version 3.1 has 16 hooks available. Windows NT version 3.5 has 32 hooks available. When the hooks are exhausted, an attempt to set a hook fails without reporting an error, so MFC is unable to detect that the hook was not set and recover gracefully. MFC applications are particularly susceptible to exhausting the available system hooks because they typically install two hooks (one for F1 help, the other for gray dialogs) at application startup. These two hooks last for the lifetime of the application. Applications that use the autosubclassing feature of CTL3D consume an additional hook.
RESOLUTIONTo run more 16-bit MFC applications under the WOW subsystem, you must reduce the number of hooks consumed by each application. The following are three common uses of hooks by MFC applications that you need to prevent if you want to execute more applications:
Removing the F1 Help HookThe F1 Help hook is installed whether or not your application uses F1 Help. If you do not support F1 help, you can remove this hook by following these steps:
Removing the Dialog Background Color HookThe Dialog Background Color hook is only installed if you call CWinApp::SetDialogBkColor(). AppWizard places a call to SetDialogBkColor() at the start of your CWinApp derived classes InitInstance() function. To remove the hook, remove this and all other calls to SetDialogBkColor() from your application. NOTE: If you are using the CTL3D library, it will paint the background of dialogs, so you do not need to call SetDialogBkColor().
Removing the CTL3D HookIf you are using the autosubclassing feature of CTL3D to add 3D effects to your application's controls and dialogs, a hook is used. You can still use CTL3D without consuming a hook if you explicitly subclass each dialog by using the Ctl3dSubclassDlgEx() function. See the CTL3D documentation for more information on how to explicitly subclass dialogs using CTL3D.
STATUSThis behavior is by design.
|
Additional reference words: 1.00 1.50 1.51 1.52 2.00 2.50 2.51 2.52 GPF
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |