汇编中的enter和leave

1. enter等价于:

push ebp

mov ebp,  esp

在函数的入口时常用。

2. leave等价于:

mov esp,  ebp

pop ebp

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 

一段常见的代码格式如下:

.text:00401450 push    ebp
.text:00401451 mov     ebp, esp
.text:00401453 sub     esp, 18h
。。。。。。。。。。。。。。。。。。。。。。。。。(此处省略代码20行O(∩_∩)O哈哈~) 

.text:0040146E call    sub_401B10

.text:00401473 mov     eax, 1
.text:00401478 mov   esp,   ebp

 pop  ebp

xor eax,  eax 

.text:00401479 retn    0Ch 

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

用enter和leave替代了以后,就可以变成这个样子。

.text:00401450 enter

.text:00401453 sub     esp, 18h
。。。。。。。。。。。。。。。。。。。。。。。。。(此处省略代码20行O(∩_∩)O哈哈~) 

.text:0040146E call    sub_401B10

.text:00401473 mov     eax, 1
.text:00401478 leave

xor eax, eax 

.text:00401479 retn    0Ch 

原文地址:https://www.cnblogs.com/keepfocus/p/2176925.html