HeapWalk
The HeapWalk
function enumerates the memory blocks in a specified heap.
BOOL HeapWalk(
HANDLE hHeap, |
// handle to the
heap to enumerate |
LPPROCESS_HEAP_ENTRY lpEntry |
// points to
structure that maintains enumeration state information |
); |
|
Parameters
hHeap
Handle to the
heap whose memory blocks you wish to enumerate.
dwFlags
Points to a PROCESS_HEAP_ENTRY
If the HeapWalk
function succeeds, returning the value TRUE, this structure s members contain
information about the next memory block in the heap.
To initiate a
heap enumeration, set the lpData field of the PROCESS_HEAP_ENTRY structure
to NULL. To continue a particular heap enumeration, call the HeapWalk
function repeatedly, with no changes to hHeap, lpEntry, or any of
the members of the PROCESS_HEAP_ENTRY structure.
Return Values
If the
function succeeds, the return value is nonzero.
If the function
fails, the return value is zero. To get extended error information, call GetLastError
If the heap
enumeration terminates successfully by reaching the end of the heap, the
function returns FALSE, and GetLastError returns the error code ERROR_NO_MORE_ITEMS.
Remarks
To initiate a
heap enumeration, call HeapWalk with the lpData field of the PROCESS_HEAP_ENTRY
structure pointed to by lpEntry set to NULL.
To continue a
heap enumeration, call HeapWalk with the same hHeap and lpEntry
values, and with the PROCESS_HEAP_ENTRY structure unchanged from the
preceding call to HeapWalk. Repeat this process until you have no need
for further enumeration, or until the function returns FALSE and GetLastError
returns ERROR_NO_MORE_ITEMS, indicating that all of the heap s memory
blocks have been enumerated.
No special
call of HeapWalk is needed to terminate the heap enumeration, since no
enumeration state data is maintained outside the contents of the PROCESS_HEAP_ENTRY
structure.
HeapWalk can fail in a multithreaded application if the heap
is not locked during the heap enumeration. Use the HeapLock and HeapUnlock
functions to control heap locking during heap enumeration.
See Also