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;
}
相关推荐
啊嘞嘞?1 小时前
力扣(回文链表)
算法·leetcode·链表
Awh-1 小时前
数据结构 第六章:哈希存储
数据结构·算法·哈希算法
M78佐菲2 小时前
Linux学习笔记:目录IO与帧缓冲
linux·笔记·学习·算法
玫瑰互动GEO2 小时前
抖音SEO优化技术拆解:搜索排名四大因子与4步落地算法分析
人工智能·算法·搜索引擎·语音识别
Interview Aid1122 小时前
Akuna OA 题目拆解|三题思路复盘
linux·运维·算法·面试·职场和发展
TAN-90°-2 小时前
Deep Learning for Computer Vision——Recurrent Neural Networks
数据结构·人工智能·rnn·深度学习·神经网络·机器学习·计算机视觉
wabs6662 小时前
关于栈【力扣150.逆波兰表达式求值的思考】
数据结构·c++·算法·leetcode··代码随想录
ZGi.ai2 小时前
ZGI 父子分块:连接检索片段与完整上下文
人工智能·算法·知识库·企业ai·zgi·父子分块
IT毕设实战小研2 小时前
基于大数据的二手车数据分析与预测
java·大数据·后端·爬虫·python·算法·课程设计
Allen_LVyingbo3 小时前
医疗AI可扩展网格信息系统中网格计算技术的智能优化
大数据·人工智能·python·算法·机器学习·django·健康医疗