• 汇编代码分析


    原来代码:

    #include <boost/thread.hpp>
    #include <iostream>
    
    class Base
    {
    public:
    	virtual void Do() = 0;
    };
    
    class Derived1: public Base
    {
    public:
    	virtual void Do()
    	{
    		std::cout << "Derived1:Do\n";
    	}
    };
    class Derived2: public Base
    {
    public:
    	virtual void Do()
    	{
    		std::cout << "Derived1:Do\n";
    	}
    };
    
    int main()
    {
    	Base* lpBase = new Derived1();
    	lpBase->Do();
    	return 0;
    }
    

     debug反汇编后:

    int main()
    {
    00517770  push        ebp  
    00517771  mov         ebp,esp 
    00517773  sub         esp,0DCh 
    00517779  push        ebx  
    0051777A  push        esi  
    0051777B  push        edi  
    0051777C  lea         edi,[ebp-0DCh] 
    00517782  mov         ecx,37h 
    00517787  mov         eax,0CCCCCCCCh 
    0051778C  rep stos    dword ptr es:[edi] 
    	Base* lpBase = new Derived1();
    0051778E  push        4    
    00517790  call        operator new (5044A9h) 
    00517795  add         esp,4 
    00517798  mov         dword ptr [ebp-0D4h],eax 
    0051779E  cmp         dword ptr [ebp-0D4h],0 
    005177A5  je          main+4Ah (5177BAh) 
    005177A7  mov         ecx,dword ptr [ebp-0D4h] 
    005177AD  call        Derived1::Derived1 (50AF84h) 
    005177B2  mov         dword ptr [ebp-0DCh],eax 
    005177B8  jmp         main+54h (5177C4h) 
    005177BA  mov         dword ptr [ebp-0DCh],0 
    005177C4  mov         eax,dword ptr [ebp-0DCh] 
    005177CA  mov         dword ptr [lpBase],eax 
    	lpBase->Do();
    005177CD  mov         eax,dword ptr [lpBase] 
    005177D0  mov         edx,dword ptr [eax] 
    005177D2  mov         esi,esp 
    005177D4  mov         ecx,dword ptr [lpBase] 
    005177D7  mov         eax,dword ptr [edx] 
    005177D9  call        eax  
    005177DB  cmp         esi,esp 
    005177DD  call        @ILT+19470(__RTC_CheckEsp) (506C13h) 
    	return 0;
    005177E2  xor         eax,eax 
    }
    005177E4  pop         edi  
    005177E5  pop         esi  
    005177E6  pop         ebx  
    005177E7  add         esp,0DCh 
    005177ED  cmp         ebp,esp 
    005177EF  call        @ILT+19470(__RTC_CheckEsp) (506C13h) 
    005177F4  mov         esp,ebp 
    005177F6  pop         ebp  
    005177F7  ret              
    

      

  • 相关阅读:
    关于iframe页面里的重定向问题
    iframe跨域解决方案
    sql 查询优化小计
    年轻不能遇见太惊艳的人
    图片上传预览
    脚本
    前端常见跨域解决方案
    react
    react高阶组件
    React + MobX 状态管理入门及实例
  • 原文地址:https://www.cnblogs.com/xiangshancuizhu/p/2941273.html
Copyright © 2020-2023  润新知