代码如下:
PHYSICAL_ADDRESS
MmGetPhysicalAddress (
IN PVOID BaseAddress
)
{
PMMPTE PointerPte;
PHYSICAL_ADDRESS PhysicalAddress;
//判断是否在[0x80000000,0xA0000000)中,如果是,这段内存被映射到物理内存中[0,20000000),这段内存采用4MB大小的分页。
if (MI_IS_PHYSICAL_ADDRESS(BaseAddress)) {
PhysicalAddress.QuadPart = MI_CONVERT_PHYSICAL_TO_PFN (BaseAddress);
} else {
PointerPte = MiGetPteAddress(BaseAddress);
//如果PTE的内容为NULL,则不对应任何物理内存。
if (PointerPte->u.Hard.Valid == 0) {
KdPrint(("MM:MmGetPhysicalAddressFailed base address was %lx",
BaseAddress));
ZERO_LARGE (PhysicalAddress);
return PhysicalAddress;
}
//从PTE中读取物理内存地址。
Physi