简体   繁体   English

如何确定逻辑地址是否在物理内存中?

[英]How to determine if a logical address is in physical memory?

My callback function that is used at a higher IRQL may need to access a range of addresses in memory. 我在较高IRQL处使用的回调函数可能需要访问内存中的一系列地址。 So I'm wondering if there's a kernel function that can tell if an address PVOID is in the NonPagedPool section of memory, or is currently mapped to physical memory and won't cause a page fault if I read from it? 所以我想知道是否有一个内核函数可以判断地址PVOID是否在内存的NonPagedPool部分中,或者当前是否映射到物理内存,并且如果我从中读取不会导致页面错误?

MmIsAddressValid will check whether a page fault will occur at the specified address residing in a non-paged pool. MmIsAddressValid将检查是否在非页面缓冲池中的指定地址处发生页面错误。 Microsoft warns against using this function because if the address passed is paged out, it will result in undefined behavior. Microsoft警告不要使用此功能,因为如果传出的地址被调出,将导致不确定的行为。 This also checks if the virtual address is within the range for physical memory and checks for a valid PTE and returns false if the conditions are not met. 这还将检查虚拟地址是否在物理内存范围内,并检查有效的PTE,如果不满足条件,则返回false。

MmGetPhysicalAddress will return the physical address for a virtual address residing in the non-paged pool. MmGetPhysicalAddress将返回驻留在非页面缓冲池中的虚拟地址的物理地址。 This returns zero if the correct conditions are not met for the routine. 如果例程不满足正确的条件,则返回零。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM