Calling Convention (VS)
CS/Common 2009. 4. 10. 22:02// Example of the __cdecl keyword on function int __cdecl system(const char *); // Example of the __cdecl keyword on function pointer typedef BOOL (__cdecl *funcname_ptr)(void * arg1, const char * arg2, DWORD flags, ...); |
004118F3 push 4 004118F5 push 3 004118F7 push 2 004118F9 push 1 004118FB call foo (411118h) 00411900 add esp,10h int __cdecl foo(int a, int b, int c, int d) { 00411840 push ebp 00411841 mov ebp,esp 00411843 sub esp,0CCh 00411849 push ebx 0041184A push esi 0041184B push edi 0041184C lea edi,[ebp-0CCh] 00411852 mov ecx,33h 00411857 mov eax,0CCCCCCCCh 0041185C rep stos dword ptr es:[edi] int x = a+b+c+d; 0041185E mov eax,dword ptr [a] 00411861 add eax,dword ptr [b] 00411864 add eax,dword ptr [c] 00411867 add eax,dword ptr [d] 0041186A mov dword ptr [x],eax return x; 0041186D mov eax,dword ptr [x] 00411870 pop edi 00411871 pop esi 00411872 pop ebx 00411873 mov esp,ebp 00411875 pop ebp 00411876 ret } |
// Example of the __stdcall keyword #define WINAPI __stdcall // Example of the __stdcall keyword on function pointer typedef BOOL (__stdcall *funcname_ptr) (void * arg1, const char * arg2, DWORD flags, ...); |
foo(1, 2, 3, 4); 004118F3 push 4 004118F5 push 3 004118F7 push 2 004118F9 push 1 004118FB call foo (411249h) int __stdcall foo(int a, int b, int c, int d) { 00411840 push ebp 00411841 mov ebp,esp 00411843 sub esp,0CCh 00411849 push ebx 0041184A push esi 0041184B push edi 0041184C lea edi,[ebp-0CCh] 00411852 mov ecx,33h 00411857 mov eax,0CCCCCCCCh 0041185C rep stos dword ptr es:[edi] int x = a+b+c+d; 0041185E mov eax,dword ptr [a] 00411861 add eax,dword ptr [b] 00411864 add eax,dword ptr [c] 00411867 add eax,dword ptr [d] 0041186A mov dword ptr [x],eax return x; 0041186D mov eax,dword ptr [x] 00411870 pop edi 00411871 pop esi 00411872 pop ebx 00411873 mov esp,ebp 00411875 pop ebp 00411876 ret 10h } |
// Example of the __fastcall keyword #define FASTCALL __fastcall void FASTCALL DeleteAggrWrapper(void* pWrapper); // Example of the __ fastcall keyword on function pointer typedef BOOL (__fastcall *funcname_ptr) (void * arg1, const char * arg2, DWORD flags, ...); |
foo(1, 2, 3, 4); 004118F3 push 4 004118F5 push 3 004118F7 mov edx,2 004118FC mov ecx,1 00411901 call foo (41124Eh) int __fastcall foo(int a, int b, int c, int d) { 004115D0 push ebp 004115D1 mov ebp,esp 004115D3 sub esp,0E4h 004115D9 push ebx 004115DA push esi 004115DB push edi 004115DC push ecx 004115DD lea edi,[ebp-0E4h] 004115E3 mov ecx,39h 004115E8 mov eax,0CCCCCCCCh 004115ED rep stos dword ptr es:[edi] 004115EF pop ecx 004115F0 mov dword ptr [ebp-14h],edx 004115F3 mov dword ptr [ebp-8],ecx int x = a+b+c+d; 004115F6 mov eax,dword ptr [a] 004115F9 add eax,dword ptr [b] 004115FC add eax,dword ptr [c] 004115FF add eax,dword ptr [d] 00411602 mov dword ptr [x],eax return x; 00411605 mov eax,dword ptr [x] 00411608 pop edi 00411609 pop esi 0041160A pop ebx 0041160B mov esp,ebp 0041160D pop ebp 0041160E ret 8 } |