ReactOS系统中平衡二叉树,在一个空间中寻找与给定地址范围重合或部分重合的(已分配)区间

在一个空间中寻找与给定地址范围重合或部分重合的(已分配)区间

PMEMORY_AREA NTAPI MmLocateMemoryAreaByRegion(

PMADDRESS_SPACE AddressSpace,

PVOID Address,

ULONG_PTR Length

);


MmLocateMemoryAreaByRegion

c 复制代码
/***************************************************************************************/
//在一个空间中寻找与给定地址范围重合或部分重合的(已分配)区间
PMEMORY_AREA STDCALL MmLocateMemoryAreaByRegion(PMADDRESS_SPACE AddressSpace,
    PVOID Address, ULONG_PTR Length)
{ 
    PMEMORY_AREA Node;
    PVOID Extent = (PVOIDK(ULONG_PTR)Address + Length);//地址范围的终点
    MmVerifyMemoryAreas(AddressSpace);//检测该AVL树是否存在问题
    /*Special ease for empty tree.*/
    if (AddressSpace->MemoryAreaBoot == NULL)
        return NULL;
    /* Traverse the tree from left to right.*/
    for (Node = MmIterateFirstNode(AddressSpace->MemoryAreaRoot);
        Node!= NULL;Node = MmIterateNextNode(Node))
    {
        if (Node->StartingAddress >= Address && Node->StartingAddress < Extent)
            return Node;//部分重合,区间的起点落在给定范围之内
        if (Node->EndingAddress > Address && Node->EndingAddress < Extent)
            return Node;//部分重合,区间的终点落在给定范围之内
        if (Node->StartingAddress <= Address && Node->EndingAddress >= Extent)
            return Node;//全部重合,给定范围落在区间之内
       if(Node->StartingAddress >= Extent)
            return NULL;
} //end for
return NULL;
}

c
相关推荐
chao1898444 小时前
基于 SPEA2 的多目标优化算法 MATLAB 实现
开发语言·算法·matlab
沪漂阿龙4 小时前
AI大模型面试题:支持向量机是什么?间隔最大化、软间隔、核函数、LinearSVC 全面拆解
人工智能·算法·支持向量机
little~钰4 小时前
倍增算法和ST表
算法
原来是猿4 小时前
网络计算器:理解序列化与反序列化(中)
linux·运维·服务器·网络·tcp/ip
知识领航员5 小时前
蘑兔AI音乐深度实测:功能拆解、实测表现与适用场景
java·c语言·c++·人工智能·python·算法·github
薛定e的猫咪5 小时前
因果推理研究方向综述笔记
人工智能·笔记·深度学习·算法
AOwhisky5 小时前
虚拟化技术学习笔记
linux·运维·笔记·学习·虚拟化技术
rabbit_pro6 小时前
Docker compose部署Ollama使用模型
linux·运维·docker
如何原谅奋力过但无声6 小时前
【灵神高频面试题合集06-08】反转链表、快慢指针(环形链表/重排链表)、前后指针(删除链表/链表去重)
数据结构·python·算法·leetcode·链表