ReactOS系统中MmLocateMemoryAreaByAddress函数的实现:搜索目标地址所在的节点

ReactOS系统中MmLocateMemoryAreaByAddress函数的实现:搜索目标地址所在的节点

ReactOS系统中MmLocateMemoryAreaByAddress函数的实现:搜索目标地址所在的节点

文章目录


//搜索目标地址所在的节点MmLocateMemoryAreaByAddress

cpp 复制代码
/* FUNCTIONS *****************************************************************/

PMEMORY_AREA NTAPI
MmLocateMemoryAreaByAddress(
    PMMSUPPORT AddressSpace,
    PVOID Address_)
{
    ULONG_PTR StartVpn = (ULONG_PTR)Address_ / PAGE_SIZE;
    PEPROCESS Process;
    PMM_AVL_TABLE Table;
    PMMADDRESS_NODE Node;
    PMEMORY_AREA MemoryArea;
    TABLE_SEARCH_RESULT Result;
    PMMVAD_LONG Vad;

	获取用户空间的AVL树
    Process = MmGetAddressSpaceOwner(AddressSpace);
    Table = (Process != NULL) ? &Process->VadRoot : &MiRosKernelVadRoot;

	//检测该AVL树是否存在问题
    Result = MiCheckForConflictingNode(StartVpn, StartVpn, Table, &Node);
    if (Result != TableFoundNode)
    {
        return NULL;
    }
  // 根据二叉搜索树的性质进行和遍历,小到其左子树遍历,大则到其右子树遍历
    Vad = (PMMVAD_LONG)Node;
    if (Vad->u.VadFlags.Spare == 0)
    {
        /* Check if this is VM VAD */
        if (Vad->ControlArea == NULL)
        {
            /* We store the reactos MEMORY_AREA here */
            MemoryArea = (PMEMORY_AREA)Vad->FirstPrototypePte;
        }
        else
        {
            /* This is a section VAD. Store the MAREA here for now */
            MemoryArea = (PMEMORY_AREA)Vad->u4.Banked;
        }
    }
    else
    {
        MemoryArea = (PMEMORY_AREA)Node;
    }

    return MemoryArea;
}
相关推荐
MicroTech20251 小时前
微算法科技(MLGO)研发突破性低复杂度CFG算法,成功缓解边缘分裂学习中的掉队者问题
科技·学习·算法
墨染点香2 小时前
LeetCode 刷题【126. 单词接龙 II】
算法·leetcode·职场和发展
aloha_7892 小时前
力扣hot100做题整理91-100
数据结构·算法·leetcode
Tiny番茄2 小时前
31.下一个排列
数据结构·python·算法·leetcode
挂科是不可能出现的2 小时前
最长连续序列
数据结构·c++·算法
_Aaron___3 小时前
List.subList() 返回值为什么不能强转成 ArrayList
数据结构·windows·list
前端小L3 小时前
动态规划的“数学之魂”:从DP推演到质因数分解——巧解「只有两个键的键盘」
算法·动态规划
RTC老炮3 小时前
webrtc弱网-ReceiveSideCongestionController类源码分析及算法原理
网络·算法·webrtc
21号 13 小时前
9.Redis 集群(重在理解)
数据库·redis·算法
码农多耕地呗4 小时前
力扣146.LRU缓存(哈希表缓存.映射+双向链表数据结构手搓.维护使用状况顺序)(java)
数据结构·leetcode·缓存