Debug Hook Function Writing

This topic applies to:


Visual Basic



Web Developer


Topic does not applyTopic does not apply

Native only

Topic does not apply

Pro, Premium, and Ultimate

Topic does not applyTopic does not apply

Native only

Topic does not apply

This section describes a number of custom debug hook functions you can write that allow you to insert your code into some predefined points inside the debugger's normal processing.

Client Block Hook Functions

Provides guidance and a prototype for writing functions that validate or report the contents of the data stored in _CLIENT_BLOCK blocks.

Allocation Hook Functions

Defines an allocation hook function, explores its different uses, points out restrictions, and provides a prototype.

Allocation Hooks and CRT Memory Allocations

Describes the restriction on allocation hook functions of explicitly ignoring _CRT_BLOCK blocks if they make any calls to C run-time library functions that allocate internal memory. This topic also lists the consequences if your allocation hook does not ignore _CRT_BLOCK blocks (with examples) and how to change the default allocation hook function, CrtDefaultAllocHook.

Report Hook Functions

Discusses _CrtSetReportHook, which you can use to filter reports to focus on specific types of allocations. This topic also provides a prototype.

CRT Debugging Techniques

Links to debugging techniques for the C Run-Time Library, including using the CRT Debug Library, macros for reporting, differences between malloc and _malloc_dbg, writing debug hook functions, and the CRT debug heap.

Community Additions