函数约定

c语言中main函数的参数为3个,在找main函数入口的时候要注意
裸函数
void __declspec(naked) name{
}如果用了裸函数一定要在中间写下面的代码
在c代码中添加汇编代码的方法
__asm{
ret
}
调用约定
1.__cdecl 从后往前压入参数,并且由调用者平衡堆栈(外平栈) 一般VC和VS默认的约定
eg: push 2
push1
call …
add esp,0x8
2.__stdcall 从后往前压入参数,由自身清理堆栈(内平栈)
eg:push 2
push 1
call …
在调用的子函数的内部最后有一个 ret 8 (这段代码的意思就是 retn 和 add esp,8的一个结合)
3.__fastcall 从后往前压入参数 前两个参数分别用ECX,EDX传入 ,自身清理堆栈(如果传入参数少于2,不用平衡堆栈)
eg: int __fastcall add(int x,int y,int a, int b){}
push b
push a
mov edx,y
mov ecx,x

猜你喜欢

转载自blog.csdn.net/z1041259928/article/details/87927414