楼主太好了,对照着看确实很容易看懂。
用VC6的debug编的时候,在主函数前面会出现下面一段话
push ebp
mov ebp, esp
sub esp, 64 ; 00000040H
push ebx
push esi
push edi
lea edi, DWORD PTR [ebp-64]
mov ecx, 16 ; 00000010H
mov eax, -858993460 ; ccccccccH
rep stosd
这是对于Debug版,调用后会调用call __chkesp,判断是否发生函数调用约定的错误。
在主函数后面会有一段这个代码进行Chkesp
pop edi
pop esi
pop ebx
add esp, 64 ; 00000040H
cmp ebp, esp
call __chkesp
mov esp, ebp
pop ebp
ret 0
如果chkesp不过的话会报以下msg
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention