Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

heapwalk (kernel32)
 
.
Summary
TODO - a short description

C# Signature:

[DllImport("kernel32.dll", SetLastError = true)]
static extern bool HeapWalk(IntPtr hHeap, ref PROCESS_HEAP_ENTRY lpEntry);

VB Signature:

Declare Function heapwalk Lib "kernel32.dll" (TODO) As TODO

User-Defined Types:

[Flags]

Flags

public enum PROCESS_HEAP_ENTRY_WFLAGS : ushort
{
    PROCESS_HEAP_ENTRY_BUSY = 0x0004,
    PROCESS_HEAP_ENTRY_DDESHARE = 0x0020,
    PROCESS_HEAP_ENTRY_MOVEABLE = 0x0010,
    PROCESS_HEAP_REGION = 0x0001,
    PROCESS_HEAP_UNCOMMITTED_RANGE = 0x0002,
}
[StructLayoutAttribute(LayoutKind.Explicit)]
public struct UNION_BLOCK
{
    [FieldOffset(0)]
    public STRUCT_BLOCK Block;

    [FieldOffset(0)]
    public STRUCT_REGION Region;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct STRUCT_BLOCK
{
    public IntPtr hMem;
    public uint dwReserved1_1;
    public uint dwReserved1_2;
    public uint dwReserved1_3;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct STRUCT_REGION
{
    public uint dwCommittedSize;
    public uint dwUnCommittedSize;
    public IntPtr lpFirstBlock;
    public IntPtr lpLastBlock;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct PROCESS_HEAP_ENTRY
{
    public IntPtr lpData;
    public uint cbData;
    public byte cbOverhead;
    public byte iRegionIndex;
    public PROCESS_HEAP_ENTRY_WFLAGS wFlags;
    public UNION_BLOCK UnionBlock;
}

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

PROCESS_HEAP_ENTRY h = new PROCESS_HEAP_ENTRY();
uint size = 0;
while(HeapWalk(heapHandle, ref h))
{
    if (h.wFlags == PROCESS_HEAP_ENTRY_WFLAGS.PROCESS_HEAP_ENTRY_BUSY)
    {
    size += h.cbData;
    }
}
Console.WriteLine("Size: " + size);

Documentation
heapwalk on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions