Created
March 26, 2017 13:00
-
-
Save hackpascal/c35a056a7d185eba3a46a01aa4045215 to your computer and use it in GitHub Desktop.
获取进程的内存映射表
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() | |
{ | |
SYSTEM_INFO si; | |
GetSystemInfo(&si); | |
char *pMin = (char*)si.lpMinimumApplicationAddress; | |
char *pMax = (char*)si.lpMaximumApplicationAddress; | |
for (char* pAddress = pMin; pAddress<pMax; /*Empty*/) | |
{ | |
MEMORY_BASIC_INFORMATION mbi; | |
DWORD res = VirtualQuery(pAddress, &mbi, sizeof(mbi)); | |
if (res != sizeof(mbi)) | |
{ | |
cerr << "VirtualQuery failed!" << endl; | |
return -1; | |
} | |
if (mbi.State == MEM_COMMIT) | |
{ | |
DWORD base = (DWORD)mbi.BaseAddress; | |
cout << hex << showbase << base << " - " << base + mbi.RegionSize-1 << endl; | |
} | |
pAddress += mbi.RegionSize; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment