XP User Program space allocation (1): General framework

Source: Internet
Author: User

Windows core programming tells us that the 4G virtual space for each application can be divided into 4 chunks:

0x0000 0000 ~ 0x0000 FFFF: null pointer assignment partition

0x0001 0000 ~ 0x7ffe FFFF: User-mode partitioning

0x7fff 0000 ~ 0x7fff ffff:64k ban on zoning

0x8000 0000 ~ 0xFFFF FFFF: kernel-mode partitioning

But to be specific, you need to study for yourself.

Let's take a look at how an application uses this 4G of space. First write a section of code to query the 4G space in the general classification of memory blocks:

HANDLE hProcess;
DWORD dwAddr;
int nCount = 0;
hProcess = GetCurrentProcess();
dwAddr = (DWORD) info.lpMinimumApplicationAddress;
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);

In this way, you will get 249 blocks of memory, as shown in the following table (all values are 16):

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.