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;
}
相关推荐
数据大魔方25 分钟前
【期货量化实战】螺纹钢量化交易指南:品种特性与策略实战(TqSdk完整方案)
python·算法·github·程序员创富·期货程序化·期货量化·交易策略实战
豆沙沙包?26 分钟前
2026年--Lc334-2130. 链表最大孪生和(链表转数组)--java版
java·数据结构·链表
千金裘换酒1 小时前
LeetCode 删除链表的倒数第N个结点
算法·leetcode
SweetCode1 小时前
【无标题】
开发语言·c++·算法
shughui1 小时前
Python基础面试题:语言定位+数据类型+核心操作+算法实战(含代码实例)
开发语言·python·算法
王老师青少年编程1 小时前
信奥赛C++提高组csp-s之拓扑排序详解
c++·算法·拓扑排序·csp·信奥赛·csp-s·提高组
kaikaile19952 小时前
matlab计算流场
人工智能·算法·matlab
3GPP仿真实验室2 小时前
【Python源码】6G:PyTorch OFDM 教学仿真平台
算法
xie_pin_an2 小时前
C++ 从入门到进阶:核心知识与实战指南
java·c++·算法
Python_Study20252 小时前
制造业数据采集系统选型指南:从技术挑战到架构实践
大数据·网络·数据结构·人工智能·架构