主程序 结果见上图
.386
.model flat,stdcall
option casemap:none
include <windows.inc>
include <user32.inc>
includelib <user32.lib>
include <kernel32.inc>
includelib <kernel32.lib>
.code
start:
call test2
test2 proc
local @loc1:dword,@loc2:word
local @loc3:byte
mov eax,@loc1
mov ax,@loc2
mov al,@loc3
leave
ret
test2 endp
end start
反汇编后内存如下:
我们经过分析发现:
主程序的地址是call 处的那个
子程序过程;
1.保护现场 入栈
2.执行程序
3.返回断点 出栈
因为根据局部变量(包括函数形参)入堆栈的原理,我们发现,要先保存ebp这个寄存器(因为访问堆栈就是用的这个寄存器,esp只是用来标识堆栈栈顶位置的)
.386
.model flat,stdcall
option casemap:none
include <windows.inc>
include <user32.inc>
includelib <user32.lib>
include <kernel32.inc>
includelib <kernel32.lib>
.code
start:
call test2
test2 proc
local @loc1:dword,@loc2:word
local @loc3:byte
mov eax,@loc1
mov ax,@loc2
mov al,@loc3
leave
ret
test2 endp
end start