三种call解释(二): 代码解释
原创
于2026-01-05 18:07:00发布
2 阅读
0
0
#include #include using namespace std; void _cdecl test111(int num) { printf("num=%d\n", num); } void _stdcall test222(int num) { printf("num=%d\n", num); } void __declspec(naked) test333(int num) { _asm{ push ebp mov ebp,esp } printf("num=%d\n", num); _asm{ mov ebp,esp pop ebp retn } } void _cdecl test(int num) { printf("_cdecl num=%d\n", num); ////// EIP的值不允许通过MOV指令来修改,可以通过PE结构修改; _asm{ push num call test111 // 调用cdcall的方法; add ESP,0x4 } int xxx = 0; _asm{ push num call test333 // 调用naked call的方法; add ESP,0x4 } _asm{ push num // 调用stdcall的方法; call test222 } int xxx2 = 1; } void _stdcall test1(int num) { printf("_stdcall num=%d\n", num); _asm{ push num call test111 // 调用cdcall的方法; add ESP,0x4 } int xxx = 0; _asm{ push num call test333 // 调用naked call的方法; add ESP,0x4 } _asm{ push num // 调用stdcall的方法; call test222 } int xxx2 = 1; } int main() { int num = 20; _asm{ mov eax,0 mov eax,0 mov eax,0 } test(num); // _cdecl test1(num); // _cdecl _asm{ mov eax,0 mov eax,0 mov eax,0 } test111(num); // _cdecl _asm{ mov eax,0 mov eax,0 mov eax,0 } test222(num); // _stdcall _asm{ mov eax,0 mov eax,0 mov eax,0 } test333(num); printf("num=%d\n", num); // MessageBoxA(0, 0, 0, 0); // getchar(); return 0; }