chapter3.5

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

#include "stdafx.h"

#include <bitset>
using std::bitset;

#include <string>
using std::string;


int _tmain(int argc, _TCHAR* argv[])
{
 bitset<16> b(0xffff);
 
 string strval("11100");
 bitset<32> bitvec1(strval,1,4);

 bitset<32> bitvec;
 bool is_set = bitvec.any();
 bool is_not_set = bitvec.none();
 size_t bits_set = bitvec.count();
 size_t sz = bitvec.size();

 for(int index = 0; index != 32; index+=2)
 {
  bitvec.set(index);
 }

 if(bitvec.test(1))
 {
 }

 if(bitvec[2])
 {
 }

 bitvec.set();
 bitvec.reset();

 bitvec.flip(3);
 bitvec[3].flip();
 bitvec.flip();

 return 0;
}

 

debug

ida

.text:00413B20
.text:00413B20 ; =============== S U B R O U T I N E =======================================
.text:00413B20
.text:00413B20 ; Attributes: bp-based frame
.text:00413B20
.text:00413B20 _wmain          proc near               ; CODE XREF: j__wmainj
.text:00413B20
.text:00413B20 var_184         = byte ptr -184h
.text:00413B20 var_180         = byte ptr -180h
.text:00413B20 var_170         = byte ptr -170h
.text:00413B20 var_160         = dword ptr -160h
.text:00413B20 var_94          = dword ptr -94h
.text:00413B20 var_88          = dword ptr -88h
.text:00413B20 var_7C          = dword ptr -7Ch
.text:00413B20 var_6D          = byte ptr -6Dh
.text:00413B20 var_61          = byte ptr -61h
.text:00413B20 var_58          = byte ptr -58h
.text:00413B20 var_4C          = byte ptr -4Ch
.text:00413B20 var_40          = byte ptr -40h
.text:00413B20 var_18          = byte ptr -18h
.text:00413B20 var_10          = dword ptr -10h
.text:00413B20 var_C           = dword ptr -0Ch
.text:00413B20 var_4           = dword ptr -4
.text:00413B20
.text:00413B20                 push    ebp
.text:00413B21                 mov     ebp, esp
.text:00413B23                 push    0FFFFFFFFh
.text:00413B25                 push    offset loc_419FF2
.text:00413B2A                 mov     eax, large fs:0
.text:00413B30                 push    eax
.text:00413B31                 sub     esp, 178h
.text:00413B37                 push    ebx
.text:00413B38                 push    esi
.text:00413B39                 push    edi
.text:00413B3A                 lea     edi, [ebp+var_184]
.text:00413B40                 mov     ecx, 5Eh
.text:00413B45                 mov     eax, 0CCCCCCCCh
.text:00413B4A                 rep stosd
.text:00413B4C                 mov     eax, __security_cookie
.text:00413B51                 xor     eax, ebp
.text:00413B53                 mov     [ebp+var_10], eax
.text:00413B56                 push    eax
.text:00413B57                 lea     eax, [ebp+var_C]
.text:00413B5A                 mov     large fs:0, eax
.text:00413B60                 push    0FFFFh
.text:00413B65                 lea     ecx, [ebp+var_18]
.text:00413B68                 call    j_??0?$bitset@$0BA@@std@@QAE@K@Z ; std::bitset<16>::bitset<16>(ulong)
.text:00413B6D                 mov     esi, esp
.text:00413B6F                 push    offset a11100   ; "11100"
.text:00413B74                 lea     ecx, [ebp+var_40]
.text:00413B77                 call    ds:__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string<char,std::char_traits<char>,std::allocator<char>>(char const *)
.text:00413B7D                 cmp     esi, esp
.text:00413B7F                 call    j___RTC_CheckEsp
.text:00413B84                 mov     [ebp+var_4], 0
.text:00413B8B                 push    30h
.text:00413B8D                 push    4
.text:00413B8F                 push    1
.text:00413B91                 lea     eax, [ebp+var_40]
.text:00413B94                 push    eax
.text:00413B95                 lea     ecx, [ebp+var_4C]
.text:00413B98                 call    j_?deallocate@?$allocator@H@std@@QAEXPAHI@Z ; std::allocator<int>::deallocate(int *,uint)
.text:00413B9D                 lea     ecx, [ebp+var_58]
.text:00413BA0                 call    j_??0?$bitset@$0CA@@std@@QAE@XZ ; std::bitset<32>::bitset<32>(void)
.text:00413BA5                 lea     ecx, [ebp+var_58]
.text:00413BA8                 call    j_?any@?$bitset@$0CA@@std@@QBE_NXZ ; std::bitset<32>::any(void)
.text:00413BAD                 mov     [ebp+var_61], al
.text:00413BB0                 lea     ecx, [ebp+var_58]
.text:00413BB3                 call    j_??9?$_Vector_const_iterator@HV?$allocator@H@std@@@std@@QBE_NABV01@@Z ; std::_Vector_const_iterator<int,std::allocator<int>>::operator!=(std::_Vector_const_iterator<int,std::allocator<int>> const &)
.text:00413BB8                 mov     [ebp+var_6D], al
.text:00413BBB                 lea     ecx, [ebp+var_58]
.text:00413BBE                 call    j_?count@?$bitset@$0CA@@std@@QBEIXZ ; std::bitset<32>::count(void)
.text:00413BC3                 mov     [ebp+var_7C], eax
.text:00413BC6                 lea     ecx, [ebp+var_58]
.text:00413BC9                 call    j_?size@?$bitset@$0CA@@std@@QBEIXZ ; std::bitset<32>::size(void)
.text:00413BCE                 mov     [ebp+var_88], eax
.text:00413BD4                 mov     [ebp+var_94], 0
.text:00413BDE                 jmp     short loc_413BEF
.text:00413BE0 ; ---------------------------------------------------------------------------
.text:00413BE0
.text:00413BE0 loc_413BE0:                             ; CODE XREF: _wmain+E9j
.text:00413BE0                 mov     eax, [ebp+var_94]
.text:00413BE6                 add     eax, 2
.text:00413BE9                 mov     [ebp+var_94], eax
.text:00413BEF
.text:00413BEF loc_413BEF:                             ; CODE XREF: _wmain+BEj
.text:00413BEF                 cmp     [ebp+var_94], 20h
.text:00413BF6                 jz      short loc_413C0B
.text:00413BF8                 push    1
.text:00413BFA                 mov     eax, [ebp+var_94]
.text:00413C00                 push    eax
.text:00413C01                 lea     ecx, [ebp+var_58]
.text:00413C04                 call    j_??1_Iterator_base@std@@QAE@XZ ; std::_Iterator_base::~_Iterator_base(void)
.text:00413C09                 jmp     short loc_413BE0
.text:00413C0B ; ---------------------------------------------------------------------------
.text:00413C0B
.text:00413C0B loc_413C0B:                             ; CODE XREF: _wmain+D6j
.text:00413C0B                 push    1
.text:00413C0D                 lea     ecx, [ebp+var_58]
.text:00413C10                 call    j_?test@?$bitset@$0CA@@std@@QBE_NI@Z ; std::bitset<32>::test(uint)
.text:00413C15                 push    2
.text:00413C17                 lea     eax, [ebp+var_180]
.text:00413C1D                 push    eax
.text:00413C1E                 lea     ecx, [ebp+var_58]
.text:00413C21                 call    j_??A?$bitset@$0CA@@std@@QAE?AVreference@01@I@Z ; std::bitset<32>::operator[](uint)
.text:00413C26                 mov     ecx, eax
.text:00413C28                 call    j_??Breference@?$bitset@$0CA@@std@@QBE_NXZ ; std::bitset<32>::reference::operator bool(void)
.text:00413C2D                 lea     ecx, [ebp+var_58]
.text:00413C30                 call    j_?set@?$bitset@$0CA@@std@@QAEAAV12@XZ ; std::bitset<32>::set(void)
.text:00413C35                 lea     ecx, [ebp+var_58]
.text:00413C38                 call    j_?_Orphan_me@_Iterator_base@std@@QAEXXZ ; std::_Iterator_base::_Orphan_me(void)
.text:00413C3D                 push    3
.text:00413C3F                 lea     ecx, [ebp+var_58]
.text:00413C42                 call    j_??1?$vector@HV?$allocator@H@std@@@std@@QAE@XZ ; std::vector<int,std::allocator<int>>::~vector<int,std::allocator<int>>(void)
.text:00413C47                 push    3
.text:00413C49                 lea     eax, [ebp+var_170]
.text:00413C4F                 push    eax
.text:00413C50                 lea     ecx, [ebp+var_58]
.text:00413C53                 call    j_??A?$bitset@$0CA@@std@@QAE?AVreference@01@I@Z ; std::bitset<32>::operator[](uint)
.text:00413C58                 mov     ecx, eax
.text:00413C5A                 call    j_?flip@reference@?$bitset@$0CA@@std@@QAEAAV123@XZ ; std::bitset<32>::reference::flip(void)
.text:00413C5F                 lea     ecx, [ebp+var_58]
.text:00413C62                 call    j_??A?$vector@HV?$allocator@H@std@@@std@@QAEAAHI@Z ; std::vector<int,std::allocator<int>>::operator[](uint)
.text:00413C67                 mov     [ebp+var_160], 0
.text:00413C71                 mov     [ebp+var_4], 0FFFFFFFFh
.text:00413C78                 mov     esi, esp
.text:00413C7A                 lea     ecx, [ebp+var_40]
.text:00413C7D                 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:00413C83                 cmp     esi, esp
.text:00413C85                 call    j___RTC_CheckEsp
.text:00413C8A                 mov     eax, [ebp+var_160]
.text:00413C90                 push    edx
.text:00413C91                 mov     ecx, ebp
.text:00413C93                 push    eax
.text:00413C94                 lea     edx, dword_413CCC
.text:00413C9A                 call    j_@_RTC_CheckStackVars@8 ; _RTC_CheckStackVars(x,x)
.text:00413C9F                 pop     eax
.text:00413CA0                 pop     edx
.text:00413CA1                 mov     ecx, [ebp+var_C]
.text:00413CA4                 mov     large fs:0, ecx
.text:00413CAB                 pop     ecx
.text:00413CAC                 pop     edi
.text:00413CAD                 pop     esi
.text:00413CAE                 pop     ebx
.text:00413CAF                 mov     ecx, [ebp+var_10]
.text:00413CB2                 xor     ecx, ebp
.text:00413CB4                 call    j_@__security_check_cookie@4 ; __security_check_cookie(x)
.text:00413CB9                 add     esp, 184h
.text:00413CBF                 cmp     ebp, esp
.text:00413CC1                 call    j___RTC_CheckEsp
.text:00413CC6                 mov     esp, ebp
.text:00413CC8                 pop     ebp
.text:00413CC9                 retn
.text:00413CC9 _wmain          endp
.text:00413CC9
.text:00413CC9 ; ---------------------------------------------------------------------------
.text:00413CCA                 align 4
.text:00413CCC dword_413CCC    dd 4                    ; DATA XREF: _wmain+174o

release

ida

 

posted @ 2010-06-21 14:53  南守拥  阅读(242)  评论(0编辑  收藏  举报