DEV Community

Tim Jan
Tim Jan

Posted on Edited on

Memory Layout

memory segments内存段

memory sections概览

  1. 栈:'FIFO',用户输入数据应该放在heap中,除非指定长度,但内存地址会放在stack中,栈指针和base pointer用于记录栈的顶部位子和底部位置,不存放静态数据,底部从高往低.栈存放局部变量,参数和返回值(调用函数时),BP和SP,通过SP偏移来访问栈帧数据;栈帧:指的是栈中分配的内存;RDI存参数;若调用下一方法:rbp=上一rsp;
  2. 堆:底部从低往高,存放无法定长度的数据,存放structures和用户输入
  3. Program Image - This is the program/executable loaded into memory. On Windows, this is typically a Portable Executable (PE).
  4. TEB:存放当前运行线程的星系 PEB:存放process and the loaded modules的信息和是否'BeingDebugged'


图中StackVar1先创建同理heapVar1也先创建

Stack Frames

存储方法的数据块
{embed https://tryhackme.com/room/win64assembly?vccr=1}

Data Storage

与如何分配内存不同


栈:地址向下增长 → 数组越界向下覆盖下方相邻局部变量
堆:地址向上增长 → 数组越界向上覆盖上方相邻堆变量

Top comments (3)

Collapse
 
call_me_sin profile image
Tim Jan

Collapse
 
call_me_sin profile image
Tim Jan

ip用于保存下一条要执行的指令,

Some comments may only be visible to logged-in visitors. Sign in to view all comments.