???????????????????????????????е???????????????????C++???????WinDbg??????????C++?????????洢????

??????????????????C++??????洢???? ?????????????????

#include <iostream>

using namespace  std;


const char* global_const_string = "hello world";
int global_int = 20;
static int global_static_int = 30;
int main()
{
static int local_static_int = 100;
int local_int = 200;
int* pValue = new int(300);
cout << global_const_string << global_int
<< global_static_int << local_static_int
<< local_int << *pValue;
delete pValue;
system("pause");
return 0;
}

??????????????????????????????????????????????е?????????????????????????????????????????new??????????????????η???????????????洢????

?????????????WinDbg???????????????????????consoleTest.exe.

?????????????????consoleTest.exe?????????????????????????????????address????

*   400000   401000     1000 MEM_IMAGE   MEM_COMMIT  PAGE_READONLY                      Image "ConsoleTest.exe"
|-  401000   41d000    1c000 MEM_IMAGE   MEM_COMMIT  PAGE_EXECUTE_READ                  Image "ConsoleTest.exe"
|-  41d000   422000     5000 MEM_IMAGE   MEM_COMMIT  PAGE_READONLY                      Image "ConsoleTest.exe"
|-  422000   426000     4000 MEM_IMAGE   MEM_COMMIT  PAGE_WRITECOPY                     Image "ConsoleTest.exe"
|-  426000   427000     1000 MEM_IMAGE   MEM_COMMIT  PAGE_READONLY                      Image "ConsoleTest.exe"

???????????consoleTest.exe?????????е?????????0x400000???????????????!dh 0x400000?????????????????????????????????ó?????????

??????? 400000 - 401000 : PE???????????????
??????? 401000 - 41d000 : .text?? ?????????????У?????????
??????? 41d000 -  422000 : .rdata?? ??????????? ??????????
??????? 422000 -  426000 : .data?? ??????д???????????????д????
??????? 426000 - 427000 : .rsrc?? ???????????????????

???????!address -f:stack????????????????

0:000> !address -f:stack
  BaseAddr EndAddr+1 RgnSize     Type       State                 Protect             Usage
-------------------------------------------------------------------------------------------
   40000   13d000    fd000 MEM_PRIVATE MEM_RESERVE                                    Stack [8b0.1d0; ~0]
  13d000   13e000     1000 MEM_PRIVATE MEM_COMMIT  PAGE_READWRITE|PAGE_GUARD          Stack [8b0.1d0; ~0]
  13e000   140000     2000 MEM_PRIVATE MEM_COMMIT  PAGE_READWRITE                     Stack [8b0.1d0; ~0]

????????????????????????????????13e000 - 140000

?????????????????????????????????洢???????x consoletest!global*????????????г???????consoletest?????global????????????

0:000> x consoletest!global*
00422000 ConsoleTest!global_const_string = 0x0041d1dc "hello world"
00422004 ConsoleTest!global_int = 0n20
00422008 ConsoleTest!global_static_int = 0n30
004238a0 ConsoleTest!global_locale = 0x00000000