//window 提供的一个特性地址窗口扩展(address window extension)
//显示如何使用AWE
void TestUsetAWE()
{
//frist reserve a 1MB region for the address window
ULONG_PTR ulRAMBytes = 1024 * 1024;
PVOID pvWindow = VirtualAlloc(NULL, ulRAMBytes, MEM_RESERVE | MEM_PHYSICAL,
PAGE_READWRITE);
// Get the number of bytes in a page for this CPU platform
SYSTEM_INFO sinf;
GetSystemInfo(&sinf);
//calculate the required number of RAM pages for the desired number of bytes
ULONG_PTR ulRAMPages = (ulRAMBytes + sinf.dwPageSize - 1) / sinf.dwPageSize;
//allocate array for RAM page's page frame numbers
ULONG_PTR* aRAMPages = (ULONG_PTR*) new ULONG_PTR[ulRAMPages];
//Allocate the pages of RAM (requires Lock Pages in memory user right)
AllocateUserPhysicalPages(GetCurrentProcess(), //allocate the stirage for our process
&ulRAMPages, //[in]:number of RAM pages [out]:number pages allocated
aRAMPages);//[out]:opaque array indicating pages allocated
//assign the RAM pages to pur window
MapUserPhysicalPages(pvWindow,//the address og the address window
ulRAMPages,//number of entries in array
aRAMPages);//array of RAM pages
//access the RAM pages via the pvWindow virtual address
//..........
//end access free the block of RAM pages
FreeUserPhysicalPages(GetCurrentProcess(),
&ulRAMPages,
aRAMPages);
//destory the address window
VirtualFree(pvWindow, 0, MEM_RELEASE);
delete[] aRAMPages;
}