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;
}
相关推荐
勇敢滴勇2 分钟前
【排序算法】选择排序、堆排序
数据结构·算法·排序算法
MrBlackmzq7 分钟前
Datawhale Leecode基础算法篇 task04:贪心算法
python·算法·贪心算法
禁默36 分钟前
C++之stack 和 queue
开发语言·数据结构·c++
啵一杯1 小时前
leetcode621. 任务调度器
服务器·前端·数据结构·算法·c#
2401_857297912 小时前
2025校招内推-招联金融
java·前端·算法·金融·求职招聘
小冉在学习2 小时前
leetcode刷题day32|动态规划Part01(509. 斐波那契数、70. 爬楼梯、746. 使用最小花费爬楼梯)
算法·leetcode·动态规划
雷达学弱狗2 小时前
孙论文——定标
算法
Mr_Xuhhh2 小时前
vector
c语言·开发语言·数据结构·算法·链表·visualstudio
枫の准大一2 小时前
空间复杂度&动态顺序表
数据结构·算法
black_blank3 小时前
众数问题,
算法