chapter3.2.2.0

// chapter3.2.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"

#include <iostream>
#include <string>

using std::string;
using std::cout;
using std::cin;
using std::endl;

int _tmain(int argc, _TCHAR* argv[])
{
 string s;
 cin>>s;
 cout<<s<<endl;
 return 0;
}

 

debug

od

 

004113F0    55              push    ebp
004113F1    8BEC            mov     ebp, esp
004113F3    6A FF           push    -1
004113F5    68 62464100     push    00414662
004113FA    64:A1 00000000  mov     eax, dword ptr fs:[0]
00411400    50              push    eax
00411401    81EC 04010000   sub     esp, 104
00411407    53              push    ebx
00411408    56              push    esi
00411409    57              push    edi
0041140A    8DBD F0FEFFFF   lea     edi, dword ptr [ebp-110]
00411410    B9 41000000     mov     ecx, 41
00411415    B8 CCCCCCCC     mov     eax, CCCCCCCC
0041141A    F3:AB           rep     stos dword ptr es:[edi]
0041141C    A1 04804100     mov     eax, dword ptr [418004]
00411421    33C5            xor     eax, ebp
00411423    8945 F0         mov     dword ptr [ebp-10], eax
00411426    50              push    eax
00411427    8D45 F4         lea     eax, dword ptr [ebp-C]
0041142A    64:A3 00000000  mov     dword ptr fs:[0], eax
00411430    6A 01           push    1
00411432    8D8D F7FEFFFF   lea     ecx, dword ptr [ebp-109]
00411438    E8 9FFCFFFF     call    004110DC
0041143D    8BF4            mov     esi, esp
0041143F    0FB600          movzx   eax, byte ptr [eax]
00411442    50              push    eax
00411443    8D4D CC         lea     ecx, dword ptr [ebp-34]
00411446    FF15 AC924100   call    dword ptr [<&MSVCP90D.std::basic>; MSVCP90D.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >
0041144C    3BF4            cmp     esi, esp
0041144E    E8 10FDFFFF     call    00411163
00411453    C745 FC 0000000>mov     dword ptr [ebp-4], 0
0041145A    8BF4            mov     esi, esp
0041145C    8D45 CC         lea     eax, dword ptr [ebp-34]
0041145F    50              push    eax
00411460    8B0D B0924100   mov     ecx, dword ptr [<&MSVCP90D.std::>; MSVCP90D.std::cin
00411466    51              push    ecx
00411467    FF15 B4924100   call    dword ptr [<&MSVCP90D.std::opera>; MSVCP90D.std::operator>><char,std::char_traits<char>,std::allocator<char> >
0041146D    83C4 08         add     esp, 8
00411470    3BF4            cmp     esi, esp
00411472    E8 ECFCFFFF     call    00411163
00411477    8BF4            mov     esi, esp
00411479    A1 C8924100     mov     eax, dword ptr [<&MSVCP90D.std::>
0041147E    50              push    eax
0041147F    8BFC            mov     edi, esp
00411481    8D4D CC         lea     ecx, dword ptr [ebp-34]
00411484    51              push    ecx
00411485    8B15 C4924100   mov     edx, dword ptr [<&MSVCP90D.std::>; MSVCP90D.std::cout
0041148B    52              push    edx
0041148C    FF15 C0924100   call    dword ptr [<&MSVCP90D.std::opera>; MSVCP90D.std::operator<<<char,std::char_traits<char>,std::allocator<char> >
00411492    83C4 08         add     esp, 8
00411495    3BFC            cmp     edi, esp
00411497    E8 C7FCFFFF     call    00411163
0041149C    8BC8            mov     ecx, eax
0041149E    FF15 BC924100   call    dword ptr [<&MSVCP90D.std::basic>; MSVCP90D.std::basic_ostream<wchar_t,std::char_traits<wchar_t> >::operator<<
004114A4    3BF4            cmp     esi, esp
004114A6    E8 B8FCFFFF     call    00411163
004114AB    C785 00FFFFFF 0>mov     dword ptr [ebp-100], 0
004114B5    C745 FC FFFFFFF>mov     dword ptr [ebp-4], -1
004114BC    8BF4            mov     esi, esp
004114BE    8D4D CC         lea     ecx, dword ptr [ebp-34]
004114C1    FF15 B8924100   call    dword ptr [<&MSVCP90D.std::basic>; MSVCP90D.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >
004114C7    3BF4            cmp     esi, esp
004114C9    E8 95FCFFFF     call    00411163
004114CE    8B85 00FFFFFF   mov     eax, dword ptr [ebp-100]
004114D4    52              push    edx
004114D5    8BCD            mov     ecx, ebp
004114D7    50              push    eax
004114D8    8D15 10154100   lea     edx, dword ptr [411510]
004114DE    E8 B3FBFFFF     call    00411096
004114E3    58              pop     eax
004114E4    5A              pop     edx
004114E5    8B4D F4         mov     ecx, dword ptr [ebp-C]
004114E8    64:890D 0000000>mov     dword ptr fs:[0], ecx
004114EF    59              pop     ecx
004114F0    5F              pop     edi
004114F1    5E              pop     esi
004114F2    5B              pop     ebx
004114F3    8B4D F0         mov     ecx, dword ptr [ebp-10]
004114F6    33CD            xor     ecx, ebp
004114F8    E8 26FBFFFF     call    00411023
004114FD    81C4 10010000   add     esp, 110
00411503    3BEC            cmp     ebp, esp
00411505    E8 59FCFFFF     call    00411163
0041150A    8BE5            mov     esp, ebp
0041150C    5D              pop     ebp
0041150D    C3              retn

 

 

ida

.text:004113F0     ; =============== S U B R O U T I N E =======================================
.text:004113F0
.text:004113F0     ; Attributes: bp-based frame
.text:004113F0
.text:004113F0     _wmain          proc near               ; CODE XREF: j__wmainj
.text:004113F0
.text:004113F0     var_110         = byte ptr -110h
.text:004113F0     var_109         = byte ptr -109h
.text:004113F0     var_100         = dword ptr -100h
.text:004113F0     var_34          = byte ptr -34h
.text:004113F0     var_10          = dword ptr -10h
.text:004113F0     var_C           = dword ptr -0Ch
.text:004113F0     var_4           = dword ptr -4
.text:004113F0
.text:004113F0 000                 push    ebp
.text:004113F1 004                 mov     ebp, esp
.text:004113F3 004                 push    0FFFFFFFFh
.text:004113F5 008                 push    offset sub_414662
.text:004113FA 00C                 mov     eax, large fs:0
.text:00411400 00C                 push    eax
.text:00411401 010                 sub     esp, 104h       ; Integer Subtraction
.text:00411407 114                 push    ebx
.text:00411408 118                 push    esi
.text:00411409 11C                 push    edi
.text:0041140A 120                 lea     edi, [ebp+var_110] ; Load Effective Address
.text:00411410 120                 mov     ecx, 41h
.text:00411415 120                 mov     eax, 0CCCCCCCCh
.text:0041141A 120                 rep stosd               ; Store String
.text:0041141C 120                 mov     eax, __security_cookie
.text:00411421 120                 xor     eax, ebp        ; Logical Exclusive OR
.text:00411423 120                 mov     [ebp+var_10], eax
.text:00411426 120                 push    eax
.text:00411427 124                 lea     eax, [ebp+var_C] ; Load Effective Address
.text:0041142A 124                 mov     large fs:0, eax
.text:00411430 124                 push    1
.text:00411432 128                 lea     ecx, [ebp+var_109] ; Load Effective Address
.text:00411438 128                 call    j_??0_Has_debug_it@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@_N@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Has_debug_it::_Has_debug_it(bool)
.text:0041143D 124                 mov     esi, esp
.text:0041143F 124                 movzx   eax, byte ptr [eax] ; Move with Zero-Extend
.text:00411442 124                 push    eax
.text:00411443 128                 lea     ecx, [ebp+var_34] ; Load Effective Address
.text:00411446 128                 call    ds:__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@U_Has_debug_it@01@@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string<char,std::char_traits<char>,std::allocator<char>>(basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Has_debug_it)
.text:0041144C 124                 cmp     esi, esp        ; Compare Two Operands
.text:0041144E 124                 call    j___RTC_CheckEsp ; Call Procedure
.text:00411453 124                 mov     [ebp+var_4], 0
.text:0041145A 124                 mov     esi, esp
.text:0041145C 124                 lea     eax, [ebp+var_34] ; Load Effective Address
.text:0041145F 124                 push    eax
.text:00411460 128                 mov     ecx, ds:__imp_?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A ; std::basic_istream<char,std::char_traits<char>> std::cin
.text:00411466 128                 push    ecx
.text:00411467 12C                 call    ds:__imp_??$?5DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z ; std::operator>><char,std::char_traits<char>,std::allocator<char>>(std::basic_istream<char,std::char_traits<char>> &,std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)
.text:0041146D 12C                 add     esp, 8          ; Add
.text:00411470 124                 cmp     esi, esp        ; Compare Two Operands
.text:00411472 124                 call    j___RTC_CheckEsp ; Call Procedure
.text:00411477 124                 mov     esi, esp
.text:00411479 124                 mov     eax, ds:__imp_?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z ; std::endl(std::basic_ostream<char,std::char_traits<char>> &)
.text:0041147E 124                 push    eax
.text:0041147F 128                 mov     edi, esp
.text:00411481 128                 lea     ecx, [ebp+var_34] ; Load Effective Address
.text:00411484 128                 push    ecx
.text:00411485 12C                 mov     edx, ds:__imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A ; std::basic_ostream<char,std::char_traits<char>> std::cout
.text:0041148B 12C                 push    edx
.text:0041148C 130                 call    ds:__imp_??$?6DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z ; std::operator<<<char,std::char_traits<char>,std::allocator<char>>(std::basic_ostream<char,std::char_traits<char>> &,std::basic_string<char,std::char_traits<char>,std::allocator<char>> const &)
.text:00411492 130                 add     esp, 8          ; Add
.text:00411495 128                 cmp     edi, esp        ; Compare Two Operands
.text:00411497 128                 call    j___RTC_CheckEsp ; Call Procedure
.text:0041149C 128                 mov     ecx, eax
.text:0041149E 128                 call    ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(std::basic_ostream<char,std::char_traits<char>> & (*)(std::basic_ostream<char,std::char_traits<char>> &))
.text:004114A4 124                 cmp     esi, esp        ; Compare Two Operands
.text:004114A6 124                 call    j___RTC_CheckEsp ; Call Procedure
.text:004114AB 124                 mov     [ebp+var_100], 0
.text:004114B5 124                 mov     [ebp+var_4], 0FFFFFFFFh
.text:004114BC 124                 mov     esi, esp
.text:004114BE 124                 lea     ecx, [ebp+var_34] ; Load Effective Address
.text:004114C1 124                 call    ds:__imp_??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::~basic_string<char,std::char_traits<char>,std::allocator<char>>(void)
.text:004114C7 124                 cmp     esi, esp        ; Compare Two Operands
.text:004114C9 124                 call    j___RTC_CheckEsp ; Call Procedure
.text:004114CE 124                 mov     eax, [ebp+var_100]
.text:004114D4 124                 push    edx
.text:004114D5 128                 mov     ecx, ebp
.text:004114D7 128                 push    eax
.text:004114D8 12C                 lea     edx, dword_411510 ; Load Effective Address
.text:004114DE 12C                 call    j_@_RTC_CheckStackVars@8 ; _RTC_CheckStackVars(x,x)
.text:004114E3 12C                 pop     eax
.text:004114E4 128                 pop     edx
.text:004114E5 124                 mov     ecx, [ebp+var_C]
.text:004114E8 124                 mov     large fs:0, ecx
.text:004114EF 124                 pop     ecx
.text:004114F0 120                 pop     edi
.text:004114F1 11C                 pop     esi
.text:004114F2 118                 pop     ebx
.text:004114F3 114                 mov     ecx, [ebp+var_10]
.text:004114F6 114                 xor     ecx, ebp        ; Logical Exclusive OR
.text:004114F8 114                 call    j_@__security_check_cookie@4 ; __security_check_cookie(x)
.text:004114FD 114                 add     esp, 110h       ; Add
.text:00411503 004                 cmp     ebp, esp        ; Compare Two Operands
.text:00411505 004                 call    j___RTC_CheckEsp ; Call Procedure
.text:0041150A 004                 mov     esp, ebp
.text:0041150C 004                 pop     ebp
.text:0041150D 000                 retn                    ; Return Near from Procedure
.text:0041150D     _wmain          endp
.text:0041150D
.text:0041150D     ; ---------------------------------------------------------------------------

release

od

 

00401000  /$  6A FF         push    -1
00401002  |.  68 B9184000   push    004018B9
00401007  |.  64:A1 0000000>mov     eax, dword ptr fs:[0]
0040100D  |.  50            push    eax
0040100E  |.  83EC 20       sub     esp, 20
00401011  |.  A1 00304000   mov     eax, dword ptr [403000]
00401016  |.  33C4          xor     eax, esp
00401018  |.  894424 1C     mov     dword ptr [esp+1C], eax
0040101C  |.  A1 00304000   mov     eax, dword ptr [403000]
00401021  |.  33C4          xor     eax, esp
00401023  |.  50            push    eax
00401024  |.  8D4424 24     lea     eax, dword ptr [esp+24]
00401028  |.  64:A3 0000000>mov     dword ptr fs:[0], eax
0040102E  |.  8D4C24 04     lea     ecx, dword ptr [esp+4]
00401032  |.  FF15 40204000 call    dword ptr [<&MSVCP90.std::basic_string<char,std::char_traits<char>,std::all>;  MSVCP90.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >
00401038  |.  8D4424 04     lea     eax, dword ptr [esp+4]
0040103C  |.  C74424 2C 000>mov     dword ptr [esp+2C], 0
00401044  |.  8B0D 50204000 mov     ecx, dword ptr [<&MSVCP90.std::cin>]                                        ;  MSVCP90.std::cin
0040104A  |.  50            push    eax
0040104B  |.  51            push    ecx
0040104C  |.  FF15 54204000 call    dword ptr [<&MSVCP90.std::operator>><char,std::char_traits<char>,std::alloc>;  MSVCP90.std::operator>><char,std::char_traits<char>,std::allocator<char> >
00401052  |.  8B15 3C204000 mov     edx, dword ptr [<&MSVCP90.std::endl>]                                       ;  MSVCP90.std::endl
00401058  |.  8B0D 48204000 mov     ecx, dword ptr [<&MSVCP90.std::cout>]                                       ;  MSVCP90.std::cout
0040105E  |.  83C4 08       add     esp, 8
00401061  |.  52            push    edx
00401062  |.  8D4424 08     lea     eax, dword ptr [esp+8]
00401066  |.  50            push    eax
00401067  |.  51            push    ecx
00401068  |.  FF15 4C204000 call    dword ptr [<&MSVCP90.std::operator<<<char,std::char_traits<char>,std::alloc>;  MSVCP90.std::operator<<<char,std::char_traits<char>,std::allocator<char> >
0040106E  |.  83C4 08       add     esp, 8
00401071  |.  8BC8          mov     ecx, eax
00401073  |.  FF15 38204000 call    dword ptr [<&MSVCP90.std::basic_ostream<char,std::char_traits<char> >::oper>;  MSVCP90.std::basic_ostream<wchar_t,std::char_traits<wchar_t> >::operator<<
00401079  |.  8D4C24 04     lea     ecx, dword ptr [esp+4]
0040107D  |.  C74424 2C FFF>mov     dword ptr [esp+2C], -1
00401085  |.  FF15 44204000 call    dword ptr [<&MSVCP90.std::basic_string<char,std::char_traits<char>,std::all>;  MSVCP90.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >
0040108B  |.  33C0          xor     eax, eax
0040108D  |.  8B4C24 24     mov     ecx, dword ptr [esp+24]
00401091  |.  64:890D 00000>mov     dword ptr fs:[0], ecx
00401098  |.  59            pop     ecx
00401099  |.  8B4C24 1C     mov     ecx, dword ptr [esp+1C]
0040109D  |.  33CC          xor     ecx, esp
0040109F  |.  E8 04000000   call    004010A8
004010A4  |.  83C4 2C       add     esp, 2C
004010A7  \.  C3            retn

 

 

ida

.text:00401000 ; =============== S U B R O U T I N E =======================================
.text:00401000
.text:00401000
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char *envp)
.text:00401000 _main           proc near               ; CODE XREF: ___tmainCRTStartup+10Ap
.text:00401000
.text:00401000 var_2C          = byte ptr -2Ch
.text:00401000 cookieone       = dword ptr -10h
.text:00401000 var_C           = dword ptr -0Ch
.text:00401000 var_4           = dword ptr -4
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    0FFFFFFFFh
.text:00401002                 push    offset loc_4018B9
.text:00401007                 mov     eax, large fs:0
.text:0040100D                 push    eax
.text:0040100E                 sub     esp, 20h
.text:00401011                 mov     eax, __security_cookie
.text:00401016                 xor     eax, esp
.text:00401018                 mov     [esp+2Ch+cookieone], eax
.text:0040101C                 mov     eax, __security_cookie
.text:00401021                 xor     eax, esp
.text:00401023                 push    eax             ; cookietwo
.text:00401024                 lea     eax, [esp+30h+var_C]
.text:00401028                 mov     large fs:0, eax
.text:0040102E                 lea     ecx, [esp+30h+var_2C]
.text:00401032                 call    ds:__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string<char,std::char_traits<char>,std::allocator<char>>(void)
.text:00401038                 lea     eax, [esp+30h+var_2C]
.text:0040103C                 mov     [esp+30h+var_4], 0
.text:00401044                 mov     ecx, ds:__imp_?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A ; std::basic_istream<char,std::char_traits<char>> std::cin
.text:0040104A                 push    eax
.text:0040104B                 push    ecx
.text:0040104C                 call    ds:__imp_??$?5DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z ; std::operator>><char,std::char_traits<char>,std::allocator<char>>(std::basic_istream<char,std::char_traits<char>> &,std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)
.text:00401052                 mov     edx, ds:__imp_?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z ; std::endl(std::basic_ostream<char,std::char_traits<char>> &)
.text:00401058                 mov     ecx, ds:__imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A ; std::basic_ostream<char,std::char_traits<char>> std::cout
.text:0040105E                 add     esp, 8
.text:00401061                 push    edx
.text:00401062                 lea     eax, [esp+34h+var_2C]
.text:00401066                 push    eax
.text:00401067                 push    ecx
.text:00401068                 call    ds:__imp_??$?6DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z ; std::operator<<<char,std::char_traits<char>,std::allocator<char>>(std::basic_ostream<char,std::char_traits<char>> &,std::basic_string<char,std::char_traits<char>,std::allocator<char>> const &)
.text:0040106E                 add     esp, 8
.text:00401071                 mov     ecx, eax
.text:00401073                 call    ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(std::basic_ostream<char,std::char_traits<char>> & (*)(std::basic_ostream<char,std::char_traits<char>> &))
.text:00401079                 lea     ecx, [esp+30h+var_2C]
.text:0040107D                 mov     [esp+30h+var_4], 0FFFFFFFFh
.text:00401085                 call    ds:__imp_??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::~basic_string<char,std::char_traits<char>,std::allocator<char>>(void)
.text:0040108B                 xor     eax, eax
.text:0040108D                 mov     ecx, [esp+30h+var_C]
.text:00401091                 mov     large fs:0, ecx
.text:00401098                 pop     ecx
.text:00401099                 mov     ecx, [esp+2Ch+cookieone]
.text:0040109D                 xor     ecx, esp
.text:0040109F                 call    @__security_check_cookie@4 ; __security_check_cookie(x)
.text:004010A4                 add     esp, 2Ch
.text:004010A7                 retn
.text:004010A7 _main           endp
.text:004010A7
.text:004010A8
.text:004010A8 ; =============== S U B R O U T I N E =======================================
.text:004010A8
.text:004010A8

posted @ 2010-06-21 09:59  南守拥  阅读(256)  评论(0编辑  收藏  举报