汇编 – c++/c 多函数调用
我比较懒,日志只能上传源代码,流程分析图和注释不能上传,想要也可以私聊我。
1: #include <stdio.h>
2: #include <windows.h>
3: int plus1(int x,int y)
4: {
00401030 push ebp
00401031 mov ebp,esp
00401033 sub esp,44h
00401036 push ebx
00401037 push esi
00401038 push edi
00401039 lea edi,[ebp-44h]
0040103C mov ecx,11h
00401041 mov eax,0CCCCCCCCh
00401046 rep stos dword ptr [edi]
5: int a;
6: a = x + y;
00401048 mov eax,dword ptr [ebp+8]
0040104B add eax,dword ptr [ebp+0Ch]
0040104E mov dword ptr [ebp-4],eax
7: return a;
00401051 mov eax,dword ptr [ebp-4]
8: }
00401054 pop edi
00401055 pop esi
00401056 pop ebx
00401057 mov esp,ebp
00401059 pop ebp
0040105A ret
---------------------------------------------------------------------------------------------------------------------------------上方plus1
10: int plus(int x,int y,int z)
11: {
00401070 push ebp
00401071 mov ebp,esp
00401073 sub esp,44h
00401076 push ebx
00401077 push esi
00401078 push edi
00401079 lea edi,[ebp-44h]
0040107C mov ecx,11h
00401081 mov eax,0CCCCCCCCh
00401086 rep stos dword ptr [edi]
12: int m;
13: m=plus1(1,2);
00401088 push 2
0040108A push 1
0040108C call @ILT+0(plus1) (00401005)
00401091 add esp,8
00401094 mov dword ptr [ebp-4],eax
14:
15: return m+z;
00401097 mov eax,dword ptr [ebp-4]
0040109A add eax,dword ptr [ebp+10h]
16:
17: }
0040109D pop edi
0040109E pop esi
0040109F pop ebx
004010A0 add esp,44h
004010A3 cmp ebp,esp
004010A5 call __chkesp (00401120)
004010AA mov esp,ebp
004010AC pop ebp
004010AD ret
上方plus
19: void main()
20: {
004010C0 push ebp
004010C1 mov ebp,esp
004010C3 sub esp,44h
004010C6 push ebx
004010C7 push esi
004010C8 push edi
004010C9 lea edi,[ebp-44h]
004010CC mov ecx,11h
004010D1 mov eax,0CCCCCCCCh
004010D6 rep stos dword ptr [edi]
21:
22: int m;
23: m=plus(1,2,3);
004010D8 push 3
004010DA push 2
004010DC push 1
004010DE call @ILT+5(plus) (0040100a)
004010E3 add esp,0Ch
004010E6 mov dword ptr [ebp-4],eax
24: printf(“m=%d”,m);
004010E9 mov eax,dword ptr [ebp-4]
004010EC push eax
004010ED push offset string “m=%d” (0042201c)
004010F2 call printf (00401160)
004010F7 add esp,8
25: __asm
26: {
27: mov eax,eax
004010FA mov eax,eax
28: }
29: return;
30:
31: }
004010FC pop edi
004010FD pop esi
004010FE pop ebx
004010FF add esp,44h
00401102 cmp ebp,esp
00401104 call __chkesp (00401120)
00401109 mov esp,ebp
0040110B pop ebp
0040110C ret