about function Invocation methods __stdcall and __cdecl
On function invocation way __stdcall and __cdecl __stdcall __cdecl the same point and different point instances
__stdcall
__stdcall's full name is standard call. is the standard invocation method for C + +.
function parameters are in the stack order from right to left. function returns with the RETN x instruction, where x is the number of bytes to adjust the stack. This method is called Automatic clearing stack. That is, the number of parameters of the called function is fixed, the caller must strictly follow the definition of the pass parameters, one is not much, a lot. __cdecl
__cdecl's full name is C declaration, which is the default function invocation of C language.
function parameters are in the stack order from right to left. function to act as a RET instruction when returning functions. Manually clearing the stack by the caller. The called function supports variable parameters. The caller manually balances the stack based on the number of arguments passed in at the time of the call. the same point of the two is the same point as the different points
Parameter stack order is the same: from right to left different point
Stack balance mode is different: __stdcall automatic cleaning stack, __cdecl manual cleaning stack. The return instruction differs: _stdcall uses RETN x, __cdecl the decorated name of a RET compiled function is different: suppose there is a function int foo (int a, int b), the __stdcall compiled function name is _foo@8, and the use of __ Cdecl the compiled function name is _foo. A function of an instance that supports variable parameters must be defined as __cdecl, such as:
int printf (char *fmt, ...);
Definition of __stdcall and __cdecl in windef.h
#define CALLBACK __stdcall #define WINAPI __stdcall #define WINAPIV __cdecl #d Efine apientry WINAPI #define apiprivate __stdcall #define PASCAL __stdcall #define CDECL _cdecl #ifndef C Decl #define CDECL _cdecl #endif