xp下用户程序空间分配(1):大致框架

快乐虾

http://blog.csdn.net/lights_joy/

[email protected]

本文适用于

Xp sp3

vs2008

欢迎转载,但请保留作者信息

windows核心编程》告诉我们,对于每个应用程序的4G虚拟空间可以分为4个大块:

0x0000 0000 ~ 0x0000 ffff:空指针赋值分区

0x0001 0000 ~ 0x7ffe ffff:用户模式分区

0x7fff 0000 ~ 0x7fff ffff64K禁入分区

0x8000 0000 ~ 0xffff ffff:内核模式分区

但是再要具体点就需要自己研究了。

咱就来看看一个应用程序是怎么使用这4G的空间的。先写段代码查询一下这4G空间中内存块的大致分类:

SYSTEM_INFO info;

MEMORY_BASIC_INFORMATION mi;

HANDLE hProcess;

DWORD dwAddr;

MEMORY_BASIC_INFORMATION miBlock[1000];

int nCount = 0;

hProcess = GetCurrentProcess();

GetSystemInfo(&info);

dwAddr = (DWORD)info.lpMinimumApplicationAddress;

do

{

VirtualQueryEx(hProcess, (LPCVOID)dwAddr, &mi, sizeof(mi));

memcpy(&miBlock[nCount++], &mi, sizeof(mi));

dwAddr += mi.RegionSize;

} while(dwAddr < (DWORD)info.lpMaximumApplicationAddress);

print_block_table(miBlock, nCount);

。。。。。。。。。。。。。

在这种方式下,将可以得到249个内存块,如下表所示(所有值均为十六进制):

基址

分配基址

分配保护

大小

状态

保护

类型

00010000

00010000

00000004
PAGE_READWRITE

00002000

00001000
MEM_COMMIT

00000004
PAGE_READWRITE

00020000
MEM_PRIVATE

00012000

00000000

00000000

0000e000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

00020000

00020000

00000004
PAGE_READWRITE

00001000

00001000
MEM_COMMIT

00000004
PAGE_READWRITE

00020000
MEM_PRIVATE

00021000

00000000

00000000

0000f000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

00030000

00030000

00000004
PAGE_READWRITE

000ed000

00002000
MEM_RESERVE

00000000

00020000
MEM_PRIVATE

0011d000

00030000

00000004
PAGE_READWRITE

00001000

00001000
MEM_COMMIT

00000104
PAGE_READWRITE
PAGE_GUARD

00020000
MEM_PRIVATE

0011e000

00030000

00000004
PAGE_READWRITE

00012000

00001000
MEM_COMMIT

00000004
PAGE_READWRITE

00020000
MEM_PRIVATE

00130000

00130000

00000002
PAGE_READONLY

00003000

00001000
MEM_COMMIT

00000002
PAGE_READONLY

00040000
MEM_MAPPED

00133000

00000000

00000000

0000d000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

00140000

00140000

00000002
PAGE_READONLY

00001000

00001000
MEM_COMMIT

00000002
PAGE_READONLY

00040000
MEM_MAPPED

00141000

00000000

00000000

0000f000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

00150000

00150000

00000004
PAGE_READWRITE

00012000

00001000
MEM_COMMIT

00000004
PAGE_READWRITE

00020000
MEM_PRIVATE

00162000

00150000

00000004
PAGE_READWRITE

000ee000

00002000
MEM_RESERVE

00000000

00020000
MEM_PRIVATE

00250000

00250000

00000004
PAGE_READWRITE

00006000

00001000
MEM_COMMIT

00000004
PAGE_READWRITE

00020000
MEM_PRIVATE

00256000

00250000

00000004
PAGE_READWRITE

0000a000

00002000
MEM_RESERVE

00000000

00020000
MEM_PRIVATE

00260000

00260000

00000004
PAGE_READWRITE

00003000

00001000
MEM_COMMIT

00000004
PAGE_READWRITE

00040000
MEM_MAPPED

00263000

00260000

00000004
PAGE_READWRITE

0000d000

00002000
MEM_RESERVE

00000000

00040000
MEM_MAPPED

00270000

00270000

00000002
PAGE_READONLY

00016000

00001000
MEM_COMMIT

00000002
PAGE_READONLY

00040000
MEM_MAPPED

00286000

00000000

00000000

0000a000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

00290000

00290000

00000002
PAGE_READONLY

00041000

00001000
MEM_COMMIT

00000002
PAGE_READONLY

00040000
MEM_MAPPED

002d1000

00000000

00000000

0000f000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

002e0000

002e0000

00000002
PAGE_READONLY

00041000

00001000
MEM_COMMIT

00000002
PAGE_READONLY

00040000
MEM_MAPPED

00321000

00000000

00000000

0000f000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

00330000

00330000

00000002
PAGE_READONLY

00006000

00001000
MEM_COMMIT

00000002
PAGE_READONLY

00040000
MEM_MAPPED

00336000

00000000

00000000

0000a000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

00340000

00340000

00000002
PAGE_READONLY

00041000

00001000
MEM_COMMIT

00000002
PAGE_READONLY

00040000
MEM_MAPPED

00381000

00000000

00000000

0000f000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

00390000

00390000

00000004
PAGE_READWRITE

0003c000

00002000
MEM_RESERVE

00000000

00020000
MEM_PRIVATE

003cc000

00390000

00000004
PAGE_READWRITE

00001000

00001000
MEM_COMMIT

00000104
PAGE_READWRITE
PAGE_GUARD

00020000
MEM_PRIVATE

003cd000

00390000

00000004
PAGE_READWRITE

00003000

00001000
MEM_COMMIT

00000004
PAGE_READWRITE

00020000
MEM_PRIVATE

003d0000

003d0000

00000002
PAGE_READONLY

00001000

00001000
MEM_COMMIT

00000002
PAGE_READONLY

00040000
MEM_MAPPED

003d1000

00000000

00000000

0000f000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

003e0000

003e0000

00000004
PAGE_READWRITE

00005000

00001000
MEM_COMMIT

00000004
PAGE_READWRITE

00020000
MEM_PRIVATE

003e5000

003e0000

00000004
PAGE_READWRITE

0000b000

00002000
MEM_RESERVE

00000000

00020000
MEM_PRIVATE

003f0000

003f0000

00000002
PAGE_READONLY

00003000

00001000
MEM_COMMIT

00000002
PAGE_READONLY

00040000
MEM_MAPPED

003f3000

00000000

00000000

0000d000

00010000
MEM_FREE

00000001
PAGE_NOACCESS

00000000

00400000

EN-

分享到:
评论
xiaoer_1982
  • 浏览: 780329 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

你可能感兴趣的:(编程,.net,框架,windows,XP)