ReactOS系统中平衡二叉树。给定地址超导其所属区块MmFindRegion()

系列文章目录

PMM_REGION NTAPI MmFindRegion(

PVOID BaseAddress,

PLIST_ENTRY RegionListHead,

PVOID Address,

PVOID* RegionBaseAddress

);

宏函数

//给定地址找到其中所属区块

c 复制代码
#define CONTAINING_RECORD(address,type,field) ((type FAR *\
    (PCHAR)(address)-(PCHAR)(&((type *)0)->field)))获取外层数据结构的指针
    ```
@[TOC](文章目录)

---

# MmFindRegion()
```c
//给定地址超导其所属区块
PMM_REGION NTAPI 
MmFindRegion(PVOID BaseAddress, PLIST_ENTRY RegionListHead,
    PVOID Address, PVOID * RegionBaseAddress)
{
    PLIST_ENTRY current_entry;
    PMM_REGION current;
    PVOID StartAddress = BaseAddress;//搜索的起点
    current_entry = RegionListHead->Flink;//获得第一个MM REGION区块指针
    while (current_entry != RegionListHead)//遍历一个MEMORY AREA即某个区间的区块双向链表
    {
        //curren获得该指向该结构的首地址
        current = CONTAINING_RECORD(current entry, MM REGION, RegionListEntry);
        //若目标地址在(StartAddress ~startAddress+current->Length)说明找到了该地址所在区块
        if (StartAddress <= Address &&
            ((char*)StartAddresS + current->Length) > (char*)Address) {//找到了
            if (RegionBaseAddress != NULL)
                *RegionBaseAddress = StartAddress;//将区块开始地址给RegionBaseAddress返回return(current);//返回该区块的结构信息
            currententry = current_entry->Flink://下一个区块StartAddress =(PVOID)((ULONG PTR)StartAddress + current->Length);
            return(NULL);
        }
        current_entry = current_entry->Flink;//下一个区块
        StartAddress = (PVOID)((ULONG_PTR)StartAddress + current->Length);
    }
    return (NULL);
}
c
相关推荐
开开心心就好13 天前
内存清理软件灵活设置,自动阈值快捷键清
运维·服务器·windows·pdf·harmonyos·risc-v·1024程序员节
学传打活15 天前
【边打字.边学昆仑正义文化】_5_宇宙物种创造简史(1)
微信公众平台·1024程序员节·汉字·昆伦正义文化
xcLeigh16 天前
打破机房围墙:VMware+cpolar构建跨网络虚拟实验室
vmware·内网穿透·cpolar·实验室·远程访问·1024程序员节
开开心心就好17 天前
免费轻量电子书阅读器,多系统记笔记听书
linux·运维·服务器·安全·ddos·可信计算技术·1024程序员节
unable code18 天前
流量包取证-大流量分析
网络安全·ctf·misc·1024程序员节·流量包取证
开开心心就好18 天前
实用PDF擦除隐藏信息工具,空白处理需留意
运维·服务器·windows·pdf·迭代器模式·桥接模式·1024程序员节
unable code19 天前
浏览器取证-[GKCTF 2021]FireFox Forensics
网络安全·ctf·misc·1024程序员节·浏览器取证
unable code19 天前
内存取证-[安洵杯 2019]Attack
网络安全·ctf·misc·1024程序员节·内存取证
unable code20 天前
CTF-SPCS-Forensics
网络安全·ctf·misc·1024程序员节·取证