..
Parameter Pass Order
1. Right-to-left in the stack: __stdcall,__cdecl,__thiscall,__fastcall
2. From left to right into the stack: __pascal
Main description __stdcall and __cdecl difference
1...__stdcall The called function itself is responsible for stack balancing
2...__CDECL Call function is responsible for the stack balance of the function
The __stdcall function itself is responsible for stack balancing *********************////////////////
Int __stdcall a (int v1,int xx) {return 5;} Int main () {int t=a (5,1); return 0;} /**/--- c:\users\hekun\desktop\cppp\cppp\ source .cpp -------------------------------------int _ _stdcall a (INT V1,INT XX) {001713c0 push ebp 001713c1 mov ebp,esp 001713C3 sub esp,0C0h 001713c9 push ebx 001713ca push esi 001713cb push edi 001713CC lea edi,[ebp-0C0h] 001713D2 mov ecx,30h 001713D7 mov eax,0CCCCCCCCh 001713dc rep stos dword ptr es:[edi] return 5;001713de mov eax,5 } 001713e3 pop edi 001713e4 pop esi 001713E5 pop ebx 001713E6 mov esp,ebp 001713E8 pop ebp 001713E9 ret 8 /* stack balance function parameters occupy 8 bytes */--- c:\users\hekun\desktop\cppp\cppp\ source .cpp --------------------- ----------------Int maiN () {00171400 push ebp 00171401 mov ebp,esp 00171403 sub esp,0CCh 00171409 push ebx 0017140A push esi 0017140b push edi 0017140C lea edi,[ebp-0CCh] 00171412 mov ecx,33h 00171417 mov eax,0CCCCCCCCh 0017141C rep stos dword ptr es:[edi] int t=a (5,1); 0017141E push 1 00171420 push 5 00171422 call a ( 01711E0H) /* Call function a*/00171427 mov dword ptr [t],eax /* return value is located in register eax*/return 0;0017142a xor eax,eax }0017142C pop edi 0017142D pop esi 0017142e pop ebx 0017142F add esp,0CCh 00171435 cmp ebp,esp 00171437 call __rtc_checkesp (017113Bh) 0017143C mov esp,ebp 0017143E pop ebp 0017143f ret
? __cdecl ? The calling function is responsible for stack balancing *********************////////////////
Int __cdecl a (int v1,int xx) {return 5;} Int main () {int t=a (5,1); return 0;} /* Disassembly */--- c:\users\hekun\desktop\cppp\cppp\ source .cpp -------------------------------------int __cdecl a (INT V1,INT XX) {00f313c0 push   EBP  00F313C1  MOV         EBP, esp 00f313c3 sub esp,0c0h 00F313C9 push ebx 00F313CA push esi 00F313CB push edi 00F313CC lea edi,[ebp-0C0h] 00F313D2 mov ecx,30h 00f313d7 mov eax,0cccccccch 00f313dc rep stos dword ptr es:[edi] return 5;00f313de mov eax,5 } 00f313e3 pop edi 00f313e4 pop esi 00F313E5 pop ebx 00F313E6 mov esp,ebp 00F313E8 pop ebp 00F313E9 ret --- c:\users\hekun\desktop\cppp\cppp\ SOURCE .cpp -------------------------------------Int main () {00f31400 push ebp 00F31401 mov ebp,esp 00f31403 sub esp,0cch 00f31409 push ebx 00F3140A push esi 00F3140B push edi 00F3140C lea edi,[ebp-0CCh] 00F31412 mov Ecx,33h 00f31417 mov eax,0cccccccch 00F3141C rep stos dword ptr es:[edi] Int t=a (5,1);00f3141e push 1 00f31420 push 5 00f31422 call a (0f311e5h) /* call function a */00F31427 add esp,8 /* because it is __cdecl Call way So the caller main responsible for stack balancing, function a back immediately stack balance (8 bytes) argument function can only be such a call, because only the caller knows Parameter Actual size */00f3142a mov dword ptr [t],eax return 0;00F3142D xor eax,eax }00f3142f pop edi 00F31430 pop esi 00f31431 pop ebx 00f31432 add esp,0cch 00f31438 cmp ebp,esp 00f3143a call _ _rtc_checkesp (0F3113BH) 00F3143F mov esp,ebp 00F31441 pop Ebp 00f31442 ret
__fastcall call parameters up to 8 bytes at a time put register ECX and edx rest parameters into the stack
function calling convention