1.MSDN:
BOOL VirtualCopy(
LPVOID lpvDest,
LPVOID lpvSrc,
DWORD cbSize,
DWORD fdwProtect
);
Parameters
lpvDest
[out] Pointer to the destination memory, which must be reserved.
lpvSrc
[out] Pointer to committed memory.
.....
PAGE_PHYSICAL Used to map a physical memory region. When using this flag, divide the physical address — that is, lpvSrc — by 256.
Remarks
The following code example shows how VirtualCopy is called to map a 128-KB region at physical address 0x64000000.
VirtualCopy(
pvDest, (void *)(0x64000000/256), 128*1024,
PAGE_READWRITE | PAGE_PHYSICAL | PAGE_NOCACHE);
Drivers or applications that run in user mode must use this function, because user-mode threads do not have permission to access physical memory directly.
printf(TEXT("VirtualAlloc reservation @%8.8lx\r\n"), lpv);
bRet = VirtualCopy(lpv, PHYSADDR>>8, SIZE, PAGE_READWRITE | PAGE_NOCACHE | PAGE_PHYSICAL);
// The lpv parameter is the virtual address returned
// by VirtualAlloc().
// Always use PAGE_NOCACHE */
// Check the return value: bRet ==0 is an error */
printf(TEXT("VirtualCopy returned: %d\r\n"), bRet);
VirtualCopy also supports the PAGE_PHYSICAL flag. You must set this flag when you are mapping physical memory that resides beyond 512 MB, that is, physical memory with an address above 0x1FFFFFFF.