函数调用约定, 以及特殊种类
C/C++函数调用约定
调用方式 参数 栈恢复
__fastcall ecx,edx,esp n
__stdcall esp 0
__cdecl esp n
__stdcall(class) ecx,esp n
__cdecl(class) ecx,esp 0
__fastcall(class) ecx,edx,esp n
以上为VS2010, 实际程序有些特殊约定方式(其他编译器, 或优化),
如参数传递使用ecx,edx,esp, 但是栈恢复没有,
如果需要定义该种类的函数指针或Hook之类的只能用汇编方式
如
__declspec(naked) int __fastcall Hook_SpdySessionDelStm(SpdySession *_ecx, int status, SpdyStream *stream)
{
__asm mov eax,[esp+4];
__asm pushad;
__asm push eax;
__asm push edx;
__asm push ecx;
__asm call OnSpdySessionDelStm;
__asm popad;
__asm jmp Real_SpdySessionDelStm;
}