【发布时间】:2013-10-23 15:03:32
【问题描述】:
我只是在学习 ASM/x86,所以请多多包涵。
问题
我在正在检查的程序中注意到以下内容,我认为它正在将参数传递给被调用的函数:
mov [ebp-04],00000005
call <some function call here>
据我所知,这似乎是将堆栈顶部的第二个字节设置为值5。
这是否有效地将参数 5 传递给函数?
它会不会类似于C 中的以下内容:
void someFunction(int num); //function declaration
someFunction(5); //In some context
如果向函数传递单个参数 5,为什么将其设置为第二个字节(-04),而不是栈顶?栈顶是什么?我对这一切的解释都错了吗?
编辑
函数的顶部是设置ebp 的位置:
push ebp
mov ebp,esp
push -01
push 184
mov eax,fs:[00000000]
... //bunch more pushes and movs with eax and ecx into [ebp-offset]
... //a couple of jump if equals
... //some more push and movs
lea ecx,[ebp-1C]
mov [ebp-04],00000005
call <some function>
这里是被调用的函数:
mov edx,[ecx]
mov eax,[ecx+08]
sub eax,edx
test edx,edx
je <label1>
cmp eax,00000080
jna <label2>
push edx
call <another function>
add esp,04
ret
label2:
push eax
push edx
call <yet another function>
add esp,08
label1:
ret
【问题讨论】: