Loading... 地址的种类: * 逻辑地址:指**段寄存器+段内偏移** 表示的一个地址。 * 线性地址:指**进程独有虚拟内存空间中** 的地址。**分段机制将逻辑地址转换为线性地址。** * 物理地址:指**实际访问到的内存条** 的地址。**分页机制将线性地址转换为物理地址。** --- PAE技术: 32 位 CPU,本身无法识别出 4G 以上的物理内存,把无法识别的物理内存映射为应用程序的虚拟地址空间。也就是说,那部分原本被忽略了的物理内存,现在虽然不能以物理内存身份出现,但还是能被投入整个存储体系,以各种磁盘缓存的形式被使用了。 --- Windows 通过页目录、页表(Page Table)与页表项(Page Table Entry ,PTE)这种二级表结构将虚拟地址转换为物理地址。系统会给每个进程分配一个不同页目录用于保存这种二级表结构体。 32微程序的虚拟地址会被解释为3各部分、即页目录索引、也表索引、字节索引、这三部分索引负责描述内存映射结构体中索引物理地址信息。 ![image.png](http://www.irohane.top/usr/uploads/2021/02/3572284224.png) <span style="color:Crimson ">控制寄存器 CR3保存着页目录基址</span> 1. 内存管理硬件找到当前进程的页目录,每次进程环境切换时会得到一个新的进程也目录地址。 2. 在进程也目录中使用页目录索引->找到PDE【包含此页面帧编号PFN】 ->找到有次序你地址映射信息的页表; 3. 找到页表中使用的页表索引->页表项(PTE),PET描述了此虚拟地址所在的物理地址。 4. 根据PTE索引找到页面,判断页面是否有效,有效则为对应物理页信息的PFN,如果无效则内存管理错误处理器会找到该页面,并尝试变为有效,如果不为有效就会产生错误 5. PTE指向的页面是有效的,清除后三位,加上字节索引,就可以定位到物理内存 x86环境下,每一个进程都会拥有自己的 4GB 虚拟地址空间,主要由 CR3 进行区分 * CR3寄存器保存了每一个进程独有的页目录表(PDT),页目录表是一个元素个数为 1024 的表,其中的每一项占有 4 个字节,叫做 页目录项(PDTE),页目录表项配合虚拟地址的高 10 位组成的索引可以寻址。 * 寻址到的页目录表项,它的低12位保存的是属性位,除开属性位就是页表(PT),页表是一个元素个数为1024 的表,其中的每一项占 4 字节,描述了一个页的信息 * 找到了页表后,配合中间的10位,寻址到最终的页(PAGE) [CR0~CR4](https://my.oschina.net/iwuyang/blog/198626 "点击查看") <span style="color:Crimson ">控制寄存器 CR4 控制是否开启PAE</span> 未开启PEA ![image.png](http://www.irohane.top/usr/uploads/2021/02/2231063187.png) 开启PEA * 2:页目录表指针表(4) + 9:页目录表(512) + 9: 页表(512) + 12:偏移(0x1000) * 不管有没有开启 PAE,能够描述的页都是一样多的,但是和没有PAE的情况相比,开了的每一个项占了8字节空间,所以可以充分利用大于 4 GB的物理内存。 ![image.png](http://www.irohane.top/usr/uploads/2021/02/947994304.png) ![image.png](http://www.irohane.top/usr/uploads/2021/02/3572284224.png) 1. 内存管理硬件找到当前进程的页目录,每次进程环境切换时会得到一个新的进程也目录地址。 2. 在进程也目录中使用页目录索引->找到PDE【包含此页面帧编号PFN】 ->找到有次序你地址映射信息的页表; 3. 找到页表中使用的页表索引->页表项(PTE),PET描述了此虚拟地址所在的物理地址。 4. 根据PTE索引找到页面,判断页面是否有效,有效则为对应物理页信息的PFN,如果无效则内存管理错误处理器会找到该页面,并尝试变为有效,如果不为有效就会产生错误 5. PTE指向的页面是有效的,清除后三位,加上字节索引,就可以定位到物理内存 # 手动解析从页目录表到物理内存 ## WINDBG解析开启PAE !process 0 0 找到记事本 ![image.png](http://www.irohane.top/usr/uploads/2021/02/3376453826.png) 使用 .process + eprocess 进入 进程 然后使用 s -u 0x0 L0x01000000 "irohane" 找到字符串 ![image.png](http://www.irohane.top/usr/uploads/2021/02/1618233153.png) ``` PROCESS 878e5030 SessionId: 1 Cid: 0434 Peb: 7ffdc000 ParentCid: 0594 DirBase: 7f24d6a0 ObjectTable: 99160ca8 HandleCount: 61. Image: notepad.exe kd> s -u 0x0 L0x01000000 "irohane" 0042e038 0069 0072 006f 0068 0061 006e 0065 0061 i.r.o.h.a.n.e.a. 018b0b60 0069 0072 006f 0068 0061 006e 0065 0000 i.r.o.h.a.n.e... //未开启PAE ---如果是未开启 PAE需要在WNDBG中重新加载符号。之后进行重复造作进行解析即可 018b0b60 : 10 10 12 0000 0001 1000 1011 0000 1011 0110 0000 10 10 12 00 0000 0110 | 00 1011 0000 | 1011 0110 0000 0 0 6 0 b 0 b 6 0 006 0b0 b60 //PEA -----演示这一种------------------------------演示这一种 PAE : 2 9 9 12 0000 0001 1000 1011 0000 1011 0110 0000 00 | 0 0000 1100 |0 1011 0000| 1011 0110 0000 0 0 0 c 0 b 0 b 6 0 0 00c 0b0 b60 dirBase : 7f24d6a0 - 地址 --------------------------------------------------- kd> !dq 7f24d6a0 #7f24d6a0 00000000`60a0a801 00000000`60e8b801 #7f24d6b0 00000000`60d0c801 00000000`6030d801 #7f24d6c0 00000000`6598c801 00000000`64f8d801 #7f24d6d0 00000000`6590e801 00000000`6540f801 801 867 是属性 60a0a000 去掉属性 kd> !dq 60a0a000+(c*8) #60a0a060 00000000`61b5c867 00000000`00000000 #60a0a070 00000000`00000000 00000000`61903867 #60a0a080 00000000`61185867 00000000`61c84867 61b5c000 去掉属性 kd> !dq 61b5c000+(b0*8) #61b5c580 80000000`6155d867 00000000`00000080 #61b5c590 00000000`00000080 00000000`00000080 #61b5c5a0 80000000`616df867 80000000`624de867 #61b5c5b0 00000000`00000080 00000000`00000080 #61b5c5c0 80000000`617e1867 80000000`61e65867 6155d000 去掉属性位 + 字节索引 kd> !dq 6155db60 #6155db60 0068006f`00720069 00000065`006e0061 #6155db70 00000000`00000000 00000000`00000000 #6155db80 00000000`00000000 00000000`00000000 kd> !du 6155db60 #6155db60 "irohane" ``` 最后修改:2021 年 03 月 11 日 © 允许规范转载 赞 0 如果觉得我的文章对你有用,请随意赞赏