回复 5楼 cacker
这是我反汇编后的代码,能麻烦解释一下吗?
第一个程序的
程序代码:
1: #include<stdio.h>
2: void g(char *string);
3: int main()
4: {
00401020 push ebp
00401021 mov ebp,esp
00401023 sub esp,48h
00401026 push ebx
00401027 push esi
00401028 push edi
00401029 lea edi,[ebp-48h]
0040102C mov ecx,12h
00401031 mov eax,0CCCCCCCCh
00401036 rep stos dword ptr [edi]
5: char *s="a";
00401038 mov dword ptr [ebp-4],offset string "a" (00422020)
6: int i=10;
0040103F mov dword ptr [ebp-8],0Ah
7:
8: while(--i){
00401046 mov eax,dword ptr [ebp-8]
00401049 sub eax,1
0040104C mov dword ptr [ebp-8],eax
0040104F cmp dword ptr [ebp-8],0
00401053 je main+43h (00401063)
9: g(s);
00401055 mov ecx,dword ptr [ebp-4]
00401058 push ecx
00401059 call @ILT+0(_g) (00401005)
0040105E add esp,4
10: }
00401061 jmp main+26h (00401046)
11: printf("\n");
00401063 push offset string "\n" (0042201c)
00401068 call printf (00401100)
0040106D add esp,4
12: return 0;
00401070 xor eax,eax
13: }
00401072 pop edi
00401073 pop esi
00401074 pop ebx
00401075 add esp,48h
00401078 cmp ebp,esp
0040107A call __chkesp (00401180)
0040107F mov esp,ebp
00401081 pop ebp
00401082 ret
这是第二个
程序代码:
1: #include<stdio.h>
2: void g(char *string);
3: int main()
4: {
00401020 push ebp
00401021 mov ebp,esp
00401023 sub esp,48h
00401026 push ebx
00401027 push esi
00401028 push edi
00401029 lea edi,[ebp-48h]
0040102C mov ecx,12h
00401031 mov eax,0CCCCCCCCh
00401036 rep stos dword ptr [edi]
5: char *s="a";
00401038 mov dword ptr [ebp-4],offset string "a" (00422020)
6: int i=10;
0040103F mov dword ptr [ebp-8],0Ah
7:
8: while(--i){
00401046 mov eax,dword ptr [ebp-8]
00401049 sub eax,1
0040104C mov dword ptr [ebp-8],eax
0040104F cmp dword ptr [ebp-8],0
00401053 je main+43h (00401063)
9: g(s);
00401055 mov ecx,dword ptr [ebp-4]
00401058 push ecx
00401059 call @ILT+0(_g) (00401005)
0040105E add esp,4
10: }
00401061 jmp main+26h (00401046)
11: printf("\n");
00401063 push offset string "\n" (0042201c)
00401068 call printf (00401100)
0040106D add esp,4
12: return 0;
00401070 xor eax,eax
13: }
00401072 pop edi
00401073 pop esi
00401074 pop ebx
00401075 add esp,48h
00401078 cmp ebp,esp
0040107A call __chkesp (00401180)
0040107F mov esp,ebp
00401081 pop ebp
00401082 ret