A report hook function, installed using _CrtSetReportHook, is called every time _CrtDbgReport generates a debug report. You can use it, among other things, for filtering reports to focus on specific types of allocations. A report hook function should have a prototype like the following:
int YourReportHook(int nRptType, char *szMsg, int *retVal);
The pointer that you pass to _CrtSetReportHook is of type _CRT_REPORT_HOOK, as defined in CRTDBG.H:
typedef int (__cdecl *_CRT_REPORT_HOOK)(int, char *, int *);
When the run-time library calls your hook function, the nRptType argument contains the category of the report (_CRT_WARN, _CRT_ERROR, or _CRT_ASSERT), szMsg contains a pointer to a fully assembled report message string, and retVal specifies the value that should be returned by _CrtDbgReport. If the hook handles the message in question completely, so that no further reporting is required, it should return FALSE. If it returns TRUE, then _CrtDbgReport will report the message in the normal way.