Win32 Memory Segment Addresses

Started by
0 comments, last by SiCrane 16 years ago
Hello, Can someone explain how a program can determine the base address and the length of its own various memory segments? In particular I'd like my program to determine the base address and length of the data segment, and any segment where static/global variables are stored. The motivation for this is that I have been working on a simple mark-sweep garbage collector, and currently it works when the roots are limited to local stack variables, but it obviously fails when the roots also include static/global variables. Any help would be appreciated. Thanks, Kranar
Advertisement
You probably want functions from the ImageHlp library. One way would be to use MapAndLoad() to fill a LOADED_IMAGE structure, use the FileHeader member to get at the image's header information and get the BaseOfData from the IMAGE_OPTIONAL_HEADER.

This topic is closed to new replies.

Advertisement