Chinaunix首页 | 论坛 | 博客
  • 博客访问: 304324
  • 博文数量: 174
  • 博客积分: 3061
  • 博客等级: 中校
  • 技术积分: 1740
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-04 22:43
文章分类

全部博文(174)

文章存档

2011年(54)

2010年(14)

2009年(30)

2008年(26)

2007年(27)

2006年(23)

我的朋友

分类: WINDOWS

2010-04-30 16:03:26

; Attributes: bp-based frame
_wmain proc near
var_CC= byte ptr -0CCh
var_5= byte ptr -5
push    ebp
mov     ebp, esp
sub     esp, 0CCh
push    ebx
push    esi
push    edi
lea     edi, [ebp+var_CC]
mov     ecx, 33h
mov     eax, 0CCCCCCCCh
rep stosd
push    1               ; int
push    0               ; int
call    ; test(int,int)
add     esp, 8
push    2               ; int
push    1               ; int
push    0               ; int
call    ; test_std(int,int,int)
push    2               ; int
mov     edx, 1          ; int
xor     ecx, ecx        ; int
call    ; test_fast(int,int,int)
push    2
push    1
call    ; CTest::static_test(int,int)
add     esp, 8
push    2
push    1
call    ; CTest::static_test(int,int)
add     esp, 8
push    2
push    1
lea     ecx, [ebp+var_5]
call    ; CTest::dotest(void)
xor     eax, eax
push    edx
mov     ecx, ebp
push    eax
lea     edx, dword_413260
call    ; _RTC_CheckStackVars(x,x)
pop     eax
pop     edx
pop     edi
pop     esi
pop     ebx
add     esp, 0CCh
cmp     ebp, esp
call    j___RTC_CheckEsp
mov     esp, ebp
pop     ebp
retn
_wmain endp ; sp-analysis failed
 
 
如果这是用vs2008 c++编译出来的代码,且实例被调用函数的参数,均是0,1,2(如果只接受两个参数那么0,1)
1. 请问你认为这个从概率上来说它是debug,还是release模式编译的?理由是什么(越多越好)?
>> debug, 或者关闭了优化。
>> 理由1,编译器进行了栈保护,即填充0xcc,而这个恰好是int 3软中断的质量,当栈出现问题时候,比如访问越界后,将会被中断。
>> 理由2: checkesp调用,往往用于明确保证栈平衡,即防止缓冲区溢出攻击的一种大的手段。不过这个debug,release都可能用到。
2. 这个代码段前3次调用 ,分别是什么调用规范?
>> 1 是c调用__cdecl ,因为从右到左压栈,且调用者清理stack;
>> 2 stdcall 从右到左,且被调用这清理stack
>> 3 fastcall 第一,第二两个参数通过ecx,edx 
>> 4/5 c call
>> 6. thiscall ,ecx作为ecx
 
 
 
阅读(841) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~