# HG changeset patch # Parent 830a4452f008bf467a58c4838a10840c16d34d2d diff --git a/fhandler_process.cc b/fhandler_process.cc --- a/fhandler_process.cc +++ b/fhandler_process.cc @@ -29,6 +29,7 @@ #include #include #include +#include #define _COMPILING_NEWLIB #include @@ -602,6 +603,51 @@ } }; +struct heap_info { + struct heap { + heap* next; + void* base; + }; + heap* heaps; + + heap_info (DWORD pid) + : heaps (0) + { + HANDLE hHeapSnap = CreateToolhelp32Snapshot (TH32CS_SNAPHEAPLIST, pid); + HEAPLIST32 hl; + hl.dwSize = sizeof(hl); + + if (hHeapSnap != INVALID_HANDLE_VALUE && Heap32ListFirst (hHeapSnap, &hl)) + do + { + heap* h = (heap*) cmalloc (HEAP_FHANDLER, sizeof (heap)); + *h = (heap) {heaps, (void*)hl.th32HeapID}; + heaps = h; + } while (Heap32ListNext (hHeapSnap, &hl)); + CloseHandle (hHeapSnap); + } + + char* fill_if_match (void* base, char* dest ) { + long count = 0; + for(heap* h = heaps; h && ++count; h = h->next) + if(base == h->base) + { + __small_sprintf (dest, "[heap %ld]", count); + return dest; + } + return 0; + } + + ~heap_info () { + heap* n = 0; + for (heap* m = heaps; m; m = n) + { + n = m->next; + cfree (m); + } + } +}; + static _off64_t format_process_maps (void *data, char *&destbuf) { @@ -628,6 +674,7 @@ MEMORY_BASIC_INFORMATION mb; dos_drive_mappings drive_maps; + heap_info heaps(p->dwProcessId); struct __stat64 st; long last_pass = 0; @@ -716,7 +763,8 @@ } else if (mb.Type & MEM_MAPPED) strcpy (posix_modname, "[shareable]"); - else + else if (!(mb.Type & MEM_PRIVATE + && heaps.fill_if_match (cur.abase, posix_modname))) posix_modname[0] = 0; } }