当前位置:网站首页>Creation and destruction of function stack frames
Creation and destruction of function stack frames
2022-07-25 21:30:00 【Wind rises and falls】
List of articles
One 、 about esp And ebp Register description
ebp esp Two registers It's the address
Use address to maintain function stack frame
Two 、 For the whole process of creation and destruction
1. about _mainCRTstarup Creation of functions for

matters needing attention :
Pressing stack (push): Put an element at the top of the stack
Out of the stack (pop): Delete an element at the top of the stack
The address of stack space should be used first , Using low address
- push Stack pressing operation take ebp Pressure into the stack
meanwhile esp Point to , ebp The upward address becomes smaller , therefore esp Your address is getting smaller

- mov: take esp The value of ebp
Both point to the same location
- sub ( reduce )
take esp subtract 0E4h( octal )
(1)
(2)esp Because the address becomes smaller Up and esp And ebp The space enclosed by the two is just main Stack frame of function
- push stay main Function stack top push ebx esi edi
With pressing data esp It also points to the data namely esp Move up
2. about main Function creation
lea representative load effective address Load valid address
take ebp-0E4h Put it in edi in
dowrd act as 4 Bytes
from edi The position begins ecx( Deposit 39h Time ) Of dword The data is all changed to 0xCCCCCCCCh Until ebp end
(1). Why does it sometimes print out hot
0Ah representative 10
hold 0Ah Put it in ebp-8 Data in
Because it's all addresses therefore ebp-8 For in ebp Address minus 8 Bytes
If a Is not assigned Then put it as 0xCCCCCCCCh
So sometimes The print result is hot hot hot
14h Print in hexadecimal representative 20 namely ebp-20
ebp-20h representative ebp-32
ebp-20 by b Value namely 20
hold ebp-14h(ebp-20) Pass in eax in
push eax take eax Pressing stack
meanwhile esp Point to eax
2.
take ebp-8 Pass in ecx in
At the same time ecx Pressing stack
here ebp-8 Deposit is a The value is 10
esp Point to ecx
3.
Call a function
Stack the address of the next instruction
meanwhile esp Point to call The address of the next instruction
3. about Add Creation of functions for

take ebp Pressing stack esp Point to ebp Here is in the main function ebp
. take esp Assign a value to ebp,ebp And esp All point to ebp
2.
sub: take esp subtract 0CCh
Because the address is small on
push Pressing stack ebx esi edi
3.
from edi Position start Conduct ecx(33h Hexadecimal ) Time dword data All into 0CCCCCCCCh
4.
hold 0 Put it in ebp-8 Location
(2). Why is the formal parameter not in the function

(3). Function return How to put the value back
>

1.
Out of the stack here esp The address gets bigger Move down
mov hold ebp Assign a value to esp
(4).ebp-main After leaving the stack ebp Register pointing
(5). Shape parameter a,b How to return to the operating system
return ret It's going back to call The address of the next instruction
Here with add Destruction of functions esp It also pops up from the address position of the next instruction to the next position
Original esp The address indicated plus 8 That is, the current position
will Set formal parameter a b And the operating system

hold eax Move to ebp-32(20h by 16 Base number ) in
the function z Value Passed to the main function c in
4. Overall process diagram
边栏推荐
- An interview question about recover in golang
- My heart's broken! After being cheated by 30000, a 16-year-old girl was unconvinced and cheated by 50000
- Job interviews are always a second kill? After reading the seckill system notes secretly stored by JD T8, I have given my knees
- Does the open source agreement have legal effect?
- Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
- Zero basic learning canoe panel (17) -- panel CAPL function
- strcpy()
- es6--解构赋值
- Programmer's Guide to health quenching 5: introduction to sports Basics
- [fiddlertx plug-in] use Fiddler to capture the package Tencent classroom video download (unable to capture the package solution)
猜你喜欢

My heart's broken! After being cheated by 30000, a 16-year-old girl was unconvinced and cheated by 50000

人脸与关键点检测:YOLO5Face实战

Sum of two numbers and three numbers

Byte side: can TCP and UDP use the same port?
![[ManageEngine] value brought by Siem to enterprises](/img/1e/56d64d193e0428523418bef5e98866.png)
[ManageEngine] value brought by Siem to enterprises

ONEFLOW V0.8.0 officially released

接口测试工具 restlet client

The adequacy of source evaluation forum · observation model test

Qixin Jushi cloud spectrum new chapter | Haitai Fangyuan and Sichuan Unicom reach ecological strategic cooperation
![[manageengine]itsm application in retail industry](/img/25/e8d9a320c5d4b1cf2e187b61180991.png)
[manageengine]itsm application in retail industry
随机推荐
Experience sharing of system architecture designers preparing for the exam: from point to surface
Pycharm跑程序时自动进入测试模式
Niuke-top101-bm38
I live far away. Is there a good way to open an account? Is it safe to open a stock account by mobile phone?
SSH private key realizes login to remote target server
Interface testing tool restlet client
Detailed explanation of Ag search tool parameters
The onnx model is exported as a TRT model
有哪些优化mysql索引的方式请举例(sqlserver索引优化)
Add startup software items when the win system starts up
Canvas fill gradient
如何自动生成短链?如何在线批量生成带UTM参数的链接?
Dear bosses, how can I print the result of Flink SQL to the console and display it completely?
mysql8.0 mha实现高可用《mha》
kali修改更新源(无法安全的用该源更新)
Achieve accurate positioning based on Tencent map, and realize the attendance punch function of wechat applet
Airtest solves the problem that a password needs to be entered in the process of "automatic packaging" (the same applies to random bullet frame processing)
【FiddlerTX插件】使用Fiddler抓包腾讯课堂视频下载(抓不到包解决方案)
数据库sql语句练习题「建议收藏」
Research: more than 70% of doctors are still prescribing unsafe antibiotic drugs

































