On Tue, Dec 1, 2009 at 11:58 AM, Bruce Bauman <bruce.bau...@andesaservices.com> wrote: > I’m trying to port/debug some ugly Pascal code. > > Is there a way I can tell if an arbitrary address is within the heap or > stack?
Without hooking/replacing the memory manager, I don't believe you can handle memory tracking this information. And even if you did hook replace the memory manager it would still fail in places where you interface with shared libraries that handle their own memory management. If don't mind using OS specific functions, Windows provides ways to query process memory base address range and memory querying (which returns the number of consecutive pages available for writing). For that look at GetSystemInfo for memory page information, OpenProcess with memory query flags (if you don't have the rights use AdjustTokenPrivileges), and VirtualQueryEx to find consecutive valid memory pages. I believe VirtualQueryEx works upon all process system memory (code/stack/heap). _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal