AddSecureMemoryCacheCallback function (winbase.h)

Registers a callback function to be called when a secured memory range is freed or its protections are changed.


BOOL AddSecureMemoryCacheCallback(


[in] pfnCallBack

A pointer to the application-defined SecureMemoryCacheCallback function to register.

Return value

If the function succeeds, it registers the callback function and returns TRUE.

If the function fails, it returns FALSE. To get extended error information, call the GetLastError function.


An application that performs I/O directly to a high-performance device typically caches a virtual-to-physical memory mapping for the buffer it uses for the I/O. The device's driver typically secures this memory address range by calling the MmSecureVirtualMemory routine, which prevents the memory range from being freed or its protections changed until the driver unsecures the memory.

An application can use AddSecureMemoryCacheCallback to register a callback function that will be called when the memory is freed or its protections are changed, so the application can invalidate its cached memory mapping. For more information, see SecureMemoryCacheCallback.

To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or later. For more information, see Using the Windows Headers.


Minimum supported client Windows Vista with SP1 [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header winbase.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also