The MFC Message Map Checks tab support validation of function signatures for functions called by MFC message map processing.
This option is not relevant if using Visual Studio .Net or VC++ 7.0 or above.
The default settings are shown below:
Enabling message map stack corruption detection will check message map function parameter counts called in release mode and debug mode.
•Check MFC message maps for correct parameter passing enable the message map parameter checks (off by default)
If enabled, ensure you also choose the correct Visual C++ version from the list to ensure errors are reported correctly
When an error is detected, a dialog is displayed. An example is shown below. The example shows that a handler called OnMemoryerrorsMessagemaperror with 2 parameters was called when 0 were expected. If a file and line number for the function can be identified, they will be displayed.
If you choose Retry, an int 3 breakpoint instruction will be executed, causing the program to either stop in the debugger, or start the debugger if Just-In-Time debugging is enabled.
You may not be able to see the full callstack, and will need to step out 3 or 4 levels (out of SvlMemoryValidatorStub.dll) before the full callstack is displayed.
This option is not relevant if using Visual Studio .Net or VC++ 7.0 or above. In the test example application, the Message Map Error button in the Memory Errors menu will be disabled for builds with newer compilers
If you specify the wrong function signature (by specifying too many or too few parameters), the code will execute without error in Debug mode, but will crash with a corrupt stack in Release mode.
For example, a button handler would be specified in the message map as:-
BEGIN_MESSAGE_MAP(CtheDlg, CDialog)
//{{AFX_MSG_MAP(CtheDlg)
ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
The function prototype would be:
void OnButtonBrowse();
and the implementation would be
void CtheDlg::OnButtonBrowse()
{
// do stuff here
}
Consider if however, this was specified as:
void OnButtonBrowse(void *anArg);
void CtheDlg::OnButtonBrowse(void *anArg)
{
// do stuff here
}
A crash would happen with a corrupted stack after the function OnButtonBrowse executes. This is because the anArg argument is popped off the stack by the OnButtonBrowse() function, although the calling MFC message map dispatcher did not push the parameter onto the stack.
This causes very hard-to-identify "release only" bugs.
In debug mode, the error is still present, but the way MFC processes message maps means that in debug mode, this error does not result in a crash.
Collection: A lot of diagnostic information is collected and displayed on the diagnostic tab when attaching to a target program.
Some of this information is always sent to Memory Validator, but if you may not want to see it all.
•Enable diagnostic data collection displays all diagnostic information in the diagnostic tab (on by default)
Disassembly: When hooking functions, some functions cannot be hooked due to the object code that corresponds to the source code location.
•Send disassembly for failed hooks shows the disassembly for function lines that cannot be hooked (off by default)
Use caution when enabling this as it can increase startup time and memory usage.
Missing functions: If the wrong version of DbgHelp.dll is loaded certain functions will not be available.
•Display DbgHelp missing function warning dialog show a warning when some functions are not available (on by default)
Use caution when enabling this as it can increase startup time and memory usage.
To see the order in which the DbgHelp.dll process checks directories to find symbols, see the diagnostic tab with the filter set to DbgHelp debug.
Reset All - Resets all global settings, not just those on the current page.
Reset - Resets the settings on the current page.