Miscellaneous Heap Functions

In addition to the heap functions I’ve already mentioned, Windows offers several more. In this section, I’ll just briefly mention them.

The ToolHelp functions (mentioned at the end of Chapter 4) allow you to enumerate a process’ heaps as well as the allocations within those heaps. For more information, look up the following functions in the Platform SDK documentation: Heap32First, Heap32Next, Heap32ListFirst, and Heap32ListNext.

Because a process can have multiple heaps within its address space, the GetProcessHeaps function allows you to get the handles of the existing heaps:

DWORD GetProcessHeaps(
   DWORD dwNumHeaps,
   PHANDLE phHeaps);

To call GetProcessHeaps, you must first allocate an array of HANDLEs and then call the ...

Get Windows® via C/C++, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.