views:

17

answers:

1

Hello,

Can anyone tell me how to get using WinAPI functions memory allocated memory regions of some process? I want know for each region, start address, size and some other things like, protect type etc.

I can't find any WinAPI function to do it ;-(

Can anyone help me?

+3  A: 

There is code to brute force this using VirtualQueryEx here:

MEMORY_BASIC_INFORMATION    mbi;
/* Get maximum address range from system info */
GetSystemInfo(&si);
/* walk process addresses */
lpMem = 0;
while (lpMem < si.lpMaximumApplicationAddress) {
        VirtualQueryEx(...)
        /* increment lpMem to next region of memory */
        lpMem = (LPVOID)((DWORD)lpList->mbi.BaseAddress +
        (DWORD)lpList->mbi.RegionSize);
}
Steve Townsend
You don't have to use `GetSystemInfo`. Alternatively you may continue the loop until `VirtualQueryEx` "fails".
valdo
@valdo - thanks for this
Steve Townsend