|
发表于 2020-4-27 12:35:26
|
显示全部楼层
都已经学了汇编语言了,那就给你一个代码,自己看
自己去分析堆栈上面的参数是如何传递的
- int main(void) {
- 00DC1810 push ebp
- 00DC1811 mov ebp,esp
- 00DC1813 sub esp,0D8h
- 00DC1819 push ebx
- 00DC181A push esi
- 00DC181B push edi
- 00DC181C lea edi,[ebp-0D8h]
- 00DC1822 mov ecx,36h
- 00DC1827 mov eax,0CCCCCCCCh
- 00DC182C rep stos dword ptr es:[edi]
- 00DC182E mov ecx,offset _8A2E5209_main@c (0DCC003h)
- 00DC1833 call @__CheckForDebuggerJustMyCode@4 (0DC1217h)
- int a = 12;
- 00DC1838 mov dword ptr [a],0Ch
- int b = 13;
- 00DC183F mov dword ptr [b],0Dh
- test(a, b);
- 00DC1846 mov eax,dword ptr [b]
- 00DC1849 push eax
- 00DC184A mov ecx,dword ptr [a]
- 00DC184D push ecx
- 00DC184E call _test (0DC1389h)
- 00DC1853 add esp,8
- return 0;
- 00DC1856 xor eax,eax
- }
- void test(int a, int b) {
- 00DC1F70 push ebp
- 00DC1F71 mov ebp,esp
- 00DC1F73 sub esp,0C0h
- 00DC1F79 push ebx
- 00DC1F7A push esi
- 00DC1F7B push edi
- 00DC1F7C lea edi,[ebp-0C0h]
- 00DC1F82 mov ecx,30h
- 00DC1F87 mov eax,0CCCCCCCCh
- 00DC1F8C rep stos dword ptr es:[edi]
- 00DC1F8E mov ecx,offset _8A2E5209_main@c (0DCC003h)
- 00DC1F93 call @__CheckForDebuggerJustMyCode@4 (0DC1217h)
- a = a + 1;
- 00DC1F98 mov eax,dword ptr [a]
- 00DC1F9B add eax,1
- 00DC1F9E mov dword ptr [a],eax
- b = b + 1;
- 00DC1FA1 mov eax,dword ptr [b]
- 00DC1FA4 add eax,1
- 00DC1FA7 mov dword ptr [b],eax
- printf("%d %d\n", a, b);
- 00DC1FAA mov eax,dword ptr [b]
- 00DC1FAD push eax
- 00DC1FAE mov ecx,dword ptr [a]
- 00DC1FB1 push ecx
- 00DC1FB2 push offset string "hello\n" (0DC7B30h)
- 00DC1FB7 call _printf (0DC1046h)
- 00DC1FBC add esp,0Ch
- }
复制代码
这个是去掉符号名的版本
- int main(void) {
- 00DC1810 push ebp
- 00DC1811 mov ebp,esp
- 00DC1813 sub esp,0D8h
- 00DC1819 push ebx
- 00DC181A push esi
- 00DC181B push edi
- 00DC181C lea edi,[ebp+FFFFFF28h]
- 00DC1822 mov ecx,36h
- 00DC1827 mov eax,0CCCCCCCCh
- 00DC182C rep stos dword ptr es:[edi]
- 00DC182E mov ecx,0DCC003h
- 00DC1833 call 00DC1217
- int a = 12;
- 00DC1838 mov dword ptr [ebp-8],0Ch
- int b = 13;
- 00DC183F mov dword ptr [ebp-14h],0Dh
- test(a, b);
- 00DC1846 mov eax,dword ptr [ebp-14h]
- 00DC1849 push eax
- 00DC184A mov ecx,dword ptr [ebp-8]
- 00DC184D push ecx
- 00DC184E call 00DC1389
- 00DC1853 add esp,8
- return 0;
- 00DC1856 xor eax,eax
- }
- void test(int a, int b) {
- 00DC1F70 push ebp
- 00DC1F71 mov ebp,esp
- 00DC1F73 sub esp,0C0h
- 00DC1F79 push ebx
- 00DC1F7A push esi
- 00DC1F7B push edi
- 00DC1F7C lea edi,[ebp+FFFFFF40h]
- 00DC1F82 mov ecx,30h
- 00DC1F87 mov eax,0CCCCCCCCh
- 00DC1F8C rep stos dword ptr es:[edi]
- 00DC1F8E mov ecx,0DCC003h
- 00DC1F93 call 00DC1217
- a = a + 1;
- 00DC1F98 mov eax,dword ptr [ebp+8]
- 00DC1F9B add eax,1
- 00DC1F9E mov dword ptr [ebp+8],eax
- b = b + 1;
- 00DC1FA1 mov eax,dword ptr [ebp+0Ch]
- 00DC1FA4 add eax,1
- 00DC1FA7 mov dword ptr [ebp+0Ch],eax
- printf("%d %d\n", a, b);
- 00DC1FAA mov eax,dword ptr [ebp+0Ch]
- 00DC1FAD push eax
- 00DC1FAE mov ecx,dword ptr [ebp+8]
- 00DC1FB1 push ecx
- 00DC1FB2 push 0DC7B30h
- 00DC1FB7 call 00DC1046
- 00DC1FBC add esp,0Ch
- }
复制代码 |
|